-
Notifications
You must be signed in to change notification settings - Fork 11
feat: adding an attachedTrigger with sheet overlay #1382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
754aaaf
5fc6508
d60e6f7
a305028
47691f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,13 @@ | ||
| @import 'color-palette'; | ||
| @import 'font'; | ||
|
|
||
| $box-shadow: -3px 0px 24px rgba(0, 0, 0, 0.12), -1px 0px 8px rgba(0, 0, 0, 0.08); | ||
|
|
||
| .sheet-overlay { | ||
| box-shadow: -3px 1px 24px rgba(0, 0, 0, 0.12), -1px -1px 8px rgba(0, 0, 0, 0.08); | ||
| box-shadow: $box-shadow; | ||
| border-radius: 16px 0 0 16px; | ||
| height: 100%; | ||
| width: 100%; | ||
| overflow: hidden; | ||
|
|
||
| padding: 24px; | ||
|
|
@@ -13,26 +16,6 @@ | |
| flex-direction: column; | ||
| z-index: 1; | ||
|
|
||
| &.sheet-size-responsive-extra-large { | ||
| width: 100%; | ||
| } | ||
|
|
||
| &.sheet-size-small { | ||
| width: 320px; | ||
| } | ||
|
|
||
| &.sheet-size-medium { | ||
| width: 600px; | ||
| } | ||
|
|
||
| &.sheet-size-large { | ||
| width: 840px; | ||
| } | ||
|
|
||
| &.sheet-size-extra-large { | ||
| width: 1280px; | ||
| } | ||
|
|
||
| .header { | ||
| display: flex; | ||
| justify-content: space-between; | ||
|
|
@@ -62,3 +45,24 @@ | |
| } | ||
| } | ||
| } | ||
|
|
||
| .attached-trigger { | ||
| cursor: pointer; | ||
| box-shadow: $box-shadow; | ||
| clip-path: inset(-20px -20px 0px -20px); | ||
| background: white; | ||
| width: 200px; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we avoid this? I know it works for our current use case.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep this for now. I want to put some restrictions on the content. |
||
| height: 40px; | ||
| transform: translate(calc(-50% - 20px), 0px) rotate(270deg); | ||
| position: relative; | ||
| top: -50%; | ||
| border-radius: 6px; | ||
|
|
||
| display: flex; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer putting flex properties directly :) |
||
| align-items: center; | ||
| padding: 0px 12px; | ||
|
|
||
| .trigger-icon { | ||
| margin-right: 14px; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { ChangeDetectionStrategy, Component, HostListener, Inject, Injector, Tem | |
| import { IconType } from '@hypertrace/assets-library'; | ||
| import { GLOBAL_HEADER_HEIGHT, LayoutChangeService } from '@hypertrace/common'; | ||
| import { ButtonStyle } from '../../button/button'; | ||
| import { IconSize } from '../../icon/icon-size'; | ||
| import { PopoverFixedPositionLocation, POPOVER_DATA } from '../../popover/popover'; | ||
| import { PopoverRef } from '../../popover/popover-ref'; | ||
| import { SheetConstructionData } from '../overlay.service'; | ||
|
|
@@ -12,29 +13,42 @@ import { SheetOverlayConfig, SheetSize } from './sheet'; | |
| styleUrls: ['./sheet-overlay.component.scss'], | ||
| changeDetection: ChangeDetectionStrategy.OnPush, | ||
| template: ` | ||
| <div *ngIf="this.visible" class="sheet-overlay" [ngClass]="'sheet-size-' + this.size"> | ||
| <div *ngIf="this.showHeader" class="header"> | ||
| <h3 class="header-title">{{ sheetTitle }}</h3> | ||
| <ht-button | ||
| class="close-button" | ||
| icon="${IconType.CloseCircle}" | ||
| display="${ButtonStyle.Outlined}" | ||
| htTooltip="Close Sheet" | ||
| (click)="this.close()" | ||
| > | ||
| </ht-button> | ||
| <ng-container *ngIf="this.visible"> | ||
| <div class="sheet-overlay"> | ||
| <ng-container *ngIf="!this.isViewCollapsed"> | ||
| <div *ngIf="this.showHeader" class="header"> | ||
| <h3 class="header-title">{{ sheetTitle }}</h3> | ||
| <ht-button | ||
| class="close-button" | ||
| icon="${IconType.CloseCircle}" | ||
| display="${ButtonStyle.Outlined}" | ||
| htTooltip="Close Sheet" | ||
| (click)="this.close()" | ||
| > | ||
| </ht-button> | ||
| </div> | ||
| <div class="content-wrapper"> | ||
| <div class="content"> | ||
| <ng-container *ngIf="this.isComponentSheet; else templateRenderer"> | ||
| <ng-container *ngComponentOutlet="this.renderer; injector: this.rendererInjector"></ng-container> | ||
| </ng-container> | ||
| <ng-template #templateRenderer> | ||
| <ng-container *ngTemplateOutlet="this.renderer"></ng-container> | ||
| </ng-template> | ||
| </div> | ||
| </div> | ||
| </ng-container> | ||
| </div> | ||
| <div class="content-wrapper"> | ||
| <div class="content"> | ||
| <ng-container *ngIf="this.isComponentSheet; else templateRenderer"> | ||
| <ng-container *ngComponentOutlet="this.renderer; injector: this.rendererInjector"></ng-container> | ||
| </ng-container> | ||
| <ng-template #templateRenderer> | ||
| <ng-container *ngTemplateOutlet="this.renderer"></ng-container> | ||
| </ng-template> | ||
| </div> | ||
| <div class="attached-trigger" *ngIf="!!this.attachedTriggerTemplate" (click)="this.toggleCollapseExpand()"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we also include
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
| <ht-icon | ||
| class="trigger-icon" | ||
| icon="{{ this.isViewCollapsed ? '${IconType.ChevronUp}' : '${IconType.ChevronDown}' }}" | ||
| size="${IconSize.Small}" | ||
| htTooltip="{{ this.isViewCollapsed ? 'Expand Sheet' : 'Collapse Sheet' }}" | ||
| ></ht-icon> | ||
| <ng-container *ngTemplateOutlet="this.attachedTriggerTemplate"></ng-container> | ||
| </div> | ||
| </div> | ||
| </ng-container> | ||
| ` | ||
| }) | ||
| export class SheetOverlayComponent { | ||
|
|
@@ -46,6 +60,8 @@ export class SheetOverlayComponent { | |
| public readonly rendererInjector: Injector; | ||
| public visible: boolean = true; | ||
| public readonly closeOnEscape: boolean; | ||
| public readonly attachedTriggerTemplate?: TemplateRef<unknown>; | ||
| public isViewCollapsed: boolean; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we repurpose the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Visible is actually hiding the entire content (including the trigger) before the popover is closed. So, it is different than |
||
|
|
||
| public constructor( | ||
| private readonly popoverRef: PopoverRef, | ||
|
|
@@ -58,13 +74,13 @@ export class SheetOverlayComponent { | |
| this.sheetTitle = sheetConfig.title === undefined ? '' : sheetConfig.title; | ||
| this.size = sheetConfig.size; | ||
| this.closeOnEscape = sheetConfig.closeOnEscapeKey ?? true; | ||
| this.attachedTriggerTemplate = sheetConfig.attachedTriggerTemplate; | ||
| this.isViewCollapsed = !!this.attachedTriggerTemplate; | ||
|
|
||
| this.isComponentSheet = !(sheetConfig.content instanceof TemplateRef); | ||
| this.renderer = sheetConfig.content; | ||
| this.popoverRef.height(this.getHeightForPopover(globalHeaderHeight, sheetConfig.position)); | ||
|
|
||
| if (this.size === SheetSize.ResponsiveExtraLarge) { | ||
| this.popoverRef.width('60%'); | ||
| } | ||
| this.setWidth(); | ||
|
|
||
| this.rendererInjector = Injector.create({ | ||
| providers: [ | ||
|
|
@@ -89,6 +105,33 @@ export class SheetOverlayComponent { | |
| this.popoverRef.close(); | ||
| } | ||
|
|
||
| public toggleCollapseExpand(): void { | ||
| this.isViewCollapsed = !this.isViewCollapsed; | ||
|
|
||
| this.setWidth(); | ||
| } | ||
|
|
||
| private setWidth(): void { | ||
| this.popoverRef.width(this.isViewCollapsed ? '0px' : this.getWidthForPopover()); | ||
| } | ||
|
|
||
| private getWidthForPopover(): string { | ||
| switch (this.size) { | ||
| case SheetSize.Small: | ||
| return '320px'; | ||
| case SheetSize.Medium: | ||
| return '600px'; | ||
| case SheetSize.Large: | ||
| return '840px'; | ||
| case SheetSize.ExtraLarge: | ||
| return '1280px'; | ||
| case SheetSize.ResponsiveExtraLarge: | ||
| return '60%'; | ||
| default: | ||
| return '100%'; | ||
| } | ||
| } | ||
|
|
||
| private getHeightForPopover(globalHeaderHeight: string, position?: PopoverFixedPositionLocation): string { | ||
| return position === PopoverFixedPositionLocation.Right ? '100vh' : `calc(100vh - ${globalHeaderHeight})`; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this size is not necessary anymore?
Edit: Moved to the component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding it programmatically in TS