-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2564 from IDEMSInternational/feat/sticky-display-…
…group feat: inline header or footer, via 'sticky' display group param
- Loading branch information
Showing
16 changed files
with
231 additions
and
94 deletions.
There are no files selected for viewing
32 changes: 17 additions & 15 deletions
32
src/app/feature/nav-stack/components/nav-stack/nav-stack.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 49 additions & 29 deletions
78
...p/shared/components/template/components/layout/display-group/display-group.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,50 @@ | ||
<div | ||
(click)="clickDisplayGroup()" | ||
class="display-group-wrapper" | ||
[attr.data-param-style]="params.style" | ||
[attr.data-rowname]="_row.name" | ||
[attr.data-variant]="params.variant" | ||
[style.marginBottom.px]="params.offset" | ||
[ngSwitch]="type" | ||
[style]="_row.style_list | styleList" | ||
> | ||
<!-- Default Layout --> | ||
<ng-container *ngSwitchDefault> | ||
<plh-template-component | ||
*ngFor="let childRow of _row.rows | filterDisplayComponent; trackBy: trackByRow" | ||
[row]="childRow" | ||
@if (params.sticky) { | ||
<!-- Sticky display group - includes placeholder padding elements above/below main content --> | ||
@if (params.sticky === "top") { | ||
<div [style.height.px]="sticky.height()"></div> | ||
} | ||
<tmpl-display-group-sticky [position]="params.sticky" #sticky> | ||
<ng-container *ngTemplateOutlet="content"></ng-container> | ||
</tmpl-display-group-sticky> | ||
@if (params.sticky === "bottom") { | ||
<div [style.height.px]="sticky.height()"></div> | ||
} | ||
} @else { | ||
<!-- Regular display group - render templated content --> | ||
<ng-container *ngTemplateOutlet="content"></ng-container> | ||
} | ||
|
||
<!-- Main Content - shown either within sticky or standard versions --> | ||
<ng-template #content> | ||
<!-- --> | ||
<div | ||
(click)="clickDisplayGroup()" | ||
class="display-group-wrapper" | ||
[attr.data-param-style]="params.style" | ||
[attr.data-rowname]="_row.name" | ||
[attr.data-variant]="params.variant" | ||
[style.marginBottom.px]="params.offset" | ||
[ngSwitch]="type" | ||
[style]="_row.style_list | styleList" | ||
> | ||
<!-- Default Layout --> | ||
<ng-container *ngSwitchDefault> | ||
<plh-template-component | ||
*ngFor="let childRow of _row.rows | filterDisplayComponent; trackBy: trackByRow" | ||
[row]="childRow" | ||
[parent]="parent" | ||
[attr.data-rowname]="_row.name" | ||
> | ||
</plh-template-component> | ||
</ng-container> | ||
<!-- Dashed-box --> | ||
<plh-advanced-dashed-box | ||
*ngSwitchCase="'dashed_box'" | ||
[inputRow]="_row" | ||
[parent]="parent" | ||
[attr.data-rowname]="_row.name" | ||
> | ||
</plh-template-component> | ||
</ng-container> | ||
<!-- Dashed-box --> | ||
<plh-advanced-dashed-box | ||
*ngSwitchCase="'dashed_box'" | ||
[inputRow]="_row" | ||
[parent]="parent" | ||
style="flex: 1" | ||
></plh-advanced-dashed-box> | ||
<!-- Form layout --> | ||
<plh-tmpl-form *ngSwitchCase="'form'" [inputRow]="_row" [parent]="parent"></plh-tmpl-form> | ||
</div> | ||
style="flex: 1" | ||
></plh-advanced-dashed-box> | ||
<!-- Form layout --> | ||
<plh-tmpl-form *ngSwitchCase="'form'" [inputRow]="_row" [parent]="parent"></plh-tmpl-form> | ||
</div> | ||
</ng-template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...nents/template/components/layout/display-group/sticky/display-group-sticky.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<ng-content></ng-content> |
19 changes: 19 additions & 0 deletions
19
...nents/template/components/layout/display-group/sticky/display-group-sticky.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// When the display group is "sticky", style it as an inline header/footer | ||
:host { | ||
display: flex; | ||
position: fixed; | ||
left: 0; | ||
width: 100vw; | ||
justify-content: center; | ||
background-color: var(--ion-background-color); | ||
z-index: 10; | ||
|
||
// use provided inputs to specify host top/bottom as signals do not nicely | ||
// map to hostAttribute https://github.com/angular/angular/issues/53888 | ||
&[ng-reflect-position="top"] { | ||
top: 0; | ||
} | ||
&[ng-reflect-position="bottom"] { | ||
bottom: 0; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...ponents/template/components/layout/display-group/sticky/display-group-sticky.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { | ||
AfterViewInit, | ||
Component, | ||
input, | ||
OnDestroy, | ||
signal, | ||
ViewContainerRef, | ||
} from "@angular/core"; | ||
|
||
@Component({ | ||
selector: "tmpl-display-group-sticky", | ||
templateUrl: "display-group-sticky.component.html", | ||
styleUrl: "display-group-sticky.component.scss", | ||
}) | ||
/** | ||
* | ||
*/ | ||
export class TmplDisplayGroupStickyComponent implements AfterViewInit, OnDestroy { | ||
position = input.required<"top" | "bottom">(); | ||
height = signal(0); | ||
|
||
private resizeObserver = new ResizeObserver((entries) => this.handleSizeChange(entries)); | ||
|
||
constructor(private readonly viewRef: ViewContainerRef) {} | ||
|
||
ngAfterViewInit() { | ||
// Observe own component height and update signal so that parent display-group | ||
// can adjust padding as required | ||
this.resizeObserver.observe(this.viewRef.element.nativeElement); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.resizeObserver.disconnect(); | ||
} | ||
|
||
private handleSizeChange(entries: ResizeObserverEntry[]) { | ||
const [{ contentRect }] = entries; | ||
|
||
let topPadding = 0; | ||
if (this.position() === "top") { | ||
// As the display group now sits at the top of the content window ignoring the app-wide padding applied to ion-content, | ||
// the height of the inline display group placeholder should account for this padding | ||
topPadding = this.getContentContainerTopPadding(); | ||
} | ||
|
||
this.height.set(contentRect.height - topPadding); | ||
} | ||
|
||
private getContentContainerTopPadding() { | ||
const computedStyles = getComputedStyle(this.viewRef.element.nativeElement); | ||
const ionContentPaddingStart = | ||
parseFloat(computedStyles.getPropertyValue("--padding-start")) || 0; | ||
return ionContentPaddingStart; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
src/app/shared/components/template/components/title/title.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="title-wrapper" [class]="params.style" [attr.data-variant]="params.variant"> | ||
<h1 | ||
[style.textAlign]="params.textAlign" | ||
[class]="'tiny standard' + ' ' + params.style" | ||
[innerHTML]="_row.value | markdown" | ||
></h1> | ||
<ion-icon | ||
*ngIf="params.help" | ||
name="help-circle-outline" | ||
class="title-help" | ||
[pTooltip]="params.help" | ||
[tooltipPosition]="params.tooltipPosition" | ||
tooltipEvent="click" | ||
></ion-icon> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.