@@ -2,6 +2,7 @@ import { ChangeDetectionStrategy, Component, HostListener, Inject, Injector, Tem
22import { IconType } from '@hypertrace/assets-library' ;
33import { GLOBAL_HEADER_HEIGHT , LayoutChangeService } from '@hypertrace/common' ;
44import { ButtonStyle } from '../../button/button' ;
5+ import { IconSize } from '../../icon/icon-size' ;
56import { PopoverFixedPositionLocation , POPOVER_DATA } from '../../popover/popover' ;
67import { PopoverRef } from '../../popover/popover-ref' ;
78import { SheetConstructionData } from '../overlay.service' ;
@@ -12,29 +13,42 @@ import { SheetOverlayConfig, SheetSize } from './sheet';
1213 styleUrls : [ './sheet-overlay.component.scss' ] ,
1314 changeDetection : ChangeDetectionStrategy . OnPush ,
1415 template : `
15- <div *ngIf="this.visible" class="sheet-overlay" [ngClass]="'sheet-size-' + this.size">
16- <div *ngIf="this.showHeader" class="header">
17- <h3 class="header-title">{{ sheetTitle }}</h3>
18- <ht-button
19- class="close-button"
20- icon="${ IconType . CloseCircle } "
21- display="${ ButtonStyle . Outlined } "
22- htTooltip="Close Sheet"
23- (click)="this.close()"
24- >
25- </ht-button>
16+ <ng-container *ngIf="this.visible">
17+ <div class="sheet-overlay">
18+ <ng-container *ngIf="!this.isViewCollapsed">
19+ <div *ngIf="this.showHeader" class="header">
20+ <h3 class="header-title">{{ sheetTitle }}</h3>
21+ <ht-button
22+ class="close-button"
23+ icon="${ IconType . CloseCircle } "
24+ display="${ ButtonStyle . Outlined } "
25+ htTooltip="Close Sheet"
26+ (click)="this.close()"
27+ >
28+ </ht-button>
29+ </div>
30+ <div class="content-wrapper">
31+ <div class="content">
32+ <ng-container *ngIf="this.isComponentSheet; else templateRenderer">
33+ <ng-container *ngComponentOutlet="this.renderer; injector: this.rendererInjector"></ng-container>
34+ </ng-container>
35+ <ng-template #templateRenderer>
36+ <ng-container *ngTemplateOutlet="this.renderer"></ng-container>
37+ </ng-template>
38+ </div>
39+ </div>
40+ </ng-container>
2641 </div>
27- <div class="content-wrapper">
28- <div class="content">
29- <ng-container *ngIf="this.isComponentSheet; else templateRenderer">
30- <ng-container *ngComponentOutlet="this.renderer; injector: this.rendererInjector"></ng-container>
31- </ng-container>
32- <ng-template #templateRenderer>
33- <ng-container *ngTemplateOutlet="this.renderer"></ng-container>
34- </ng-template>
35- </div>
42+ <div class="attached-trigger" *ngIf="!!this.attachedTriggerTemplate" (click)="this.toggleCollapseExpand()">
43+ <ht-icon
44+ class="trigger-icon"
45+ icon="{{ this.isViewCollapsed ? '${ IconType . ChevronUp } ' : '${ IconType . ChevronDown } ' }}"
46+ size="${ IconSize . Small } "
47+ htTooltip="{{ this.isViewCollapsed ? 'Expand Sheet' : 'Collapse Sheet' }}"
48+ ></ht-icon>
49+ <ng-container *ngTemplateOutlet="this.attachedTriggerTemplate"></ng-container>
3650 </div>
37- </div >
51+ </ng-container >
3852 `
3953} )
4054export class SheetOverlayComponent {
@@ -46,6 +60,8 @@ export class SheetOverlayComponent {
4660 public readonly rendererInjector : Injector ;
4761 public visible : boolean = true ;
4862 public readonly closeOnEscape : boolean ;
63+ public readonly attachedTriggerTemplate ?: TemplateRef < unknown > ;
64+ public isViewCollapsed : boolean ;
4965
5066 public constructor (
5167 private readonly popoverRef : PopoverRef ,
@@ -58,13 +74,13 @@ export class SheetOverlayComponent {
5874 this . sheetTitle = sheetConfig . title === undefined ? '' : sheetConfig . title ;
5975 this . size = sheetConfig . size ;
6076 this . closeOnEscape = sheetConfig . closeOnEscapeKey ?? true ;
77+ this . attachedTriggerTemplate = sheetConfig . attachedTriggerTemplate ;
78+ this . isViewCollapsed = ! ! this . attachedTriggerTemplate ;
79+
6180 this . isComponentSheet = ! ( sheetConfig . content instanceof TemplateRef ) ;
6281 this . renderer = sheetConfig . content ;
6382 this . popoverRef . height ( this . getHeightForPopover ( globalHeaderHeight , sheetConfig . position ) ) ;
64-
65- if ( this . size === SheetSize . ResponsiveExtraLarge ) {
66- this . popoverRef . width ( '60%' ) ;
67- }
83+ this . setWidth ( ) ;
6884
6985 this . rendererInjector = Injector . create ( {
7086 providers : [
@@ -89,6 +105,33 @@ export class SheetOverlayComponent {
89105 this . popoverRef . close ( ) ;
90106 }
91107
108+ public toggleCollapseExpand ( ) : void {
109+ this . isViewCollapsed = ! this . isViewCollapsed ;
110+
111+ this . setWidth ( ) ;
112+ }
113+
114+ private setWidth ( ) : void {
115+ this . popoverRef . width ( this . isViewCollapsed ? '0px' : this . getWidthForPopover ( ) ) ;
116+ }
117+
118+ private getWidthForPopover ( ) : string {
119+ switch ( this . size ) {
120+ case SheetSize . Small :
121+ return '320px' ;
122+ case SheetSize . Medium :
123+ return '600px' ;
124+ case SheetSize . Large :
125+ return '840px' ;
126+ case SheetSize . ExtraLarge :
127+ return '1280px' ;
128+ case SheetSize . ResponsiveExtraLarge :
129+ return '60%' ;
130+ default :
131+ return '100%' ;
132+ }
133+ }
134+
92135 private getHeightForPopover ( globalHeaderHeight : string , position ?: PopoverFixedPositionLocation ) : string {
93136 return position === PopoverFixedPositionLocation . Right ? '100vh' : `calc(100vh - ${ globalHeaderHeight } )` ;
94137 }
0 commit comments