@egose/shadcn-theme-ng-tw 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 +20 -20
- package/alert/README.md +343 -34
- package/alert/fesm2022/alert.mjs +18 -18
- package/alert-dialog/README.md +471 -5
- package/alert-dialog/fesm2022/alert-dialog.mjs +48 -48
- package/alert-dialog/types/alert-dialog.d.ts +1 -1
- 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 +54 -54
- package/autocomplete/types/autocomplete.d.ts +1 -1
- package/avatar/README.md +357 -5
- package/avatar/fesm2022/avatar.mjs +32 -32
- package/badge/README.md +289 -34
- package/badge/fesm2022/badge.mjs +4 -4
- package/basic-alert/README.md +324 -34
- package/basic-alert/fesm2022/basic-alert.mjs +4 -4
- package/basic-alert/types/basic-alert.d.ts +1 -1
- package/breadcrumb/README.md +406 -5
- package/breadcrumb/fesm2022/breadcrumb.mjs +34 -34
- package/button/README.md +453 -34
- package/button/fesm2022/button.mjs +96 -118
- 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 +154 -154
- package/card/README.md +331 -5
- package/card/fesm2022/card.mjs +33 -33
- package/carousel/README.md +333 -5
- package/carousel/fesm2022/carousel.mjs +47 -44
- package/carousel/types/carousel.d.ts +1 -1
- package/checkbox/README.md +291 -34
- package/checkbox/fesm2022/checkbox.mjs +22 -20
- 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 +95 -92
- package/combobox/types/combobox.d.ts +1 -1
- package/command/README.md +435 -5
- package/command/fesm2022/command.mjs +56 -56
- package/confirmation-dialog/README.md +272 -34
- package/confirmation-dialog/fesm2022/confirmation-dialog.mjs +13 -12
- package/confirmation-dialog/types/confirmation-dialog.d.ts +9 -5
- 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 +79 -68
- package/date-picker/types/date-picker.d.ts +8 -4
- package/dialog/README.md +419 -34
- package/dialog/fesm2022/dialog.mjs +48 -48
- package/drawer/README.md +395 -5
- package/drawer/fesm2022/drawer.mjs +45 -45
- package/dropdown-menu/README.md +417 -5
- package/dropdown-menu/fesm2022/dropdown-menu.mjs +85 -73
- package/dropdown-menu/types/dropdown-menu.d.ts +4 -0
- package/empty/README.md +329 -5
- package/empty/fesm2022/empty.mjs +31 -31
- package/field/README.md +385 -5
- package/field/fesm2022/field.mjs +59 -59
- package/field/types/field.d.ts +1 -1
- package/form-checkbox/README.md +283 -34
- package/form-checkbox/fesm2022/form-checkbox.mjs +37 -19
- 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 +59 -24
- 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 +30 -16
- 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 +41 -21
- package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +8 -2
- package/form-select/README.md +321 -34
- package/form-select/fesm2022/form-select.mjs +62 -29
- 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 +43 -55
- 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 +42 -23
- 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 +37 -37
- package/input-group/types/input-group.d.ts +3 -3
- package/input-otp/README.md +375 -5
- package/input-otp/fesm2022/input-otp.mjs +27 -27
- package/item/README.md +385 -5
- package/item/fesm2022/item.mjs +54 -54
- package/kbd/README.md +291 -5
- package/kbd/fesm2022/kbd.mjs +13 -13
- package/label/README.md +243 -34
- package/label/fesm2022/label.mjs +9 -9
- package/label/types/label.d.ts +1 -1
- package/layout-simple/README.md +174 -44
- package/layout-simple/fesm2022/layout-simple.mjs +917 -398
- package/layout-simple/types/layout-simple.d.ts +180 -129
- package/menu/README.md +418 -0
- package/menu/fesm2022/menu.mjs +461 -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 +37 -37
- package/package.json +183 -154
- package/pagination/README.md +388 -5
- package/pagination/fesm2022/pagination.mjs +63 -63
- 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/resizable/README.md +269 -5
- package/resizable/fesm2022/resizable.mjs +19 -19
- 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 +63 -16
- package/searchable-multiselect/types/searchable-multiselect.d.ts +8 -2
- package/select/README.md +408 -34
- package/select/fesm2022/select.mjs +80 -72
- 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 +30 -30
- package/sidebar/README.md +457 -5
- package/sidebar/fesm2022/sidebar.mjs +136 -134
- package/sidebar/types/sidebar.d.ts +3 -3
- package/skeleton/README.md +217 -5
- package/skeleton/fesm2022/skeleton.mjs +9 -9
- package/slider/README.md +273 -5
- package/slider/fesm2022/slider.mjs +29 -25
- package/sonner/README.md +317 -34
- package/sonner/fesm2022/sonner.mjs +9 -9
- package/spinner/README.md +255 -34
- package/spinner/fesm2022/spinner.mjs +8 -8
- package/switch/README.md +281 -34
- package/switch/fesm2022/switch.mjs +12 -14
- package/table/README.md +423 -5
- package/table/fesm2022/table.mjs +41 -41
- package/tabs/README.md +382 -34
- package/tabs/fesm2022/tabs.mjs +48 -38
- package/textarea/README.md +282 -5
- package/textarea/fesm2022/textarea.mjs +9 -9
- package/toggle/README.md +270 -5
- package/toggle/fesm2022/toggle.mjs +14 -14
- 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 +12 -12
- 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/tooltip/README.md
CHANGED
|
@@ -1,64 +1,270 @@
|
|
|
1
|
-
# Tooltip
|
|
1
|
+
# Tooltip (`@egose/shadcn-theme-ng/tooltip`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Contextual hints, equivalent to [shadcn/ui Tooltip](https://ui.shadcn.com/docs/components/tooltip). This subpath ships a single thin directive, `HlmTooltip` (`[hlmTooltip]`), that configures spartan-ng's `BrnTooltip` primitive with shadcn styling: it provides default content classes (`DEFAULT_TOOLTIP_CONTENT_CLASSES`), arrow SVG classes (`DEFAULT_TOOLTIP_SVG_CLASS`), and per-position arrow placement (`tooltipPositionVariants`). All show/hide behavior comes from `BrnTooltip` — this package only themes it.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> **Ships as:** `@egose/shadcn-theme-ng/tooltip` and `@egose/shadcn-theme-ng-tw/tooltip` (the `tw:`-prefixed Tailwind variant). See the [package README](../../README.md) for install steps, peer dependencies, Tailwind setup, and testing/release guidance. Do not publish this project directory independently.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
|
|
10
|
+
# Plain Tailwind (no prefix)
|
|
11
|
+
npm install @egose/shadcn-theme-ng
|
|
12
|
+
|
|
13
|
+
# Or the tw:-prefixed variant
|
|
14
|
+
npm install @egose/shadcn-theme-ng-tw
|
|
11
15
|
```
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
`@spartan-ng/brain` and `class-variance-authority` arrive transitively. See the [package README](../../README.md) for the full peer-dependency table.
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
## Imports
|
|
20
|
+
|
|
21
|
+
All public symbols are re-exported from `projects/tooltip/src/public-api.ts`:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import {
|
|
25
|
+
DEFAULT_TOOLTIP_CONTENT_CLASSES,
|
|
26
|
+
DEFAULT_TOOLTIP_SVG_CLASS,
|
|
27
|
+
HlmTooltip,
|
|
28
|
+
HlmTooltipImports,
|
|
29
|
+
HlmTooltipModule,
|
|
30
|
+
tooltipPositionVariants,
|
|
31
|
+
} from '@egose/shadcn-theme-ng/tooltip';
|
|
32
|
+
// tw variant: swap to '@egose/shadcn-theme-ng-tw/tooltip'
|
|
17
33
|
```
|
|
18
34
|
|
|
19
|
-
|
|
35
|
+
Standalone-component usage (preferred):
|
|
20
36
|
|
|
21
|
-
|
|
37
|
+
```ts
|
|
38
|
+
import { Component } from '@angular/core';
|
|
39
|
+
import { HlmTooltipImports } from '@egose/shadcn-theme-ng/tooltip';
|
|
22
40
|
|
|
23
|
-
|
|
24
|
-
|
|
41
|
+
@Component({
|
|
42
|
+
selector: 'app-demo',
|
|
43
|
+
standalone: true,
|
|
44
|
+
imports: [...HlmTooltipImports],
|
|
45
|
+
template: `<button [hlmTooltip]="'Save document'">Save</button>`,
|
|
46
|
+
})
|
|
47
|
+
export class DemoComponent {}
|
|
25
48
|
```
|
|
26
49
|
|
|
27
|
-
|
|
50
|
+
NgModule usage:
|
|
28
51
|
|
|
29
|
-
|
|
52
|
+
```ts
|
|
53
|
+
import { NgModule } from '@angular/core';
|
|
54
|
+
import { HlmTooltipModule } from '@egose/shadcn-theme-ng/tooltip';
|
|
30
55
|
|
|
31
|
-
|
|
56
|
+
@NgModule({ imports: [HlmTooltipModule] })
|
|
57
|
+
export class FeatureModule {}
|
|
58
|
+
```
|
|
32
59
|
|
|
33
|
-
|
|
60
|
+
| Symbol | Kind | Description |
|
|
61
|
+
| --------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
62
|
+
| `HlmTooltip` | Directive | `[hlmTooltip]` — themed `BrnTooltip` with shadcn defaults. |
|
|
63
|
+
| `DEFAULT_TOOLTIP_CONTENT_CLASSES` | `const` (string) | Default bubble classes (`bg-foreground text-background rounded-md px-3 py-1.5 text-xs …`). |
|
|
64
|
+
| `DEFAULT_TOOLTIP_SVG_CLASS` | `const` (string) | Default arrow classes (`bg-foreground fill-foreground size-2.5 rotate-45 …`). (Note: unprefixed utilities; overridden by the provider with `hlm()`.) |
|
|
65
|
+
| `tooltipPositionVariants` | cva fn | `tooltipPositionVariants({ position })` — arrow placement for `top/bottom/left/right`. |
|
|
66
|
+
| `HlmTooltipImports` | `const` array | `[HlmTooltip]` — spread into `imports: [...]`. |
|
|
67
|
+
| `HlmTooltipModule` | NgModule | Imports + re-exports `HlmTooltip`. |
|
|
34
68
|
|
|
35
|
-
|
|
36
|
-
cd dist/tooltip
|
|
37
|
-
```
|
|
69
|
+
## Anatomy / Structure
|
|
38
70
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```
|
|
71
|
+
```html
|
|
72
|
+
<!-- basic: string content -->
|
|
73
|
+
<button hlmBtn [hlmTooltip]="'Add to library'">Add</button>
|
|
43
74
|
|
|
44
|
-
|
|
75
|
+
<!-- positioned, delayed -->
|
|
76
|
+
<button hlmBtn [hlmTooltip]="'Settings'" position="right" [showDelay]="300" [hideDelay]="100">Settings</button>
|
|
45
77
|
|
|
46
|
-
|
|
78
|
+
<!-- disabled tooltip -->
|
|
79
|
+
<button hlmBtn [hlmTooltip]="'Hidden hint'" [tooltipDisabled]="true">No tooltip</button>
|
|
80
|
+
```
|
|
47
81
|
|
|
48
|
-
|
|
49
|
-
|
|
82
|
+
The directive takes the tooltip **text as its input value** (`brnTooltip: hlmTooltip`) and renders the floating bubble + arrow via the CDK overlay. No extra outlet component is needed.
|
|
83
|
+
|
|
84
|
+
## API reference
|
|
85
|
+
|
|
86
|
+
### `HlmTooltip` — selector `[hlmTooltip]` (directive, hosts `BrnTooltip`)
|
|
87
|
+
|
|
88
|
+
The directive declares **no own inputs** — everything is forwarded to `BrnTooltip` (plus provider defaults):
|
|
89
|
+
|
|
90
|
+
| Input | Type | Default (via provider) | Description |
|
|
91
|
+
| ----------------- | --------------------------------------------------------------- | ---------------------- | -------------------------------------------------------------------- |
|
|
92
|
+
| `hlmTooltip` | `string` (forwarded as `brnTooltip`) | — | Tooltip text content. Required to show anything. |
|
|
93
|
+
| `position` | `BrnTooltipPosition` (`'top' \| 'bottom' \| 'left' \| 'right'`) | — (Brn default) | Bubble side + arrow placement (arrow via `tooltipPositionVariants`). |
|
|
94
|
+
| `showDelay` | `number` (forwarded) | — (Brn default) | ms before the tooltip appears on hover/focus. |
|
|
95
|
+
| `hideDelay` | `number` (forwarded) | — (Brn default) | ms before the tooltip hides on leave/blur. |
|
|
96
|
+
| `tooltipDisabled` | `boolean` (forwarded) | — (Brn default) | Suppress the tooltip entirely. |
|
|
97
|
+
|
|
98
|
+
Provider defaults (`provideBrnTooltipDefaultOptions`, applied automatically): `svgClasses: DEFAULT_TOOLTIP_SVG_CLASS`, `tooltipContentClasses: DEFAULT_TOOLTIP_CONTENT_CLASSES`, `arrowClasses: (position) => hlm(tooltipPositionVariants({ position }))`.
|
|
99
|
+
|
|
100
|
+
No outputs. Can attach to any element (buttons, icons, toggles, links).
|
|
101
|
+
|
|
102
|
+
## Examples
|
|
103
|
+
|
|
104
|
+
### 1. Basic usage
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
// demo-basic.component.ts
|
|
108
|
+
import { Component } from '@angular/core';
|
|
109
|
+
import { HlmTooltipImports } from '@egose/shadcn-theme-ng/tooltip';
|
|
110
|
+
import { HlmButtonImports } from '@egose/shadcn-theme-ng/button';
|
|
111
|
+
|
|
112
|
+
@Component({
|
|
113
|
+
selector: 'demo-basic',
|
|
114
|
+
standalone: true,
|
|
115
|
+
imports: [...HlmTooltipImports, ...HlmButtonImports],
|
|
116
|
+
template: ` <button hlmBtn variant="outline" [hlmTooltip]="'Add to library'">Add</button> `,
|
|
117
|
+
})
|
|
118
|
+
export class DemoBasic {}
|
|
50
119
|
```
|
|
51
120
|
|
|
52
|
-
|
|
121
|
+
### 2. All positions
|
|
53
122
|
|
|
54
|
-
|
|
123
|
+
```ts
|
|
124
|
+
// demo-positions.component.ts
|
|
125
|
+
import { Component } from '@angular/core';
|
|
126
|
+
import { HlmTooltipImports } from '@egose/shadcn-theme-ng/tooltip';
|
|
127
|
+
import { HlmButtonImports } from '@egose/shadcn-theme-ng/button';
|
|
55
128
|
|
|
56
|
-
|
|
57
|
-
|
|
129
|
+
@Component({
|
|
130
|
+
selector: 'demo-positions',
|
|
131
|
+
standalone: true,
|
|
132
|
+
imports: [...HlmTooltipImports, ...HlmButtonImports],
|
|
133
|
+
template: `
|
|
134
|
+
<div class="flex flex-wrap gap-2">
|
|
135
|
+
<button hlmBtn variant="outline" [hlmTooltip]="'On top'" position="top">Top</button>
|
|
136
|
+
<button hlmBtn variant="outline" [hlmTooltip]="'Below'" position="bottom">Bottom</button>
|
|
137
|
+
<button hlmBtn variant="outline" [hlmTooltip]="'On the left'" position="left">Left</button>
|
|
138
|
+
<button hlmBtn variant="outline" [hlmTooltip]="'On the right'" position="right">Right</button>
|
|
139
|
+
</div>
|
|
140
|
+
`,
|
|
141
|
+
})
|
|
142
|
+
export class DemoPositions {}
|
|
58
143
|
```
|
|
59
144
|
|
|
60
|
-
|
|
145
|
+
The arrow repositions automatically per side via `tooltipPositionVariants({ position })`.
|
|
146
|
+
|
|
147
|
+
### 3. Delays + disabled state
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
// demo-delays.component.ts
|
|
151
|
+
import { Component, signal } from '@angular/core';
|
|
152
|
+
import { HlmTooltipImports } from '@egose/shadcn-theme-ng/tooltip';
|
|
153
|
+
import { HlmButtonImports } from '@egose/shadcn-theme-ng/button';
|
|
154
|
+
|
|
155
|
+
@Component({
|
|
156
|
+
selector: 'demo-delays',
|
|
157
|
+
standalone: true,
|
|
158
|
+
imports: [...HlmTooltipImports, ...HlmButtonImports],
|
|
159
|
+
template: `
|
|
160
|
+
<div class="flex gap-2">
|
|
161
|
+
<button hlmBtn variant="outline" [hlmTooltip]="'Slow to appear'" [showDelay]="600" [hideDelay]="100">
|
|
162
|
+
Hover me
|
|
163
|
+
</button>
|
|
164
|
+
<button hlmBtn variant="outline" [hlmTooltip]="'Never shows'" [tooltipDisabled]="muted()">
|
|
165
|
+
{{ muted() ? 'Muted (no tip)' : 'Unmuted' }}
|
|
166
|
+
</button>
|
|
167
|
+
<button hlmBtn size="sm" (click)="muted.set(!muted())">Toggle mute</button>
|
|
168
|
+
</div>
|
|
169
|
+
`,
|
|
170
|
+
})
|
|
171
|
+
export class DemoDelays {
|
|
172
|
+
readonly muted = signal(false);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 4. Icon-only buttons and toggles (accessible names still required)
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
// demo-icons.component.ts
|
|
180
|
+
import { Component } from '@angular/core';
|
|
181
|
+
import { HlmTooltipImports } from '@egose/shadcn-theme-ng/tooltip';
|
|
182
|
+
import { HlmToggleImports } from '@egose/shadcn-theme-ng/toggle';
|
|
183
|
+
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
184
|
+
import { lucideBold, lucideItalic } from '@ng-icons/lucide';
|
|
185
|
+
|
|
186
|
+
@Component({
|
|
187
|
+
selector: 'demo-icons',
|
|
188
|
+
standalone: true,
|
|
189
|
+
imports: [...HlmTooltipImports, ...HlmToggleImports, NgIcon],
|
|
190
|
+
providers: [provideIcons({ lucideBold, lucideItalic })],
|
|
191
|
+
template: `
|
|
192
|
+
<div class="flex gap-1">
|
|
193
|
+
<button hlmToggle aria-label="Toggle bold" [hlmTooltip]="'Bold (Ctrl+B)'">
|
|
194
|
+
<ng-icon name="lucideBold" />
|
|
195
|
+
</button>
|
|
196
|
+
<button hlmToggle aria-label="Toggle italic" [hlmTooltip]="'Italic (Ctrl+I)'" position="bottom">
|
|
197
|
+
<ng-icon name="lucideItalic" />
|
|
198
|
+
</button>
|
|
199
|
+
</div>
|
|
200
|
+
`,
|
|
201
|
+
})
|
|
202
|
+
export class DemoIcons {}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
> The tooltip is a visual hint only — icon buttons still need `aria-label` (tooltips are not reliably announced).
|
|
206
|
+
|
|
207
|
+
### 5. Dynamic content from signals
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
// demo-dynamic.component.ts
|
|
211
|
+
import { Component, computed, signal } from '@angular/core';
|
|
212
|
+
import { HlmTooltipImports } from '@egose/shadcn-theme-ng/tooltip';
|
|
213
|
+
import { HlmButtonImports } from '@egose/shadcn-theme-ng/button';
|
|
214
|
+
|
|
215
|
+
@Component({
|
|
216
|
+
selector: 'demo-dynamic',
|
|
217
|
+
standalone: true,
|
|
218
|
+
imports: [...HlmTooltipImports, ...HlmButtonImports],
|
|
219
|
+
template: `
|
|
220
|
+
<button hlmBtn variant="outline" [hlmTooltip]="tip()" (click)="count.set(count() + 1)">
|
|
221
|
+
Clicked {{ count() }}×
|
|
222
|
+
</button>
|
|
223
|
+
`,
|
|
224
|
+
})
|
|
225
|
+
export class DemoDynamic {
|
|
226
|
+
readonly count = signal(0);
|
|
227
|
+
readonly tip = computed(() => (this.count() === 0 ? 'Click to start' : `Clicked ${this.count()} times`));
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### 6. Advanced: reusing the class constants
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
// demo-classes.component.ts
|
|
235
|
+
import { Component } from '@angular/core';
|
|
236
|
+
import { DEFAULT_TOOLTIP_CONTENT_CLASSES, tooltipPositionVariants } from '@egose/shadcn-theme-ng/tooltip';
|
|
237
|
+
import { hlm } from '@egose/shadcn-theme-ng/utils';
|
|
238
|
+
|
|
239
|
+
@Component({
|
|
240
|
+
selector: 'demo-classes',
|
|
241
|
+
standalone: true,
|
|
242
|
+
template: `<p class="text-sm">Content classes length: {{ len }}</p>`,
|
|
243
|
+
})
|
|
244
|
+
export class DemoClasses {
|
|
245
|
+
readonly len = DEFAULT_TOOLTIP_CONTENT_CLASSES.length;
|
|
246
|
+
|
|
247
|
+
arrowFor(position: 'top' | 'bottom' | 'left' | 'right') {
|
|
248
|
+
return hlm(tooltipPositionVariants({ position }));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Accessibility notes
|
|
254
|
+
|
|
255
|
+
- Tooltips appear on hover **and** focus (via Brn) — keyboard users get them automatically; do not gate hints behind hover-only behavior.
|
|
256
|
+
- Never put essential information _only_ in a tooltip: screen-reader and touch support is best-effort. Mirror critical hints as visible text or `aria-label`s.
|
|
257
|
+
- Icon-only triggers need `aria-label` regardless of tooltip text.
|
|
258
|
+
- Keep tooltip text short (a few words); long prose belongs in a popover/dialog.
|
|
259
|
+
- `tooltipDisabled` removes the hint entirely — only use it when the control is self-explanatory in that state, not to hide errors.
|
|
260
|
+
|
|
261
|
+
## Theming / CSS variables
|
|
262
|
+
|
|
263
|
+
The bubble uses `bg-foreground text-background` with entrance/exit animations per side and theme-aware shadows; the arrow inherits the same fill. Follows your shadcn theme automatically. Override globally by providing your own `provideBrnTooltipDefaultOptions`, or per case by wrapping triggers with custom classes.
|
|
61
264
|
|
|
62
|
-
##
|
|
265
|
+
## Related subpaths
|
|
63
266
|
|
|
64
|
-
|
|
267
|
+
- `@egose/shadcn-theme-ng/button` — most common tooltip anchor.
|
|
268
|
+
- `@egose/shadcn-theme-ng/toggle` / `@egose/shadcn-theme-ng/toggle-group` — icon toggles that pair well with hints.
|
|
269
|
+
- `@egose/shadcn-theme-ng/popover` / `@egose/shadcn-theme-ng/hover-card` — richer floating content (vs. short tooltip text).
|
|
270
|
+
- `@egose/shadcn-theme-ng/utils` — `hlm()` used to compose arrow/content classes.
|
|
@@ -6,20 +6,20 @@ import { hlm } from '@egose/shadcn-theme-ng-tw/utils';
|
|
|
6
6
|
import { cva } from 'class-variance-authority';
|
|
7
7
|
|
|
8
8
|
const DEFAULT_TOOLTIP_SVG_CLASS = 'bg-foreground fill-foreground z-50 block size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]';
|
|
9
|
-
const DEFAULT_TOOLTIP_CONTENT_CLASSES = hlm('data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 rounded-md px-3 py-1.5 text-xs bg-foreground text-background data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) text-balance');
|
|
10
|
-
const tooltipPositionVariants = cva('absolute', {
|
|
9
|
+
const DEFAULT_TOOLTIP_CONTENT_CLASSES = hlm('tw:data-open:animate-in data-open:fade-in-0 tw:data-open:zoom-in-95 tw:data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 tw:data-[state=delayed-open]:zoom-in-95 tw:data-closed:animate-out data-closed:fade-out-0 tw:data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 tw:rounded-md tw:px-3 tw:py-1.5 tw:text-xs tw:bg-foreground tw:text-background tw:data-open:animate-in data-open:fade-in-0 tw:data-open:zoom-in-95 tw:data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 tw:data-[state=delayed-open]:zoom-in-95 tw:data-closed:animate-out data-closed:fade-out-0 tw:data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 tw:z-50 tw:w-fit tw:origin-(--radix-tooltip-content-transform-origin) tw:text-balance');
|
|
10
|
+
const tooltipPositionVariants = cva('tw:absolute', {
|
|
11
11
|
variants: {
|
|
12
12
|
position: {
|
|
13
|
-
top: 'bottom-0 left-[calc(50%-5px)] translate-y-full',
|
|
14
|
-
bottom: '
|
|
15
|
-
left: '
|
|
16
|
-
right: '
|
|
13
|
+
top: 'tw:bottom-0 tw:left-[calc(50%-5px)] tw:translate-y-full',
|
|
14
|
+
bottom: 'tw:-top-2.5 tw:left-[calc(50%-5px)] tw:translate-y-0 tw:rotate-180',
|
|
15
|
+
left: 'tw:-end-2.5 tw:top-[calc(50%-5px)] tw:translate-y-0 tw:rotate-270 tw:rtl:-rotate-270',
|
|
16
|
+
right: 'tw:-start-2.5 tw:top-[calc(50%-5px)] tw:translate-y-0 tw:rotate-90 tw:rtl:-rotate-90',
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
20
|
class HlmTooltip {
|
|
21
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
22
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.
|
|
21
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: HlmTooltip, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
22
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.3", type: HlmTooltip, isStandalone: true, selector: "[hlmTooltip]", providers: [
|
|
23
23
|
provideBrnTooltipDefaultOptions({
|
|
24
24
|
svgClasses: DEFAULT_TOOLTIP_SVG_CLASS,
|
|
25
25
|
tooltipContentClasses: DEFAULT_TOOLTIP_CONTENT_CLASSES,
|
|
@@ -27,7 +27,7 @@ class HlmTooltip {
|
|
|
27
27
|
}),
|
|
28
28
|
], hostDirectives: [{ directive: i1.BrnTooltip, inputs: ["brnTooltip", "hlmTooltip", "position", "position", "hideDelay", "hideDelay", "showDelay", "showDelay", "tooltipDisabled", "tooltipDisabled"] }], ngImport: i0 });
|
|
29
29
|
}
|
|
30
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
30
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: HlmTooltip, decorators: [{
|
|
31
31
|
type: Directive,
|
|
32
32
|
args: [{
|
|
33
33
|
selector: '[hlmTooltip]',
|
|
@@ -52,11 +52,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
52
52
|
*/
|
|
53
53
|
const HlmTooltipImports = [HlmTooltip];
|
|
54
54
|
class HlmTooltipModule {
|
|
55
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
56
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.
|
|
57
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.
|
|
55
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: HlmTooltipModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
56
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.1.3", ngImport: i0, type: HlmTooltipModule, imports: [HlmTooltip], exports: [HlmTooltip] });
|
|
57
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: HlmTooltipModule });
|
|
58
58
|
}
|
|
59
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
59
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: HlmTooltipModule, decorators: [{
|
|
60
60
|
type: NgModule,
|
|
61
61
|
args: [{
|
|
62
62
|
imports: [...HlmTooltipImports],
|
|
@@ -69,4 +69,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
69
69
|
*/
|
|
70
70
|
|
|
71
71
|
export { DEFAULT_TOOLTIP_CONTENT_CLASSES, DEFAULT_TOOLTIP_SVG_CLASS, HlmTooltip, HlmTooltipImports, HlmTooltipModule, tooltipPositionVariants };
|
|
72
|
-
|
|
72
|
+
|
package/typography/README.md
CHANGED
|
@@ -1,11 +1,277 @@
|
|
|
1
|
-
# Typography
|
|
1
|
+
# Typography (`@egose/shadcn-theme-ng/typography`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Document type styles, equivalent to [shadcn/ui Typography](https://ui.shadcn.com/docs/components/typography). This subpath ships twelve **thin styling directives** — no behavior, no primitives, no inputs/outputs. Attach them to native elements (`h1`–`h4`, `p`, `blockquote`, `code`, `ul`, …) for shadcn type scale, plus matching exported class constants (`hlmH1`, `hlmP`, …) for reuse in custom components.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> **Ships as:** `@egose/shadcn-theme-ng/typography` and `@egose/shadcn-theme-ng-tw/typography` (the `tw:`-prefixed Tailwind variant). See the [package README](../../README.md) for install steps, peer dependencies, Tailwind setup, and testing/release guidance. Do not publish this project directory independently.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
|
|
10
|
+
# Plain Tailwind (no prefix)
|
|
11
|
+
npm install @egose/shadcn-theme-ng
|
|
12
|
+
|
|
13
|
+
# Or the tw:-prefixed variant
|
|
14
|
+
npm install @egose/shadcn-theme-ng-tw
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
No extra runtime dependencies. See the [package README](../../README.md) for the peer-dependency table.
|
|
18
|
+
|
|
19
|
+
## Imports
|
|
20
|
+
|
|
21
|
+
All public symbols are re-exported from `projects/typography/src/public-api.ts`:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import {
|
|
25
|
+
HlmBlockquote,
|
|
26
|
+
HlmCode,
|
|
27
|
+
HlmH1,
|
|
28
|
+
HlmH2,
|
|
29
|
+
HlmH3,
|
|
30
|
+
HlmH4,
|
|
31
|
+
HlmLarge,
|
|
32
|
+
HlmLead,
|
|
33
|
+
HlmMuted,
|
|
34
|
+
HlmP,
|
|
35
|
+
HlmSmall,
|
|
36
|
+
HlmTypographyImports,
|
|
37
|
+
HlmTypographyModule,
|
|
38
|
+
HlmUl,
|
|
39
|
+
} from '@egose/shadcn-theme-ng/typography';
|
|
40
|
+
// tw variant: swap to '@egose/shadcn-theme-ng-tw/typography'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Class constants are exported alongside (`hlmH1`, `hlmH2`, `hlmH3`, `hlmH4`, `hlmP`, `hlmBlockquote`, `hlmCode`, `hlmLarge`, `hlmLead`, `hlmMuted`, `hlmSmall`, `hlmUl`).
|
|
44
|
+
|
|
45
|
+
Standalone-component usage (preferred):
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { Component } from '@angular/core';
|
|
49
|
+
import { HlmTypographyImports } from '@egose/shadcn-theme-ng/typography';
|
|
50
|
+
|
|
51
|
+
@Component({
|
|
52
|
+
selector: 'app-demo',
|
|
53
|
+
standalone: true,
|
|
54
|
+
imports: [...HlmTypographyImports],
|
|
55
|
+
template: `<h1 hlmH1>Title</h1>`,
|
|
56
|
+
})
|
|
57
|
+
export class DemoComponent {}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
NgModule usage:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { NgModule } from '@angular/core';
|
|
64
|
+
import { HlmTypographyModule } from '@egose/shadcn-theme-ng/typography';
|
|
65
|
+
|
|
66
|
+
@NgModule({ imports: [HlmTypographyModule] })
|
|
67
|
+
export class FeatureModule {}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
| Symbol | Kind | Host selector (real) |
|
|
71
|
+
| ---------------------- | ------------- | -------------------------------- |
|
|
72
|
+
| `HlmH1` | Directive | `[hlmH1]` |
|
|
73
|
+
| `HlmH2` | Directive | `[hlmH2]` |
|
|
74
|
+
| `HlmH3` | Directive | `[hlmH3]` |
|
|
75
|
+
| `HlmH4` | Directive | `[hlmH4]` |
|
|
76
|
+
| `HlmP` | Directive | `[hlmP]` |
|
|
77
|
+
| `HlmBlockquote` | Directive | `[hlmBlockquote]` |
|
|
78
|
+
| `HlmCode` | Directive | `[hlmCode]` |
|
|
79
|
+
| `HlmLarge` | Directive | `[hlmLarge]` |
|
|
80
|
+
| `HlmLead` | Directive | `[hlmLead]` |
|
|
81
|
+
| `HlmMuted` | Directive | `[hlmMuted]` |
|
|
82
|
+
| `HlmSmall` | Directive | `[hlmSmall]` |
|
|
83
|
+
| `HlmUl` | Directive | `[hlmUl]` |
|
|
84
|
+
| `HlmTypographyImports` | `const` array | All twelve directives. |
|
|
85
|
+
| `HlmTypographyModule` | NgModule | Imports + re-exports all twelve. |
|
|
86
|
+
|
|
87
|
+
## Anatomy / Structure
|
|
88
|
+
|
|
89
|
+
```html
|
|
90
|
+
<h1 hlmH1>The Joke Tax Chronicles</h1>
|
|
91
|
+
<p hlmLead>Once upon a time, in a far-off land, there was a very lazy king.</p>
|
|
92
|
+
<h2 hlmH2>The King's Plan</h2>
|
|
93
|
+
<p hlmP>The king thought…</p>
|
|
94
|
+
<blockquote hlmBlockquote>"After all," he said, "everyone enjoys a good joke."</blockquote>
|
|
95
|
+
<h3 hlmH3>The Joke Tax</h3>
|
|
96
|
+
<ul hlmUl>
|
|
97
|
+
<li>1st level of puns: 5 gold coins</li>
|
|
98
|
+
<li>2nd level of jokes: 10 gold coins</li>
|
|
99
|
+
</ul>
|
|
100
|
+
<p hlmP>Learn more with <code hlmCode>ng add</code>.</p>
|
|
101
|
+
<p hlmLarge>Large callout line.</p>
|
|
102
|
+
<p hlmMuted>Muted fine print.</p>
|
|
103
|
+
<p hlmSmall>Small label text.</p>
|
|
104
|
+
<h4 hlmH4>Appendix</h4>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Attach each directive to its matching semantic element (`HlmH1`→`<h1>`, `HlmUl`→`<ul>`, `HlmCode`→`<code>`, …) — the directive adds classes only and does not change semantics.
|
|
108
|
+
|
|
109
|
+
## API reference
|
|
110
|
+
|
|
111
|
+
None of the twelve directives declare inputs, outputs, or methods. Each merges a fixed class string (also exported as a constant) via `classes()`:
|
|
112
|
+
|
|
113
|
+
| Directive / constant | Element | Fixed classes (abridged) |
|
|
114
|
+
| --------------------------------- | -------------- | ----------------------------------------------------------------------------------- |
|
|
115
|
+
| `HlmH1` / `hlmH1` | `<h1>` | `scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl` |
|
|
116
|
+
| `HlmH2` / `hlmH2` | `<h2>` | `scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0` |
|
|
117
|
+
| `HlmH3` / `hlmH3` | `<h3>` | `scroll-m-20 text-2xl font-semibold tracking-tight` |
|
|
118
|
+
| `HlmH4` / `hlmH4` | `<h4>` | `scroll-m-20 text-xl font-semibold tracking-tight` |
|
|
119
|
+
| `HlmP` / `hlmP` | `<p>` | `leading-7 [&:not(:first-child)]:mt-6` |
|
|
120
|
+
| `HlmBlockquote` / `hlmBlockquote` | `<blockquote>` | `mt-6 border-l-2 pl-6 italic` |
|
|
121
|
+
| `HlmCode` / `hlmCode` | `<code>` | `relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold` |
|
|
122
|
+
| `HlmUl` / `hlmUl` | `<ul>` | `my-6 ml-6 list-disc [&>li]:mt-2` |
|
|
123
|
+
| `HlmLarge` / `hlmLarge` | any | `text-lg font-semibold` |
|
|
124
|
+
| `HlmLead` / `hlmLead` | `<p>` | `text-xl text-muted-foreground` |
|
|
125
|
+
| `HlmMuted` / `hlmMuted` | `<p>` | `text-sm text-muted-foreground` |
|
|
126
|
+
| `HlmSmall` / `hlmSmall` | any | `text-sm font-medium leading-none` |
|
|
127
|
+
|
|
128
|
+
User `class` attributes merge (not clobbered) through the shared `classes()` helper.
|
|
129
|
+
|
|
130
|
+
## Examples
|
|
131
|
+
|
|
132
|
+
### 1. Full article page
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
// demo-article.component.ts
|
|
136
|
+
import { Component } from '@angular/core';
|
|
137
|
+
import { HlmTypographyImports } from '@egose/shadcn-theme-ng/typography';
|
|
138
|
+
|
|
139
|
+
@Component({
|
|
140
|
+
selector: 'demo-article',
|
|
141
|
+
standalone: true,
|
|
142
|
+
imports: [...HlmTypographyImports],
|
|
143
|
+
template: `
|
|
144
|
+
<article class="max-w-2xl">
|
|
145
|
+
<h1 hlmH1>Taxing Laughter: The Joke Tax</h1>
|
|
146
|
+
<p hlmLead>Once upon a time, a king decided to tax every joke told in his kingdom.</p>
|
|
147
|
+
<h2 hlmH2>The King's Plan</h2>
|
|
148
|
+
<p hlmP>The king thought long and hard, and finally came up with a brilliant plan.</p>
|
|
149
|
+
<blockquote hlmBlockquote>"After all," he said, "everyone enjoys a good joke, so it's only fair."</blockquote>
|
|
150
|
+
<h3 hlmH3>The Joke Tax</h3>
|
|
151
|
+
<p hlmP>The king's subjects were not amused. They grumbled and complained.</p>
|
|
152
|
+
<ul hlmUl>
|
|
153
|
+
<li>1st level of puns: 5 gold coins</li>
|
|
154
|
+
<li>2nd level of jokes: 10 gold coins</li>
|
|
155
|
+
<li>3rd level of one-liners: 20 gold coins</li>
|
|
156
|
+
</ul>
|
|
157
|
+
</article>
|
|
158
|
+
`,
|
|
159
|
+
})
|
|
160
|
+
export class DemoArticle {}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 2. Headings hierarchy (h1–h4)
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
// demo-headings.component.ts
|
|
167
|
+
import { Component } from '@angular/core';
|
|
168
|
+
import { HlmTypographyImports } from '@egose/shadcn-theme-ng/typography';
|
|
169
|
+
|
|
170
|
+
@Component({
|
|
171
|
+
selector: 'demo-headings',
|
|
172
|
+
standalone: true,
|
|
173
|
+
imports: [...HlmTypographyImports],
|
|
174
|
+
template: `
|
|
175
|
+
<h1 hlmH1>Heading 1 — page title</h1>
|
|
176
|
+
<h2 hlmH2>Heading 2 — section (with bottom border)</h2>
|
|
177
|
+
<h3 hlmH3>Heading 3 — subsection</h3>
|
|
178
|
+
<h4 hlmH4>Heading 4 — detail header</h4>
|
|
179
|
+
`,
|
|
180
|
+
})
|
|
181
|
+
export class DemoHeadings {}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Keep one `<h1>` per page and nest levels without skipping (h1→h2→h3).
|
|
185
|
+
|
|
186
|
+
### 3. Lead, large, muted, small
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
// demo-scale.component.ts
|
|
190
|
+
import { Component } from '@angular/core';
|
|
191
|
+
import { HlmTypographyImports } from '@egose/shadcn-theme-ng/typography';
|
|
192
|
+
|
|
193
|
+
@Component({
|
|
194
|
+
selector: 'demo-scale',
|
|
195
|
+
standalone: true,
|
|
196
|
+
imports: [...HlmTypographyImports],
|
|
197
|
+
template: `
|
|
198
|
+
<p hlmLead>A lead paragraph introduces the page — larger, muted.</p>
|
|
199
|
+
<p hlmP>Body copy with comfortable <code hlmCode>leading-7</code> rhythm.</p>
|
|
200
|
+
<div hlmLarge>Large: callouts, card titles, key figures.</div>
|
|
201
|
+
<p hlmMuted>Muted: timestamps, helper text, captions.</p>
|
|
202
|
+
<span hlmSmall>Small: labels, badges, table meta.</span>
|
|
203
|
+
`,
|
|
204
|
+
})
|
|
205
|
+
export class DemoScale {}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### 4. Inline code + blockquote
|
|
209
|
+
|
|
210
|
+
```html
|
|
211
|
+
<p hlmP>Run <code hlmCode>ng build my-lib</code> to build, then ship the output.</p>
|
|
212
|
+
<blockquote hlmBlockquote>
|
|
213
|
+
"Design is the silent ambassador of your brand." — pair with a <cite>cite</cite> for attribution.
|
|
214
|
+
</blockquote>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### 5. Lists (bulleted + mixed content)
|
|
218
|
+
|
|
219
|
+
```html
|
|
220
|
+
<ul hlmUl>
|
|
221
|
+
<li>Ship one library per component.</li>
|
|
222
|
+
<li>
|
|
223
|
+
Consume via subpath imports:
|
|
224
|
+
<code hlmCode>@egose/shadcn-theme-ng/button</code>
|
|
225
|
+
</li>
|
|
226
|
+
<li>Theme with CSS variables — no forks.</li>
|
|
227
|
+
</ul>
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### 6. Advanced: reusing class constants in custom components
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
// prose.component.ts
|
|
234
|
+
import { Component, input } from '@angular/core';
|
|
235
|
+
import { hlm } from '@egose/shadcn-theme-ng/utils';
|
|
236
|
+
import { hlmH2, hlmP } from '@egose/shadcn-theme-ng/typography';
|
|
237
|
+
|
|
238
|
+
@Component({
|
|
239
|
+
selector: 'app-prose-title',
|
|
240
|
+
standalone: true,
|
|
241
|
+
template: `<h2 [class]="classes()"><ng-content /></h2>`,
|
|
242
|
+
})
|
|
243
|
+
export class ProseTitle {
|
|
244
|
+
readonly tone = input<'default' | 'muted'>('default');
|
|
245
|
+
|
|
246
|
+
protected classes() {
|
|
247
|
+
return hlm(hlmH2, this.tone() === 'muted' && 'text-muted-foreground');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@Component({
|
|
252
|
+
selector: 'app-prose-body',
|
|
253
|
+
standalone: true,
|
|
254
|
+
template: `<p [class]="hlmP"><ng-content /></p>`,
|
|
255
|
+
})
|
|
256
|
+
export class ProseBody {
|
|
257
|
+
protected readonly hlmP = hlmP;
|
|
258
|
+
}
|
|
11
259
|
```
|
|
260
|
+
|
|
261
|
+
## Accessibility notes
|
|
262
|
+
|
|
263
|
+
- Use real heading levels in order (`h1`→`h2`→`h3`); the directives style but never repair skipped levels — screen-reader navigation depends on the elements you choose.
|
|
264
|
+
- `HlmMuted`/`HlmSmall` reduce size/contrast — verify contrast ratios for body text (muted grays can fail on light backgrounds at small sizes).
|
|
265
|
+
- `<blockquote>` should contain the quote; add `<cite>`/attribution outside or within per your style guide.
|
|
266
|
+
- `<code hlmCode>` is inline; for multi-line samples use `<pre><code>` with your own overflow handling and a plaintext alternative when meaning depends on formatting.
|
|
267
|
+
|
|
268
|
+
## Theming / CSS variables
|
|
269
|
+
|
|
270
|
+
Type styles key off `border-border`, `bg-muted`, and `text-muted-foreground` tokens, so they track your shadcn theme automatically. No per-component CSS variables.
|
|
271
|
+
|
|
272
|
+
## Related subpaths
|
|
273
|
+
|
|
274
|
+
- `@egose/shadcn-theme-ng/card` — `CardTitle`/`CardDescription` surfaces that pair with type scale.
|
|
275
|
+
- `@egose/shadcn-theme-ng/table` — tabular content styled alongside prose.
|
|
276
|
+
- `@egose/shadcn-theme-ng/badge` / `@egose/shadcn-theme-ng/kbd` — inline semantics to mix into paragraphs.
|
|
277
|
+
- `@egose/shadcn-theme-ng/utils` — `hlm()` for composing the exported class constants.
|