@egose/shadcn-theme-ng 0.0.28 → 0.2.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 +130 -13
- package/accordion/README.md +376 -34
- package/accordion/fesm2022/accordion.mjs +27 -39
- package/alert/README.md +343 -34
- package/alert/fesm2022/alert.mjs +47 -47
- package/alert-dialog/README.md +471 -5
- package/alert-dialog/fesm2022/alert-dialog.mjs +47 -47
- package/aspect-ratio/README.md +272 -5
- package/aspect-ratio/fesm2022/aspect-ratio.mjs +9 -9
- package/autocomplete/README.md +473 -34
- package/autocomplete/fesm2022/autocomplete.mjs +53 -71
- package/avatar/README.md +357 -5
- package/avatar/fesm2022/avatar.mjs +32 -32
- package/badge/README.md +289 -34
- package/badge/fesm2022/badge.mjs +57 -57
- package/basic-alert/README.md +324 -34
- package/basic-alert/fesm2022/basic-alert.mjs +6 -18
- package/breadcrumb/README.md +406 -5
- package/breadcrumb/fesm2022/breadcrumb.mjs +33 -39
- package/button/README.md +453 -34
- package/button/fesm2022/button.mjs +147 -219
- package/button/types/button.d.ts +7 -10
- package/button-group/README.md +318 -5
- package/button-group/fesm2022/button-group.mjs +20 -20
- package/calendar/README.md +328 -34
- package/calendar/fesm2022/calendar.mjs +29 -743
- package/card/README.md +331 -5
- package/card/fesm2022/card.mjs +33 -33
- package/carousel/README.md +333 -5
- package/carousel/fesm2022/carousel.mjs +39 -78
- package/checkbox/README.md +291 -34
- package/checkbox/fesm2022/checkbox.mjs +20 -58
- package/checkbox/types/checkbox.d.ts +5 -4
- package/collapsible/README.md +332 -5
- package/collapsible/fesm2022/collapsible.mjs +15 -15
- package/combobox/README.md +507 -5
- package/combobox/fesm2022/combobox.mjs +91 -224
- package/command/README.md +435 -5
- package/command/fesm2022/command.mjs +49 -109
- package/confirmation-dialog/README.md +272 -34
- package/confirmation-dialog/fesm2022/confirmation-dialog.mjs +15 -40
- package/confirmation-dialog/types/confirmation-dialog.d.ts +8 -4
- package/context-menu/README.md +366 -5
- package/context-menu/fesm2022/context-menu.mjs +9 -9
- package/date-picker/README.md +436 -34
- package/date-picker/fesm2022/date-picker.mjs +64 -267
- package/date-picker/types/date-picker.d.ts +7 -3
- package/dialog/README.md +419 -34
- package/dialog/fesm2022/dialog.mjs +45 -71
- package/drawer/README.md +395 -5
- package/drawer/fesm2022/drawer.mjs +44 -54
- package/dropdown-menu/README.md +417 -5
- package/dropdown-menu/fesm2022/dropdown-menu.mjs +82 -70
- package/dropdown-menu/types/dropdown-menu.d.ts +4 -0
- package/empty/README.md +329 -5
- package/empty/fesm2022/empty.mjs +30 -30
- package/field/README.md +385 -5
- package/field/fesm2022/field.mjs +56 -72
- package/form-checkbox/README.md +283 -34
- package/form-checkbox/fesm2022/form-checkbox.mjs +25 -85
- package/form-checkbox/types/form-checkbox.d.ts +7 -1
- package/form-date-picker/README.md +293 -34
- package/form-date-picker/fesm2022/form-date-picker.mjs +31 -84
- package/form-date-picker/types/form-date-picker.d.ts +7 -1
- package/form-field/README.md +327 -34
- package/form-field/fesm2022/form-field.mjs +33 -19
- package/form-field/types/form-field.d.ts +28 -20
- package/form-field-simple/README.md +311 -34
- package/form-field-simple/fesm2022/form-field-simple.mjs +4 -4
- package/form-searchable-multiselect/README.md +332 -34
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +31 -91
- package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +7 -1
- package/form-select/README.md +321 -34
- package/form-select/fesm2022/form-select.mjs +32 -149
- package/form-select/types/form-select.d.ts +7 -1
- package/form-text-input/README.md +342 -34
- package/form-text-input/fesm2022/form-text-input.mjs +35 -149
- package/form-text-input/types/form-text-input.d.ts +9 -12
- package/form-textarea/README.md +318 -34
- package/form-textarea/fesm2022/form-textarea.mjs +34 -109
- package/form-textarea/types/form-textarea.d.ts +8 -1
- package/hover-card/README.md +256 -5
- package/hover-card/fesm2022/hover-card.mjs +19 -19
- package/icon/README.md +210 -34
- package/icon/fesm2022/icon.mjs +8 -8
- package/input/README.md +240 -34
- package/input/fesm2022/input.mjs +17 -12
- package/input/types/input.d.ts +2 -1
- package/input-group/README.md +335 -5
- package/input-group/fesm2022/input-group.mjs +34 -34
- package/input-otp/README.md +375 -5
- package/input-otp/fesm2022/input-otp.mjs +26 -26
- package/item/README.md +385 -5
- package/item/fesm2022/item.mjs +53 -53
- package/kbd/README.md +291 -5
- package/kbd/fesm2022/kbd.mjs +12 -12
- package/label/README.md +243 -34
- package/label/fesm2022/label.mjs +10 -10
- package/label/types/label.d.ts +1 -1
- package/layout-simple/README.md +174 -44
- package/layout-simple/fesm2022/layout-simple.mjs +508 -603
- package/layout-simple/types/layout-simple.d.ts +179 -128
- package/menu/README.md +418 -0
- package/menu/fesm2022/menu.mjs +455 -0
- package/menu/package.json +24 -0
- package/menu/types/menu.d.ts +137 -0
- package/menubar/README.md +343 -5
- package/menubar/fesm2022/menubar.mjs +13 -13
- package/native-select/README.md +323 -5
- package/native-select/fesm2022/native-select.mjs +19 -19
- package/navigation-menu/README.md +369 -5
- package/navigation-menu/fesm2022/navigation-menu.mjs +35 -47
- package/package.json +183 -154
- package/pagination/README.md +388 -5
- package/pagination/fesm2022/pagination.mjs +45 -331
- package/popover/README.md +302 -34
- package/popover/fesm2022/popover.mjs +30 -30
- package/progress/README.md +311 -5
- package/progress/fesm2022/progress.mjs +13 -13
- package/radio-group/README.md +335 -34
- package/radio-group/fesm2022/radio-group.mjs +26 -19
- package/radio-group/types/radio-group.d.ts +1 -1
- package/resizable/README.md +269 -5
- package/resizable/fesm2022/resizable.mjs +18 -26
- package/scroll-area/README.md +233 -5
- package/scroll-area/fesm2022/scroll-area.mjs +9 -9
- package/searchable-multiselect/README.md +294 -34
- package/searchable-multiselect/fesm2022/searchable-multiselect.mjs +28 -117
- package/searchable-multiselect/types/searchable-multiselect.d.ts +8 -2
- package/select/README.md +408 -34
- package/select/fesm2022/select.mjs +71 -111
- package/select/types/select.d.ts +3 -1
- package/separator/README.md +193 -34
- package/separator/fesm2022/separator.mjs +9 -9
- package/separator/types/separator.d.ts +1 -1
- package/sheet/README.md +282 -34
- package/sheet/fesm2022/sheet.mjs +41 -53
- package/sidebar/README.md +457 -5
- package/sidebar/fesm2022/sidebar.mjs +125 -227
- package/skeleton/README.md +217 -5
- package/skeleton/fesm2022/skeleton.mjs +9 -9
- package/slider/README.md +273 -5
- package/slider/fesm2022/slider.mjs +10 -80
- package/sonner/README.md +317 -34
- package/sonner/fesm2022/sonner.mjs +13 -13
- package/spinner/README.md +255 -34
- package/spinner/fesm2022/spinner.mjs +11 -11
- package/switch/README.md +281 -34
- package/switch/fesm2022/switch.mjs +13 -15
- package/table/README.md +423 -5
- package/table/fesm2022/table.mjs +41 -41
- package/tabs/README.md +382 -34
- package/tabs/fesm2022/tabs.mjs +35 -111
- package/textarea/README.md +282 -5
- package/textarea/fesm2022/textarea.mjs +9 -9
- package/toggle/README.md +270 -5
- package/toggle/fesm2022/toggle.mjs +13 -13
- package/toggle-group/README.md +340 -5
- package/toggle-group/fesm2022/toggle-group.mjs +13 -13
- package/toggle-group/types/toggle-group.d.ts +13 -7
- package/tooltip/README.md +240 -34
- package/tooltip/fesm2022/tooltip.mjs +14 -14
- package/typography/README.md +271 -5
- package/typography/fesm2022/typography.mjs +53 -53
- package/typography/types/typography.d.ts +19 -19
- package/utils/README.md +274 -34
- package/utils/fesm2022/utils.mjs +68 -44
- package/accordion/fesm2022/accordion.mjs.map +0 -1
- package/alert/fesm2022/alert.mjs.map +0 -1
- package/alert-dialog/fesm2022/alert-dialog.mjs.map +0 -1
- package/aspect-ratio/fesm2022/aspect-ratio.mjs.map +0 -1
- package/autocomplete/fesm2022/autocomplete.mjs.map +0 -1
- package/avatar/fesm2022/avatar.mjs.map +0 -1
- package/badge/fesm2022/badge.mjs.map +0 -1
- package/basic-alert/fesm2022/basic-alert.mjs.map +0 -1
- package/breadcrumb/fesm2022/breadcrumb.mjs.map +0 -1
- package/button/fesm2022/button.mjs.map +0 -1
- package/button-group/fesm2022/button-group.mjs.map +0 -1
- package/calendar/fesm2022/calendar.mjs.map +0 -1
- package/card/fesm2022/card.mjs.map +0 -1
- package/carousel/fesm2022/carousel.mjs.map +0 -1
- package/checkbox/fesm2022/checkbox.mjs.map +0 -1
- package/collapsible/fesm2022/collapsible.mjs.map +0 -1
- package/combobox/fesm2022/combobox.mjs.map +0 -1
- package/command/fesm2022/command.mjs.map +0 -1
- package/confirmation-dialog/fesm2022/confirmation-dialog.mjs.map +0 -1
- package/context-menu/fesm2022/context-menu.mjs.map +0 -1
- package/date-picker/fesm2022/date-picker.mjs.map +0 -1
- package/dialog/fesm2022/dialog.mjs.map +0 -1
- package/drawer/fesm2022/drawer.mjs.map +0 -1
- package/dropdown-menu/fesm2022/dropdown-menu.mjs.map +0 -1
- package/empty/fesm2022/empty.mjs.map +0 -1
- package/field/fesm2022/field.mjs.map +0 -1
- package/form-checkbox/fesm2022/form-checkbox.mjs.map +0 -1
- package/form-date-picker/fesm2022/form-date-picker.mjs.map +0 -1
- package/form-field/fesm2022/form-field.mjs.map +0 -1
- package/form-field-simple/fesm2022/form-field-simple.mjs.map +0 -1
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs.map +0 -1
- package/form-select/fesm2022/form-select.mjs.map +0 -1
- package/form-text-input/fesm2022/form-text-input.mjs.map +0 -1
- package/form-textarea/fesm2022/form-textarea.mjs.map +0 -1
- package/hover-card/fesm2022/hover-card.mjs.map +0 -1
- package/icon/fesm2022/icon.mjs.map +0 -1
- package/input/fesm2022/input.mjs.map +0 -1
- package/input-group/fesm2022/input-group.mjs.map +0 -1
- package/input-otp/fesm2022/input-otp.mjs.map +0 -1
- package/item/fesm2022/item.mjs.map +0 -1
- package/kbd/fesm2022/kbd.mjs.map +0 -1
- package/label/fesm2022/label.mjs.map +0 -1
- package/layout-simple/fesm2022/layout-simple.mjs.map +0 -1
- package/menubar/fesm2022/menubar.mjs.map +0 -1
- package/native-select/fesm2022/native-select.mjs.map +0 -1
- package/navigation-menu/fesm2022/navigation-menu.mjs.map +0 -1
- package/pagination/fesm2022/pagination.mjs.map +0 -1
- package/popover/fesm2022/popover.mjs.map +0 -1
- package/progress/fesm2022/progress.mjs.map +0 -1
- package/radio-group/fesm2022/radio-group.mjs.map +0 -1
- package/resizable/fesm2022/resizable.mjs.map +0 -1
- package/scroll-area/fesm2022/scroll-area.mjs.map +0 -1
- package/searchable-multiselect/fesm2022/searchable-multiselect.mjs.map +0 -1
- package/select/fesm2022/select.mjs.map +0 -1
- package/separator/fesm2022/separator.mjs.map +0 -1
- package/sheet/fesm2022/sheet.mjs.map +0 -1
- package/sidebar/fesm2022/sidebar.mjs.map +0 -1
- package/skeleton/fesm2022/skeleton.mjs.map +0 -1
- package/slider/fesm2022/slider.mjs.map +0 -1
- package/sonner/fesm2022/sonner.mjs.map +0 -1
- package/spinner/fesm2022/spinner.mjs.map +0 -1
- package/switch/fesm2022/switch.mjs.map +0 -1
- package/table/fesm2022/table.mjs.map +0 -1
- package/tabs/fesm2022/tabs.mjs.map +0 -1
- package/textarea/fesm2022/textarea.mjs.map +0 -1
- package/toggle/fesm2022/toggle.mjs.map +0 -1
- package/toggle-group/fesm2022/toggle-group.mjs.map +0 -1
- package/tooltip/fesm2022/tooltip.mjs.map +0 -1
- package/typography/fesm2022/typography.mjs.map +0 -1
- package/utils/fesm2022/utils.mjs.map +0 -1
package/badge/README.md
CHANGED
|
@@ -1,64 +1,319 @@
|
|
|
1
|
-
# Badge
|
|
1
|
+
# Badge (`@egose/shadcn-theme-ng/badge`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A compact status/count chip in the shadcn/ui Badge style: a small pill for labels like "New",
|
|
4
|
+
"Beta", unread counts, or role tags. Use it inline in headings, list rows, tabs, and buttons where
|
|
5
|
+
a full [Alert](https://ui.shadcn.com/docs/components/alert) would be too heavy.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
This is a **standalone component with no brain primitive and no `*Imports`/`*Module` wrapper** —
|
|
8
|
+
import `HlmBadge` itself. Variants come from a `cva` table (`badgeVariants`), merged with
|
|
9
|
+
`hlm()`; the `outline` / `outline-filled` appearances add per-tone border/hover classes computed
|
|
10
|
+
by private helpers. An imperative `setClass()` escape hatch appends extra classes.
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
> **Ships as:** `@egose/shadcn-theme-ng/badge` and `@egose/shadcn-theme-ng-tw/badge`
|
|
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
|
|
8
18
|
|
|
9
19
|
```bash
|
|
10
|
-
|
|
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
|
|
11
25
|
```
|
|
12
26
|
|
|
13
|
-
|
|
27
|
+
Peer dependencies (Angular, `@spartan-ng/brain`, `@ng-icons/*`, `rxjs`, …) are documented in the
|
|
28
|
+
[package README](../../README.md#peer-dependencies). Runtime styling helper:
|
|
29
|
+
`@egose/shadcn-theme-ng/utils` (`hlm()`).
|
|
14
30
|
|
|
15
|
-
|
|
16
|
-
|
|
31
|
+
## Imports
|
|
32
|
+
|
|
33
|
+
`HlmBadge` is exported from the subpath root (`projects/badge/src/public-api.ts`). Note there is
|
|
34
|
+
**no** `HlmBadgeImports` array and **no** `HlmBadgeModule` — import the component directly:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import {
|
|
38
|
+
HlmBadge,
|
|
39
|
+
badgeVariants,
|
|
40
|
+
type BadgeVariants,
|
|
41
|
+
type BadgeVariantType,
|
|
42
|
+
type BadgeSizeType,
|
|
43
|
+
type BadgeAppearanceType,
|
|
44
|
+
} from '@egose/shadcn-theme-ng/badge';
|
|
45
|
+
// tw variant: replace with '@egose/shadcn-theme-ng-tw/badge'
|
|
17
46
|
```
|
|
18
47
|
|
|
19
|
-
|
|
48
|
+
Standalone component usage:
|
|
20
49
|
|
|
21
|
-
|
|
50
|
+
```ts
|
|
51
|
+
import { Component } from '@angular/core';
|
|
52
|
+
import { HlmBadge } from '@egose/shadcn-theme-ng/badge';
|
|
22
53
|
|
|
23
|
-
|
|
24
|
-
|
|
54
|
+
@Component({
|
|
55
|
+
selector: 'app-demo',
|
|
56
|
+
standalone: true,
|
|
57
|
+
imports: [HlmBadge],
|
|
58
|
+
template: `<span hlmBadge>New</span>`,
|
|
59
|
+
})
|
|
60
|
+
export class DemoComponent {}
|
|
25
61
|
```
|
|
26
62
|
|
|
27
|
-
|
|
63
|
+
NgModule-based consumer — list the component in the module imports (it is standalone):
|
|
28
64
|
|
|
29
|
-
|
|
65
|
+
```ts
|
|
66
|
+
import { NgModule } from '@angular/core';
|
|
67
|
+
import { HlmBadge } from '@egose/shadcn-theme-ng/badge';
|
|
30
68
|
|
|
31
|
-
|
|
69
|
+
@NgModule({ imports: [HlmBadge] })
|
|
70
|
+
export class DemoModule {}
|
|
71
|
+
```
|
|
32
72
|
|
|
33
|
-
|
|
73
|
+
## Anatomy / Structure
|
|
34
74
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
75
|
+
```html
|
|
76
|
+
<span hlmBadge variant="success" size="default" appearance="solid">Active</span>
|
|
77
|
+
<a hlmBadge variant="link" href="/changelog">v2.4.1</a>
|
|
78
|
+
```
|
|
38
79
|
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
npm publish
|
|
42
|
-
```
|
|
80
|
+
Real selector (from source):
|
|
43
81
|
|
|
44
|
-
|
|
82
|
+
| Class | Selector(s) | Kind |
|
|
83
|
+
| ---------- | ----------------------------- | --------- |
|
|
84
|
+
| `HlmBadge` | `span[hlmBadge], a[hlmBadge]` | Component |
|
|
45
85
|
|
|
46
|
-
|
|
86
|
+
Only `<span>` and `<a>` hosts match — the component projects its content (`<ng-content>`) and
|
|
87
|
+
computes its host class from `variant` + `size` + `appearance` + `userClass`.
|
|
47
88
|
|
|
48
|
-
|
|
49
|
-
|
|
89
|
+
## API reference
|
|
90
|
+
|
|
91
|
+
### `HlmBadge` — `span[hlmBadge], a[hlmBadge]`
|
|
92
|
+
|
|
93
|
+
| Input | Type | Default | Description |
|
|
94
|
+
| ------------ | --------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
95
|
+
| `variant` | `BadgeVariantType` | `'primary'` | Color tone (13 values, see below). |
|
|
96
|
+
| `size` | `BadgeSizeType` | `'default'` | `sm` (`h-5 px-2 text-xs`), `default` (`h-6 px-3 text-sm`), `lg` (`h-7 px-4 text-base`). |
|
|
97
|
+
| `appearance` | `BadgeAppearanceType` | `'solid'` | `solid` (filled), `outline` (white bg + tone border/text), `outline-filled` (outline + fills with the tone on hover). |
|
|
98
|
+
| `userClass` | `ClassValue` | `''` | Extra classes merged into the `cva` call. **Note:** unlike most `hlm*` pieces this input has **no `class` alias** — bind `[userClass]`, not `[class]`. |
|
|
99
|
+
|
|
100
|
+
| Method | Signature | Description |
|
|
101
|
+
| ---------- | --------------------------------- | -------------------------------------------------------------------------------- |
|
|
102
|
+
| `setClass` | `setClass(classes: string): void` | Imperatively appends extra classes (stored in a private signal and merged last). |
|
|
103
|
+
|
|
104
|
+
`variant` values: `primary` · `secondary` · `success` · `warning` · `danger` · `info` ·
|
|
105
|
+
`light` · `dark` · `accent` · `destructive` · `muted` · `link` · `ghost`.
|
|
106
|
+
|
|
107
|
+
Exported helpers: `badgeVariants` (the `cva` table — reuse it for custom badge-like hosts),
|
|
108
|
+
`BadgeVariants`, `BadgeVariantType`, `BadgeSizeType`, `BadgeAppearanceType`.
|
|
109
|
+
|
|
110
|
+
## Examples
|
|
111
|
+
|
|
112
|
+
### 1. Basic badge
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import { Component } from '@angular/core';
|
|
116
|
+
import { HlmBadge } from '@egose/shadcn-theme-ng/badge';
|
|
117
|
+
|
|
118
|
+
@Component({
|
|
119
|
+
selector: 'app-badge-basic',
|
|
120
|
+
standalone: true,
|
|
121
|
+
imports: [HlmBadge],
|
|
122
|
+
template: `<span hlmBadge>New</span>`,
|
|
123
|
+
})
|
|
124
|
+
export class BadgeBasicComponent {}
|
|
50
125
|
```
|
|
51
126
|
|
|
52
|
-
|
|
127
|
+
```html
|
|
128
|
+
<app-badge-basic />
|
|
129
|
+
```
|
|
53
130
|
|
|
54
|
-
|
|
131
|
+
### 2. All variants × solid
|
|
55
132
|
|
|
56
|
-
```
|
|
57
|
-
|
|
133
|
+
```ts
|
|
134
|
+
import { Component } from '@angular/core';
|
|
135
|
+
import { HlmBadge, type BadgeVariantType } from '@egose/shadcn-theme-ng/badge';
|
|
136
|
+
|
|
137
|
+
@Component({
|
|
138
|
+
selector: 'app-badge-variants',
|
|
139
|
+
standalone: true,
|
|
140
|
+
imports: [HlmBadge],
|
|
141
|
+
template: `
|
|
142
|
+
<div class="tw:flex tw:flex-wrap tw:gap-2">
|
|
143
|
+
@for (v of variants; track v) {
|
|
144
|
+
<span hlmBadge [variant]="v">{{ v }}</span>
|
|
145
|
+
}
|
|
146
|
+
</div>
|
|
147
|
+
`,
|
|
148
|
+
})
|
|
149
|
+
export class BadgeVariantsComponent {
|
|
150
|
+
readonly variants: BadgeVariantType[] = [
|
|
151
|
+
'primary',
|
|
152
|
+
'secondary',
|
|
153
|
+
'success',
|
|
154
|
+
'warning',
|
|
155
|
+
'danger',
|
|
156
|
+
'info',
|
|
157
|
+
'light',
|
|
158
|
+
'dark',
|
|
159
|
+
'accent',
|
|
160
|
+
'destructive',
|
|
161
|
+
'muted',
|
|
162
|
+
'link',
|
|
163
|
+
'ghost',
|
|
164
|
+
];
|
|
165
|
+
}
|
|
58
166
|
```
|
|
59
167
|
|
|
60
|
-
|
|
168
|
+
### 3. Sizes and outline appearances
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
import { Component } from '@angular/core';
|
|
172
|
+
import { HlmBadge } from '@egose/shadcn-theme-ng/badge';
|
|
173
|
+
|
|
174
|
+
@Component({
|
|
175
|
+
selector: 'app-badge-sizes',
|
|
176
|
+
standalone: true,
|
|
177
|
+
imports: [HlmBadge],
|
|
178
|
+
template: `
|
|
179
|
+
<div class="tw:flex tw:items-center tw:gap-2">
|
|
180
|
+
<span hlmBadge size="sm">small</span>
|
|
181
|
+
<span hlmBadge size="default">default</span>
|
|
182
|
+
<span hlmBadge size="lg">large</span>
|
|
183
|
+
</div>
|
|
184
|
+
<div class="tw:mt-3 tw:flex tw:items-center tw:gap-2">
|
|
185
|
+
<span hlmBadge variant="success" appearance="outline">outline</span>
|
|
186
|
+
<span hlmBadge variant="destructive" appearance="outline-filled">outline-filled (hover me)</span>
|
|
187
|
+
</div>
|
|
188
|
+
`,
|
|
189
|
+
})
|
|
190
|
+
export class BadgeSizesComponent {}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### 4. Link badge + count badge composed with other components
|
|
194
|
+
|
|
195
|
+
`a[hlmBadge]` is a real link host; badges also sit naturally inside buttons and headings:
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
import { Component, signal } from '@angular/core';
|
|
199
|
+
import { HlmBadge } from '@egose/shadcn-theme-ng/badge';
|
|
200
|
+
import { HlmButtonImports } from '@egose/shadcn-theme-ng/button';
|
|
201
|
+
|
|
202
|
+
@Component({
|
|
203
|
+
selector: 'app-badge-composed',
|
|
204
|
+
standalone: true,
|
|
205
|
+
imports: [HlmBadge, ...HlmButtonImports],
|
|
206
|
+
template: `
|
|
207
|
+
<h2 class="tw:flex tw:items-center tw:gap-2 tw:text-lg tw:font-semibold">
|
|
208
|
+
Inbox <span hlmBadge variant="secondary" size="sm">{{ unread() }}</span>
|
|
209
|
+
</h2>
|
|
210
|
+
<p class="tw:mt-2">
|
|
211
|
+
<a hlmBadge variant="link" href="/changelog">v2.4.1 — see what's new</a>
|
|
212
|
+
</p>
|
|
213
|
+
<button hlmButton variant="outline" size="sm" class="tw:mt-3" (click)="unread.set(0)">
|
|
214
|
+
Mark all read <span hlmBadge variant="muted" size="sm">{{ unread() }}</span>
|
|
215
|
+
</button>
|
|
216
|
+
`,
|
|
217
|
+
})
|
|
218
|
+
export class BadgeComposedComponent {
|
|
219
|
+
readonly unread = signal(7);
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### 5. Status mapping from domain state (signal-driven)
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
import { Component, computed, signal } from '@angular/core';
|
|
227
|
+
import { HlmBadge, type BadgeVariantType } from '@egose/shadcn-theme-ng/badge';
|
|
228
|
+
|
|
229
|
+
type OrderState = 'pending' | 'shipped' | 'delivered' | 'cancelled';
|
|
230
|
+
|
|
231
|
+
const tone: Record<OrderState, BadgeVariantType> = {
|
|
232
|
+
pending: 'warning',
|
|
233
|
+
shipped: 'info',
|
|
234
|
+
delivered: 'success',
|
|
235
|
+
cancelled: 'destructive',
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
@Component({
|
|
239
|
+
selector: 'app-badge-status',
|
|
240
|
+
standalone: true,
|
|
241
|
+
imports: [HlmBadge],
|
|
242
|
+
template: `
|
|
243
|
+
<ul class="tw:flex tw:flex-col tw:gap-2">
|
|
244
|
+
@for (o of orders(); track o.id) {
|
|
245
|
+
<li class="tw:flex tw:items-center tw:gap-2 tw:text-sm">
|
|
246
|
+
Order #{{ o.id }}
|
|
247
|
+
<span hlmBadge [variant]="toneFor(o.state)" [userClass]="'tw:capitalize'">
|
|
248
|
+
{{ o.state }}
|
|
249
|
+
</span>
|
|
250
|
+
</li>
|
|
251
|
+
}
|
|
252
|
+
</ul>
|
|
253
|
+
`,
|
|
254
|
+
})
|
|
255
|
+
export class BadgeStatusComponent {
|
|
256
|
+
readonly orders = signal<{ id: number; state: OrderState }[]>([
|
|
257
|
+
{ id: 101, state: 'pending' },
|
|
258
|
+
{ id: 102, state: 'shipped' },
|
|
259
|
+
{ id: 103, state: 'delivered' },
|
|
260
|
+
{ id: 104, state: 'cancelled' },
|
|
261
|
+
]);
|
|
262
|
+
toneFor = (s: OrderState) => tone[s];
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### 6. Advanced: `badgeVariants()` for custom hosts + imperative `setClass`
|
|
267
|
+
|
|
268
|
+
Reuse the exported `cva` table for elements that cannot host the directive, and use `setClass`
|
|
269
|
+
for runtime class injection (e.g. from a directive or test harness):
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
import { Component, viewChild } from '@angular/core';
|
|
273
|
+
import { HlmBadge, badgeVariants } from '@egose/shadcn-theme-ng/badge';
|
|
274
|
+
|
|
275
|
+
@Component({
|
|
276
|
+
selector: 'app-badge-advanced',
|
|
277
|
+
standalone: true,
|
|
278
|
+
imports: [HlmBadge],
|
|
279
|
+
template: `
|
|
280
|
+
<!-- custom host styled identically without the directive -->
|
|
281
|
+
<mark [class]="markClass">review</mark>
|
|
282
|
+
<!-- imperative escape hatch -->
|
|
283
|
+
<span hlmBadge #imp variant="info">runtime-tinted</span>
|
|
284
|
+
<button (click)="tint()">Tint via setClass()</button>
|
|
285
|
+
`,
|
|
286
|
+
})
|
|
287
|
+
export class BadgeAdvancedComponent {
|
|
288
|
+
readonly markClass = badgeVariants({ variant: 'warning', size: 'sm' });
|
|
289
|
+
private readonly badge = viewChild<HlmBadge>('imp');
|
|
290
|
+
|
|
291
|
+
tint() {
|
|
292
|
+
this.badge()?.setClass('tw:tracking-widest tw:uppercase');
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Accessibility notes
|
|
298
|
+
|
|
299
|
+
- Badges are visual labels, not live regions: dynamic counts ("7 unread") should live next to
|
|
300
|
+
properly labelled content (e.g. an `aria-label="Inbox, 7 unread"` heading) rather than relying
|
|
301
|
+
on the badge text alone.
|
|
302
|
+
- Never convey state by color only — the examples above pair each tone with explicit text
|
|
303
|
+
("delivered", "cancelled"). The `light`/`ghost` tones are low-contrast by design; reserve them
|
|
304
|
+
for large/bold text or decorative contexts.
|
|
305
|
+
- `a[hlmBadge]` must have a real `href` (or be replaced by a `<button>`); do not use a link badge
|
|
306
|
+
as a click-handler span — keyboard users lose focusability.
|
|
307
|
+
|
|
308
|
+
## Theming / CSS variables
|
|
309
|
+
|
|
310
|
+
Class-based `cva` theming over shadcn tokens (`bg-*/text-*`); no component-specific CSS variables.
|
|
311
|
+
Extend per-instance with `[userClass]` (note: no `class` alias on this component) or reuse
|
|
312
|
+
`badgeVariants()` for custom hosts.
|
|
61
313
|
|
|
62
|
-
##
|
|
314
|
+
## Related subpaths
|
|
63
315
|
|
|
64
|
-
|
|
316
|
+
- `@egose/shadcn-theme-ng/alert` — full banner alerts for non-inline feedback
|
|
317
|
+
- `@egose/shadcn-theme-ng/basic-alert` — ready-made icon + title + description alert
|
|
318
|
+
- `@egose/shadcn-theme-ng/button` — action buttons badges decorate
|
|
319
|
+
- `@egose/shadcn-theme-ng/avatar` — identity visuals that pair with role/status badges
|
package/badge/fesm2022/badge.mjs
CHANGED
|
@@ -4,41 +4,41 @@ import { cva } from 'class-variance-authority';
|
|
|
4
4
|
import { hlm } from '@egose/shadcn-theme-ng/utils';
|
|
5
5
|
|
|
6
6
|
const badgeVariants = cva([
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
"inline-flex",
|
|
8
|
+
"items-center",
|
|
9
|
+
"rounded-sm",
|
|
10
|
+
"font-medium",
|
|
11
|
+
"whitespace-nowrap",
|
|
12
|
+
"transition-colors",
|
|
13
|
+
"focus-visible:outline-none",
|
|
14
|
+
"focus-visible:ring-1",
|
|
15
|
+
"focus-visible:ring-ring",
|
|
16
16
|
], {
|
|
17
17
|
variants: {
|
|
18
18
|
variant: {
|
|
19
|
-
primary:
|
|
20
|
-
secondary:
|
|
21
|
-
success:
|
|
22
|
-
warning:
|
|
23
|
-
danger:
|
|
24
|
-
info:
|
|
25
|
-
light:
|
|
26
|
-
dark:
|
|
27
|
-
accent:
|
|
28
|
-
destructive:
|
|
29
|
-
muted:
|
|
30
|
-
link:
|
|
31
|
-
ghost:
|
|
19
|
+
primary: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
20
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/90",
|
|
21
|
+
success: "bg-success text-success-foreground hover:bg-success/90",
|
|
22
|
+
warning: "bg-warning text-warning-foreground hover:bg-warning/90",
|
|
23
|
+
danger: "bg-danger text-danger-foreground hover:bg-danger/90",
|
|
24
|
+
info: "bg-info text-info-foreground hover:bg-info/90",
|
|
25
|
+
light: "bg-light text-light-foreground hover:bg-light/90",
|
|
26
|
+
dark: "bg-dark text-dark-foreground hover:bg-dark/90",
|
|
27
|
+
accent: "bg-accent text-accent-foreground hover:bg-accent/90",
|
|
28
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
29
|
+
muted: "bg-muted text-muted-foreground hover:bg-muted/90",
|
|
30
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
31
|
+
ghost: "hover:bg-light hover:text-light-foreground",
|
|
32
32
|
},
|
|
33
33
|
size: {
|
|
34
|
-
sm:
|
|
35
|
-
default:
|
|
36
|
-
lg:
|
|
34
|
+
sm: "h-5 px-2 text-xs",
|
|
35
|
+
default: "h-6 px-3 text-sm",
|
|
36
|
+
lg: "h-7 px-4 text-base",
|
|
37
37
|
},
|
|
38
38
|
appearance: {
|
|
39
39
|
solid: '',
|
|
40
|
-
outline:
|
|
41
|
-
'outline-filled':
|
|
40
|
+
outline: "bg-white border",
|
|
41
|
+
'outline-filled': "bg-white border",
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
44
|
defaultVariants: {
|
|
@@ -81,44 +81,44 @@ class HlmBadge {
|
|
|
81
81
|
/** Helper functions */
|
|
82
82
|
getOutlineClasses(variant) {
|
|
83
83
|
const colors = {
|
|
84
|
-
primary:
|
|
85
|
-
secondary:
|
|
86
|
-
success:
|
|
87
|
-
warning:
|
|
88
|
-
danger:
|
|
89
|
-
info:
|
|
90
|
-
light:
|
|
91
|
-
dark:
|
|
92
|
-
accent:
|
|
93
|
-
destructive:
|
|
94
|
-
muted:
|
|
95
|
-
link:
|
|
96
|
-
ghost:
|
|
84
|
+
primary: "border-primary text-primary hover:bg-primary/10",
|
|
85
|
+
secondary: "border-secondary text-secondary hover:bg-secondary/10",
|
|
86
|
+
success: "border-success text-success hover:bg-success/10",
|
|
87
|
+
warning: "border-warning text-warning hover:bg-warning/10",
|
|
88
|
+
danger: "border-danger text-danger hover:bg-danger/10",
|
|
89
|
+
info: "border-info text-info hover:bg-info/10",
|
|
90
|
+
light: "border-light text-light-foreground hover:bg-light/10",
|
|
91
|
+
dark: "border-dark text-dark hover:bg-dark/10",
|
|
92
|
+
accent: "border-accent text-accent hover:bg-accent/10",
|
|
93
|
+
destructive: "border-destructive text-destructive hover:bg-destructive/10",
|
|
94
|
+
muted: "border-muted text-muted-foreground hover:bg-muted/10",
|
|
95
|
+
link: "text-primary",
|
|
96
|
+
ghost: "text-light-foreground",
|
|
97
97
|
};
|
|
98
98
|
return colors[variant];
|
|
99
99
|
}
|
|
100
100
|
getOutlineFilledClasses(variant) {
|
|
101
101
|
const colors = {
|
|
102
|
-
primary:
|
|
103
|
-
secondary:
|
|
104
|
-
success:
|
|
105
|
-
warning:
|
|
106
|
-
danger:
|
|
107
|
-
info:
|
|
108
|
-
light:
|
|
109
|
-
dark:
|
|
110
|
-
accent:
|
|
111
|
-
destructive:
|
|
112
|
-
muted:
|
|
113
|
-
link:
|
|
114
|
-
ghost:
|
|
102
|
+
primary: "hover:bg-primary hover:text-primary-foreground",
|
|
103
|
+
secondary: "hover:bg-secondary hover:text-secondary-foreground",
|
|
104
|
+
success: "hover:bg-success hover:text-success-foreground",
|
|
105
|
+
warning: "hover:bg-warning hover:text-warning-foreground",
|
|
106
|
+
danger: "hover:bg-danger hover:text-danger-foreground",
|
|
107
|
+
info: "hover:bg-info hover:text-info-foreground",
|
|
108
|
+
light: "hover:bg-light hover:text-light-foreground",
|
|
109
|
+
dark: "hover:bg-dark hover:text-dark-foreground",
|
|
110
|
+
accent: "hover:bg-accent hover:text-accent-foreground",
|
|
111
|
+
destructive: "hover:bg-destructive hover:text-destructive-foreground",
|
|
112
|
+
muted: "hover:bg-muted hover:text-muted-foreground",
|
|
113
|
+
link: "hover:underline",
|
|
114
|
+
ghost: "hover:bg-light",
|
|
115
115
|
};
|
|
116
116
|
return colors[variant];
|
|
117
117
|
}
|
|
118
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
119
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.
|
|
118
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: HlmBadge, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
119
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.3", type: HlmBadge, isStandalone: true, selector: "span[hlmBadge], a[hlmBadge]", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "userClass", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "_computedClass()" } }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
120
120
|
}
|
|
121
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
121
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: HlmBadge, decorators: [{
|
|
122
122
|
type: Component,
|
|
123
123
|
args: [{
|
|
124
124
|
selector: 'span[hlmBadge], a[hlmBadge]',
|
|
@@ -140,4 +140,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
140
140
|
*/
|
|
141
141
|
|
|
142
142
|
export { HlmBadge, badgeVariants };
|
|
143
|
-
|
|
143
|
+
|