@egose/shadcn-theme-ng 0.1.0 → 0.3.0
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/README.md +2 -2
- package/accordion/README.md +405 -2
- package/alert/README.md +372 -2
- package/alert-dialog/README.md +471 -5
- package/aspect-ratio/README.md +272 -5
- package/autocomplete/README.md +502 -2
- package/autocomplete/fesm2022/autocomplete.mjs +1 -1
- package/avatar/README.md +357 -5
- package/badge/README.md +318 -2
- package/basic-alert/README.md +353 -2
- package/breadcrumb/README.md +406 -5
- package/button/README.md +482 -2
- package/button/fesm2022/button.mjs +85 -107
- package/button/types/button.d.ts +5 -8
- package/button-group/README.md +318 -5
- package/calendar/README.md +357 -2
- package/card/README.md +331 -5
- package/carousel/README.md +333 -5
- package/carousel/fesm2022/carousel.mjs +4 -1
- package/checkbox/README.md +320 -2
- package/checkbox/fesm2022/checkbox.mjs +6 -7
- package/checkbox/types/checkbox.d.ts +1 -1
- package/collapsible/README.md +332 -5
- package/combobox/README.md +507 -5
- package/combobox/fesm2022/combobox.mjs +5 -2
- package/command/README.md +435 -5
- package/confirmation-dialog/README.md +301 -2
- package/context-menu/README.md +366 -5
- package/date-picker/README.md +469 -2
- package/date-picker/fesm2022/date-picker.mjs +150 -32
- package/date-picker/types/date-picker.d.ts +102 -9
- package/dialog/README.md +448 -2
- package/drawer/README.md +395 -5
- package/dropdown-menu/README.md +417 -5
- package/empty/README.md +329 -5
- package/field/README.md +385 -5
- package/form-autocomplete/README.md +177 -0
- package/form-autocomplete/fesm2022/form-autocomplete.mjs +125 -0
- package/form-autocomplete/package.json +24 -0
- package/form-autocomplete/types/form-autocomplete.d.ts +61 -0
- package/form-checkbox/README.md +322 -2
- package/form-checkbox/fesm2022/form-checkbox.mjs +22 -9
- package/form-checkbox/types/form-checkbox.d.ts +23 -4
- package/form-combobox/README.md +202 -0
- package/form-combobox/fesm2022/form-combobox.mjs +147 -0
- package/form-combobox/package.json +24 -0
- package/form-combobox/types/form-combobox.d.ts +73 -0
- package/form-date-picker/README.md +348 -2
- package/form-date-picker/fesm2022/form-date-picker.mjs +38 -12
- package/form-date-picker/types/form-date-picker.d.ts +17 -1
- package/form-date-picker-multi/README.md +191 -0
- package/form-date-picker-multi/fesm2022/form-date-picker-multi.mjs +129 -0
- package/form-date-picker-multi/package.json +24 -0
- package/form-date-picker-multi/types/form-date-picker-multi.d.ts +58 -0
- package/form-date-range-picker/README.md +253 -0
- package/form-date-range-picker/fesm2022/form-date-range-picker.mjs +130 -0
- package/form-date-range-picker/package.json +24 -0
- package/form-date-range-picker/types/form-date-range-picker.d.ts +55 -0
- package/form-field/README.md +356 -2
- package/form-field-simple/README.md +340 -2
- package/form-input-otp/README.md +194 -0
- package/form-input-otp/fesm2022/form-input-otp.mjs +106 -0
- package/form-input-otp/package.json +24 -0
- package/form-input-otp/types/form-input-otp.d.ts +58 -0
- package/form-month-year-picker/README.md +188 -0
- package/form-month-year-picker/fesm2022/form-month-year-picker.mjs +125 -0
- package/form-month-year-picker/package.json +24 -0
- package/form-month-year-picker/types/form-month-year-picker.d.ts +53 -0
- package/form-native-select/README.md +205 -0
- package/form-native-select/fesm2022/form-native-select.mjs +103 -0
- package/form-native-select/package.json +24 -0
- package/form-native-select/types/form-native-select.d.ts +57 -0
- package/form-phone-input/README.md +188 -0
- package/form-phone-input/fesm2022/form-phone-input.mjs +113 -0
- package/form-phone-input/package.json +24 -0
- package/form-phone-input/types/form-phone-input.d.ts +58 -0
- package/form-radio-group/README.md +198 -0
- package/form-radio-group/fesm2022/form-radio-group.mjs +111 -0
- package/form-radio-group/package.json +24 -0
- package/form-radio-group/types/form-radio-group.d.ts +63 -0
- package/form-searchable-multiselect/README.md +371 -2
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +19 -10
- package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +18 -1
- package/form-select/README.md +360 -2
- package/form-select/fesm2022/form-select.mjs +20 -11
- package/form-select/types/form-select.d.ts +18 -1
- package/form-slider/README.md +182 -0
- package/form-slider/fesm2022/form-slider.mjs +106 -0
- package/form-slider/package.json +24 -0
- package/form-slider/types/form-slider.d.ts +60 -0
- package/form-switch/README.md +173 -0
- package/form-switch/fesm2022/form-switch.mjs +100 -0
- package/form-switch/package.json +24 -0
- package/form-switch/types/form-switch.d.ts +50 -0
- package/form-text-input/README.md +381 -2
- package/form-text-input/fesm2022/form-text-input.mjs +19 -10
- package/form-text-input/types/form-text-input.d.ts +18 -1
- package/form-textarea/README.md +357 -2
- package/form-textarea/fesm2022/form-textarea.mjs +19 -10
- package/form-textarea/types/form-textarea.d.ts +18 -1
- package/form-toggle/README.md +186 -0
- package/form-toggle/fesm2022/form-toggle.mjs +159 -0
- package/form-toggle/package.json +24 -0
- package/form-toggle/types/form-toggle.d.ts +82 -0
- package/form-toggle-group/README.md +176 -0
- package/form-toggle-group/fesm2022/form-toggle-group.mjs +116 -0
- package/form-toggle-group/package.json +24 -0
- package/form-toggle-group/types/form-toggle-group.d.ts +65 -0
- package/hover-card/README.md +256 -5
- package/icon/README.md +239 -2
- package/input/README.md +269 -2
- package/input-group/README.md +335 -5
- package/input-group/fesm2022/input-group.mjs +22 -12
- package/input-group/types/input-group.d.ts +4 -1
- package/input-otp/README.md +375 -5
- package/item/README.md +385 -5
- package/item/fesm2022/item.mjs +3 -3
- package/kbd/README.md +291 -5
- package/label/README.md +272 -2
- package/layout-simple/README.md +193 -2
- package/layout-simple/fesm2022/layout-simple.mjs +472 -236
- package/layout-simple/types/layout-simple.d.ts +174 -137
- package/menu/README.md +417 -2
- package/menubar/README.md +343 -5
- package/native-select/README.md +323 -5
- package/native-select/fesm2022/native-select.mjs +18 -6
- package/native-select/types/native-select.d.ts +7 -2
- package/navigation-menu/README.md +369 -5
- package/package.json +57 -1
- package/pagination/README.md +388 -5
- package/phone-input/README.md +114 -0
- package/phone-input/fesm2022/phone-input.mjs +191 -0
- package/phone-input/package.json +24 -0
- package/phone-input/types/phone-input.d.ts +67 -0
- package/popover/README.md +331 -2
- package/progress/README.md +311 -5
- package/radio-group/README.md +364 -2
- package/radio-group/fesm2022/radio-group.mjs +5 -1
- package/resizable/README.md +269 -5
- package/scroll-area/README.md +233 -5
- package/searchable-multiselect/README.md +323 -2
- package/select/README.md +437 -2
- package/separator/README.md +222 -2
- package/sheet/README.md +311 -2
- package/sidebar/README.md +457 -5
- package/skeleton/README.md +217 -5
- package/slider/README.md +273 -5
- package/slider/fesm2022/slider.mjs +3 -3
- package/sonner/README.md +346 -2
- package/spinner/README.md +284 -2
- package/switch/README.md +310 -2
- package/switch/fesm2022/switch.mjs +7 -5
- package/switch/types/switch.d.ts +2 -1
- package/table/README.md +423 -5
- package/tabs/README.md +411 -2
- package/tabs/fesm2022/tabs.mjs +2 -2
- package/textarea/README.md +282 -5
- package/toggle/README.md +270 -5
- package/toggle-group/README.md +340 -5
- package/tooltip/README.md +269 -2
- package/typography/README.md +271 -5
- package/utils/README.md +303 -2
package/basic-alert/README.md
CHANGED
|
@@ -1,3 +1,354 @@
|
|
|
1
|
-
# Basic Alert
|
|
1
|
+
# Basic Alert (`@egose/shadcn-theme-ng/basic-alert`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A one-tag convenience alert in the shadcn/ui Alert style: icon + title + description with zero
|
|
4
|
+
composition boilerplate. Where `@egose/shadcn-theme-ng/alert` asks you to assemble `HlmAlert` /
|
|
5
|
+
`HlmAlertIcon` / `HlmAlertTitle` / `HlmAlertDescription` by hand, `EgBasicAlert` takes `variant`,
|
|
6
|
+
`appearance`, `title`, and `description` inputs and renders the whole banner — picking a matching
|
|
7
|
+
Lucide icon per tone automatically.
|
|
8
|
+
|
|
9
|
+
This is a **standalone component with no `*Imports`/`*Module` wrapper** — import `EgBasicAlert`
|
|
10
|
+
itself. Internally it composes the `alert` subpath directives plus `NgIcon`/`HlmIcon`, and maps
|
|
11
|
+
each `VariantType` to an icon name through its `getIconName()` method.
|
|
12
|
+
|
|
13
|
+
> **Ships as:** `@egose/shadcn-theme-ng/basic-alert` and `@egose/shadcn-theme-ng-tw/basic-alert`
|
|
14
|
+
> (the `tw:`-prefixed Tailwind variant). Both expose the identical TypeScript surface; only the
|
|
15
|
+
> emitted Tailwind class strings differ. See the [package README](../../README.md) for install
|
|
16
|
+
> steps, peer dependencies, and Tailwind setup. Do not publish this project directory independently.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Plain Tailwind (no prefix)
|
|
22
|
+
npm install @egose/shadcn-theme-ng
|
|
23
|
+
|
|
24
|
+
# tw:-prefixed Tailwind variant
|
|
25
|
+
npm install @egose/shadcn-theme-ng-tw
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Peer dependencies (Angular, `@spartan-ng/brain`, `@ng-icons/*`, `rxjs`, …) are documented in the
|
|
29
|
+
[package README](../../README.md#peer-dependencies). This subpath depends at runtime on
|
|
30
|
+
`@egose/shadcn-theme-ng/alert` (`HlmAlert*`, `VariantType`, `AppearanceType`),
|
|
31
|
+
`@egose/shadcn-theme-ng/icon` (`HlmIcon`), and `@ng-icons/lucide` for its icon set.
|
|
32
|
+
|
|
33
|
+
## Imports
|
|
34
|
+
|
|
35
|
+
`EgBasicAlert` is exported from the subpath root (`projects/basic-alert/src/public-api.ts`). Note
|
|
36
|
+
there is **no** `EgBasicAlertImports` array and **no** `*Module` — import the component directly:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { EgBasicAlert } from '@egose/shadcn-theme-ng/basic-alert';
|
|
40
|
+
// tw variant: replace with '@egose/shadcn-theme-ng-tw/basic-alert'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Standalone component usage:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { Component } from '@angular/core';
|
|
47
|
+
import { EgBasicAlert } from '@egose/shadcn-theme-ng/basic-alert';
|
|
48
|
+
|
|
49
|
+
@Component({
|
|
50
|
+
selector: 'app-demo',
|
|
51
|
+
standalone: true,
|
|
52
|
+
imports: [EgBasicAlert],
|
|
53
|
+
template: `<eg-basic-alert variant="info" title="Heads up" description="..." />`,
|
|
54
|
+
})
|
|
55
|
+
export class DemoComponent {}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
NgModule-based consumer — list the component in the module imports (it is standalone):
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { NgModule } from '@angular/core';
|
|
62
|
+
import { EgBasicAlert } from '@egose/shadcn-theme-ng/basic-alert';
|
|
63
|
+
|
|
64
|
+
@NgModule({ imports: [EgBasicAlert] })
|
|
65
|
+
export class DemoModule {}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Anatomy / Structure
|
|
69
|
+
|
|
70
|
+
```html
|
|
71
|
+
<eg-basic-alert variant="success" appearance="solid" title="Saved" description="All changes stored." />
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Real selector (from source):
|
|
75
|
+
|
|
76
|
+
| Class | Selector | Kind |
|
|
77
|
+
| -------------- | ---------------- | --------- |
|
|
78
|
+
| `EgBasicAlert` | `eg-basic-alert` | Component |
|
|
79
|
+
|
|
80
|
+
Its internal template (from source) is:
|
|
81
|
+
|
|
82
|
+
```html
|
|
83
|
+
<div hlmAlert [variant]="variant()" [appearance]="appearance()" class="">
|
|
84
|
+
<ng-icon hlm hlmAlertIcon [name]="getIconName(variant())" />
|
|
85
|
+
<h4 hlmAlertTitle class="tw:capitalize">{{ title() }}</h4>
|
|
86
|
+
<p hlmAlertDescription>{{ description() }}</p>
|
|
87
|
+
</div>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
So the rendered output is a standard `HlmAlert` banner whose title is auto-capitalized
|
|
91
|
+
(`tw:capitalize`) and whose icon is chosen by `getIconName(variant())`.
|
|
92
|
+
|
|
93
|
+
## API reference
|
|
94
|
+
|
|
95
|
+
### `EgBasicAlert` — `eg-basic-alert`
|
|
96
|
+
|
|
97
|
+
| Input | Type | Default | Description |
|
|
98
|
+
| ------------- | ----------------------------------------------- | --------- | ------------------------------------------------- |
|
|
99
|
+
| `variant` | `VariantType` (re-exported from `.../alert`) | `'info'` | Color tone; also selects the icon (see table). |
|
|
100
|
+
| `appearance` | `AppearanceType` (re-exported from `.../alert`) | `'solid'` | `'solid'` or `'light'` — forwarded to `HlmAlert`. |
|
|
101
|
+
| `title` | `string` | `''` | Banner heading (rendered capitalized). |
|
|
102
|
+
| `description` | `string` | `''` | Banner body text. |
|
|
103
|
+
|
|
104
|
+
| Method | Signature | Description |
|
|
105
|
+
| ------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
106
|
+
| `getIconName` | `getIconName(variant: VariantType): string` | Returns the `ng-icon` name for a tone. Public — call it in your own templates to keep custom alerts visually consistent. |
|
|
107
|
+
|
|
108
|
+
Variant → icon mapping (read from `getIconName` source):
|
|
109
|
+
|
|
110
|
+
| `variant` | Icon |
|
|
111
|
+
| ------------------------------ | ---------------------- |
|
|
112
|
+
| `success` | `lucideCircleCheck` |
|
|
113
|
+
| `info` | `lucideInfo` |
|
|
114
|
+
| `warning` | `lucideBatteryWarning` |
|
|
115
|
+
| `danger`, `destructive` | `lucideCircleAlert` |
|
|
116
|
+
| `muted` | `lucideBell` |
|
|
117
|
+
| `accent` | `lucideStar` |
|
|
118
|
+
| `primary` | `lucideThumbsUp` |
|
|
119
|
+
| `secondary` | `lucideZap` |
|
|
120
|
+
| `link` | `lucideLink` |
|
|
121
|
+
| `ghost` | `lucideGhost` |
|
|
122
|
+
| `light`, `dark`, anything else | `lucideInfo` (default) |
|
|
123
|
+
|
|
124
|
+
`VariantType` values (from `.../alert`): `primary` · `secondary` · `success` · `warning` ·
|
|
125
|
+
`danger` · `info` · `light` · `dark` · `accent` · `destructive` · `muted` · `link` · `ghost`.
|
|
126
|
+
|
|
127
|
+
## Examples
|
|
128
|
+
|
|
129
|
+
### 1. Basic usage
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import { Component } from '@angular/core';
|
|
133
|
+
import { EgBasicAlert } from '@egose/shadcn-theme-ng/basic-alert';
|
|
134
|
+
|
|
135
|
+
@Component({
|
|
136
|
+
selector: 'app-basic-alert-basic',
|
|
137
|
+
standalone: true,
|
|
138
|
+
imports: [EgBasicAlert],
|
|
139
|
+
template: `
|
|
140
|
+
<eg-basic-alert
|
|
141
|
+
variant="info"
|
|
142
|
+
title="Maintenance scheduled"
|
|
143
|
+
description="The dashboard will be offline Sunday 02:00–04:00 UTC."
|
|
144
|
+
/>
|
|
145
|
+
`,
|
|
146
|
+
})
|
|
147
|
+
export class BasicAlertBasicComponent {}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
```html
|
|
151
|
+
<app-basic-alert-basic />
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 2. Semantic tones (success / warning / danger)
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
import { Component } from '@angular/core';
|
|
158
|
+
import { EgBasicAlert } from '@egose/shadcn-theme-ng/basic-alert';
|
|
159
|
+
|
|
160
|
+
@Component({
|
|
161
|
+
selector: 'app-basic-alert-tones',
|
|
162
|
+
standalone: true,
|
|
163
|
+
imports: [EgBasicAlert],
|
|
164
|
+
template: `
|
|
165
|
+
<eg-basic-alert variant="success" title="Payment confirmed" description="Receipt emailed." class="tw:mb-3" />
|
|
166
|
+
<eg-basic-alert variant="warning" title="Storage almost full" description="9.2 of 10 GB used." class="tw:mb-3" />
|
|
167
|
+
<eg-basic-alert variant="danger" title="Sync failed" description="Retrying in 30 seconds." />
|
|
168
|
+
`,
|
|
169
|
+
})
|
|
170
|
+
export class BasicAlertTonesComponent {}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
(`class` on the host works because every Angular component host accepts a `class` attribute;
|
|
174
|
+
inner banner styling still comes from the alert subpath.)
|
|
175
|
+
|
|
176
|
+
### 3. Light appearance across variants
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
import { Component } from '@angular/core';
|
|
180
|
+
import { EgBasicAlert } from '@egose/shadcn-theme-ng/basic-alert';
|
|
181
|
+
import type { VariantType } from '@egose/shadcn-theme-ng/alert';
|
|
182
|
+
|
|
183
|
+
@Component({
|
|
184
|
+
selector: 'app-basic-alert-light',
|
|
185
|
+
standalone: true,
|
|
186
|
+
imports: [EgBasicAlert],
|
|
187
|
+
template: `
|
|
188
|
+
@for (v of variants; track v) {
|
|
189
|
+
<eg-basic-alert
|
|
190
|
+
[variant]="v"
|
|
191
|
+
appearance="light"
|
|
192
|
+
[title]="v"
|
|
193
|
+
[description]="'The ' + v + ' tone in light appearance.'"
|
|
194
|
+
class="tw:mb-3 tw:block"
|
|
195
|
+
/>
|
|
196
|
+
}
|
|
197
|
+
`,
|
|
198
|
+
})
|
|
199
|
+
export class BasicAlertLightComponent {
|
|
200
|
+
readonly variants: VariantType[] = ['primary', 'success', 'warning', 'danger', 'info', 'muted'];
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### 4. Signal-driven form feedback
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
import { Component, computed, signal } from '@angular/core';
|
|
208
|
+
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
209
|
+
import { EgBasicAlert } from '@egose/shadcn-theme-ng/basic-alert';
|
|
210
|
+
|
|
211
|
+
@Component({
|
|
212
|
+
selector: 'app-basic-alert-form',
|
|
213
|
+
standalone: true,
|
|
214
|
+
imports: [EgBasicAlert, ReactiveFormsModule],
|
|
215
|
+
template: `
|
|
216
|
+
<label class="tw:mb-1 tw:block tw:text-sm tw:font-medium" for="email">Email</label>
|
|
217
|
+
<input id="email" [formControl]="email" placeholder="you@example.com" class="tw:mb-3 tw:block" />
|
|
218
|
+
@if (banner(); as b) {
|
|
219
|
+
<eg-basic-alert [variant]="b.variant" [title]="b.title" [description]="b.description" />
|
|
220
|
+
}
|
|
221
|
+
`,
|
|
222
|
+
})
|
|
223
|
+
export class BasicAlertFormComponent {
|
|
224
|
+
readonly email = new FormControl('', { validators: [Validators.required, Validators.email], nonNullable: true });
|
|
225
|
+
private readonly submitted = signal(false);
|
|
226
|
+
|
|
227
|
+
readonly banner = computed(() => {
|
|
228
|
+
if (!this.submitted()) return null;
|
|
229
|
+
return this.email.valid
|
|
230
|
+
? { variant: 'success' as const, title: 'Looks good', description: 'We will send the receipt there.' }
|
|
231
|
+
: {
|
|
232
|
+
variant: 'destructive' as const,
|
|
233
|
+
title: 'Invalid email',
|
|
234
|
+
description: 'Enter an address like you@example.com.',
|
|
235
|
+
};
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
constructor() {
|
|
239
|
+
this.email.valueChanges.subscribe(() => this.submitted.set(true));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### 5. Dismissible + async loading pattern
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
import { Component, signal } from '@angular/core';
|
|
248
|
+
import { EgBasicAlert } from '@egose/shadcn-theme-ng/basic-alert';
|
|
249
|
+
|
|
250
|
+
@Component({
|
|
251
|
+
selector: 'app-basic-alert-async',
|
|
252
|
+
standalone: true,
|
|
253
|
+
imports: [EgBasicAlert],
|
|
254
|
+
template: `
|
|
255
|
+
<button (click)="save()" [disabled]="saving()">Save settings</button>
|
|
256
|
+
@if (saving()) {
|
|
257
|
+
<eg-basic-alert variant="muted" title="Saving" description="Writing your settings…" class="tw:mt-3 tw:block" />
|
|
258
|
+
} @else if (saved()) {
|
|
259
|
+
<eg-basic-alert
|
|
260
|
+
variant="success"
|
|
261
|
+
title="Saved"
|
|
262
|
+
description="Settings updated just now."
|
|
263
|
+
class="tw:mt-3 tw:block"
|
|
264
|
+
/>
|
|
265
|
+
} @else if (failed()) {
|
|
266
|
+
<eg-basic-alert
|
|
267
|
+
variant="destructive"
|
|
268
|
+
title="Save failed"
|
|
269
|
+
description="Check your connection and retry."
|
|
270
|
+
class="tw:mt-3 tw:block"
|
|
271
|
+
/>
|
|
272
|
+
}
|
|
273
|
+
`,
|
|
274
|
+
})
|
|
275
|
+
export class BasicAlertAsyncComponent {
|
|
276
|
+
readonly saving = signal(false);
|
|
277
|
+
readonly saved = signal(false);
|
|
278
|
+
readonly failed = signal(false);
|
|
279
|
+
|
|
280
|
+
async save() {
|
|
281
|
+
this.saving.set(true);
|
|
282
|
+
this.saved.set(false);
|
|
283
|
+
this.failed.set(false);
|
|
284
|
+
try {
|
|
285
|
+
await fetch('/api/settings', { method: 'POST' });
|
|
286
|
+
this.saved.set(true);
|
|
287
|
+
} catch {
|
|
288
|
+
this.failed.set(true);
|
|
289
|
+
} finally {
|
|
290
|
+
this.saving.set(false);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### 6. Advanced: reusing `getIconName` for a custom banner
|
|
297
|
+
|
|
298
|
+
Because `getIconName` is public, custom compositions can stay icon-consistent with the built-in
|
|
299
|
+
mapping. Grab the component with a template ref (or `@ViewChild`) and call it:
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
import { Component, viewChild } from '@angular/core';
|
|
303
|
+
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
304
|
+
import * as lucide from '@ng-icons/lucide';
|
|
305
|
+
import { EgBasicAlert } from '@egose/shadcn-theme-ng/basic-alert';
|
|
306
|
+
import { HlmAlertImports, type VariantType } from '@egose/shadcn-theme-ng/alert';
|
|
307
|
+
import { HlmIcon } from '@egose/shadcn-theme-ng/icon';
|
|
308
|
+
|
|
309
|
+
@Component({
|
|
310
|
+
selector: 'app-basic-alert-custom',
|
|
311
|
+
standalone: true,
|
|
312
|
+
imports: [...HlmAlertImports, EgBasicAlert, NgIcon, HlmIcon],
|
|
313
|
+
providers: [provideIcons({ ...lucide })],
|
|
314
|
+
template: `
|
|
315
|
+
<!-- hidden helper instance purely as an icon-name resolver -->
|
|
316
|
+
<eg-basic-alert #helper variant="info" title="" description="" class="tw:hidden" />
|
|
317
|
+
<div hlmAlert [variant]="variant">
|
|
318
|
+
<ng-icon hlm hlmAlertIcon [name]="helper.getIconName(variant)" />
|
|
319
|
+
<h4 hlmAlertTitle>Custom layout, stock icon</h4>
|
|
320
|
+
<p hlmAlertDescription>Extra actions or rich content here — the icon still matches the {{ variant }} tone.</p>
|
|
321
|
+
</div>
|
|
322
|
+
`,
|
|
323
|
+
})
|
|
324
|
+
export class BasicAlertCustomComponent {
|
|
325
|
+
readonly variant: VariantType = 'accent';
|
|
326
|
+
private readonly helper = viewChild<EgBasicAlert>('helper');
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
> Prefer importing the `alert` subpath directly for hand-built banners; the helper-instance trick
|
|
331
|
+
> above is only for teams that want a single source of truth for the icon map.
|
|
332
|
+
|
|
333
|
+
## Accessibility notes
|
|
334
|
+
|
|
335
|
+
- Inherits everything from `HlmAlert`: the banner carries `role="alert"`, so dynamically shown
|
|
336
|
+
instances (after save/fail) are announced. Do not render empty `title` + `description`
|
|
337
|
+
instances permanently — screen readers would announce an empty alert region.
|
|
338
|
+
- Titles render with `tw:capitalize` — keep them short, human-phrased headings ("Save failed",
|
|
339
|
+
not "ERR_SAVE_500"). The description should state the consequence and next step.
|
|
340
|
+
- The icon is decorative; all meaning must be in the text since icon names/tones alone are not
|
|
341
|
+
announced.
|
|
342
|
+
|
|
343
|
+
## Theming / CSS variables
|
|
344
|
+
|
|
345
|
+
No variables of its own — theming flows through the composed `HlmAlert` (`variant` /
|
|
346
|
+
`appearance` + shadcn tokens). For layouts beyond icon/title/description, drop down to
|
|
347
|
+
`@egose/shadcn-theme-ng/alert` and compose the directives yourself.
|
|
348
|
+
|
|
349
|
+
## Related subpaths
|
|
350
|
+
|
|
351
|
+
- `@egose/shadcn-theme-ng/alert` — hand-composed banners (`HlmAlert*`) and the `VariantType` / `AppearanceType` types
|
|
352
|
+
- `@egose/shadcn-theme-ng/badge` — inline chips for compact status
|
|
353
|
+
- `@egose/shadcn-theme-ng/sonner` — transient toasts for fire-and-forget feedback
|
|
354
|
+
- `@egose/shadcn-theme-ng/icon` — `HlmIcon` and icon configuration
|