File
Implements
Index
Properties
|
|
|
Methods
|
|
|
HostBindings
|
|
|
HostBindings
|
class.has-margins
|
Type : boolean
|
Default value : false
|
|
|
|
class.is-dark
|
Type : boolean
|
Default value : false
|
|
|
|
class.is-floating
|
Type : boolean
|
Default value : false
|
|
|
|
container
|
Type : ViewContainerRef
|
Decorators :
@ViewChild('container', {read: ViewContainerRef, static: true})
|
|
|
|
hasMargins
|
Default value : false
|
Decorators :
@HostBinding('class.has-margins')
|
|
|
|
isDark
|
Default value : false
|
Decorators :
@HostBinding('class.is-dark')
|
|
|
|
isFloating
|
Default value : false
|
Decorators :
@HostBinding('class.is-floating')
|
|
|
|
render
|
Default value : false
|
|
|
import {
AfterViewInit,
Component,
DestroyRef,
EmbeddedViewRef,
HostBinding,
inject,
ViewChild,
ViewContainerRef
} from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { combineLatest } from 'rxjs';
import { distinctUntilChanged, tap } from 'rxjs/operators';
import { SidebarTemplateSet, TalyFrameSidebarService } from '../../services/sidebar.service';
@Component({
selector: 'frame-sidebar',
styleUrls: ['sidebar.component.scss'],
templateUrl: 'sidebar.component.html',
standalone: false
})
export class SidebarComponent implements AfterViewInit {
private _sidebarService = inject(TalyFrameSidebarService);
@HostBinding('class.is-dark')
isDark = false;
@HostBinding('class.is-floating')
isFloating = false;
@HostBinding('class.has-margins')
hasMargins = false;
protected header = '';
@ViewChild('container', { read: ViewContainerRef, static: true }) container!: ViewContainerRef;
render = false;
private destroyRef = inject(DestroyRef);
_renderTemplates(templates: SidebarTemplateSet) {
this._clearContent();
templates.forEach((template) => {
this.container.createEmbeddedView(template);
this.render = true;
});
}
ngAfterViewInit() {
combineLatest([this._sidebarService.show$, this._sidebarService.templateList$])
.pipe(
takeUntilDestroyed(this.destroyRef),
distinctUntilChanged(),
tap(([enabled, templates]) => {
if (enabled) {
this._renderTemplates(templates);
} else {
this._clearContent();
}
})
)
.subscribe();
this._sidebarService.sidebarConfig$
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((config) => {
if (config.header) {
this.header = config.header;
this.hasMargins = true;
}
this.isDark = config.appearance === 'dark';
this.isFloating = config.position === 'floating';
});
}
private _clearContent() {
this.container.clear();
}
toggle() {
if (this.render) {
this._sidebarService.hideContent();
} else {
this._sidebarService.moveContentToSidebar();
}
}
}
@if (header) {
<div class="header">
<div data-testid="taly-frame-sidebar-header">{{ header }}</div>
<button
data-testid="taly-frame-sidebar-close-button"
nxPlainButton
type="button"
(click)="toggle()"
>
<nx-icon name="close"></nx-icon>
</button>
</div>
}
<div class="content">
<ng-container #container></ng-container>
</div>
:host {
--default-padding: 32px;
--header-bottom-padding: 24px;
--header-line-height: 32px;
display: block;
height: 100%;
background-color: var(--sidepanel-light-background-color);
&:not(.is-floating) {
position: sticky;
top: var(--frame-header-height);
height: calc(100vh - var(--frame-header-height));
}
&.is-dark {
background-color: var(--sidepanel-background-color);
&.is-floating {
box-shadow: var(--sidepanel-floating-shadow);
}
}
&.has-margins {
.content {
padding: 0px var(--default-padding) var(--default-padding);
max-height: calc(
100% -
calc(var(--default-padding) + var(--header-bottom-padding) + var(--header-line-height))
);
}
}
// Remove dynamic-form grid layout gutters negative margins
// to prevent horizontal overflow and keep edge gutters
&:not(.has-margins) .content ::ng-deep taly-dynamic-form-bb .dynamic-form-bb-grid-row {
margin-left: 0;
margin-right: 0;
}
}
.header {
display: flex;
justify-content: space-between;
padding: var(--default-padding) var(--default-padding) var(--header-bottom-padding);
font-size: 24px;
font-style: normal;
font-weight: 600;
line-height: var(--header-line-height);
letter-spacing: 0.2px;
}
.content {
display: block;
height: 100%;
overflow-y: auto;
}
Legend
Html element with directive