Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(window): template as window title #2915

Merged
merged 5 commits into from
Oct 31, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat(window): provide a template to window title
  • Loading branch information
katebatura committed Oct 30, 2021
commit 06e3bc55f703d7e85d649ac8aad15d736718e154
12 changes: 2 additions & 10 deletions src/framework/theme/components/window/window.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import { NbWindowRef } from './window-ref';
template: `
<nb-card>
<nb-card-header>
<div *ngIf="titleTemplatePortal; else textTitleTemplate" cdkFocusInitial>
<div *ngIf="titleTemplatePortal; else textTitleTemplate" cdkFocusInitial tabindex="-1">
<ng-container *ngTemplateOutlet="config.titleTemplate; context: {$implicit: config.titleTemplateContext}"></ng-container>
</div>

<ng-template #textTitleTemplate>
<div *ngIf="!titleTemplatePortal" cdkFocusInitial class="title" tabindex="-1">{{ config.title }}</div>
<div cdkFocusInitial class="title" tabindex="-1">{{ config.title }}</div>
</ng-template>

<div class="buttons">
Expand Down Expand Up @@ -120,14 +120,6 @@ export class NbWindowComponent implements OnInit, AfterViewChecked, OnDestroy {
if (this.config.windowClass) {
this.renderer.addClass(this.elementRef.nativeElement, this.config.windowClass);
}

if (this.config.titleTemplate instanceof TemplateRef) {
this.titleTemplatePortal = new TemplatePortal(
this.config.titleTemplate,
this.viewContainerRef,
{ $implicit: this.config.titleTemplateContext },
);
}
}

ngAfterViewChecked() {
Expand Down