@cloudfrogger/goodui 0.0.65 → 0.0.71
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.
- package/ai/README.md +15 -0
- package/ai/case-studies/dockerhub.md +7 -0
- package/ai/case-studies/index.md +1 -0
- package/ai/catalog/component.schema.json +6 -0
- package/ai/catalog/components/good-action-menu.json +2 -2
- package/ai/catalog/components/good-alert.json +2 -2
- package/ai/catalog/components/{good-topbar.json → good-app-header.json} +75 -81
- package/ai/catalog/components/{good-app-layout.json → good-app-shell.json} +32 -68
- package/ai/catalog/components/good-brand-icon.json +6 -6
- package/ai/catalog/components/good-button.json +2 -2
- package/ai/catalog/components/good-dropdown.json +2 -2
- package/ai/catalog/components/good-header-actions.json +10 -1
- package/ai/catalog/components/{good-topbar-dropdown-item.json → good-header-dropdown-item.json} +17 -17
- package/ai/catalog/components/{good-topbar-dropdown-menu.json → good-header-dropdown-menu.json} +14 -14
- package/ai/catalog/components/{good-topbar-menu-item.json → good-header-menu-item.json} +17 -15
- package/ai/catalog/components/{good-topbar-menu-container.json → good-header-menu.json} +16 -14
- package/ai/catalog/components/good-header-search.json +12 -3
- package/ai/catalog/components/{good-topbar-submenu.json → good-header-submenu.json} +12 -12
- package/ai/catalog/components/good-header-themetoggle.json +3 -1
- package/ai/catalog/components/{good-heading.json → good-heading-1.json} +15 -33
- package/ai/catalog/components/good-heading-2.json +46 -0
- package/ai/catalog/components/{good-subheading.json → good-heading-3.json} +9 -30
- package/ai/catalog/components/good-heading-4.json +46 -0
- package/ai/catalog/components/good-heading-5.json +46 -0
- package/ai/catalog/components/good-heading-6.json +46 -0
- package/ai/catalog/components/good-heading-7.json +46 -0
- package/ai/catalog/components/good-heading-group.json +1 -1
- package/ai/catalog/components/good-main-view.json +6 -49
- package/ai/catalog/components/good-notification-host.json +1 -1
- package/ai/catalog/components/good-section.json +20 -2
- package/ai/catalog/components/good-sidebar-item.json +4 -2
- package/ai/catalog/components/good-sidebar-menu-container.json +4 -2
- package/ai/catalog/components/good-sidebar-submenu-group.json +1 -1
- package/ai/catalog/components/good-sidebar-submenu-item.json +1 -1
- package/ai/catalog/components/{good-sidebar-container.json → good-sidebar.json} +23 -26
- package/ai/catalog/components/good-summary.json +6 -1
- package/ai/catalog/index.json +170 -110
- package/ai/examples/edit-form.html +3 -1
- package/ai/examples/edit-form.ts +2 -2
- package/ai/examples/login.html +3 -1
- package/ai/examples/login.ts +2 -2
- package/ai/examples/settings.html +3 -1
- package/ai/examples/settings.ts +2 -2
- package/ai/examples/shell.html +18 -0
- package/ai/examples/shell.ts +11 -0
- package/ai/examples/table-view.html +3 -1
- package/ai/examples/table-view.ts +2 -2
- package/ai/examples/tsconfig.json +2 -1
- package/ai/guides/component-discovery.md +2 -2
- package/ai/guides/layout.md +5 -3
- package/ai/guides/page-patterns.md +7 -3
- package/ai/manifest.json +2 -2
- package/ai/skill/goodui/SKILL.md +11 -3
- package/angular/projects/goodui/package.json +1 -1
- package/angular/projects/goodui/src/lib/actions.ts +27 -3
- package/angular/projects/goodui/src/lib/app-shell.ts +109 -0
- package/angular/projects/goodui/src/lib/{topbar.ts → header.ts} +96 -69
- package/angular/projects/goodui/src/lib/main-view.ts +22 -13
- package/angular/projects/goodui/src/lib/shell-context.ts +46 -0
- package/angular/projects/goodui/src/lib/sidebar.ts +58 -40
- package/angular/projects/goodui/src/lib/typography.ts +51 -41
- package/angular/projects/goodui/src/public-api.ts +2 -2
- package/angular/projects/goodui/src/styles.css +95 -61
- package/angular/projects/goodui/src/tokens.generated.css +43 -6
- package/design/app-shell-contract.json +118 -0
- package/design/component-map.json +153 -71
- package/design/header-search-variants.json +55 -0
- package/design/typography-components.json +327 -0
- package/design-tokens/penpot.tokens.json +160 -6
- package/design.md +49 -37
- package/fesm2022/cloudfrogger-goodui.mjs +501 -342
- package/fesm2022/cloudfrogger-goodui.mjs.map +1 -1
- package/guides/README.md +1 -1
- package/guides/components/action-bar.md +1 -1
- package/guides/components/app-header.md +27 -0
- package/guides/components/columns.md +3 -3
- package/guides/components/header-actions.md +10 -5
- package/guides/components/header-avatar.md +1 -1
- package/guides/components/header-menu.md +64 -0
- package/guides/components/header-notification.md +1 -1
- package/guides/components/header-search.md +26 -5
- package/guides/components/header-themetoggle.md +3 -3
- package/guides/components/icon.md +1 -1
- package/guides/components/main-view.md +30 -8
- package/guides/components/notifications.md +1 -1
- package/guides/components/settings.md +1 -1
- package/guides/components/sidebar.md +16 -34
- package/guides/components/submenus.md +4 -4
- package/guides/components/subnav.md +4 -3
- package/guides/components/typography.md +76 -19
- package/guides/contributing/design-to-code.md +61 -31
- package/guides/foundations/naming.md +1 -1
- package/guides/foundations/tokens.md +7 -7
- package/guides/intro.md +17 -19
- package/guides/layout/app-shell.md +37 -0
- package/guides/layout/layout-rules.md +2 -2
- package/guides/migrations/app-shell.md +28 -0
- package/guides/migrations/explicit-headings.md +20 -0
- package/guides/migrations/header-actions.md +1 -1
- package/guides/migrations/header-menu.md +16 -0
- package/homepage/src/app/examples/calendar-workspace/calendar-workspace-page.ts +2 -10
- package/homepage/src/app/examples/calendar-workspace/source-code.generated.ts +1 -1
- package/homepage/src/app/examples/case-studies/cloudhoster/billing-page.html +6 -4
- package/homepage/src/app/examples/case-studies/cloudhoster/billing-page.ts +2 -20
- package/homepage/src/app/examples/case-studies/cloudhoster/create-database-page.html +5 -5
- package/homepage/src/app/examples/case-studies/cloudhoster/create-database-page.ts +2 -20
- package/homepage/src/app/examples/case-studies/cloudhoster/database-detail-page.html +3 -1
- package/homepage/src/app/examples/case-studies/cloudhoster/database-detail-page.ts +2 -20
- package/homepage/src/app/examples/case-studies/cloudhoster/databases-page.html +7 -5
- package/homepage/src/app/examples/case-studies/cloudhoster/databases-page.ts +2 -14
- package/homepage/src/app/examples/case-studies/cloudhoster/home-page.html +4 -4
- package/homepage/src/app/examples/case-studies/cloudhoster/home-page.ts +2 -12
- package/homepage/src/app/examples/case-studies/cloudhoster/source-code.generated.ts +10 -10
- package/homepage/src/app/examples/case-studies/vpshoster/create-server-page.html +6 -6
- package/homepage/src/app/examples/case-studies/vpshoster/create-server-page.ts +2 -18
- package/homepage/src/app/examples/case-studies/vpshoster/overview-page.html +4 -4
- package/homepage/src/app/examples/case-studies/vpshoster/overview-page.ts +2 -8
- package/homepage/src/app/examples/case-studies/vpshoster/servers-page.html +4 -1
- package/homepage/src/app/examples/case-studies/vpshoster/servers-page.ts +2 -12
- package/homepage/src/app/examples/case-studies/vpshoster/source-code.generated.ts +4 -4
- package/homepage/src/app/examples/case-studies/webmailer/webmailer-page.html +4 -4
- package/homepage/src/app/examples/case-studies/webmailer/webmailer-page.ts +2 -8
- package/homepage/src/app/examples/error-pages/error-pages-example-page.html +3 -1
- package/homepage/src/app/examples/error-pages/error-pages-example-page.ts +2 -7
- package/homepage/src/app/examples/error-pages/source-code.generated.ts +2 -2
- package/homepage/src/app/examples/mail-compose/mail-compose-page.ts +2 -4
- package/homepage/src/app/examples/mail-workspace/mail-workspace-page.ts +2 -10
- package/homepage/src/app/examples/mail-workspace/source-code.generated.ts +1 -1
- package/homepage/src/app/examples/notifications/notifications-page.html +3 -1
- package/homepage/src/app/examples/notifications/notifications-page.ts +2 -8
- package/homepage/src/app/examples/notifications/source-code.generated.ts +2 -2
- package/homepage/src/app/examples/pdf-reader/pdf-reader-page.html +3 -1
- package/homepage/src/app/examples/pdf-reader/pdf-reader-page.ts +2 -7
- package/homepage/src/app/examples/pdf-reader/source-code.generated.ts +2 -2
- package/homepage/src/app/examples/user-registration/source-code.generated.ts +3 -3
- package/homepage/src/app/examples/user-registration/user-registration-example-page.html +1 -1
- package/homepage/src/app/examples/user-registration/user-registration-example-page.ts +2 -2
- package/homepage/src/app/examples/user-registration/user-registration-form.ts +2 -13
- package/homepage/src/app/examples/user-registration/user-registration-page.html +1 -1
- package/homepage/src/app/examples/user-registration/user-registration-page.ts +2 -7
- package/package.json +2 -2
- package/styles.css +1 -1
- package/types/cloudfrogger-goodui.d.ts +202 -107
- package/angular/projects/goodui/src/lib/app-layout.ts +0 -84
- package/guides/components/topbar.md +0 -89
- package/guides/layout/app-layout.md +0 -81
package/ai/skill/goodui/SKILL.md
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: goodui
|
|
3
|
-
description:
|
|
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
|
-
##
|
|
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
|
|
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,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"
|
|
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
|
|
42
|
-
|
|
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,
|
|
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-
|
|
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-
|
|
59
|
+
host: { class: 'good-header-dropdown-item' },
|
|
59
60
|
})
|
|
60
|
-
export class
|
|
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.
|
|
72
|
+
readonly isActive = computed(() => goodTopbarItemContainsRoute(this.item(), this.routeState()));
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
@Component({
|
|
73
|
-
selector: 'good-
|
|
76
|
+
selector: 'good-header-dropdown-menu',
|
|
74
77
|
standalone: true,
|
|
75
|
-
imports: [
|
|
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-
|
|
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-
|
|
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-
|
|
95
|
+
host: { class: 'good-header-dropdown-menu' },
|
|
93
96
|
})
|
|
94
|
-
export class
|
|
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(
|
|
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-
|
|
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-
|
|
164
|
+
selector: 'good-header-submenu',
|
|
160
165
|
standalone: true,
|
|
161
|
-
imports: [
|
|
166
|
+
imports: [GoodHeaderDropdownMenuComponent],
|
|
162
167
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
163
|
-
template: `<good-
|
|
164
|
-
host: { class: 'good-
|
|
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
|
|
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(
|
|
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-
|
|
195
|
+
selector: 'good-header-menu-item',
|
|
189
196
|
standalone: true,
|
|
190
|
-
imports: [RouterLink, GoodIconComponent,
|
|
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-
|
|
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-
|
|
214
|
+
host: { class: 'good-header-menu-item' },
|
|
208
215
|
})
|
|
209
|
-
export class
|
|
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.
|
|
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(
|
|
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-
|
|
307
|
+
selector: 'good-header-menu',
|
|
299
308
|
standalone: true,
|
|
300
|
-
imports: [GoodIconComponent,
|
|
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
|
|
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-
|
|
308
|
-
[attr.role]="mobileMode() === 'popup' ? 'navigation' : null" [attr.aria-label]="mobileMode() === 'popup' ? '
|
|
309
|
-
@for (item of items(); track item.id) { <good-
|
|
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-
|
|
322
|
+
host: { class: 'good-header-menu', '[attr.data-mobile-mode]': 'mobileMode()' },
|
|
314
323
|
})
|
|
315
|
-
export class
|
|
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-
|
|
364
|
+
selector: 'good-app-header',
|
|
354
365
|
standalone: true,
|
|
355
|
-
imports: [GoodIconComponent, GoodBrandIconComponent,
|
|
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)="
|
|
360
|
-
@if (
|
|
361
|
-
@if (
|
|
362
|
-
<good-brand-icon class="good-mobile-brand-icon" [src]="
|
|
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]="!!
|
|
365
|
-
@if (
|
|
366
|
-
<img class="good-brand-logo good-brand-logo-light" [src]="
|
|
367
|
-
@if (
|
|
368
|
-
} @else { {{
|
|
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 (
|
|
373
|
-
|
|
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]="
|
|
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-
|
|
390
|
+
host: { class: 'good-app-header' },
|
|
381
391
|
})
|
|
382
|
-
export class
|
|
383
|
-
readonly
|
|
384
|
-
readonly
|
|
385
|
-
readonly
|
|
386
|
-
readonly
|
|
387
|
-
readonly
|
|
388
|
-
readonly
|
|
389
|
-
readonly
|
|
390
|
-
readonly
|
|
391
|
-
readonly
|
|
392
|
-
readonly
|
|
393
|
-
readonly
|
|
394
|
-
readonly
|
|
395
|
-
readonly
|
|
396
|
-
readonly
|
|
397
|
-
readonly
|
|
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
|
|
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,
|
|
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
|
|
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 (
|
|
15
|
+
@if (hasHeading()) {
|
|
16
16
|
<header class="good-main-view-heading">
|
|
17
|
-
<good-heading-
|
|
18
|
-
|
|
19
|
-
@if (
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
36
|
-
readonly
|
|
37
|
-
readonly eyebrow =
|
|
38
|
-
readonly
|
|
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
|
+
}
|