Skip to content

Commit

Permalink
support always showing header or footer
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 committed Jan 15, 2025
1 parent 560ff20 commit b86543f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
import {
daffSidebarIsFloatingMode,
DaffSidebarModeEnum,
DaffSidebarRegistration,
} from '@daffodil/design/sidebar';

import { DaffioSidebarRegistration } from '../../registration/type';
import { DaffioSidebarService } from '../../services/sidebar.service';

@Component({
Expand All @@ -29,7 +29,7 @@ export class DaffioSidebarViewportContainer implements OnInit {
mode$: Observable<DaffSidebarModeEnum>;
showSidebarHeader$: Observable<boolean>;
showSidebarFooter$: Observable<boolean>;
component$: Observable<DaffSidebarRegistration>;
component$: Observable<DaffioSidebarRegistration>;

ngOnInit() {
this.component$ = this.sidebarService.activeRegistration$;
Expand All @@ -39,13 +39,13 @@ export class DaffioSidebarViewportContainer implements OnInit {
this.component$,
this.mode$,
]).pipe(
map(([component, mode]) => component?.header && daffSidebarIsFloatingMode(mode)),
map(([component, mode]) => component?.header && (component.alwaysShowHeader || daffSidebarIsFloatingMode(mode))),
);
this.showSidebarFooter$ = combineLatest([
this.component$,
this.mode$,
]).pipe(
map(([component, mode]) => component?.footer && daffSidebarIsFloatingMode(mode)),
map(([component, mode]) => component?.footer && (component.alwaysShowFooter || daffSidebarIsFloatingMode(mode))),
);
}

Expand Down
11 changes: 5 additions & 6 deletions apps/daffio/src/app/core/sidebar/models/route.type.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { Route } from '@angular/router';

import {
DaffSidebarModeEnum,
DaffSidebarRegistration,
} from '@daffodil/design/sidebar';
import { DaffSidebarModeEnum } from '@daffodil/design/sidebar';

import { DaffioSidebarRegistration } from '../registration/type';

export interface DaffioRouteWithSidebars extends Route {
data?: Route['data'] & {
/**
* A collection of sidebars available on the current page.
*/
daffioSidebars?: Record<DaffSidebarRegistration['id'], DaffSidebarRegistration>;
daffioSidebars?: Record<DaffioSidebarRegistration['id'], DaffioSidebarRegistration>;
/**
* The sidebar that should be shown automatically (if any) when the viewport enters big tablet.
*/
daffioDockedSidebar?: DaffSidebarRegistration['id'];
daffioDockedSidebar?: DaffioSidebarRegistration['id'];
sidebarMode?: DaffSidebarModeEnum;
};
}
12 changes: 12 additions & 0 deletions apps/daffio/src/app/core/sidebar/registration/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { DaffSidebarRegistration } from '@daffodil/design/sidebar';

export interface DaffioSidebarRegistration extends DaffSidebarRegistration {
/**
* Whether to show the sidebar header regardless of sidebar mode.
*/
alwaysShowHeader?: boolean;
/**
* Whether to show the sidebar footer regardless of sidebar mode.
*/
alwaysShowFooter?: boolean;
}

0 comments on commit b86543f

Please sign in to comment.