@ojiepermana/angular 21.1.12 → 21.1.13
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/brand/etos/README.md +149 -76
- package/package.json +1 -1
package/brand/etos/README.md
CHANGED
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Etos implementation lives under `projects/angular/brand/etos`. Published consumers should use `@ojiepermana/angular/etos`.
|
|
4
4
|
|
|
5
|
+
This package is the Etos-specific layer on top of the shared Angular libraries. It owns the Etos brand defaults, shell composition, brand stylesheet, and Etos-only UI such as the profile/theme switcher.
|
|
6
|
+
|
|
5
7
|
Use this folder for Etos-specific implementation:
|
|
6
8
|
|
|
7
|
-
- `core/` contains
|
|
9
|
+
- `core/` contains brand defaults and provider composition.
|
|
10
|
+
- `component/` contains Etos-owned UI such as `EtosThemeSwitcherComponent`.
|
|
11
|
+
- `shells/` contains `EtosLayoutComponent` and the Etos empty, horizontal, and vertical shells.
|
|
8
12
|
- `themes/` contains Etos color, style, layout, and component-facing CSS.
|
|
9
|
-
- `navigation/`, `
|
|
13
|
+
- `navigation/`, `assets/`, and `docs/` can be added when Etos needs brand-specific behavior beyond shared primitives.
|
|
10
14
|
|
|
11
15
|
Shared services, types, and primitives stay in the generic libraries:
|
|
12
16
|
|
|
@@ -14,36 +18,87 @@ Shared services, types, and primitives stay in the generic libraries:
|
|
|
14
18
|
- `@ojiepermana/angular/layout`
|
|
15
19
|
- `@ojiepermana/angular/navigation`
|
|
16
20
|
|
|
17
|
-
##
|
|
21
|
+
## Public entrypoint
|
|
18
22
|
|
|
19
23
|
Published consumers should import Etos through the short public entrypoint:
|
|
20
24
|
|
|
21
25
|
```ts
|
|
22
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
EtosLayoutComponent,
|
|
28
|
+
EtosThemeSwitcherComponent,
|
|
29
|
+
provideEtosBrand,
|
|
30
|
+
provideEtosLayout,
|
|
31
|
+
provideEtosTheme,
|
|
32
|
+
type EtosBrandOptions,
|
|
33
|
+
type EtosThemeSwitcherQuickAction,
|
|
34
|
+
type EtosThemeSwitcherUserInfo,
|
|
35
|
+
} from '@ojiepermana/angular/etos';
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`@ojiepermana/angular/etos` currently exports:
|
|
39
|
+
|
|
40
|
+
- `provideEtosBrand()` to apply the Etos theme and layout defaults together and optionally register navigation items.
|
|
41
|
+
- `provideEtosTheme()` to install only the Etos theme wrapper over the shared theme provider.
|
|
42
|
+
- `provideEtosLayout()` to install only the Etos layout wrapper over the shared layout provider.
|
|
43
|
+
- `EtosLayoutComponent` to render the Etos shell from the current layout mode.
|
|
44
|
+
- `EtosThemeSwitcherComponent` and related types for the profile/preferences UI.
|
|
45
|
+
|
|
46
|
+
## Provider setup
|
|
47
|
+
|
|
48
|
+
Etos ships with these defaults:
|
|
49
|
+
|
|
50
|
+
- Theme defaults to brand `etos` with light mode.
|
|
51
|
+
- Layout defaults to `vertical` mode with `container` width.
|
|
52
|
+
|
|
53
|
+
Recommended provider configuration:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { ApplicationConfig, provideBrowserGlobalErrorListeners } from '@angular/core';
|
|
57
|
+
import { provideRouter } from '@angular/router';
|
|
58
|
+
import { type EtosBrandOptions, provideEtosBrand } from '@ojiepermana/angular/etos';
|
|
59
|
+
|
|
60
|
+
import { AppNavigation } from './app.navigation';
|
|
61
|
+
import { routes } from './app.routes';
|
|
23
62
|
|
|
24
63
|
export const etosBrandConfig = {
|
|
25
64
|
theme: {
|
|
26
65
|
mode: 'light',
|
|
27
|
-
style: 'default',
|
|
28
66
|
},
|
|
29
67
|
layout: {
|
|
30
68
|
mode: 'vertical',
|
|
31
|
-
width: 'container',
|
|
32
69
|
},
|
|
70
|
+
navigation: AppNavigation,
|
|
33
71
|
} satisfies EtosBrandOptions;
|
|
34
72
|
|
|
35
|
-
export const appConfig = {
|
|
36
|
-
providers: [provideEtosBrand(etosBrandConfig)],
|
|
73
|
+
export const appConfig: ApplicationConfig = {
|
|
74
|
+
providers: [provideBrowserGlobalErrorListeners(), provideRouter(routes), provideEtosBrand(etosBrandConfig)],
|
|
37
75
|
};
|
|
38
76
|
```
|
|
39
77
|
|
|
40
|
-
`provideEtosBrand()`
|
|
78
|
+
`provideEtosBrand()` accepts these Etos-specific options:
|
|
79
|
+
|
|
80
|
+
- `theme` merges into the shared Material theme config while keeping the Etos brand tokens.
|
|
81
|
+
- `layout` merges into the shared Material layout config while keeping the Etos layout defaults.
|
|
82
|
+
- `navigation` registers navigation items during application startup.
|
|
83
|
+
- `navigationId` targets a non-default navigation registry id when needed.
|
|
84
|
+
- `materialDefaults` defaults to `true`; set it to `false` to skip `withMaterialDefaults()`.
|
|
85
|
+
|
|
86
|
+
Use the granular providers when the consumer only needs one part of the Etos stack:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { ApplicationConfig } from '@angular/core';
|
|
90
|
+
import { provideEtosLayout, provideEtosTheme } from '@ojiepermana/angular/etos';
|
|
91
|
+
|
|
92
|
+
export const appConfig: ApplicationConfig = {
|
|
93
|
+
providers: [provideEtosTheme(), provideEtosLayout({ mode: 'horizontal', width: 'wide' })],
|
|
94
|
+
};
|
|
95
|
+
```
|
|
41
96
|
|
|
42
97
|
## Using the brand theme
|
|
43
98
|
|
|
44
99
|
The Etos brand theme has two parts:
|
|
45
100
|
|
|
46
|
-
- TypeScript setup through
|
|
101
|
+
- TypeScript setup through one of the Etos providers.
|
|
47
102
|
- CSS setup through the Etos stylesheet so the `theme-brand="etos"` tokens are available at runtime.
|
|
48
103
|
|
|
49
104
|
App CSS should import the Etos package stylesheet before Tailwind:
|
|
@@ -54,77 +109,100 @@ App CSS should import the Etos package stylesheet before Tailwind:
|
|
|
54
109
|
@import '@ojiepermana/angular/theme/tailwind/theme.css';
|
|
55
110
|
```
|
|
56
111
|
|
|
57
|
-
|
|
112
|
+
## Using the layout shell
|
|
58
113
|
|
|
59
|
-
|
|
60
|
-
import { type EtosBrandOptions, provideEtosBrand } from '@ojiepermana/angular/etos';
|
|
114
|
+
`EtosLayoutComponent` is the exported shell component for Etos. It resolves `empty`, `horizontal`, or `vertical` from its `mode` input or from `LayoutService` when the input is omitted.
|
|
61
115
|
|
|
62
|
-
|
|
63
|
-
theme: {
|
|
64
|
-
mode: 'light',
|
|
65
|
-
style: 'default',
|
|
66
|
-
},
|
|
67
|
-
layout: {
|
|
68
|
-
mode: 'vertical',
|
|
69
|
-
width: 'container',
|
|
70
|
-
},
|
|
71
|
-
} satisfies EtosBrandOptions;
|
|
116
|
+
This is the same composition pattern used by the Etos demo:
|
|
72
117
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
118
|
+
```ts
|
|
119
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
120
|
+
import { RouterLink } from '@angular/router';
|
|
121
|
+
import {
|
|
122
|
+
EtosLayoutComponent,
|
|
123
|
+
type EtosThemeSwitcherQuickAction,
|
|
124
|
+
EtosThemeSwitcherComponent,
|
|
125
|
+
type EtosThemeSwitcherUserInfo,
|
|
126
|
+
} from '@ojiepermana/angular/etos';
|
|
127
|
+
|
|
128
|
+
@Component({
|
|
129
|
+
selector: 'app-pages',
|
|
130
|
+
imports: [RouterLink, EtosLayoutComponent, EtosThemeSwitcherComponent],
|
|
131
|
+
template: `
|
|
132
|
+
<ng-template #layoutBrand>
|
|
133
|
+
<a routerLink="/" class="flex min-w-0 items-center gap-3 px-2 py-1.5 transition-colors">
|
|
134
|
+
<span class="text-sm font-semibold leading-none tracking-tight">Ojiepermana UI</span>
|
|
135
|
+
</a>
|
|
136
|
+
</ng-template>
|
|
137
|
+
|
|
138
|
+
<ng-template #layoutPanel>
|
|
139
|
+
<div class="flex h-full w-full min-w-0 items-center justify-start gap-3 px-2 py-0">
|
|
140
|
+
<etos-theme-switcher [userInfo]="profileInfo" [quickActions]="quickActions" />
|
|
141
|
+
|
|
142
|
+
<div class="min-w-0 flex flex-col gap-px">
|
|
143
|
+
<span class="truncate text-sm font-semibold leading-none text-foreground">{{ profileName }}</span>
|
|
144
|
+
<span class="truncate text-xs leading-none text-muted-foreground">{{ profileTitle }}</span>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
</ng-template>
|
|
148
|
+
|
|
149
|
+
<etos-layout [layoutBrandTemplate]="layoutBrand" [layoutProfileTemplate]="layoutPanel" />
|
|
150
|
+
`,
|
|
151
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
152
|
+
})
|
|
153
|
+
export class Pages {
|
|
154
|
+
protected readonly profileName = 'Ojie Permana';
|
|
155
|
+
protected readonly profileTitle = 'Etos design system navigator';
|
|
156
|
+
protected readonly profileInfo = {
|
|
157
|
+
name: this.profileName,
|
|
158
|
+
subtitle: this.profileTitle,
|
|
159
|
+
avatarSrc: '/avatar-ojie.svg',
|
|
160
|
+
avatarAlt: 'Portrait of Ojie Permana',
|
|
161
|
+
} satisfies EtosThemeSwitcherUserInfo;
|
|
162
|
+
|
|
163
|
+
protected readonly quickActions = [
|
|
164
|
+
{ value: 'notifications', label: 'Notifications', icon: 'notifications' },
|
|
165
|
+
{ value: 'sign-out', label: 'Logout', icon: 'logout', tone: 'destructive' },
|
|
166
|
+
] satisfies readonly EtosThemeSwitcherQuickAction[];
|
|
167
|
+
}
|
|
76
168
|
```
|
|
77
169
|
|
|
78
|
-
|
|
170
|
+
Layout inputs:
|
|
79
171
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
172
|
+
- `mode`: optional explicit override for the active layout mode.
|
|
173
|
+
- `layoutBrandTemplate`: used in the horizontal brand area and as the default vertical sidebar header.
|
|
174
|
+
- `layoutProfileTemplate`: used in the horizontal profile area and as the default vertical sidebar footer.
|
|
175
|
+
- `sidebarHeaderTemplate`: optional vertical-only override for the sidebar header.
|
|
176
|
+
- `sidebarFooterTemplate`: optional vertical-only override for the sidebar footer.
|
|
83
177
|
|
|
84
|
-
|
|
178
|
+
That fallback behavior means a single `layoutBrandTemplate` and `layoutProfileTemplate` pair is enough for most consumers, while vertical layouts can still diverge when needed.
|
|
85
179
|
|
|
86
|
-
|
|
87
|
-
- `quickActions`: required array of action items rendered in the popup footer.
|
|
88
|
-
- `notificationShortcut`: object input for the standalone notification trigger shown beside the avatar in horizontal mode.
|
|
89
|
-
- `popoverAlign` and `popoverSide`: override the popover anchor position.
|
|
90
|
-
- `showNotificationShortcut`: legacy boolean shortcut for rendering the default notification button. Prefer `notificationShortcut` when the data should come from the parent.
|
|
180
|
+
## Using the theme switcher
|
|
91
181
|
|
|
92
|
-
|
|
182
|
+
`EtosThemeSwitcherComponent` is exported from `@ojiepermana/angular/etos` and is intended to live inside the Etos shell profile area or any consumer-owned profile trigger.
|
|
93
183
|
|
|
94
|
-
|
|
95
|
-
<div ui-layout-profile class="etos-profile-trigger gap-2 px-0 py-0">
|
|
96
|
-
<etos-theme-switcher
|
|
97
|
-
[userInfo]="profileInfo"
|
|
98
|
-
[quickActions]="horizontalQuickActions"
|
|
99
|
-
[notificationShortcut]="horizontalNotificationShortcut" />
|
|
100
|
-
</div>
|
|
101
|
-
```
|
|
184
|
+
Common inputs and output:
|
|
102
185
|
|
|
103
|
-
|
|
186
|
+
- `quickActions`: required array rendered in the popup footer. Pass `[]` if you only want the built-in theme and layout controls.
|
|
187
|
+
- `userInfo`: object input for `name`, `subtitle`, `avatarSrc`, and `avatarAlt`.
|
|
188
|
+
- `userName`, `userSubtitle`, `avatarSrc`, and `avatarAlt`: fallback inputs when `userInfo` is not supplied.
|
|
189
|
+
- `notificationShortcut`: configures the standalone notification trigger shown beside the avatar.
|
|
190
|
+
- `showNotificationShortcut`: legacy boolean shortcut for rendering the default notification button.
|
|
191
|
+
- `popoverSide`, `popoverAlign`, and `popoverSideOffset`: explicit popover placement overrides.
|
|
192
|
+
- `actionSelected`: emits the selected quick action or notification shortcut value.
|
|
104
193
|
|
|
105
|
-
|
|
194
|
+
The popup always exposes theme scheme, layout mode, and layout width controls. The quick action area is fully consumer-driven:
|
|
106
195
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
<div class="min-w-0 flex flex-col gap-px">
|
|
112
|
-
<span class="truncate text-sm font-semibold leading-none text-foreground">Ojie Permana</span>
|
|
113
|
-
<span class="truncate text-xs leading-none text-muted-foreground">Etos design system navigator</span>
|
|
114
|
-
</div>
|
|
115
|
-
</div>
|
|
116
|
-
```
|
|
196
|
+
- Provide the action values and labels you need in `quickActions`.
|
|
197
|
+
- Handle actions such as logout in the app consumer through `(actionSelected)`.
|
|
198
|
+
- When `notificationShortcut.value` matches one of the `quickActions` values, the matching popup item is removed to avoid duplication.
|
|
117
199
|
|
|
118
|
-
|
|
200
|
+
Popover defaults now follow the active layout automatically:
|
|
119
201
|
|
|
120
|
-
|
|
202
|
+
- Vertical layout defaults to `side="top"` and `align="start"`.
|
|
203
|
+
- Horizontal and empty layouts default to `side="bottom"` and `align="end"`.
|
|
121
204
|
|
|
122
|
-
|
|
123
|
-
<sidebar [ariaLabel]="'Primary'">
|
|
124
|
-
<div sidebar-header>Brand</div>
|
|
125
|
-
<div sidebar-footer>Footer actions</div>
|
|
126
|
-
</sidebar>
|
|
127
|
-
```
|
|
205
|
+
Only pass `popoverSide`, `popoverAlign`, or `popoverSideOffset` when you need to override those defaults.
|
|
128
206
|
|
|
129
207
|
Input shape examples:
|
|
130
208
|
|
|
@@ -136,30 +214,24 @@ profileInfo = {
|
|
|
136
214
|
avatarAlt: 'Portrait of Ojie Permana',
|
|
137
215
|
};
|
|
138
216
|
|
|
139
|
-
|
|
217
|
+
notificationShortcut = {
|
|
140
218
|
value: 'notifications',
|
|
141
219
|
icon: 'notifications',
|
|
142
220
|
ariaLabel: 'Open notifications for Ojie Permana',
|
|
143
221
|
};
|
|
144
222
|
|
|
145
|
-
|
|
223
|
+
quickActions = [
|
|
146
224
|
{ value: 'notifications', label: 'Notifications', icon: 'notifications' },
|
|
147
225
|
{ value: 'sign-out', label: 'Logout', icon: 'logout', tone: 'destructive' },
|
|
148
226
|
];
|
|
149
227
|
```
|
|
150
228
|
|
|
151
|
-
The popup always exposes theme scheme, layout mode, and layout width controls. The quick action area is fully consumer-driven:
|
|
152
|
-
|
|
153
|
-
- Provide the action values and labels you need in `quickActions`.
|
|
154
|
-
- Handle actions such as logout in the app consumer through `(actionSelected)`.
|
|
155
|
-
- When `notificationShortcut.value` matches one of the `quickActions` values, the matching popup item is removed to avoid duplication.
|
|
156
|
-
|
|
157
229
|
Example consumer-owned action handling:
|
|
158
230
|
|
|
159
231
|
```html
|
|
160
232
|
<etos-theme-switcher
|
|
161
233
|
[userInfo]="profileInfo"
|
|
162
|
-
[quickActions]="
|
|
234
|
+
[quickActions]="quickActions"
|
|
163
235
|
(actionSelected)="onThemeSwitcherAction($event)" />
|
|
164
236
|
```
|
|
165
237
|
|
|
@@ -173,9 +245,10 @@ onThemeSwitcherAction(action: string): void {
|
|
|
173
245
|
|
|
174
246
|
## Workspace usage in this repository
|
|
175
247
|
|
|
176
|
-
The Etos demo under `projects/demo/etos` already uses the short TypeScript entrypoint for provider setup:
|
|
248
|
+
The Etos demo under `projects/demo/etos` already uses the short TypeScript entrypoint for provider setup and shell composition:
|
|
177
249
|
|
|
178
|
-
- `src/app/app.config.ts` imports `provideEtosBrand`
|
|
250
|
+
- `src/app/app.config.ts` imports `provideEtosBrand` and passes `navigation: AppNavigation`.
|
|
251
|
+
- `src/pages/pages.ts` imports `EtosLayoutComponent` and `EtosThemeSwitcherComponent` and wires `layoutBrandTemplate` plus `layoutProfileTemplate`.
|
|
179
252
|
|
|
180
253
|
For CSS, the workspace demo currently imports the Etos source stylesheet directly:
|
|
181
254
|
|