@egose/shadcn-theme-ng 0.1.0 → 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 +1 -1
- 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/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/collapsible/README.md +332 -5
- package/combobox/README.md +507 -5
- package/combobox/fesm2022/combobox.mjs +4 -1
- 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 +465 -2
- package/date-picker/fesm2022/date-picker.mjs +2 -2
- 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-checkbox/README.md +312 -2
- package/form-date-picker/README.md +322 -2
- package/form-field/README.md +356 -2
- package/form-field-simple/README.md +340 -2
- package/form-searchable-multiselect/README.md +361 -2
- package/form-select/README.md +350 -2
- package/form-text-input/README.md +371 -2
- package/form-textarea/README.md +347 -2
- 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 +3 -3
- 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/navigation-menu/README.md +369 -5
- package/package.json +1 -1
- package/pagination/README.md +388 -5
- 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/radio-group/types/radio-group.d.ts +1 -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/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/typography/types/typography.d.ts +8 -8
- package/utils/README.md +303 -2
package/aspect-ratio/README.md
CHANGED
|
@@ -1,11 +1,278 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Aspect Ratio (`@egose/shadcn-theme-ng/aspect-ratio`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A layout helper in the shadcn/ui Aspect Ratio style: it forces a box to keep a fixed
|
|
4
|
+
width-to-height proportion (16:9 video embeds, square thumbnails, 4:3 cards) regardless of the
|
|
5
|
+
viewport. Content placed inside simply fills the ratio-locked frame.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
This is a **standalone utility directive with no brain primitive**. `HlmAspectRatio` writes the
|
|
8
|
+
numeric ratio to a `--ratio` CSS custom property and applies the `aspect-(--ratio)` Tailwind class;
|
|
9
|
+
it accepts plain numbers, coercible values, or `"W/H"` strings such as `"16/9"`.
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
> **Ships as:** `@egose/shadcn-theme-ng/aspect-ratio` and `@egose/shadcn-theme-ng-tw/aspect-ratio`
|
|
12
|
+
> (the `tw:`-prefixed Tailwind variant). Both expose the identical TypeScript surface; only the
|
|
13
|
+
> emitted Tailwind class strings differ. See the [package README](../../README.md) for install
|
|
14
|
+
> steps, peer dependencies, and Tailwind setup. Do not publish this project directory independently.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
8
17
|
|
|
9
18
|
```bash
|
|
10
|
-
|
|
19
|
+
# Plain Tailwind (no prefix)
|
|
20
|
+
npm install @egose/shadcn-theme-ng
|
|
21
|
+
|
|
22
|
+
# tw:-prefixed Tailwind variant
|
|
23
|
+
npm install @egose/shadcn-theme-ng-tw
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Peer dependencies (Angular core/common) are documented in the
|
|
27
|
+
[package README](../../README.md#peer-dependencies). Runtime styling helper:
|
|
28
|
+
`@egose/shadcn-theme-ng/utils` (`classes()`).
|
|
29
|
+
|
|
30
|
+
## Imports
|
|
31
|
+
|
|
32
|
+
All symbols are exported from the subpath root (`projects/aspect-ratio/src/public-api.ts`):
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { HlmAspectRatio, HlmAspectRatioImports, HlmAspectRatioModule } from '@egose/shadcn-theme-ng/aspect-ratio';
|
|
36
|
+
// tw variant: replace with '@egose/shadcn-theme-ng-tw/aspect-ratio'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Standalone component — spread the `*Imports` array (single entry):
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { Component } from '@angular/core';
|
|
43
|
+
import { HlmAspectRatioImports } from '@egose/shadcn-theme-ng/aspect-ratio';
|
|
44
|
+
|
|
45
|
+
@Component({
|
|
46
|
+
selector: 'app-demo',
|
|
47
|
+
standalone: true,
|
|
48
|
+
imports: [...HlmAspectRatioImports],
|
|
49
|
+
template: `...`,
|
|
50
|
+
})
|
|
51
|
+
export class DemoComponent {}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
NgModule-based consumer — import the module:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { NgModule } from '@angular/core';
|
|
58
|
+
import { HlmAspectRatioModule } from '@egose/shadcn-theme-ng/aspect-ratio';
|
|
59
|
+
|
|
60
|
+
@NgModule({ imports: [HlmAspectRatioModule] })
|
|
61
|
+
export class DemoModule {}
|
|
11
62
|
```
|
|
63
|
+
|
|
64
|
+
You can also import `HlmAspectRatio` itself directly — it is a standalone directive.
|
|
65
|
+
|
|
66
|
+
## Anatomy / Structure
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<div [hlmAspectRatio]="16 / 9">
|
|
70
|
+
<img src="hero.jpg" alt="Hero" class="tw:h-full tw:w-full tw:object-cover tw:rounded-md" />
|
|
71
|
+
</div>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Real selector (from source):
|
|
75
|
+
|
|
76
|
+
| Class | Selector | Kind |
|
|
77
|
+
| ---------------- | ------------------ | --------- |
|
|
78
|
+
| `HlmAspectRatio` | `[hlmAspectRatio]` | Directive |
|
|
79
|
+
|
|
80
|
+
The host gets `data-slot="aspect-ratio"`, `[style.--ratio]` bound to the coerced value, and the
|
|
81
|
+
`tw:relative tw:aspect-(--ratio)` classes. Anything projected inside lays out against that frame.
|
|
82
|
+
|
|
83
|
+
## API reference
|
|
84
|
+
|
|
85
|
+
### `HlmAspectRatio` — `[hlmAspectRatio]`
|
|
86
|
+
|
|
87
|
+
| Input | Type | Default | Description |
|
|
88
|
+
| --------------------------------------- | ----------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
89
|
+
| `hlmAspectRatio` (aliased as `ratio()`) | `number \| NumberInput` | `1` | Width ÷ height. Accepts numbers (`1.777`), numeric strings (`"1.5"`), or `"W/H"` strings (`"16/9"`, `"4/3"`, `"1/1"`). Values that coerce to `≤ 0` (or `NaN`) fall back to `1`. |
|
|
90
|
+
|
|
91
|
+
Coercion details (read from source): `"W/H"` strings are split on `/`, each side parsed with
|
|
92
|
+
`parseInt`, then divided; the result passes through `coerceNumberProperty` from
|
|
93
|
+
`@angular/cdk/coercion`. So `[hlmAspectRatio]="'16/9'"` ⇒ `16 / 9 ≈ 1.778`.
|
|
94
|
+
|
|
95
|
+
No outputs, no methods — purely presentational.
|
|
96
|
+
|
|
97
|
+
## Examples
|
|
98
|
+
|
|
99
|
+
### 1. Basic 16:9 embed
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { Component } from '@angular/core';
|
|
103
|
+
import { HlmAspectRatioImports } from '@egose/shadcn-theme-ng/aspect-ratio';
|
|
104
|
+
|
|
105
|
+
@Component({
|
|
106
|
+
selector: 'app-ratio-basic',
|
|
107
|
+
standalone: true,
|
|
108
|
+
imports: [...HlmAspectRatioImports],
|
|
109
|
+
template: `
|
|
110
|
+
<div [hlmAspectRatio]="16 / 9" class="tw:overflow-hidden tw:rounded-md tw:bg-muted">
|
|
111
|
+
<img src="https://picsum.photos/800/450" alt="Landscape" class="tw:h-full tw:w-full tw:object-cover" />
|
|
112
|
+
</div>
|
|
113
|
+
`,
|
|
114
|
+
})
|
|
115
|
+
export class RatioBasicComponent {}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```html
|
|
119
|
+
<app-ratio-basic />
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 2. String ratios: square, portrait, cinematic
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import { Component } from '@angular/core';
|
|
126
|
+
import { HlmAspectRatioImports } from '@egose/shadcn-theme-ng/aspect-ratio';
|
|
127
|
+
|
|
128
|
+
@Component({
|
|
129
|
+
selector: 'app-ratio-strings',
|
|
130
|
+
standalone: true,
|
|
131
|
+
imports: [...HlmAspectRatioImports],
|
|
132
|
+
template: `
|
|
133
|
+
<div class="tw:grid tw:grid-cols-3 tw:gap-4">
|
|
134
|
+
<div hlmAspectRatio="1/1" class="tw:overflow-hidden tw:rounded-md tw:bg-muted">
|
|
135
|
+
<img src="https://picsum.photos/400/400" alt="Square" class="tw:h-full tw:w-full tw:object-cover" />
|
|
136
|
+
</div>
|
|
137
|
+
<div hlmAspectRatio="3/4" class="tw:overflow-hidden tw:rounded-md tw:bg-muted">
|
|
138
|
+
<img src="https://picsum.photos/300/400" alt="Portrait" class="tw:h-full tw:w-full tw:object-cover" />
|
|
139
|
+
</div>
|
|
140
|
+
<div hlmAspectRatio="21/9" class="tw:overflow-hidden tw:rounded-md tw:bg-muted">
|
|
141
|
+
<img src="https://picsum.photos/630/270" alt="Cinematic" class="tw:h-full tw:w-full tw:object-cover" />
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
`,
|
|
145
|
+
})
|
|
146
|
+
export class RatioStringsComponent {}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 3. Video / iframe embed
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import { Component } from '@angular/core';
|
|
153
|
+
import { HlmAspectRatioImports } from '@egose/shadcn-theme-ng/aspect-ratio';
|
|
154
|
+
|
|
155
|
+
@Component({
|
|
156
|
+
selector: 'app-ratio-video',
|
|
157
|
+
standalone: true,
|
|
158
|
+
imports: [...HlmAspectRatioImports],
|
|
159
|
+
template: `
|
|
160
|
+
<div [hlmAspectRatio]="16 / 9" class="tw:overflow-hidden tw:rounded-lg tw:border">
|
|
161
|
+
<iframe
|
|
162
|
+
class="tw:absolute tw:inset-0 tw:h-full tw:w-full"
|
|
163
|
+
src="https://www.youtube.com/embed/dQw4w9WgXcQ"
|
|
164
|
+
title="Product tour"
|
|
165
|
+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
166
|
+
allowfullscreen
|
|
167
|
+
></iframe>
|
|
168
|
+
</div>
|
|
169
|
+
`,
|
|
170
|
+
})
|
|
171
|
+
export class RatioVideoComponent {}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
(The host is `relative`, so absolute-positioned media pins to the frame.)
|
|
175
|
+
|
|
176
|
+
### 4. Dynamic ratio from a signal (user-selectable)
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
import { Component, signal } from '@angular/core';
|
|
180
|
+
import { HlmAspectRatioImports } from '@egose/shadcn-theme-ng/aspect-ratio';
|
|
181
|
+
|
|
182
|
+
@Component({
|
|
183
|
+
selector: 'app-ratio-dynamic',
|
|
184
|
+
standalone: true,
|
|
185
|
+
imports: [...HlmAspectRatioImports],
|
|
186
|
+
template: `
|
|
187
|
+
<div class="tw:mb-3 tw:flex tw:gap-2">
|
|
188
|
+
@for (preset of presets; track preset.label) {
|
|
189
|
+
<button (click)="ratio.set(preset.value)" [disabled]="ratio() === preset.value">
|
|
190
|
+
{{ preset.label }}
|
|
191
|
+
</button>
|
|
192
|
+
}
|
|
193
|
+
</div>
|
|
194
|
+
<div [hlmAspectRatio]="ratio()" class="tw:overflow-hidden tw:rounded-md tw:bg-muted">
|
|
195
|
+
<img src="https://picsum.photos/800/600" alt="Preview" class="tw:h-full tw:w-full tw:object-cover" />
|
|
196
|
+
</div>
|
|
197
|
+
`,
|
|
198
|
+
})
|
|
199
|
+
export class RatioDynamicComponent {
|
|
200
|
+
readonly presets = [
|
|
201
|
+
{ label: 'Square', value: 1 },
|
|
202
|
+
{ label: '16:9', value: 16 / 9 },
|
|
203
|
+
{ label: '4:3', value: 4 / 3 },
|
|
204
|
+
];
|
|
205
|
+
readonly ratio = signal<number>(16 / 9);
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### 5. Card media header with overlay content
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
import { Component } from '@angular/core';
|
|
213
|
+
import { HlmAspectRatioImports } from '@egose/shadcn-theme-ng/aspect-ratio';
|
|
214
|
+
import { HlmBadge } from '@egose/shadcn-theme-ng/badge';
|
|
215
|
+
|
|
216
|
+
@Component({
|
|
217
|
+
selector: 'app-ratio-card',
|
|
218
|
+
standalone: true,
|
|
219
|
+
imports: [...HlmAspectRatioImports, HlmBadge],
|
|
220
|
+
template: `
|
|
221
|
+
<article class="tw:overflow-hidden tw:rounded-lg tw:border">
|
|
222
|
+
<div hlmAspectRatio="16/9" class="tw:bg-muted">
|
|
223
|
+
<img src="https://picsum.photos/640/360" alt="Post cover" class="tw:h-full tw:w-full tw:object-cover" />
|
|
224
|
+
<span hlmBadge class="tw:absolute tw:top-2 tw:left-2">New</span>
|
|
225
|
+
</div>
|
|
226
|
+
<div class="tw:p-4">
|
|
227
|
+
<h3 class="tw:font-semibold">Ratio-locked covers</h3>
|
|
228
|
+
<p class="tw:text-sm tw:text-muted-foreground">Every card image lines up, whatever the source size.</p>
|
|
229
|
+
</div>
|
|
230
|
+
</article>
|
|
231
|
+
`,
|
|
232
|
+
})
|
|
233
|
+
export class RatioCardComponent {}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### 6. Invalid values fall back to square
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
import { Component } from '@angular/core';
|
|
240
|
+
import { HlmAspectRatioImports } from '@egose/shadcn-theme-ng/aspect-ratio';
|
|
241
|
+
|
|
242
|
+
@Component({
|
|
243
|
+
selector: 'app-ratio-fallback',
|
|
244
|
+
standalone: true,
|
|
245
|
+
imports: [...HlmAspectRatioImports],
|
|
246
|
+
template: `
|
|
247
|
+
<!-- 0, negatives, and NaN coerce to ratio 1 (square) instead of breaking layout -->
|
|
248
|
+
<div [hlmAspectRatio]="userValue" class="tw:bg-muted tw:rounded-md">
|
|
249
|
+
<p class="tw:p-4 tw:text-sm">ratio input: {{ userValue }} → renders square</p>
|
|
250
|
+
</div>
|
|
251
|
+
`,
|
|
252
|
+
})
|
|
253
|
+
export class RatioFallbackComponent {
|
|
254
|
+
userValue = 0; // try -2, Number.NaN, or a valid number
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Accessibility notes
|
|
259
|
+
|
|
260
|
+
- The directive adds no semantics (`data-slot` only) — the _content_ carries meaning. Always give
|
|
261
|
+
images real `alt` text and iframes a `title`.
|
|
262
|
+
- Do not use aspect-ratio boxes as click targets by themselves; put a real `<button>` or `<a>`
|
|
263
|
+
inside or around them so keyboard users get a focusable control.
|
|
264
|
+
- Avoid extreme ratios for text content (e.g. `21/9` with paragraphs) — zoomed text can overflow
|
|
265
|
+
the locked frame. Prefer images/video, or allow the frame to grow with `min-h` utilities.
|
|
266
|
+
|
|
267
|
+
## Theming / CSS variables
|
|
268
|
+
|
|
269
|
+
The directive sets one custom property on its host: `--ratio` (unitless number). The frame size
|
|
270
|
+
comes from the `aspect-(--ratio)` utility reading that property. You can read or override
|
|
271
|
+
`--ratio` in your own CSS if you need derived sizing (e.g. `height: calc(100vw / var(--ratio))`).
|
|
272
|
+
|
|
273
|
+
## Related subpaths
|
|
274
|
+
|
|
275
|
+
- `@egose/shadcn-theme-ng/avatar` — fixed-size ratio-locked identity images
|
|
276
|
+
- `@egose/shadcn-theme-ng/card` — cards whose media headers use ratio frames
|
|
277
|
+
- `@egose/shadcn-theme-ng/carousel` — slides with consistent media proportions
|
|
278
|
+
- `@egose/shadcn-theme-ng/skeleton` — ratio-shaped loading placeholders
|