@cloudfrogger/goodui 0.0.65 → 0.0.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/ai/README.md +15 -0
  2. package/ai/case-studies/dockerhub.md +7 -0
  3. package/ai/case-studies/index.md +1 -0
  4. package/ai/catalog/component.schema.json +6 -0
  5. package/ai/catalog/components/good-action-menu.json +2 -2
  6. package/ai/catalog/components/good-alert.json +2 -2
  7. package/ai/catalog/components/{good-topbar.json → good-app-header.json} +75 -81
  8. package/ai/catalog/components/{good-app-layout.json → good-app-shell.json} +32 -68
  9. package/ai/catalog/components/good-brand-icon.json +6 -6
  10. package/ai/catalog/components/good-button.json +2 -2
  11. package/ai/catalog/components/good-dropdown.json +2 -2
  12. package/ai/catalog/components/good-header-actions.json +10 -1
  13. package/ai/catalog/components/{good-topbar-dropdown-item.json → good-header-dropdown-item.json} +17 -17
  14. package/ai/catalog/components/{good-topbar-dropdown-menu.json → good-header-dropdown-menu.json} +14 -14
  15. package/ai/catalog/components/{good-topbar-menu-item.json → good-header-menu-item.json} +17 -15
  16. package/ai/catalog/components/{good-topbar-menu-container.json → good-header-menu.json} +16 -14
  17. package/ai/catalog/components/good-header-search.json +12 -3
  18. package/ai/catalog/components/{good-topbar-submenu.json → good-header-submenu.json} +12 -12
  19. package/ai/catalog/components/good-header-themetoggle.json +3 -1
  20. package/ai/catalog/components/{good-heading.json → good-heading-1.json} +15 -33
  21. package/ai/catalog/components/good-heading-2.json +46 -0
  22. package/ai/catalog/components/{good-subheading.json → good-heading-3.json} +9 -30
  23. package/ai/catalog/components/good-heading-4.json +46 -0
  24. package/ai/catalog/components/good-heading-5.json +46 -0
  25. package/ai/catalog/components/good-heading-6.json +46 -0
  26. package/ai/catalog/components/good-heading-7.json +46 -0
  27. package/ai/catalog/components/good-heading-group.json +1 -1
  28. package/ai/catalog/components/good-main-view.json +6 -49
  29. package/ai/catalog/components/good-notification-host.json +1 -1
  30. package/ai/catalog/components/good-section.json +20 -2
  31. package/ai/catalog/components/good-sidebar-item.json +4 -2
  32. package/ai/catalog/components/good-sidebar-menu-container.json +4 -2
  33. package/ai/catalog/components/good-sidebar-submenu-group.json +1 -1
  34. package/ai/catalog/components/good-sidebar-submenu-item.json +1 -1
  35. package/ai/catalog/components/{good-sidebar-container.json → good-sidebar.json} +23 -26
  36. package/ai/catalog/components/good-summary.json +6 -1
  37. package/ai/catalog/index.json +170 -110
  38. package/ai/examples/edit-form.html +3 -1
  39. package/ai/examples/edit-form.ts +2 -2
  40. package/ai/examples/login.html +3 -1
  41. package/ai/examples/login.ts +2 -2
  42. package/ai/examples/settings.html +3 -1
  43. package/ai/examples/settings.ts +2 -2
  44. package/ai/examples/shell.html +18 -0
  45. package/ai/examples/shell.ts +11 -0
  46. package/ai/examples/table-view.html +3 -1
  47. package/ai/examples/table-view.ts +2 -2
  48. package/ai/examples/tsconfig.json +2 -1
  49. package/ai/guides/component-discovery.md +2 -2
  50. package/ai/guides/layout.md +5 -3
  51. package/ai/guides/page-patterns.md +7 -3
  52. package/ai/manifest.json +2 -2
  53. package/ai/skill/goodui/SKILL.md +11 -3
  54. package/angular/projects/goodui/package.json +1 -1
  55. package/angular/projects/goodui/src/lib/actions.ts +27 -3
  56. package/angular/projects/goodui/src/lib/app-shell.ts +109 -0
  57. package/angular/projects/goodui/src/lib/{topbar.ts → header.ts} +96 -69
  58. package/angular/projects/goodui/src/lib/main-view.ts +22 -13
  59. package/angular/projects/goodui/src/lib/shell-context.ts +46 -0
  60. package/angular/projects/goodui/src/lib/sidebar.ts +58 -40
  61. package/angular/projects/goodui/src/lib/typography.ts +51 -41
  62. package/angular/projects/goodui/src/public-api.ts +2 -2
  63. package/angular/projects/goodui/src/styles.css +95 -61
  64. package/angular/projects/goodui/src/tokens.generated.css +43 -6
  65. package/design/app-shell-contract.json +118 -0
  66. package/design/component-map.json +153 -71
  67. package/design/header-search-variants.json +55 -0
  68. package/design/typography-components.json +327 -0
  69. package/design-tokens/penpot.tokens.json +160 -6
  70. package/design.md +49 -37
  71. package/fesm2022/cloudfrogger-goodui.mjs +501 -342
  72. package/fesm2022/cloudfrogger-goodui.mjs.map +1 -1
  73. package/guides/README.md +1 -1
  74. package/guides/components/action-bar.md +1 -1
  75. package/guides/components/app-header.md +27 -0
  76. package/guides/components/columns.md +3 -3
  77. package/guides/components/header-actions.md +10 -5
  78. package/guides/components/header-avatar.md +1 -1
  79. package/guides/components/header-menu.md +64 -0
  80. package/guides/components/header-notification.md +1 -1
  81. package/guides/components/header-search.md +26 -5
  82. package/guides/components/header-themetoggle.md +3 -3
  83. package/guides/components/icon.md +1 -1
  84. package/guides/components/main-view.md +30 -8
  85. package/guides/components/notifications.md +1 -1
  86. package/guides/components/settings.md +1 -1
  87. package/guides/components/sidebar.md +16 -34
  88. package/guides/components/submenus.md +4 -4
  89. package/guides/components/subnav.md +4 -3
  90. package/guides/components/typography.md +76 -19
  91. package/guides/contributing/design-to-code.md +61 -31
  92. package/guides/foundations/naming.md +1 -1
  93. package/guides/foundations/tokens.md +7 -7
  94. package/guides/intro.md +17 -19
  95. package/guides/layout/app-shell.md +37 -0
  96. package/guides/layout/layout-rules.md +2 -2
  97. package/guides/migrations/app-shell.md +28 -0
  98. package/guides/migrations/explicit-headings.md +20 -0
  99. package/guides/migrations/header-actions.md +1 -1
  100. package/guides/migrations/header-menu.md +16 -0
  101. package/homepage/src/app/examples/calendar-workspace/calendar-workspace-page.ts +2 -10
  102. package/homepage/src/app/examples/calendar-workspace/source-code.generated.ts +1 -1
  103. package/homepage/src/app/examples/case-studies/cloudhoster/billing-page.html +6 -4
  104. package/homepage/src/app/examples/case-studies/cloudhoster/billing-page.ts +2 -20
  105. package/homepage/src/app/examples/case-studies/cloudhoster/create-database-page.html +5 -5
  106. package/homepage/src/app/examples/case-studies/cloudhoster/create-database-page.ts +2 -20
  107. package/homepage/src/app/examples/case-studies/cloudhoster/database-detail-page.html +3 -1
  108. package/homepage/src/app/examples/case-studies/cloudhoster/database-detail-page.ts +2 -20
  109. package/homepage/src/app/examples/case-studies/cloudhoster/databases-page.html +7 -5
  110. package/homepage/src/app/examples/case-studies/cloudhoster/databases-page.ts +2 -14
  111. package/homepage/src/app/examples/case-studies/cloudhoster/home-page.html +4 -4
  112. package/homepage/src/app/examples/case-studies/cloudhoster/home-page.ts +2 -12
  113. package/homepage/src/app/examples/case-studies/cloudhoster/source-code.generated.ts +10 -10
  114. package/homepage/src/app/examples/case-studies/vpshoster/create-server-page.html +6 -6
  115. package/homepage/src/app/examples/case-studies/vpshoster/create-server-page.ts +2 -18
  116. package/homepage/src/app/examples/case-studies/vpshoster/overview-page.html +4 -4
  117. package/homepage/src/app/examples/case-studies/vpshoster/overview-page.ts +2 -8
  118. package/homepage/src/app/examples/case-studies/vpshoster/servers-page.html +4 -1
  119. package/homepage/src/app/examples/case-studies/vpshoster/servers-page.ts +2 -12
  120. package/homepage/src/app/examples/case-studies/vpshoster/source-code.generated.ts +4 -4
  121. package/homepage/src/app/examples/case-studies/webmailer/webmailer-page.html +4 -4
  122. package/homepage/src/app/examples/case-studies/webmailer/webmailer-page.ts +2 -8
  123. package/homepage/src/app/examples/error-pages/error-pages-example-page.html +3 -1
  124. package/homepage/src/app/examples/error-pages/error-pages-example-page.ts +2 -7
  125. package/homepage/src/app/examples/error-pages/source-code.generated.ts +2 -2
  126. package/homepage/src/app/examples/mail-compose/mail-compose-page.ts +2 -4
  127. package/homepage/src/app/examples/mail-workspace/mail-workspace-page.ts +2 -10
  128. package/homepage/src/app/examples/mail-workspace/source-code.generated.ts +1 -1
  129. package/homepage/src/app/examples/notifications/notifications-page.html +3 -1
  130. package/homepage/src/app/examples/notifications/notifications-page.ts +2 -8
  131. package/homepage/src/app/examples/notifications/source-code.generated.ts +2 -2
  132. package/homepage/src/app/examples/pdf-reader/pdf-reader-page.html +3 -1
  133. package/homepage/src/app/examples/pdf-reader/pdf-reader-page.ts +2 -7
  134. package/homepage/src/app/examples/pdf-reader/source-code.generated.ts +2 -2
  135. package/homepage/src/app/examples/user-registration/source-code.generated.ts +3 -3
  136. package/homepage/src/app/examples/user-registration/user-registration-example-page.html +1 -1
  137. package/homepage/src/app/examples/user-registration/user-registration-example-page.ts +2 -2
  138. package/homepage/src/app/examples/user-registration/user-registration-form.ts +2 -13
  139. package/homepage/src/app/examples/user-registration/user-registration-page.html +1 -1
  140. package/homepage/src/app/examples/user-registration/user-registration-page.ts +2 -7
  141. package/package.json +2 -2
  142. package/styles.css +1 -1
  143. package/types/cloudfrogger-goodui.d.ts +202 -107
  144. package/angular/projects/goodui/src/lib/app-layout.ts +0 -84
  145. package/guides/components/topbar.md +0 -89
  146. package/guides/layout/app-layout.md +0 -81
@@ -1,11 +1,19 @@
1
1
  ---
2
2
  name: goodui
3
- description: Build or refine Angular screens with GoodUI components, or compose linked GoodUI designs in Penpot. Use the installed package's component catalog, API details, layout rules, and examples.
3
+ description: Design linked GoodUI screens in Penpot, or build Angular screens with GoodUI components. Use the live design library for Penpot and version-matched component references for Angular.
4
4
  ---
5
5
 
6
6
  # GoodUI
7
7
 
8
- ## Find the matching references
8
+ ## Start with a Penpot design
9
+
10
+ For a design-only task, no Angular project or npm package is required. Use the available Penpot MCP connection to inspect the target file and the live shared GoodUI library. Ask for a missing file link or connection when it cannot be discovered. The skill itself does not install the Penpot library or configure MCP.
11
+
12
+ Compose linked GoodUI instances in the target file, reuse published variants and tokens, and inspect the rendered desktop and mobile designs. Keep domain-specific content in the consuming design. Do not create Angular code unless requested. If a reusable capability is missing, explain the gap before substituting an unrelated custom component.
13
+
14
+ If local GoodUI references are unavailable, read only the relevant design guides and mapping from `https://github.com/cloudfrogger/goodui`: start with `design.md` and `design/component-map.json`, then the affected component guides under `guides/components/`. Use the live library to verify names, IDs, variants, and availability; repository references do not replace live inspection. When implementation begins, use the installed Angular package's matching references as described below.
15
+
16
+ ## Find the matching Angular references
9
17
 
10
18
  In the consuming application's root, read `node_modules/@cloudfrogger/goodui/package.json`. Prefer the references bundled in that same package. Set your reference root to `node_modules/@cloudfrogger/goodui`; paths below are relative to that directory. Check its `ai/manifest.json` and `ai/catalog/index.json` against the installed package name and version.
11
19
 
@@ -16,7 +24,7 @@ For a source checkout, use its root and `angular/projects/goodui/package.json`.
16
24
  1. Read `ai/catalog/index.json` to find suitable selectors and import symbols. `ai/guides/component-discovery.md` explains how to find components, services, and exported types from a task description. Read only the relevant component detail files and linked guides. Catalog files record inputs, defaults, required values, outputs, model changes, projection slots, forms integration, and Penpot ownership. Use `angular/projects/goodui/src/public-api.ts` and the referenced source files for exported types, services, and behavior that needs clarification.
17
25
  2. Read `ai/guides/layout.md` and `ai/guides/page-patterns.md` when composing a page. Choose the shell and page layout before arranging controls. MainView owns page insets and heading alignment; Group, FormRow, Card, Columns, ActionGroup, and the workspace components own their layout. Prefer these capabilities and shared tokens when they satisfy the requested screen. Describe a missing reusable capability when the library cannot express the requested layout, and agree on the approach with the user.
18
26
  3. Import public symbols from `@cloudfrogger/goodui` and global CSS from `@cloudfrogger/goodui/styles.css`. Check the app's root `provideGoodUI()` configuration and router. Use the catalog's exact inputs, outputs, projected slots, and Angular Forms integration. Keep domain data, persistence, and product-specific commands in the consuming application.
19
- 4. For configurable topbar actions, project `good-header-actions` into AppLayout or Topbar and compose action components inside it. Read `guides/components/header-actions.md` and each child guide; configure projected children directly. For notifications, read `guides/components/notifications.md`. AppLayout includes a notification host and a bell in its default menu. A custom HeaderActions chooses whether to include the bell. Use `GoodNotificationCenter` for revisitable messages, an inline Alert for nearby task/form problems, and a transient toast for immediate feedback.
27
+ 4. For configurable topbar actions, project `good-header-actions` into `good-app-header` inside AppShell and compose action components inside it. Read `guides/components/header-actions.md` and each child guide; configure projected children directly. For notifications, read `guides/components/notifications.md`. AppShell includes a notification host; AppHeader supplies a bell when it renders its default actions. A custom HeaderActions chooses whether to include the bell. Use `GoodNotificationCenter` for revisitable messages, an inline Alert for nearby task/form problems, and a transient toast for immediate feedback.
20
28
  5. Use `ai/examples/` for small form, table, and settings patterns. Guides link to complete homepage examples when useful. For a named case study, read `ai/case-studies/index.md`, then that study and its relevant screen. Keep routine component work focused on its relevant references.
21
29
  6. Build the consuming app and exercise the requested interaction. Inspect desktop and mobile layouts, light and dark themes, and applicable keyboard, focus, and form behavior. State what was verified and what still needs a real backend, browser, or device check.
22
30
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudfrogger/goodui",
3
- "version": "0.0.65",
3
+ "version": "0.0.72",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -1,3 +1,4 @@
1
+ import { DOCUMENT } from '@angular/common';
1
2
  import { ChangeDetectionStrategy, Component, ElementRef, HostListener, computed, forwardRef, inject, input, output, signal, viewChild } from '@angular/core';
2
3
  import { RouterLink } from '@angular/router';
3
4
  import { GoodIconComponent } from './icon';
@@ -17,7 +18,11 @@ import { LucideInfo } from '@lucide/angular';
17
18
  imports: [GoodIconComponent, RouterLink],
18
19
  changeDetection: ChangeDetectionStrategy.OnPush,
19
20
  template: `
20
- <button #trigger type="button" class="good-action-button" aria-label="Search" (click)="open()"><good-icon name="search" /></button>
21
+ <button #trigger type="button" class="good-action-button" [class.good-header-search-hotkey]="hotkey()"
22
+ aria-label="Search" [attr.aria-keyshortcuts]="hotkey() ? 'Control+k Meta+k' : null" (click)="open()">
23
+ <good-icon name="search" />
24
+ @if (hotkey()) { <span class="good-header-search-label">Search…</span><kbd class="good-header-search-shortcut" aria-hidden="true">{{ shortcutHint }}</kbd> }
25
+ </button>
21
26
  <dialog #dialog class="good-search-dialog" aria-label="Search" (keydown.escape)="close()" (close)="trigger.focus()">
22
27
  <div class="good-dialog-heading"><strong>Search</strong><button type="button" class="good-action-button" aria-label="Close" (click)="close()"><good-icon name="close" /></button></div>
23
28
  <label class="good-search-field"><good-icon name="search" /><input #searchInput type="search" placeholder="Search…" [value]="query()" (input)="query.set(searchInput.value)" /></label>
@@ -32,14 +37,33 @@ import { LucideInfo } from '@lucide/angular';
32
37
  })
33
38
  export class GoodHeaderSearchComponent {
34
39
  readonly items = input<readonly GoodSearchItem[]>([]);
40
+ readonly hotkey = input(false);
41
+ private readonly document = inject(DOCUMENT);
42
+ readonly shortcutHint = /Mac|iPhone|iPad|iPod/i.test(this.document.defaultView?.navigator.platform ?? '') ? '⌘ K' : 'Ctrl K';
43
+ private readonly trigger = viewChild.required<ElementRef<HTMLButtonElement>>('trigger');
35
44
  readonly query = signal('');
36
45
  readonly results = computed(() => this.items().filter(item => `${item.label} ${item.description ?? ''}`.toLocaleLowerCase().includes(this.query().toLocaleLowerCase())));
37
46
  private readonly dialog = viewChild.required<ElementRef<HTMLDialogElement>>('dialog');
38
47
  private readonly searchInput = viewChild.required<ElementRef<HTMLInputElement>>('searchInput');
39
48
 
49
+ @HostListener('document:keydown', ['$event'])
50
+ onShortcut(event: KeyboardEvent): void {
51
+ if (!this.hotkey() || event.defaultPrevented || event.repeat || event.isComposing ||
52
+ event.altKey || event.shiftKey || event.ctrlKey === event.metaKey || event.key.toLowerCase() !== 'k') return;
53
+ const trigger = this.trigger().nativeElement;
54
+ const style = this.document.defaultView?.getComputedStyle(trigger);
55
+ if (!trigger.getClientRects().length || style?.visibility === 'hidden' || style?.visibility === 'collapse' ||
56
+ trigger.closest('[inert]') || this.document.querySelector('dialog[open], [aria-modal="true"]')) return;
57
+ event.preventDefault();
58
+ this.open();
59
+ }
60
+
40
61
  open(): void {
41
- this.dialog().nativeElement.showModal();
42
- queueMicrotask(() => this.searchInput().nativeElement.focus());
62
+ const dialog = this.dialog().nativeElement;
63
+ if (dialog.open) return;
64
+ dialog.showModal();
65
+ const searchInput = this.searchInput().nativeElement;
66
+ queueMicrotask(() => { if (dialog.open) searchInput.focus(); });
43
67
  }
44
68
  close(): void { this.dialog().nativeElement.close(); }
45
69
  }
@@ -0,0 +1,109 @@
1
+ import { DOCUMENT } from '@angular/common';
2
+ import { ChangeDetectionStrategy, Component, ElementRef, afterNextRender, contentChild, effect, inject, input, signal, viewChild, DestroyRef } from '@angular/core';
3
+ import { GoodSidebarComponent } from './sidebar';
4
+ import { GoodMenuAction, GoodNotification, GoodSearchItem, GoodUser } from './models';
5
+ import { GoodNotificationHostComponent } from './notification-host';
6
+ import { GoodNavigationState, GoodShellContext } from './shell-context';
7
+
8
+ @Component({
9
+ selector: 'good-app-shell', standalone: true,
10
+ imports: [GoodNotificationHostComponent],
11
+ providers: [GoodShellContext],
12
+ changeDetection: ChangeDetectionStrategy.OnPush,
13
+ template: `
14
+ <dialog #drawer open class="good-shell-sidebar" [attr.role]="mobile() ? 'dialog' : 'presentation'"
15
+ [attr.aria-label]="mobile() ? 'Navigation' : null" (click)="onBackdropClick($event)" (close)="onDrawerClose()">
16
+ <ng-content select="good-sidebar" />
17
+ <button type="button" class="good-drawer-close" aria-label="Close sidebar" (click)="closeDrawer()">Close</button>
18
+ </dialog>
19
+ <div class="good-app-main">
20
+ <ng-content select="good-app-header" />
21
+ <div class="good-app-page"><ng-content /></div>
22
+ </div>
23
+ <good-notification-host />
24
+ `,
25
+ host: { class: 'good-app-shell', '[class.good-shell-without-sidebar]': '!sidebar()' },
26
+ })
27
+ export class GoodAppShellComponent {
28
+ private readonly document = inject(DOCUMENT);
29
+ private readonly destroyRef = inject(DestroyRef);
30
+ private readonly context = inject(GoodShellContext);
31
+ private readonly navigation = inject(GoodNavigationState);
32
+ readonly sidebar = contentChild(GoodSidebarComponent);
33
+ private readonly drawer = viewChild<ElementRef<HTMLDialogElement>>('drawer');
34
+ readonly mobile = signal(false);
35
+ private returnFocus: HTMLElement | null = null;
36
+ readonly brand = input('GOODUI');
37
+ readonly brandLogoSrc = input('');
38
+ readonly brandLogoDarkSrc = input('');
39
+ readonly brandMarkSrc = input('');
40
+ readonly brandMarkDarkSrc = input('');
41
+ readonly showBrandIcon = input(false);
42
+ readonly showMobileBrand = input(true);
43
+ readonly user = input<GoodUser | null>(null);
44
+ readonly notifications = input<readonly GoodNotification[]>([]);
45
+ readonly searchItems = input<readonly GoodSearchItem[]>([]);
46
+ readonly settingsActions = input<readonly GoodMenuAction[]>([]);
47
+ readonly showThemeToggle = input(true);
48
+ readonly showSettings = input(false);
49
+ readonly avatarActions = input<readonly GoodMenuAction[]>([]);
50
+
51
+ constructor() {
52
+ effect(() => {
53
+ this.context.hasSidebar.set(!!this.sidebar());
54
+ this.context.options.set({
55
+ brand: this.brand(),
56
+ brandLogoSrc: this.brandLogoSrc(),
57
+ brandLogoDarkSrc: this.brandLogoDarkSrc(),
58
+ brandMarkSrc: this.brandMarkSrc(),
59
+ brandMarkDarkSrc: this.brandMarkDarkSrc(),
60
+ showBrandIcon: this.showBrandIcon(),
61
+ showMobileBrand: this.showMobileBrand(),
62
+ user: this.user(),
63
+ notifications: this.notifications(),
64
+ searchItems: this.searchItems(),
65
+ settingsActions: this.settingsActions(),
66
+ showThemeToggle: this.showThemeToggle(),
67
+ showSettings: this.showSettings(),
68
+ avatarActions: this.avatarActions(),
69
+ });
70
+ });
71
+ effect(() => {
72
+ this.navigation.activeRoute();
73
+ this.context.sidebarOpen.set(false);
74
+ });
75
+ effect(() => {
76
+ const element = this.drawer()?.nativeElement;
77
+ if (!element) return;
78
+ if (!this.mobile()) {
79
+ this.context.sidebarOpen.set(false);
80
+ if (element.matches(':modal')) element.close();
81
+ if (!element.open) element.open = true;
82
+ } else if (this.context.sidebarOpen() && this.sidebar()) {
83
+ if (!element.open) {
84
+ this.returnFocus = this.document.activeElement as HTMLElement;
85
+ element.showModal();
86
+ }
87
+ } else if (element.open) element.close();
88
+ });
89
+ afterNextRender(() => {
90
+ const query = this.document.defaultView?.matchMedia('(max-width: 900px)');
91
+ if (!query) return;
92
+ this.mobile.set(query.matches);
93
+ const update = () => this.mobile.set(query.matches);
94
+ query.addEventListener('change', update);
95
+ this.destroyRef.onDestroy(() => query.removeEventListener('change', update));
96
+ });
97
+ }
98
+
99
+ openDrawer(): void { this.context.sidebarOpen.set(true); }
100
+ closeDrawer(): void { this.context.sidebarOpen.set(false); }
101
+ onBackdropClick(event: MouseEvent): void {
102
+ if (this.mobile() && event.target === this.drawer()!.nativeElement) this.closeDrawer();
103
+ }
104
+ onDrawerClose(): void {
105
+ if (!this.mobile() || this.drawer()?.nativeElement.open) return;
106
+ this.context.sidebarOpen.set(false);
107
+ this.returnFocus?.focus();
108
+ }
109
+ }
@@ -1,4 +1,5 @@
1
- import { ChangeDetectionStrategy, Component, ElementRef, HostListener, OnDestroy, computed, contentChild, forwardRef, inject, input, output, signal, viewChild } from '@angular/core';
1
+ import { ChangeDetectionStrategy, Component, ElementRef, HostListener, OnDestroy, computed, forwardRef, inject, input, output, signal, viewChild } from '@angular/core';
2
+ import { GoodNavigationState, GoodShellContext, GOOD_SHELL_DEFAULTS } from './shell-context';
2
3
  import { RouterLink } from '@angular/router';
3
4
  import { GoodHeaderActionsComponent } from './actions';
4
5
  import { GoodIconComponent } from './icon';
@@ -30,7 +31,7 @@ export class GoodBrandIconComponent {
30
31
  }
31
32
 
32
33
  @Component({
33
- selector: 'good-topbar-dropdown-item',
34
+ selector: 'good-header-dropdown-item',
34
35
  standalone: true,
35
36
  imports: [RouterLink, GoodIconComponent],
36
37
  changeDetection: ChangeDetectionStrategy.OnPush,
@@ -55,49 +56,53 @@ export class GoodBrandIconComponent {
55
56
  </span>
56
57
  }
57
58
  `,
58
- host: { class: 'good-topbar-dropdown-item' },
59
+ host: { class: 'good-header-dropdown-item' },
59
60
  })
60
- export class GoodTopbarDropdownItemComponent {
61
+ export class GoodHeaderDropdownItemComponent {
61
62
  readonly item = input.required<GoodTopbarItem>();
62
63
  readonly activeRoute = input('');
64
+ private readonly navigation = inject(GoodNavigationState);
65
+ readonly routeState = computed(() => this.activeRoute() || this.navigation.activeRoute());
63
66
  readonly expanded = input(false);
64
67
  readonly panelId = input<string | null>(null);
65
68
  readonly hover = output<void>();
66
69
  readonly focused = output<void>();
67
70
  readonly toggle = output<void>();
68
71
  readonly navigate = output<void>();
69
- readonly isActive = computed(() => goodTopbarItemContainsRoute(this.item(), this.activeRoute()));
72
+ readonly isActive = computed(() => goodTopbarItemContainsRoute(this.item(), this.routeState()));
70
73
  }
71
74
 
72
75
  @Component({
73
- selector: 'good-topbar-dropdown-menu',
76
+ selector: 'good-header-dropdown-menu',
74
77
  standalone: true,
75
- imports: [GoodTopbarDropdownItemComponent, forwardRef(() => GoodTopbarSubmenuComponent)],
78
+ imports: [GoodHeaderDropdownItemComponent, forwardRef(() => GoodHeaderSubmenuComponent)],
76
79
  changeDetection: ChangeDetectionStrategy.OnPush,
77
80
  template: `
78
81
  <div class="good-dropdown-panel" role="group" [attr.aria-label]="label()">
79
82
  @for (item of items(); track item.id) {
80
83
  <div class="good-dropdown-entry" [class.good-dropdown-separated]="item.separatorBefore">
81
- <good-topbar-dropdown-item [item]="item" [activeRoute]="activeRoute()"
84
+ <good-header-dropdown-item [item]="item" [activeRoute]="routeState()"
82
85
  [expanded]="openChildId() === item.id" [panelId]="item.children?.length ? panelId(item) : null"
83
86
  (hover)="onHover(item)" (focused)="onFocus(item)" (toggle)="onToggle(item)" (navigate)="onNavigate()" />
84
87
  @if (item.children?.length && openChildId() === item.id) {
85
- <good-topbar-submenu [id]="panelId(item)" [items]="item.children!" [activeRoute]="activeRoute()"
88
+ <good-header-submenu [id]="panelId(item)" [items]="item.children!" [activeRoute]="routeState()"
86
89
  [label]="item.label" (navigate)="onNavigate()" />
87
90
  }
88
91
  </div>
89
92
  }
90
93
  </div>
91
94
  `,
92
- host: { class: 'good-topbar-dropdown-menu' },
95
+ host: { class: 'good-header-dropdown-menu' },
93
96
  })
94
- export class GoodTopbarDropdownMenuComponent {
97
+ export class GoodHeaderDropdownMenuComponent {
95
98
  readonly items = input<readonly GoodTopbarItem[]>([]);
96
99
  readonly label = input('Menu');
97
100
  readonly activeRoute = input('');
101
+ private readonly navigation = inject(GoodNavigationState);
102
+ readonly routeState = computed(() => this.activeRoute() || this.navigation.activeRoute());
98
103
  readonly navigate = output<void>();
99
104
  readonly openChildId = signal<string | null>(null);
100
- readonly submenu = viewChild(GoodTopbarSubmenuComponent);
105
+ readonly submenu = viewChild(GoodHeaderSubmenuComponent);
101
106
  private readonly uid = `good-dropdown-${++nextDropdownId}`;
102
107
  private readonly element: ElementRef<HTMLElement> = inject(ElementRef);
103
108
  private openedByClick = false;
@@ -139,7 +144,7 @@ export class GoodTopbarDropdownMenuComponent {
139
144
  closeDeepest(): boolean {
140
145
  if (this.submenu()?.menu()?.closeDeepest()) return true;
141
146
  if (!this.openChildId()) return false;
142
- const trigger = this.element.nativeElement.querySelector<HTMLElement>(':scope > .good-dropdown-panel > .good-dropdown-entry > good-topbar-dropdown-item > button[aria-expanded="true"]');
147
+ const trigger = this.element.nativeElement.querySelector<HTMLElement>(':scope > .good-dropdown-panel > .good-dropdown-entry > good-header-dropdown-item > button[aria-expanded="true"]');
143
148
  this.openChildId.set(null);
144
149
  this.openedByClick = false;
145
150
  this.suppressFocusOpen = true;
@@ -156,20 +161,22 @@ export class GoodTopbarDropdownMenuComponent {
156
161
  }
157
162
 
158
163
  @Component({
159
- selector: 'good-topbar-submenu',
164
+ selector: 'good-header-submenu',
160
165
  standalone: true,
161
- imports: [GoodTopbarDropdownMenuComponent],
166
+ imports: [GoodHeaderDropdownMenuComponent],
162
167
  changeDetection: ChangeDetectionStrategy.OnPush,
163
- template: `<good-topbar-dropdown-menu [items]="items()" [label]="label()" [activeRoute]="activeRoute()" (navigate)="navigate.emit()" />`,
164
- host: { class: 'good-topbar-submenu', '[class.good-submenu-flipped]': 'flipped()' },
168
+ template: `<good-header-dropdown-menu [items]="items()" [label]="label()" [activeRoute]="routeState()" (navigate)="navigate.emit()" />`,
169
+ host: { class: 'good-header-submenu', '[class.good-submenu-flipped]': 'flipped()' },
165
170
  })
166
- export class GoodTopbarSubmenuComponent {
171
+ export class GoodHeaderSubmenuComponent {
167
172
  readonly items = input<readonly GoodTopbarItem[]>([]);
168
173
  readonly label = input('Submenu');
169
174
  readonly activeRoute = input('');
175
+ private readonly navigation = inject(GoodNavigationState);
176
+ readonly routeState = computed(() => this.activeRoute() || this.navigation.activeRoute());
170
177
  readonly navigate = output<void>();
171
178
  readonly flipped = signal(false);
172
- readonly menu = viewChild(GoodTopbarDropdownMenuComponent);
179
+ readonly menu = viewChild(GoodHeaderDropdownMenuComponent);
173
180
  private readonly element: ElementRef<HTMLElement> = inject(ElementRef);
174
181
 
175
182
  constructor() { setTimeout(() => this.updatePlacement()); }
@@ -185,9 +192,9 @@ export class GoodTopbarSubmenuComponent {
185
192
  }
186
193
 
187
194
  @Component({
188
- selector: 'good-topbar-menu-item',
195
+ selector: 'good-header-menu-item',
189
196
  standalone: true,
190
- imports: [RouterLink, GoodIconComponent, GoodTopbarDropdownMenuComponent],
197
+ imports: [RouterLink, GoodIconComponent, GoodHeaderDropdownMenuComponent],
191
198
  changeDetection: ChangeDetectionStrategy.OnPush,
192
199
  template: `
193
200
  @if (children().length) {
@@ -197,27 +204,29 @@ export class GoodTopbarSubmenuComponent {
197
204
  {{ text() }}<good-icon name="chevron-down" />
198
205
  </button>
199
206
  @if (open()) {
200
- <good-topbar-dropdown-menu [id]="panelId" [items]="children()" [label]="text()" [activeRoute]="activeRoute()" (navigate)="closeMenu()" />
207
+ <good-header-dropdown-menu [id]="panelId" [items]="children()" [label]="text()" [activeRoute]="routeState()" (navigate)="closeMenu()" />
201
208
  }
202
209
  } @else if (link()) {
203
210
  <a class="good-topbar-link" [class.good-is-active]="isActive()" [routerLink]="link()"
204
211
  [attr.aria-current]="isActive() ? 'page' : null">{{ text() }}</a>
205
212
  } @else { <span class="good-topbar-link">{{ text() }}</span> }
206
213
  `,
207
- host: { class: 'good-topbar-menu-item' },
214
+ host: { class: 'good-header-menu-item' },
208
215
  })
209
- export class GoodTopbarMenuItemComponent implements OnDestroy {
216
+ export class GoodHeaderMenuItemComponent implements OnDestroy {
210
217
  readonly item = input<GoodTopbarItem | null>(null);
211
218
  readonly label = input('');
212
219
  readonly route = input<string | undefined>();
213
220
  readonly active = input(false);
214
221
  readonly activeRoute = input('');
222
+ private readonly navigation = inject(GoodNavigationState);
223
+ readonly routeState = computed(() => this.activeRoute() || this.navigation.activeRoute());
215
224
  readonly text = computed(() => this.item()?.label ?? this.label());
216
225
  readonly link = computed(() => this.item()?.route ?? this.route());
217
226
  readonly children = computed(() => this.item()?.children ?? []);
218
- readonly isActive = computed(() => this.active() || goodRouteActive(this.link(), this.activeRoute()) || (this.item() ? goodTopbarItemContainsRoute(this.item()!, this.activeRoute()) : false));
227
+ readonly isActive = computed(() => this.active() || goodRouteActive(this.link(), this.routeState()) || (this.item() ? goodTopbarItemContainsRoute(this.item()!, this.routeState()) : false));
219
228
  readonly open = signal(false);
220
- readonly dropdown = viewChild(GoodTopbarDropdownMenuComponent);
229
+ readonly dropdown = viewChild(GoodHeaderDropdownMenuComponent);
221
230
  readonly panelId = `good-topbar-panel-${++nextDropdownId}`;
222
231
  private readonly element: ElementRef<HTMLElement> = inject(ElementRef);
223
232
  private openedByClick = false;
@@ -295,26 +304,28 @@ export class GoodTopbarMenuItemComponent implements OnDestroy {
295
304
  }
296
305
 
297
306
  @Component({
298
- selector: 'good-topbar-menu-container',
307
+ selector: 'good-header-menu',
299
308
  standalone: true,
300
- imports: [GoodIconComponent, GoodTopbarMenuItemComponent],
309
+ imports: [GoodIconComponent, GoodHeaderMenuItemComponent],
301
310
  changeDetection: ChangeDetectionStrategy.OnPush,
302
311
  template: `
303
312
  <button #mobileTrigger type="button" class="good-topbar-mobile-trigger good-action-button"
304
- [attr.aria-label]="mobileOpen() ? 'Close topbar menu' : 'Open topbar menu'"
313
+ [attr.aria-label]="mobileOpen() ? 'Close header menu' : 'Open header menu'"
305
314
  aria-haspopup="true" [attr.aria-expanded]="mobileOpen()" [attr.aria-controls]="mobilePanelId"
306
315
  (click)="toggleMobileMenu()"><good-icon name="grid" /></button>
307
- <div class="good-topbar-menu-items" [id]="mobilePanelId" [class.good-topbar-menu-popup-open]="mobileOpen()"
308
- [attr.role]="mobileMode() === 'popup' ? 'navigation' : null" [attr.aria-label]="mobileMode() === 'popup' ? 'Topbar menu' : null">
309
- @for (item of items(); track item.id) { <good-topbar-menu-item [item]="item" [activeRoute]="activeRoute()" /> }
316
+ <div class="good-header-menu-items" [id]="mobilePanelId" [class.good-header-menu-popup-open]="mobileOpen()"
317
+ [attr.role]="mobileMode() === 'popup' ? 'navigation' : null" [attr.aria-label]="mobileMode() === 'popup' ? 'Header menu' : null">
318
+ @for (item of items(); track item.id) { <good-header-menu-item [item]="item" [activeRoute]="routeState()" /> }
310
319
  <ng-content />
311
320
  </div>
312
321
  `,
313
- host: { class: 'good-topbar-menu-container', '[attr.data-mobile-mode]': 'mobileMode()' },
322
+ host: { class: 'good-header-menu', '[attr.data-mobile-mode]': 'mobileMode()' },
314
323
  })
315
- export class GoodTopbarMenuContainerComponent {
324
+ export class GoodHeaderMenuComponent {
316
325
  readonly items = input<readonly GoodTopbarItem[]>([]);
317
326
  readonly activeRoute = input('');
327
+ private readonly navigation = inject(GoodNavigationState);
328
+ readonly routeState = computed(() => this.activeRoute() || this.navigation.activeRoute());
318
329
  readonly mobileMode = input<GoodTopbarMobileMenuMode>('hidden');
319
330
  readonly mobileOpen = signal(false);
320
331
  readonly mobilePanelId = `good-topbar-mobile-panel-${++nextDropdownId}`;
@@ -350,53 +361,69 @@ export class GoodTopbarMenuContainerComponent {
350
361
  }
351
362
 
352
363
  @Component({
353
- selector: 'good-topbar',
364
+ selector: 'good-app-header',
354
365
  standalone: true,
355
- imports: [GoodIconComponent, GoodBrandIconComponent, GoodTopbarMenuContainerComponent, GoodHeaderActionsComponent],
366
+ imports: [GoodIconComponent, GoodBrandIconComponent, GoodHeaderActionsComponent],
356
367
  changeDetection: ChangeDetectionStrategy.OnPush,
357
368
  template: `
358
369
  <div class="good-topbar-left">
359
- <button type="button" class="good-mobile-menu-button good-action-button" aria-label="Open sidebar" (click)="menuToggle.emit()"><good-icon name="menu" /></button>
360
- @if (showMobileBrand()) {
361
- @if (brandMarkSrc()) {
362
- <good-brand-icon class="good-mobile-brand-icon" [src]="brandMarkSrc()" [darkSrc]="brandMarkDarkSrc()" [label]="brand()" />
370
+ @if (!shell || shell.hasSidebar()) { <button type="button" class="good-mobile-menu-button good-action-button" aria-label="Open sidebar" (click)="openSidebar()"><good-icon name="menu" /></button> }
371
+ @if (config().showMobileBrand) {
372
+ @if (config().brandMarkSrc) {
373
+ <good-brand-icon class="good-mobile-brand-icon" [src]="config().brandMarkSrc" [darkSrc]="config().brandMarkDarkSrc" [label]="config().brand" />
363
374
  } @else {
364
- <span class="good-mobile-brand" [class.good-has-dark-logo]="!!brandLogoDarkSrc()">
365
- @if (brandLogoSrc()) {
366
- <img class="good-brand-logo good-brand-logo-light" [src]="brandLogoSrc()" [alt]="brand()" />
367
- @if (brandLogoDarkSrc()) { <img class="good-brand-logo good-brand-logo-dark" [src]="brandLogoDarkSrc()" [alt]="brand()" /> }
368
- } @else { {{ brand() }} }
375
+ <span class="good-mobile-brand" [class.good-has-dark-logo]="!!config().brandLogoDarkSrc">
376
+ @if (config().brandLogoSrc) {
377
+ <img class="good-brand-logo good-brand-logo-light" [src]="config().brandLogoSrc" [alt]="config().brand" />
378
+ @if (config().brandLogoDarkSrc) { <img class="good-brand-logo good-brand-logo-dark" [src]="config().brandLogoDarkSrc" [alt]="config().brand" /> }
379
+ } @else { {{ config().brand }} }
369
380
  </span>
370
381
  }
371
382
  }
372
- @if (showBrandIcon()) { <good-brand-icon class="good-desktop-brand-icon" [src]="brandMarkSrc()" [darkSrc]="brandMarkDarkSrc()" [label]="brand()" /> }
373
- @if (!projectedMenu()) { <good-topbar-menu-container [items]="items()" [activeRoute]="activeRoute()" [mobileMode]="mobileMenuMode()" /> }
374
- <ng-content select="good-topbar-menu-container" />
383
+ @if (config().showBrandIcon) { <good-brand-icon class="good-desktop-brand-icon" [src]="config().brandMarkSrc" [darkSrc]="config().brandMarkDarkSrc" [label]="config().brand" /> }
384
+ <ng-content select="good-header-menu" />
375
385
  </div>
376
386
  <ng-content select="good-header-actions">
377
- <good-header-actions [user]="user()" [notifications]="notifications()" [searchItems]="searchItems()" [settingsActions]="settingsActions()" [avatarActions]="avatarActions()" [showThemeToggle]="showThemeToggle()" [showSettings]="showSettings()" />
387
+ <good-header-actions [user]="config().user" [notifications]="config().notifications" [searchItems]="config().searchItems" [settingsActions]="config().settingsActions" [avatarActions]="config().avatarActions" [showThemeToggle]="config().showThemeToggle" [showSettings]="config().showSettings" />
378
388
  </ng-content>
379
389
  `,
380
- host: { class: 'good-topbar', '[attr.data-mobile-menu]': 'mobileMenuMode()' },
390
+ host: { class: 'good-app-header' },
381
391
  })
382
- export class GoodTopbarComponent {
383
- readonly brand = input('GOODUI');
384
- readonly brandLogoSrc = input('');
385
- readonly brandLogoDarkSrc = input('');
386
- readonly brandMarkSrc = input('');
387
- readonly brandMarkDarkSrc = input('');
388
- readonly showBrandIcon = input(false);
389
- readonly showMobileBrand = input(true);
390
- readonly items = input<readonly GoodTopbarItem[]>([]);
391
- readonly activeRoute = input('');
392
- readonly mobileMenuMode = input<GoodTopbarMobileMenuMode>('hidden');
393
- readonly user = input<GoodUser | null>(null);
394
- readonly notifications = input<readonly GoodNotification[]>([]);
395
- readonly searchItems = input<readonly GoodSearchItem[]>([]);
396
- readonly settingsActions = input<readonly GoodMenuAction[]>([]);
397
- readonly showThemeToggle = input(true);
398
- readonly showSettings = input(false);
399
- readonly avatarActions = input<readonly GoodMenuAction[]>([]);
392
+ export class GoodAppHeaderComponent {
393
+ readonly shell = inject(GoodShellContext, { optional: true });
394
+ readonly brand = input<string>();
395
+ readonly brandLogoSrc = input<string>();
396
+ readonly brandLogoDarkSrc = input<string>();
397
+ readonly brandMarkSrc = input<string>();
398
+ readonly brandMarkDarkSrc = input<string>();
399
+ readonly showBrandIcon = input<boolean>();
400
+ readonly showMobileBrand = input<boolean>();
401
+ readonly user = input<GoodUser | null>();
402
+ readonly notifications = input<readonly GoodNotification[]>();
403
+ readonly searchItems = input<readonly GoodSearchItem[]>();
404
+ readonly settingsActions = input<readonly GoodMenuAction[]>();
405
+ readonly showThemeToggle = input<boolean>();
406
+ readonly showSettings = input<boolean>();
407
+ readonly avatarActions = input<readonly GoodMenuAction[]>();
400
408
  readonly menuToggle = output<void>();
401
- readonly projectedMenu = contentChild(GoodTopbarMenuContainerComponent);
409
+ readonly config = computed(() => {
410
+ const inherited = this.shell?.options() ?? GOOD_SHELL_DEFAULTS;
411
+ return {
412
+ brand: this.brand() ?? inherited.brand,
413
+ brandLogoSrc: this.brandLogoSrc() ?? inherited.brandLogoSrc,
414
+ brandLogoDarkSrc: this.brandLogoDarkSrc() ?? inherited.brandLogoDarkSrc,
415
+ brandMarkSrc: this.brandMarkSrc() ?? inherited.brandMarkSrc,
416
+ brandMarkDarkSrc: this.brandMarkDarkSrc() ?? inherited.brandMarkDarkSrc,
417
+ showBrandIcon: this.showBrandIcon() ?? inherited.showBrandIcon,
418
+ showMobileBrand: this.showMobileBrand() ?? inherited.showMobileBrand,
419
+ user: this.user() === undefined ? inherited.user : this.user()!,
420
+ notifications: this.notifications() ?? inherited.notifications,
421
+ searchItems: this.searchItems() ?? inherited.searchItems,
422
+ settingsActions: this.settingsActions() ?? inherited.settingsActions,
423
+ showThemeToggle: this.showThemeToggle() ?? inherited.showThemeToggle,
424
+ showSettings: this.showSettings() ?? inherited.showSettings,
425
+ avatarActions: this.avatarActions() ?? inherited.avatarActions,
426
+ };
427
+ });
428
+ openSidebar(): void { this.shell?.sidebarOpen.set(true); this.menuToggle.emit(); }
402
429
  }
@@ -1,6 +1,6 @@
1
- import { ChangeDetectionStrategy, Component, input } from '@angular/core';
1
+ import { ChangeDetectionStrategy, Component, computed, contentChild, input } from '@angular/core';
2
2
  import { GoodSubnavComponent } from './subnav';
3
- import { GoodEyebrowComponent, GoodEyebrowAppearance, GoodHeadingComponent, GoodHeadingGroupComponent, GoodSummaryComponent } from './typography';
3
+ import { GoodEyebrowComponent, GoodHeading1Component, GoodHeadingGroupComponent, GoodSummaryComponent } from './typography';
4
4
  import { GoodSubnavAction, GoodSubnavItem } from './models';
5
5
 
6
6
  export type GoodMainViewLayout = 'page' | 'fill';
@@ -8,17 +8,24 @@ export type GoodMainViewLayout = 'page' | 'fill';
8
8
  @Component({
9
9
  selector: 'good-main-view',
10
10
  standalone: true,
11
- imports: [GoodSubnavComponent, GoodHeadingGroupComponent, GoodEyebrowComponent, GoodHeadingComponent, GoodSummaryComponent],
11
+ imports: [GoodSubnavComponent],
12
12
  changeDetection: ChangeDetectionStrategy.OnPush,
13
13
  template: `
14
14
  @if (subnavItems().length) { <good-subnav [items]="subnavItems()" [actions]="subnavActions()" [ariaLabel]="subnavLabel()" /> }
15
- @if (eyebrow() || title() || description()) {
15
+ @if (hasHeading()) {
16
16
  <header class="good-main-view-heading">
17
- <good-heading-group>
18
- @if (eyebrow()) { <good-eyebrow [appearance]="eyebrowAppearance()">{{ eyebrow() }}</good-eyebrow> }
19
- @if (title()) { <good-heading>{{ title() }}</good-heading> }
20
- @if (description()) { <good-summary>{{ description() }}</good-summary> }
21
- </good-heading-group>
17
+ <div class="good-main-view-heading-content">
18
+ <ng-content select="good-heading-group" />
19
+ @if (hasDirectHeading()) {
20
+ <div class="good-heading-group">
21
+ <ng-content select="good-eyebrow" />
22
+ <div class="good-heading-group-text">
23
+ <ng-content select="good-heading-1" />
24
+ <ng-content select="good-summary" />
25
+ </div>
26
+ </div>
27
+ }
28
+ </div>
22
29
  <div class="good-main-view-actions"><ng-content select="[good-main-view-actions]" /></div>
23
30
  </header>
24
31
  }
@@ -32,8 +39,10 @@ export class GoodMainViewComponent {
32
39
  readonly subnavItems = input<readonly GoodSubnavItem[]>([]);
33
40
  readonly subnavActions = input<readonly GoodSubnavAction[]>([]);
34
41
  readonly subnavLabel = input('Subnav');
35
- readonly title = input('');
36
- readonly description = input('');
37
- readonly eyebrow = input('');
38
- readonly eyebrowAppearance = input<GoodEyebrowAppearance>('brand');
42
+ private readonly heading = contentChild(GoodHeading1Component, { descendants: false });
43
+ private readonly summary = contentChild(GoodSummaryComponent, { descendants: false });
44
+ private readonly eyebrow = contentChild(GoodEyebrowComponent, { descendants: false });
45
+ private readonly headingGroup = contentChild(GoodHeadingGroupComponent, { descendants: false });
46
+ protected readonly hasDirectHeading = computed(() => !!(this.heading() || this.summary() || this.eyebrow()));
47
+ protected readonly hasHeading = computed(() => this.hasDirectHeading() || !!this.headingGroup());
39
48
  }
@@ -0,0 +1,46 @@
1
+ import { Injectable, inject, signal } from '@angular/core';
2
+ import { NavigationEnd, Router } from '@angular/router';
3
+ import { toSignal } from '@angular/core/rxjs-interop';
4
+ import { filter, map } from 'rxjs';
5
+ import { GoodMenuAction, GoodNotification, GoodSearchItem, GoodUser } from './models';
6
+
7
+ export interface GoodShellOptions {
8
+ brand: string;
9
+ brandLogoSrc: string;
10
+ brandLogoDarkSrc: string;
11
+ brandMarkSrc: string;
12
+ brandMarkDarkSrc: string;
13
+ showBrandIcon: boolean;
14
+ showMobileBrand: boolean;
15
+ user: GoodUser | null;
16
+ notifications: readonly GoodNotification[];
17
+ searchItems: readonly GoodSearchItem[];
18
+ settingsActions: readonly GoodMenuAction[];
19
+ showThemeToggle: boolean;
20
+ showSettings: boolean;
21
+ avatarActions: readonly GoodMenuAction[];
22
+ }
23
+
24
+ export const GOOD_SHELL_DEFAULTS: GoodShellOptions = {
25
+ brand: 'GOODUI', brandLogoSrc: '', brandLogoDarkSrc: '', brandMarkSrc: '', brandMarkDarkSrc: '',
26
+ showBrandIcon: false, showMobileBrand: true, user: null, notifications: [], searchItems: [],
27
+ settingsActions: [], showThemeToggle: true, showSettings: false, avatarActions: [],
28
+ };
29
+
30
+ @Injectable()
31
+ export class GoodShellContext {
32
+ readonly options = signal<GoodShellOptions>(GOOD_SHELL_DEFAULTS);
33
+ readonly hasSidebar = signal(false);
34
+ readonly sidebarOpen = signal(false);
35
+ }
36
+
37
+ @Injectable({ providedIn: 'root' })
38
+ export class GoodNavigationState {
39
+ private readonly router = inject(Router, { optional: true });
40
+ readonly activeRoute = this.router
41
+ ? toSignal(this.router.events.pipe(
42
+ filter((event): event is NavigationEnd => event instanceof NavigationEnd),
43
+ map(event => event.urlAfterRedirects.split(/[?#]/)[0] || '/'),
44
+ ), { initialValue: this.router.url.split(/[?#]/)[0] || '/' })
45
+ : signal('/');
46
+ }