@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/alert/README.md
CHANGED
|
@@ -1,3 +1,373 @@
|
|
|
1
|
-
# Alert
|
|
1
|
+
# Alert (`@egose/shadcn-theme-ng/alert`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A non-modal status banner in the shadcn/ui Alert style: an icon, a title, and a description
|
|
4
|
+
arranged in a bordered, tone-colored box. Use it for inline feedback (success confirmations,
|
|
5
|
+
warnings, informational hints) that stays visible in the page flow.
|
|
6
|
+
|
|
7
|
+
This is a **pure styling layer — no brain primitive underneath**. `HlmAlert` and its pieces are
|
|
8
|
+
plain attribute directives that compute shadcn classes with `cva` + `hlm()` from
|
|
9
|
+
`@egose/shadcn-theme-ng/utils`. The host gets `role="alert"` automatically. `HlmAlertIcon` only
|
|
10
|
+
applies the `sm` icon-size config (`provideHlmIconConfig`); pair it with an `ng-icon`.
|
|
11
|
+
|
|
12
|
+
> **Ships as:** `@egose/shadcn-theme-ng/alert` and `@egose/shadcn-theme-ng-tw/alert`
|
|
13
|
+
> (the `tw:`-prefixed Tailwind variant). Both expose the identical TypeScript surface; only the
|
|
14
|
+
> emitted Tailwind class strings differ. See the [package README](../../README.md) for install
|
|
15
|
+
> steps, peer dependencies, and Tailwind setup. Do not publish this project directory independently.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Plain Tailwind (no prefix)
|
|
21
|
+
npm install @egose/shadcn-theme-ng
|
|
22
|
+
|
|
23
|
+
# tw:-prefixed Tailwind variant
|
|
24
|
+
npm install @egose/shadcn-theme-ng-tw
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Peer dependencies (Angular, `@spartan-ng/brain`, `@ng-icons/*`, `rxjs`, …) are documented in the
|
|
28
|
+
[package README](../../README.md#peer-dependencies). This subpath additionally relies at runtime on
|
|
29
|
+
`@egose/shadcn-theme-ng/utils` (`hlm()`) and `@egose/shadcn-theme-ng/icon`
|
|
30
|
+
(`provideHlmIconConfig`).
|
|
31
|
+
|
|
32
|
+
## Imports
|
|
33
|
+
|
|
34
|
+
All symbols are exported from the subpath root (`projects/alert/src/public-api.ts`):
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import {
|
|
38
|
+
HlmAlert,
|
|
39
|
+
HlmAlertTitle,
|
|
40
|
+
HlmAlertDescription,
|
|
41
|
+
HlmAlertIcon,
|
|
42
|
+
HlmAlertImports,
|
|
43
|
+
HlmAlertModule,
|
|
44
|
+
type AlertVariants,
|
|
45
|
+
type VariantType,
|
|
46
|
+
type AppearanceType,
|
|
47
|
+
} from '@egose/shadcn-theme-ng/alert';
|
|
48
|
+
// tw variant: replace with '@egose/shadcn-theme-ng-tw/alert'
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Standalone component — spread the `*Imports` array:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { Component } from '@angular/core';
|
|
55
|
+
import { HlmAlertImports } from '@egose/shadcn-theme-ng/alert';
|
|
56
|
+
|
|
57
|
+
@Component({
|
|
58
|
+
selector: 'app-demo',
|
|
59
|
+
standalone: true,
|
|
60
|
+
imports: [...HlmAlertImports],
|
|
61
|
+
template: `...`,
|
|
62
|
+
})
|
|
63
|
+
export class DemoComponent {}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
NgModule-based consumer — import the module:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { NgModule } from '@angular/core';
|
|
70
|
+
import { HlmAlertModule } from '@egose/shadcn-theme-ng/alert';
|
|
71
|
+
|
|
72
|
+
@NgModule({ imports: [HlmAlertModule] })
|
|
73
|
+
export class DemoModule {}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Anatomy / Structure
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<div hlmAlert variant="info" appearance="solid">
|
|
80
|
+
<ng-icon hlm hlmAlertIcon name="lucideInfo" />
|
|
81
|
+
<h4 hlmAlertTitle>Heads up</h4>
|
|
82
|
+
<p hlmAlertDescription>Detail text goes here.</p>
|
|
83
|
+
</div>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Real selectors (from source):
|
|
87
|
+
|
|
88
|
+
| Class | Selector(s) | Kind |
|
|
89
|
+
| --------------------- | --------------------------------------- | --------- |
|
|
90
|
+
| `HlmAlert` | `[hlmAlert]` | Directive |
|
|
91
|
+
| `HlmAlertTitle` | `[hlmAlertTitle]` | Directive |
|
|
92
|
+
| `HlmAlertDescription` | `[hlmAlertDesc], [hlmAlertDescription]` | Directive |
|
|
93
|
+
| `HlmAlertIcon` | `[hlmAlertIcon]` | Directive |
|
|
94
|
+
|
|
95
|
+
When an `[hlmAlertIcon]` child is present, the host switches to a two-column grid
|
|
96
|
+
(`grid-cols-[calc(theme(spacing.1)*4)_1fr]`) with the title/description placed in column 2 —
|
|
97
|
+
no extra markup needed.
|
|
98
|
+
|
|
99
|
+
## API reference
|
|
100
|
+
|
|
101
|
+
### `HlmAlert` — `[hlmAlert]`
|
|
102
|
+
|
|
103
|
+
| Input | Type | Default | Description |
|
|
104
|
+
| ------------ | -------------------------------------- | ----------- | ---------------------------------------------------------------- |
|
|
105
|
+
| `variant` | `AlertVariants['variant']` (see below) | `'primary'` | Color tone. |
|
|
106
|
+
| `appearance` | `AlertVariants['appearance']` | `'solid'` | `'solid'` (saturated fill) or `'light'` (tinted `bg-*/20` fill). |
|
|
107
|
+
| `class` | `ClassValue` | `''` | Extra classes merged via `hlm()`. |
|
|
108
|
+
|
|
109
|
+
`variant` values: `primary` · `secondary` · `success` · `warning` · `danger` · `info` ·
|
|
110
|
+
`light` · `dark` · `accent` · `destructive` · `muted` · `link` · `ghost`.
|
|
111
|
+
|
|
112
|
+
`appearance` values: `solid` · `light`. Every `variant × light` pair has a dedicated
|
|
113
|
+
`compoundVariants` entry (e.g. `warning + light` → `bg-warning/20 text-warning`).
|
|
114
|
+
|
|
115
|
+
Exported helper types: `AlertVariants` (`VariantProps<typeof alertVariants>`), `VariantType`,
|
|
116
|
+
`AppearanceType`.
|
|
117
|
+
|
|
118
|
+
### `HlmAlertTitle` — `[hlmAlertTitle]`
|
|
119
|
+
|
|
120
|
+
| Input | Type | Default | Description |
|
|
121
|
+
| ------- | ------------ | ------- | --------------------------------- |
|
|
122
|
+
| `class` | `ClassValue` | `''` | Extra classes merged via `hlm()`. |
|
|
123
|
+
|
|
124
|
+
Renders semibold, tracking-tight, single-line-clamped title text in grid column 2.
|
|
125
|
+
|
|
126
|
+
### `HlmAlertDescription` — `[hlmAlertDesc], [hlmAlertDescription]`
|
|
127
|
+
|
|
128
|
+
| Input | Type | Default | Description |
|
|
129
|
+
| ------- | ------------ | ------- | --------------------------------- |
|
|
130
|
+
| `class` | `ClassValue` | `''` | Extra classes merged via `hlm()`. |
|
|
131
|
+
|
|
132
|
+
Small relaxed-leading body text in grid column 2. Both selector spellings are equivalent.
|
|
133
|
+
|
|
134
|
+
### `HlmAlertIcon` — `[hlmAlertIcon]`
|
|
135
|
+
|
|
136
|
+
Size-only directive: provides `provideHlmIconConfig({ size: 'sm' })` so the decorated `ng-icon`
|
|
137
|
+
renders small. It declares **no inputs** and adds no classes of its own — the parent `HlmAlert`
|
|
138
|
+
stylesheet sizes/positions it (`size-4`, `translate-y-0.5`, `text-current`).
|
|
139
|
+
|
|
140
|
+
## Examples
|
|
141
|
+
|
|
142
|
+
### 1. Basic alert with icon, title, and description
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import { Component } from '@angular/core';
|
|
146
|
+
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
147
|
+
import { lucideInfo } from '@ng-icons/lucide';
|
|
148
|
+
import { HlmAlertImports } from '@egose/shadcn-theme-ng/alert';
|
|
149
|
+
import { HlmIcon } from '@egose/shadcn-theme-ng/icon';
|
|
150
|
+
|
|
151
|
+
@Component({
|
|
152
|
+
selector: 'app-alert-basic',
|
|
153
|
+
standalone: true,
|
|
154
|
+
imports: [...HlmAlertImports, NgIcon, HlmIcon],
|
|
155
|
+
providers: [provideIcons({ lucideInfo })],
|
|
156
|
+
template: `
|
|
157
|
+
<div hlmAlert variant="info">
|
|
158
|
+
<ng-icon hlm hlmAlertIcon name="lucideInfo" />
|
|
159
|
+
<h4 hlmAlertTitle>Heads up</h4>
|
|
160
|
+
<p hlmAlertDescription>Your trial ends in 3 days. Upgrade to keep your data.</p>
|
|
161
|
+
</div>
|
|
162
|
+
`,
|
|
163
|
+
})
|
|
164
|
+
export class AlertBasicComponent {}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
```html
|
|
168
|
+
<app-alert-basic />
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 2. All variants (solid)
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
import { Component } from '@angular/core';
|
|
175
|
+
import { HlmAlertImports, type VariantType } from '@egose/shadcn-theme-ng/alert';
|
|
176
|
+
|
|
177
|
+
@Component({
|
|
178
|
+
selector: 'app-alert-variants',
|
|
179
|
+
standalone: true,
|
|
180
|
+
imports: [...HlmAlertImports],
|
|
181
|
+
template: `
|
|
182
|
+
@for (v of variants; track v) {
|
|
183
|
+
<div hlmAlert [variant]="v" class="tw:mb-3">
|
|
184
|
+
<h4 hlmAlertTitle class="tw:capitalize">{{ v }}</h4>
|
|
185
|
+
<p hlmAlertDescription>This is the {{ v }} tone in solid appearance.</p>
|
|
186
|
+
</div>
|
|
187
|
+
}
|
|
188
|
+
`,
|
|
189
|
+
})
|
|
190
|
+
export class AlertVariantsComponent {
|
|
191
|
+
readonly variants: VariantType[] = [
|
|
192
|
+
'primary',
|
|
193
|
+
'secondary',
|
|
194
|
+
'success',
|
|
195
|
+
'warning',
|
|
196
|
+
'danger',
|
|
197
|
+
'info',
|
|
198
|
+
'light',
|
|
199
|
+
'dark',
|
|
200
|
+
'accent',
|
|
201
|
+
'destructive',
|
|
202
|
+
'muted',
|
|
203
|
+
'link',
|
|
204
|
+
'ghost',
|
|
205
|
+
];
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### 3. Light appearance + semantic states
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
import { Component } from '@angular/core';
|
|
213
|
+
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
214
|
+
import { lucideCircleCheck, lucideCircleAlert, lucideInfo } from '@ng-icons/lucide';
|
|
215
|
+
import { HlmAlertImports } from '@egose/shadcn-theme-ng/alert';
|
|
216
|
+
import { HlmIcon } from '@egose/shadcn-theme-ng/icon';
|
|
217
|
+
|
|
218
|
+
@Component({
|
|
219
|
+
selector: 'app-alert-states',
|
|
220
|
+
standalone: true,
|
|
221
|
+
imports: [...HlmAlertImports, NgIcon, HlmIcon],
|
|
222
|
+
providers: [provideIcons({ lucideCircleCheck, lucideCircleAlert, lucideInfo })],
|
|
223
|
+
template: `
|
|
224
|
+
<div hlmAlert variant="success" appearance="light" class="tw:mb-3">
|
|
225
|
+
<ng-icon hlm hlmAlertIcon name="lucideCircleCheck" />
|
|
226
|
+
<h4 hlmAlertTitle>Payment confirmed</h4>
|
|
227
|
+
<p hlmAlertDescription>Receipt #INV-2041 was emailed to you.</p>
|
|
228
|
+
</div>
|
|
229
|
+
<div hlmAlert variant="warning" appearance="light" class="tw:mb-3">
|
|
230
|
+
<ng-icon hlm hlmAlertIcon name="lucideCircleAlert" />
|
|
231
|
+
<h4 hlmAlertTitle>Storage almost full</h4>
|
|
232
|
+
<p hlmAlertDescription>You have used 9.2 of 10 GB.</p>
|
|
233
|
+
</div>
|
|
234
|
+
<div hlmAlert variant="destructive" appearance="light">
|
|
235
|
+
<ng-icon hlm hlmAlertIcon name="lucideCircleAlert" />
|
|
236
|
+
<h4 hlmAlertTitle>Deployment failed</h4>
|
|
237
|
+
<p hlmAlertDescription>Unit tests failed on step 4. See the logs.</p>
|
|
238
|
+
</div>
|
|
239
|
+
`,
|
|
240
|
+
})
|
|
241
|
+
export class AlertStatesComponent {}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### 4. Conditional alert driven by a signal (form error pattern)
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
import { Component, computed, signal } from '@angular/core';
|
|
248
|
+
import { HlmAlertImports, type VariantType } from '@egose/shadcn-theme-ng/alert';
|
|
249
|
+
|
|
250
|
+
@Component({
|
|
251
|
+
selector: 'app-alert-conditional',
|
|
252
|
+
standalone: true,
|
|
253
|
+
imports: [...HlmAlertImports],
|
|
254
|
+
template: `
|
|
255
|
+
@if (tone(); as t) {
|
|
256
|
+
<div hlmAlert [variant]="t">
|
|
257
|
+
<h4 hlmAlertTitle>{{ title() }}</h4>
|
|
258
|
+
<p hlmAlertDescription>{{ message() }}</p>
|
|
259
|
+
</div>
|
|
260
|
+
}
|
|
261
|
+
<div class="tw:mt-3 tw:flex tw:gap-2">
|
|
262
|
+
<button (click)="show('success')">Succeed</button>
|
|
263
|
+
<button (click)="show('destructive')">Fail</button>
|
|
264
|
+
<button (click)="clear()">Clear</button>
|
|
265
|
+
</div>
|
|
266
|
+
`,
|
|
267
|
+
})
|
|
268
|
+
export class AlertConditionalComponent {
|
|
269
|
+
private readonly _tone = signal<VariantType | null>(null);
|
|
270
|
+
readonly tone = this._tone.asReadonly();
|
|
271
|
+
readonly title = computed(() => (this._tone() === 'success' ? 'Saved' : 'Something went wrong'));
|
|
272
|
+
readonly message = computed(() =>
|
|
273
|
+
this._tone() === 'success' ? 'Your changes were saved.' : 'Please fix the highlighted fields.',
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
show(t: VariantType) {
|
|
277
|
+
this._tone.set(t);
|
|
278
|
+
}
|
|
279
|
+
clear() {
|
|
280
|
+
this._tone.set(null);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### 5. Title-only and description-only compositions
|
|
286
|
+
|
|
287
|
+
The title and description are independent directives — use either alone:
|
|
288
|
+
|
|
289
|
+
```ts
|
|
290
|
+
import { Component } from '@angular/core';
|
|
291
|
+
import { HlmAlertImports } from '@egose/shadcn-theme-ng/alert';
|
|
292
|
+
|
|
293
|
+
@Component({
|
|
294
|
+
selector: 'app-alert-minimal',
|
|
295
|
+
standalone: true,
|
|
296
|
+
imports: [...HlmAlertImports],
|
|
297
|
+
template: `
|
|
298
|
+
<!-- title only -->
|
|
299
|
+
<div hlmAlert variant="muted" class="tw:mb-3">
|
|
300
|
+
<h4 hlmAlertTitle>Maintenance window: Sunday 02:00–04:00 UTC</h4>
|
|
301
|
+
</div>
|
|
302
|
+
<!-- description only, short spelling -->
|
|
303
|
+
<div hlmAlert variant="ghost">
|
|
304
|
+
<p hlmAlertDesc>Cookies help us improve. No action required.</p>
|
|
305
|
+
</div>
|
|
306
|
+
`,
|
|
307
|
+
})
|
|
308
|
+
export class AlertMinimalComponent {}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### 6. Dismissible alert + composition with a button
|
|
312
|
+
|
|
313
|
+
```ts
|
|
314
|
+
import { Component, signal } from '@angular/core';
|
|
315
|
+
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
316
|
+
import { lucideInfo, lucideX } from '@ng-icons/lucide';
|
|
317
|
+
import { HlmAlertImports } from '@egose/shadcn-theme-ng/alert';
|
|
318
|
+
import { HlmButtonImports } from '@egose/shadcn-theme-ng/button';
|
|
319
|
+
import { HlmIcon } from '@egose/shadcn-theme-ng/icon';
|
|
320
|
+
|
|
321
|
+
@Component({
|
|
322
|
+
selector: 'app-alert-dismissible',
|
|
323
|
+
standalone: true,
|
|
324
|
+
imports: [...HlmAlertImports, ...HlmButtonImports, NgIcon, HlmIcon],
|
|
325
|
+
providers: [provideIcons({ lucideInfo, lucideX })],
|
|
326
|
+
template: `
|
|
327
|
+
@if (visible()) {
|
|
328
|
+
<div hlmAlert variant="info" class="tw:relative tw:pr-12">
|
|
329
|
+
<ng-icon hlm hlmAlertIcon name="lucideInfo" />
|
|
330
|
+
<h4 hlmAlertTitle>New version available</h4>
|
|
331
|
+
<p hlmAlertDescription>Restart the app to apply v2.4.1.</p>
|
|
332
|
+
<button
|
|
333
|
+
hlmBtn
|
|
334
|
+
variant="ghost"
|
|
335
|
+
size="icon-sm"
|
|
336
|
+
class="tw:absolute tw:top-2 tw:right-2"
|
|
337
|
+
(click)="visible.set(false)"
|
|
338
|
+
aria-label="Dismiss"
|
|
339
|
+
>
|
|
340
|
+
<ng-icon hlm name="lucideX" size="sm" />
|
|
341
|
+
</button>
|
|
342
|
+
</div>
|
|
343
|
+
}
|
|
344
|
+
`,
|
|
345
|
+
})
|
|
346
|
+
export class AlertDismissibleComponent {
|
|
347
|
+
readonly visible = signal(true);
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Accessibility notes
|
|
352
|
+
|
|
353
|
+
- The host carries `role="alert"`, so assistive technology announces content injected dynamically
|
|
354
|
+
(e.g. after a failed save). For purely decorative/informational banners that should not
|
|
355
|
+
interrupt, prefer `variant="muted"` copy and consider whether a `role="status"` wrapper of your
|
|
356
|
+
own is more appropriate — the role is baked into the directive and cannot be switched off.
|
|
357
|
+
- Keep the title short and the description actionable; screen readers read both in DOM order
|
|
358
|
+
(icon → title → description).
|
|
359
|
+
- Do not put interactive controls other than a dismiss button inside an `role="alert"` region;
|
|
360
|
+
links and buttons inside the description are allowed but keep them minimal.
|
|
361
|
+
|
|
362
|
+
## Theming / CSS variables
|
|
363
|
+
|
|
364
|
+
Class-based theming via `cva` variants (`bg-*/text-*` tokens); no component-specific CSS variables.
|
|
365
|
+
Extend with `class` on any piece. The `link` and `ghost` variants are intentionally low-chrome for
|
|
366
|
+
embedding alerts in prose or cards.
|
|
367
|
+
|
|
368
|
+
## Related subpaths
|
|
369
|
+
|
|
370
|
+
- `@egose/shadcn-theme-ng/basic-alert` — ready-made `EgBasicAlert` (icon + title + description in one tag)
|
|
371
|
+
- `@egose/shadcn-theme-ng/badge` — inline status chips for compact labeling
|
|
372
|
+
- `@egose/shadcn-theme-ng/button` — dismiss/action buttons inside alerts
|
|
373
|
+
- `@egose/shadcn-theme-ng/icon` — `HlmIcon` sizing and `provideHlmIconConfig`
|