Skip to content

Commit

Permalink
fix(theme:layout): fix display service cascade
Browse files Browse the repository at this point in the history
  • Loading branch information
devcui committed Feb 17, 2023
1 parent 301a2e7 commit 4d1209f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
9 changes: 8 additions & 1 deletion packages/bis/layout/layout-basic/layout-basic.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class YunzaiLayoutBasicComponent implements OnInit, OnDestroy {
if (!this.state.display.nav) {
cascadingStyleSheet = {
...cascadingStyleSheet,
top: 0
top: '0px'
};
}
if (!this.state.display.aside) {
Expand Down Expand Up @@ -207,6 +207,13 @@ class YunzaiLayoutBasicComponent implements OnInit, OnDestroy {
this.layoutDisplayService.listen('reuseTab', (display: boolean) => {
this.state.display.reusetab = display;
});
this.layoutDisplayService.listen('nav', (display: boolean) => {
this.state.display.nav = display;
});

this.layoutDisplayService.listen('aside', (display: boolean) => {
this.state.display.aside = display;
});
}

ngOnDestroy(): void {
Expand Down
24 changes: 15 additions & 9 deletions packages/theme/layout-default/layout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ import { LayoutDefaultOptions } from './types';
<div class="yunzai-default__progress-bar" *ngIf="isFetching"></div>
<layout-default-header *ngIf="!opt.hideHeader && displayNav" [items]="headerItems"></layout-default-header>
<ng-container *ngIf="displayAside">
<div
*ngIf="!opt.hideAside"
class="yunzai-default__aside"
[ngStyle]="!displayAside ? { 'margin-top': '0px' } : {}"
>
<div *ngIf="!opt.hideAside" class="yunzai-default__aside" [ngStyle]="asideStyle">
<div class="yunzai-default__aside-wrap">
<div class="yunzai-default__aside-inner">
<ng-container *ngTemplateOutlet="asideUser"></ng-container>
Expand All @@ -60,10 +56,7 @@ import { LayoutDefaultOptions } from './types';
</div>
</div>
</ng-container>
<section
class="yunzai-default__content"
[ngStyle]="{ 'margin-top': !displayNav ? '0px' : '', 'margin-left': !displayAside ? '0px' : '' }"
>
<section class="yunzai-default__content" [ngStyle]="contentStyle">
<ng-container *ngTemplateOutlet="content"></ng-container>
<ng-content></ng-content>
</section>
Expand All @@ -87,6 +80,19 @@ export class LayoutDefaultComponent implements OnInit, OnDestroy {
@Input() content: TemplateRef<void> | null = null;
@Input() customError?: string | null;

get contentStyle(): any {
return {
'margin-top': !this.displayNav ? '0px' : '',
'margin-left': !this.displayAside ? '0px' : ''
};
}

get asideStyle(): any {
return {
'margin-top': !this.displayNav ? '0px' : ''
};
}

displayNav = true;
displayAside = true;

Expand Down

0 comments on commit 4d1209f

Please sign in to comment.