@@ -2,6 +2,7 @@ import { ChangeDetectionStrategy, Component, HostListener, Inject, Injector, Tem
2
2
import { IconType } from '@hypertrace/assets-library' ;
3
3
import { GLOBAL_HEADER_HEIGHT , LayoutChangeService } from '@hypertrace/common' ;
4
4
import { ButtonStyle } from '../../button/button' ;
5
+ import { IconSize } from '../../icon/icon-size' ;
5
6
import { PopoverFixedPositionLocation , POPOVER_DATA } from '../../popover/popover' ;
6
7
import { PopoverRef } from '../../popover/popover-ref' ;
7
8
import { SheetConstructionData } from '../overlay.service' ;
@@ -12,29 +13,42 @@ import { SheetOverlayConfig, SheetSize } from './sheet';
12
13
styleUrls : [ './sheet-overlay.component.scss' ] ,
13
14
changeDetection : ChangeDetectionStrategy . OnPush ,
14
15
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>
26
41
</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>
36
50
</div>
37
- </div >
51
+ </ng-container >
38
52
`
39
53
} )
40
54
export class SheetOverlayComponent {
@@ -46,6 +60,8 @@ export class SheetOverlayComponent {
46
60
public readonly rendererInjector : Injector ;
47
61
public visible : boolean = true ;
48
62
public readonly closeOnEscape : boolean ;
63
+ public readonly attachedTriggerTemplate ?: TemplateRef < unknown > ;
64
+ public isViewCollapsed : boolean ;
49
65
50
66
public constructor (
51
67
private readonly popoverRef : PopoverRef ,
@@ -58,13 +74,13 @@ export class SheetOverlayComponent {
58
74
this . sheetTitle = sheetConfig . title === undefined ? '' : sheetConfig . title ;
59
75
this . size = sheetConfig . size ;
60
76
this . closeOnEscape = sheetConfig . closeOnEscapeKey ?? true ;
77
+ this . attachedTriggerTemplate = sheetConfig . attachedTriggerTemplate ;
78
+ this . isViewCollapsed = ! ! this . attachedTriggerTemplate ;
79
+
61
80
this . isComponentSheet = ! ( sheetConfig . content instanceof TemplateRef ) ;
62
81
this . renderer = sheetConfig . content ;
63
82
this . popoverRef . height ( this . getHeightForPopover ( globalHeaderHeight , sheetConfig . position ) ) ;
64
-
65
- if ( this . size === SheetSize . ResponsiveExtraLarge ) {
66
- this . popoverRef . width ( '60%' ) ;
67
- }
83
+ this . setWidth ( ) ;
68
84
69
85
this . rendererInjector = Injector . create ( {
70
86
providers : [
@@ -89,6 +105,33 @@ export class SheetOverlayComponent {
89
105
this . popoverRef . close ( ) ;
90
106
}
91
107
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
+
92
135
private getHeightForPopover ( globalHeaderHeight : string , position ?: PopoverFixedPositionLocation ) : string {
93
136
return position === PopoverFixedPositionLocation . Right ? '100vh' : `calc(100vh - ${ globalHeaderHeight } )` ;
94
137
}
0 commit comments