Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions modules/ui/src/app/components/callout/dynamic-top.directive.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { AfterViewInit, Directive, Renderer2, ElementRef } from '@angular/core';
import {
AfterViewInit,
Directive,
Renderer2,
ElementRef,
OnDestroy,
} from '@angular/core';

@Directive({
selector: '[appDynamicTop]',
standalone: true,
})
export class DynamicTopDirective implements AfterViewInit {
export class DynamicTopDirective implements AfterViewInit, OnDestroy {
constructor(
private renderer: Renderer2,
private element: ElementRef
Expand All @@ -20,6 +26,10 @@ export class DynamicTopDirective implements AfterViewInit {
this.setTop();
}

ngOnDestroy() {
this.moveBottomCalloutsToTop();
}

private setTop() {
const firstCallout =
this.element.nativeElement.parentNode?.firstElementChild;
Expand All @@ -39,4 +49,18 @@ export class DynamicTopDirective implements AfterViewInit {
}
}
}

private moveBottomCalloutsToTop() {
let top = 0; // next callout should be moved to top
const next = this.element.nativeElement.nextElementSibling;
let el = next.nodeName === 'APP-CALLOUT' ? next : null;
while (el) {
this.renderer.setStyle(el, 'top', `${top}px`);
top = el.offsetHeight - 36;
el =
el.nextElementSibling.nodeName === 'APP-CALLOUT'
? el.nextElementSibling
: null;
}
}
}
39 changes: 16 additions & 23 deletions modules/ui/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -260,29 +260,22 @@ body:has(.filter-dialog-content)
opacity: 0;
}

body
#main:has(app-callout)
app-device-repository:not(:has(.device-repository-content-empty)),
body #main:has(app-callout) app-history:not(:has(.results-content-empty)),
body #main:has(app-callout) app-progress:not(:has(.progress-content-empty)),
body #main:has(app-callout) app-risk-assessment .risk-assessment-container {
margin-top: 96px;
}

body
#main:has(app-callout + app-callout)
app-device-repository:not(:has(.device-repository-content-empty)),
body
#main:has(app-callout + app-callout)
app-history:not(:has(.results-content-empty)),
body
#main:has(app-callout + app-callout)
app-progress:not(:has(.progress-content-empty)),
body
#main:has(app-callout + app-callout)
app-risk-assessment
.risk-assessment-container {
margin-top: 156px;
body #main:has(> app-callout) {
& app-device-repository:not(:has(.device-repository-content-empty)),
& app-history:not(:has(.results-content-empty)),
& app-progress:not(:has(.progress-content-empty)),
& app-risk-assessment .risk-assessment-container {
margin-top: 96px;
}
}

body #main:has(> app-callout + app-callout) {
& app-device-repository:not(:has(.device-repository-content-empty)),
& app-history:not(:has(.results-content-empty)),
& app-progress:not(:has(.progress-content-empty)),
& app-risk-assessment .risk-assessment-container {
margin-top: 156px;
}
}

body:has(app-risk-assessment .profiles-drawer) #main app-callout {
Expand Down