@dashforge/tw 0.1.0-beta → 0.2.0-beta
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/CHANGELOG.md +108 -0
- package/dist/index.d.ts +1 -82
- package/dist/index.esm.js +1563 -2
- package/dist/src/components/AspectRatio/AspectRatio.d.ts +36 -0
- package/dist/src/components/AspectRatio/AspectRatio.d.ts.map +1 -0
- package/dist/src/components/AspectRatio/aspectRatio.types.d.ts +50 -0
- package/dist/src/components/AspectRatio/aspectRatio.types.d.ts.map +1 -0
- package/dist/src/components/Box/Box.d.ts +36 -0
- package/dist/src/components/Box/Box.d.ts.map +1 -0
- package/dist/src/components/Box/box.types.d.ts +54 -0
- package/dist/src/components/Box/box.types.d.ts.map +1 -0
- package/dist/src/components/Box/box.variants.d.ts +402 -0
- package/dist/src/components/Box/box.variants.d.ts.map +1 -0
- package/dist/src/components/Container/Container.d.ts +35 -0
- package/dist/src/components/Container/Container.d.ts.map +1 -0
- package/dist/src/components/Container/container.types.d.ts +41 -0
- package/dist/src/components/Container/container.types.d.ts.map +1 -0
- package/dist/src/components/Container/container.variants.d.ts +93 -0
- package/dist/src/components/Container/container.variants.d.ts.map +1 -0
- package/dist/src/components/Divider/Divider.d.ts +50 -0
- package/dist/src/components/Divider/Divider.d.ts.map +1 -0
- package/dist/src/components/Divider/divider.types.d.ts +47 -0
- package/dist/src/components/Divider/divider.types.d.ts.map +1 -0
- package/dist/src/components/Divider/divider.variants.d.ts +129 -0
- package/dist/src/components/Divider/divider.variants.d.ts.map +1 -0
- package/dist/src/components/Grid/Grid.d.ts +32 -0
- package/dist/src/components/Grid/Grid.d.ts.map +1 -0
- package/dist/src/components/Grid/grid.types.d.ts +103 -0
- package/dist/src/components/Grid/grid.types.d.ts.map +1 -0
- package/dist/src/components/Grid/grid.variants.d.ts +453 -0
- package/dist/src/components/Grid/grid.variants.d.ts.map +1 -0
- package/dist/src/components/Stack/Stack.d.ts +24 -0
- package/dist/src/components/Stack/Stack.d.ts.map +1 -0
- package/dist/src/components/Stack/stack.types.d.ts +61 -0
- package/dist/src/components/Stack/stack.types.d.ts.map +1 -0
- package/dist/src/components/Stack/stack.variants.d.ts +163 -0
- package/dist/src/components/Stack/stack.variants.d.ts.map +1 -0
- package/dist/src/components/Typography/Typography.d.ts +42 -0
- package/dist/src/components/Typography/Typography.d.ts.map +1 -0
- package/dist/src/components/Typography/typography.types.d.ts +61 -0
- package/dist/src/components/Typography/typography.types.d.ts.map +1 -0
- package/dist/src/components/Typography/typography.variants.d.ts +167 -0
- package/dist/src/components/Typography/typography.variants.d.ts.map +1 -0
- package/dist/src/components/VisuallyHidden/VisuallyHidden.d.ts +42 -0
- package/dist/src/components/VisuallyHidden/VisuallyHidden.d.ts.map +1 -0
- package/dist/src/components/VisuallyHidden/visuallyHidden.types.d.ts +42 -0
- package/dist/src/components/VisuallyHidden/visuallyHidden.types.d.ts.map +1 -0
- package/dist/src/index.d.ts +22 -0
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/AspectRatio/AspectRatio.test.tsx +173 -0
- package/src/components/AspectRatio/AspectRatio.tsx +73 -0
- package/src/components/AspectRatio/aspectRatio.types.ts +54 -0
- package/src/components/Box/Box.test.tsx +349 -0
- package/src/components/Box/Box.tsx +83 -0
- package/src/components/Box/box.types.ts +61 -0
- package/src/components/Box/box.variants.ts +211 -0
- package/src/components/Container/Container.test.tsx +209 -0
- package/src/components/Container/Container.tsx +74 -0
- package/src/components/Container/container.types.ts +45 -0
- package/src/components/Container/container.variants.ts +81 -0
- package/src/components/Divider/Divider.test.tsx +241 -0
- package/src/components/Divider/Divider.tsx +140 -0
- package/src/components/Divider/divider.types.ts +52 -0
- package/src/components/Divider/divider.variants.ts +115 -0
- package/src/components/Grid/Grid.test.tsx +321 -0
- package/src/components/Grid/Grid.tsx +148 -0
- package/src/components/Grid/grid.types.ts +112 -0
- package/src/components/Grid/grid.variants.ts +133 -0
- package/src/components/Stack/Stack.test.tsx +309 -0
- package/src/components/Stack/Stack.tsx +115 -0
- package/src/components/Stack/stack.types.ts +68 -0
- package/src/components/Stack/stack.variants.ts +80 -0
- package/src/components/Typography/Typography.test.tsx +230 -0
- package/src/components/Typography/Typography.tsx +112 -0
- package/src/components/Typography/typography.types.ts +65 -0
- package/src/components/Typography/typography.variants.ts +113 -0
- package/src/components/VisuallyHidden/VisuallyHidden.test.tsx +86 -0
- package/src/components/VisuallyHidden/VisuallyHidden.tsx +59 -0
- package/src/components/VisuallyHidden/visuallyHidden.types.ts +45 -0
- package/src/index.ts +49 -0
- package/dist/components/AppShell/AppShell.d.ts +0 -32
- package/dist/components/AppShell/AppShell.d.ts.map +0 -1
- package/dist/components/AppShell/appShell.types.d.ts +0 -62
- package/dist/components/AppShell/appShell.types.d.ts.map +0 -1
- package/dist/components/AppShell/appShell.variants.d.ts +0 -65
- package/dist/components/AppShell/appShell.variants.d.ts.map +0 -1
- package/dist/components/Autocomplete/Autocomplete.d.ts +0 -32
- package/dist/components/Autocomplete/Autocomplete.d.ts.map +0 -1
- package/dist/components/Autocomplete/autocomplete.types.d.ts +0 -214
- package/dist/components/Autocomplete/autocomplete.types.d.ts.map +0 -1
- package/dist/components/Autocomplete/autocomplete.variants.d.ts +0 -214
- package/dist/components/Autocomplete/autocomplete.variants.d.ts.map +0 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +0 -23
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts.map +0 -1
- package/dist/components/Breadcrumbs/breadcrumbs.types.d.ts +0 -98
- package/dist/components/Breadcrumbs/breadcrumbs.types.d.ts.map +0 -1
- package/dist/components/Breadcrumbs/breadcrumbs.variants.d.ts +0 -85
- package/dist/components/Breadcrumbs/breadcrumbs.variants.d.ts.map +0 -1
- package/dist/components/Button/Button.d.ts +0 -44
- package/dist/components/Button/Button.d.ts.map +0 -1
- package/dist/components/Button/button.types.d.ts +0 -66
- package/dist/components/Button/button.types.d.ts.map +0 -1
- package/dist/components/Button/button.variants.d.ts +0 -104
- package/dist/components/Button/button.variants.d.ts.map +0 -1
- package/dist/components/Checkbox/Checkbox.d.ts +0 -31
- package/dist/components/Checkbox/Checkbox.d.ts.map +0 -1
- package/dist/components/Checkbox/checkbox.types.d.ts +0 -86
- package/dist/components/Checkbox/checkbox.types.d.ts.map +0 -1
- package/dist/components/Checkbox/checkbox.variants.d.ts +0 -109
- package/dist/components/Checkbox/checkbox.variants.d.ts.map +0 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +0 -38
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts.map +0 -1
- package/dist/components/ConfirmDialog/confirmDialog.types.d.ts +0 -80
- package/dist/components/ConfirmDialog/confirmDialog.types.d.ts.map +0 -1
- package/dist/components/ConfirmDialog/confirmDialog.variants.d.ts +0 -90
- package/dist/components/ConfirmDialog/confirmDialog.variants.d.ts.map +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +0 -49
- package/dist/components/DateTimePicker/DateTimePicker.d.ts.map +0 -1
- package/dist/components/DateTimePicker/dateTimePicker.types.d.ts +0 -95
- package/dist/components/DateTimePicker/dateTimePicker.types.d.ts.map +0 -1
- package/dist/components/DateTimePicker/dateTimePicker.variants.d.ts +0 -165
- package/dist/components/DateTimePicker/dateTimePicker.variants.d.ts.map +0 -1
- package/dist/components/LeftNav/LeftNav.d.ts +0 -34
- package/dist/components/LeftNav/LeftNav.d.ts.map +0 -1
- package/dist/components/LeftNav/leftNav.types.d.ts +0 -136
- package/dist/components/LeftNav/leftNav.types.d.ts.map +0 -1
- package/dist/components/LeftNav/leftNav.variants.d.ts +0 -143
- package/dist/components/LeftNav/leftNav.variants.d.ts.map +0 -1
- package/dist/components/NumberField/NumberField.d.ts +0 -18
- package/dist/components/NumberField/NumberField.d.ts.map +0 -1
- package/dist/components/NumberField/numberField.types.d.ts +0 -79
- package/dist/components/NumberField/numberField.types.d.ts.map +0 -1
- package/dist/components/NumberField/numberField.variants.d.ts +0 -169
- package/dist/components/NumberField/numberField.variants.d.ts.map +0 -1
- package/dist/components/OTPField/OTPField.d.ts +0 -25
- package/dist/components/OTPField/OTPField.d.ts.map +0 -1
- package/dist/components/OTPField/otpField.types.d.ts +0 -74
- package/dist/components/OTPField/otpField.types.d.ts.map +0 -1
- package/dist/components/OTPField/otpField.variants.d.ts +0 -105
- package/dist/components/OTPField/otpField.variants.d.ts.map +0 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +0 -35
- package/dist/components/RadioGroup/RadioGroup.d.ts.map +0 -1
- package/dist/components/RadioGroup/radioGroup.types.d.ts +0 -103
- package/dist/components/RadioGroup/radioGroup.types.d.ts.map +0 -1
- package/dist/components/RadioGroup/radioGroup.variants.d.ts +0 -166
- package/dist/components/RadioGroup/radioGroup.variants.d.ts.map +0 -1
- package/dist/components/Snackbar/Snackbar.d.ts +0 -37
- package/dist/components/Snackbar/Snackbar.d.ts.map +0 -1
- package/dist/components/Snackbar/snackbar.types.d.ts +0 -86
- package/dist/components/Snackbar/snackbar.types.d.ts.map +0 -1
- package/dist/components/Snackbar/snackbar.variants.d.ts +0 -153
- package/dist/components/Snackbar/snackbar.variants.d.ts.map +0 -1
- package/dist/components/Switch/Switch.d.ts +0 -15
- package/dist/components/Switch/Switch.d.ts.map +0 -1
- package/dist/components/Switch/switch.types.d.ts +0 -47
- package/dist/components/Switch/switch.types.d.ts.map +0 -1
- package/dist/components/Switch/switch.variants.d.ts +0 -105
- package/dist/components/Switch/switch.variants.d.ts.map +0 -1
- package/dist/components/TextField/TextField.d.ts +0 -25
- package/dist/components/TextField/TextField.d.ts.map +0 -1
- package/dist/components/TextField/textField.types.d.ts +0 -72
- package/dist/components/TextField/textField.types.d.ts.map +0 -1
- package/dist/components/TextField/textField.variants.d.ts +0 -160
- package/dist/components/TextField/textField.variants.d.ts.map +0 -1
- package/dist/components/Textarea/Textarea.d.ts +0 -16
- package/dist/components/Textarea/Textarea.d.ts.map +0 -1
- package/dist/components/Textarea/textarea.types.d.ts +0 -63
- package/dist/components/Textarea/textarea.types.d.ts.map +0 -1
- package/dist/components/Textarea/textarea.variants.d.ts +0 -197
- package/dist/components/Textarea/textarea.variants.d.ts.map +0 -1
- package/dist/components/TopBar/TopBar.d.ts +0 -33
- package/dist/components/TopBar/TopBar.d.ts.map +0 -1
- package/dist/components/TopBar/topBar.types.d.ts +0 -49
- package/dist/components/TopBar/topBar.types.d.ts.map +0 -1
- package/dist/components/TopBar/topBar.variants.d.ts +0 -79
- package/dist/components/TopBar/topBar.variants.d.ts.map +0 -1
- package/dist/components/_shared/resolveValidationState.d.ts +0 -42
- package/dist/components/_shared/resolveValidationState.d.ts.map +0 -1
- package/dist/hooks/useAccessState.d.ts +0 -37
- package/dist/hooks/useAccessState.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/tsconfig.lib.tsbuildinfo +0 -1
- package/dist/utils/cn.d.ts +0 -26
- package/dist/utils/cn.d.ts.map +0 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { TypographyProps } from './typography.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* `<Typography>` — semantic typed text, the foundation of every readable
|
|
4
|
+
* surface in @dashforge/tw.
|
|
5
|
+
*
|
|
6
|
+
* Why this exists:
|
|
7
|
+
* Tailwind ships a typographic scale (`text-xl`, `font-bold`,
|
|
8
|
+
* `leading-relaxed`) but leaves the SEMANTIC HTML tag and the
|
|
9
|
+
* intent-coloured palette to the consumer. That's fine for one-off
|
|
10
|
+
* marketing surfaces, but at app scale it means every `<h2>` and every
|
|
11
|
+
* body paragraph re-derives its own utility chain — and they drift.
|
|
12
|
+
*
|
|
13
|
+
* Typography moves that decision into a typed prop set: the visual
|
|
14
|
+
* scale, the intent colour, the alignment, the truncation all live in
|
|
15
|
+
* `tailwind-variants` and resolve to the same utility chain everywhere
|
|
16
|
+
* in the app. The default HTML tag is inferred from `variant` so the
|
|
17
|
+
* semantic layer follows the visual layer; `as` and `asChild` are the
|
|
18
|
+
* two escape hatches when you need something else.
|
|
19
|
+
*
|
|
20
|
+
* Layering:
|
|
21
|
+
* • Sits BENEATH every component that renders text — `<Button>`'s
|
|
22
|
+
* label, `<TextField>`'s helper text, MDX prose in our own docs.
|
|
23
|
+
* • Composes ON TOP of `@dashforge/tw-tokens` colour scales (so
|
|
24
|
+
* `color="primary"` paints `text-primary-700` in light, `-400` in dark,
|
|
25
|
+
* reactive to `setMode()`).
|
|
26
|
+
* • Polymorphic via Radix Slot — pairs cleanly with router `<Link>`,
|
|
27
|
+
* `<button>`, or `<a>` without injecting an extra wrapper element.
|
|
28
|
+
*
|
|
29
|
+
* Polymorphism rules — `as` vs `asChild`:
|
|
30
|
+
* • `as` swaps the rendered tag (we still render the element ourselves).
|
|
31
|
+
* • `asChild` removes our element entirely — the single React child
|
|
32
|
+
* becomes the rendered tag, with our className/ref merged onto it.
|
|
33
|
+
* This is the Radix Slot pattern; use when you need a router Link
|
|
34
|
+
* to style as a heading.
|
|
35
|
+
* When BOTH are passed, `asChild` wins. We considered making this a
|
|
36
|
+
* compile-time error via discriminated unions, but the API surface
|
|
37
|
+
* already has 8 axes and adding one more dimension to the props type
|
|
38
|
+
* would inflate IntelliSense suggestions for marginal benefit. The
|
|
39
|
+
* runtime preference is documented; the test asserts it.
|
|
40
|
+
*/
|
|
41
|
+
export declare const Typography: import("react").ForwardRefExoticComponent<TypographyProps & import("react").RefAttributes<HTMLElement>>;
|
|
42
|
+
//# sourceMappingURL=Typography.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Typography.d.ts","sourceRoot":"","sources":["../../../../src/components/Typography/Typography.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA0B7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,UAAU,yGAwCtB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ElementType, HTMLAttributes } from 'react';
|
|
2
|
+
import type { TypographyVariants } from './typography.variants.js';
|
|
3
|
+
/**
|
|
4
|
+
* Props for `<Typography>`.
|
|
5
|
+
*
|
|
6
|
+
* Composition with native `HTMLAttributes`:
|
|
7
|
+
* • `className` is omitted in favour of `sx` (string of utility classes)
|
|
8
|
+
* — same convention as Button/TextField/Checkbox/Switch in this
|
|
9
|
+
* package. `sx` is merged via `tailwind-merge`, so the consumer's
|
|
10
|
+
* classes always win over variant defaults.
|
|
11
|
+
* • `color` is omitted because the native HTML attribute (the
|
|
12
|
+
* deprecated `color="red"` from HTML4) collides with our intent
|
|
13
|
+
* prop — TypeScript would otherwise widen to a confusing union.
|
|
14
|
+
*
|
|
15
|
+
* Variant axes picked from `TypographyVariants`:
|
|
16
|
+
* • `variant` — the type scale (h1–h6, subtitle1/2, body1/2, caption, overline)
|
|
17
|
+
* • `color` — the intent (primary, secondary, success, warning, danger, info, neutral, muted, inherit)
|
|
18
|
+
* • `weight` — overrides the variant's default font-weight
|
|
19
|
+
* • `align` — text-align
|
|
20
|
+
* • `truncate` — one-line ellipsis
|
|
21
|
+
* • `noWrap` — one-line without ellipsis
|
|
22
|
+
* • `gutterBottom` — adds mb-3 (mirror of MUI's same prop)
|
|
23
|
+
*
|
|
24
|
+
* Polymorphism:
|
|
25
|
+
* • `as` — override the HTML tag while keeping the variant's visual
|
|
26
|
+
* style (e.g. `<Typography variant="h1" as="h2">` renders an
|
|
27
|
+
* `<h2>` styled like h1 — useful when the semantic heading
|
|
28
|
+
* level matters more than the type scale).
|
|
29
|
+
* • `asChild` — render as the single child element via Radix Slot
|
|
30
|
+
* (so the styles paint onto a `<Link>`, `<a>`, etc.).
|
|
31
|
+
* Mutually exclusive with `as` — see component header for
|
|
32
|
+
* the rationale.
|
|
33
|
+
*/
|
|
34
|
+
export interface TypographyProps extends Omit<HTMLAttributes<HTMLElement>, 'className' | 'color'>, Pick<TypographyVariants, 'variant' | 'color' | 'weight' | 'align' | 'truncate' | 'noWrap' | 'gutterBottom'> {
|
|
35
|
+
/**
|
|
36
|
+
* Override the HTML tag. Defaults to a sensible mapping per variant
|
|
37
|
+
* (h1→h1, …, body1→p, caption→span, overline→span). Use when the
|
|
38
|
+
* semantic heading level should differ from the visual scale —
|
|
39
|
+
* e.g. a "hero" rendered as an `<h2>` but styled like `h1`.
|
|
40
|
+
*
|
|
41
|
+
* Ignored when `asChild` is true.
|
|
42
|
+
*/
|
|
43
|
+
as?: ElementType;
|
|
44
|
+
/**
|
|
45
|
+
* Render via Radix `Slot` — the Typography styles paint onto the
|
|
46
|
+
* single React child instead of wrapping it in our own tag. Useful
|
|
47
|
+
* for `<Typography asChild><Link>...</Link></Typography>` to get a
|
|
48
|
+
* styled router link with no extra DOM.
|
|
49
|
+
*
|
|
50
|
+
* Mutually exclusive with `as` (when both are passed, `asChild` wins
|
|
51
|
+
* and `as` is ignored — see Typography.tsx for the reason).
|
|
52
|
+
*/
|
|
53
|
+
asChild?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Utility classes appended to the variant chain. Resolved via
|
|
56
|
+
* `tailwind-merge` so the consumer's classes always win over the
|
|
57
|
+
* variant defaults — e.g. `sx="text-pink-500"` overrides `color="primary"`.
|
|
58
|
+
*/
|
|
59
|
+
sx?: string;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=typography.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typography.types.d.ts","sourceRoot":"","sources":["../../../../src/components/Typography/typography.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,EACxD,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,cAAc,CAAC;IACnH;;;;;;;OAOG;IACH,EAAE,CAAC,EAAE,WAAW,CAAC;IAEjB;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
/**
|
|
3
|
+
* `typographyVariants` — the full type scale for the @dashforge/tw library.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the MUI Typography variant set (h1–h6 · subtitle1/2 · body1/2 ·
|
|
6
|
+
* caption · overline) so the mental model carries over for developers
|
|
7
|
+
* moving between the two ecosystems. Each variant baseline maps to a
|
|
8
|
+
* Tailwind utility chain that resolves through the @dashforge/tw-tokens
|
|
9
|
+
* scale (so the visual stays in sync with the rest of the system when the
|
|
10
|
+
* token theme is patched).
|
|
11
|
+
*
|
|
12
|
+
* Variant axes are intentionally ORTHOGONAL — `variant` chooses the type
|
|
13
|
+
* scale, `weight` overrides the variant's default weight (useful for "h2
|
|
14
|
+
* but lighter"), `color` picks the intent, `align` picks the axis. They
|
|
15
|
+
* never collide, so consumers can mix them freely.
|
|
16
|
+
*
|
|
17
|
+
* Two boolean flags (`truncate`, `noWrap`) encode the most common one-line
|
|
18
|
+
* patterns; `gutterBottom` adds the conventional bottom margin used when a
|
|
19
|
+
* heading precedes a paragraph block (mirror of MUI's same flag).
|
|
20
|
+
*/
|
|
21
|
+
export declare const typographyVariants: import("tailwind-variants").TVReturnType<{
|
|
22
|
+
variant: {
|
|
23
|
+
h1: string;
|
|
24
|
+
h2: string;
|
|
25
|
+
h3: string;
|
|
26
|
+
h4: string;
|
|
27
|
+
h5: string;
|
|
28
|
+
h6: string;
|
|
29
|
+
subtitle1: string;
|
|
30
|
+
subtitle2: string;
|
|
31
|
+
body1: string;
|
|
32
|
+
body2: string;
|
|
33
|
+
caption: string;
|
|
34
|
+
overline: string;
|
|
35
|
+
};
|
|
36
|
+
color: {
|
|
37
|
+
inherit: string;
|
|
38
|
+
primary: string;
|
|
39
|
+
secondary: string;
|
|
40
|
+
success: string;
|
|
41
|
+
warning: string;
|
|
42
|
+
danger: string;
|
|
43
|
+
info: string;
|
|
44
|
+
neutral: string;
|
|
45
|
+
muted: string;
|
|
46
|
+
};
|
|
47
|
+
weight: {
|
|
48
|
+
normal: string;
|
|
49
|
+
medium: string;
|
|
50
|
+
semibold: string;
|
|
51
|
+
bold: string;
|
|
52
|
+
extrabold: string;
|
|
53
|
+
};
|
|
54
|
+
align: {
|
|
55
|
+
left: string;
|
|
56
|
+
center: string;
|
|
57
|
+
right: string;
|
|
58
|
+
justify: string;
|
|
59
|
+
};
|
|
60
|
+
truncate: {
|
|
61
|
+
true: string;
|
|
62
|
+
};
|
|
63
|
+
noWrap: {
|
|
64
|
+
true: string;
|
|
65
|
+
};
|
|
66
|
+
gutterBottom: {
|
|
67
|
+
true: string;
|
|
68
|
+
};
|
|
69
|
+
}, undefined, "text-inherit", {
|
|
70
|
+
variant: {
|
|
71
|
+
h1: string;
|
|
72
|
+
h2: string;
|
|
73
|
+
h3: string;
|
|
74
|
+
h4: string;
|
|
75
|
+
h5: string;
|
|
76
|
+
h6: string;
|
|
77
|
+
subtitle1: string;
|
|
78
|
+
subtitle2: string;
|
|
79
|
+
body1: string;
|
|
80
|
+
body2: string;
|
|
81
|
+
caption: string;
|
|
82
|
+
overline: string;
|
|
83
|
+
};
|
|
84
|
+
color: {
|
|
85
|
+
inherit: string;
|
|
86
|
+
primary: string;
|
|
87
|
+
secondary: string;
|
|
88
|
+
success: string;
|
|
89
|
+
warning: string;
|
|
90
|
+
danger: string;
|
|
91
|
+
info: string;
|
|
92
|
+
neutral: string;
|
|
93
|
+
muted: string;
|
|
94
|
+
};
|
|
95
|
+
weight: {
|
|
96
|
+
normal: string;
|
|
97
|
+
medium: string;
|
|
98
|
+
semibold: string;
|
|
99
|
+
bold: string;
|
|
100
|
+
extrabold: string;
|
|
101
|
+
};
|
|
102
|
+
align: {
|
|
103
|
+
left: string;
|
|
104
|
+
center: string;
|
|
105
|
+
right: string;
|
|
106
|
+
justify: string;
|
|
107
|
+
};
|
|
108
|
+
truncate: {
|
|
109
|
+
true: string;
|
|
110
|
+
};
|
|
111
|
+
noWrap: {
|
|
112
|
+
true: string;
|
|
113
|
+
};
|
|
114
|
+
gutterBottom: {
|
|
115
|
+
true: string;
|
|
116
|
+
};
|
|
117
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
118
|
+
variant: {
|
|
119
|
+
h1: string;
|
|
120
|
+
h2: string;
|
|
121
|
+
h3: string;
|
|
122
|
+
h4: string;
|
|
123
|
+
h5: string;
|
|
124
|
+
h6: string;
|
|
125
|
+
subtitle1: string;
|
|
126
|
+
subtitle2: string;
|
|
127
|
+
body1: string;
|
|
128
|
+
body2: string;
|
|
129
|
+
caption: string;
|
|
130
|
+
overline: string;
|
|
131
|
+
};
|
|
132
|
+
color: {
|
|
133
|
+
inherit: string;
|
|
134
|
+
primary: string;
|
|
135
|
+
secondary: string;
|
|
136
|
+
success: string;
|
|
137
|
+
warning: string;
|
|
138
|
+
danger: string;
|
|
139
|
+
info: string;
|
|
140
|
+
neutral: string;
|
|
141
|
+
muted: string;
|
|
142
|
+
};
|
|
143
|
+
weight: {
|
|
144
|
+
normal: string;
|
|
145
|
+
medium: string;
|
|
146
|
+
semibold: string;
|
|
147
|
+
bold: string;
|
|
148
|
+
extrabold: string;
|
|
149
|
+
};
|
|
150
|
+
align: {
|
|
151
|
+
left: string;
|
|
152
|
+
center: string;
|
|
153
|
+
right: string;
|
|
154
|
+
justify: string;
|
|
155
|
+
};
|
|
156
|
+
truncate: {
|
|
157
|
+
true: string;
|
|
158
|
+
};
|
|
159
|
+
noWrap: {
|
|
160
|
+
true: string;
|
|
161
|
+
};
|
|
162
|
+
gutterBottom: {
|
|
163
|
+
true: string;
|
|
164
|
+
};
|
|
165
|
+
}, undefined, "text-inherit", unknown, unknown, undefined>>;
|
|
166
|
+
export type TypographyVariants = VariantProps<typeof typographyVariants>;
|
|
167
|
+
//# sourceMappingURL=typography.variants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typography.variants.d.ts","sourceRoot":"","sources":["../../../../src/components/Typography/typography.variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2DAyF7B,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { VisuallyHiddenProps } from './visuallyHidden.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* `<VisuallyHidden>` — the accessibility primitive.
|
|
4
|
+
*
|
|
5
|
+
* Hides children from sighted users (zero pixels rendered, no layout
|
|
6
|
+
* impact) while keeping them in the accessibility tree. Screen readers
|
|
7
|
+
* speak the content; voice control software uses it for click targets;
|
|
8
|
+
* keyboard users see nothing — same as if it weren't there.
|
|
9
|
+
*
|
|
10
|
+
* Implementation: Tailwind's built-in `sr-only` utility, which expands to:
|
|
11
|
+
*
|
|
12
|
+
* .sr-only {
|
|
13
|
+
* position: absolute;
|
|
14
|
+
* width: 1px;
|
|
15
|
+
* height: 1px;
|
|
16
|
+
* padding: 0;
|
|
17
|
+
* margin: -1px;
|
|
18
|
+
* overflow: hidden;
|
|
19
|
+
* clip: rect(0,0,0,0);
|
|
20
|
+
* white-space: nowrap;
|
|
21
|
+
* border-width: 0;
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* This is the canonical "visually-hidden but screen-reader-accessible"
|
|
25
|
+
* pattern, also known as the WebAIM clip technique. Critically:
|
|
26
|
+
*
|
|
27
|
+
* • NOT `display: none` (removes from a11y tree)
|
|
28
|
+
* • NOT `visibility: hidden` (also removes from a11y tree)
|
|
29
|
+
* • NOT `opacity: 0` (technically still rendered, doesn't help AT)
|
|
30
|
+
* • NOT `width/height: 0` (collapses, some AT skips it)
|
|
31
|
+
*
|
|
32
|
+
* Default tag is `<span>` (inline) — the 99% case is "label inside a
|
|
33
|
+
* button or link". For block content, override with `as="div"`, but
|
|
34
|
+
* be aware nesting block inside inline is invalid HTML.
|
|
35
|
+
*
|
|
36
|
+
* The component is intentionally tiny (~30 LoC total): one className,
|
|
37
|
+
* one tag. The value is the COMPONENT NAME — `<VisuallyHidden>` reads
|
|
38
|
+
* as an intentional a11y decision in code review, while
|
|
39
|
+
* `className="sr-only"` looks like a typo or a forgotten utility.
|
|
40
|
+
*/
|
|
41
|
+
export declare const VisuallyHidden: import("react").ForwardRefExoticComponent<VisuallyHiddenProps & import("react").RefAttributes<HTMLElement>>;
|
|
42
|
+
//# sourceMappingURL=VisuallyHidden.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisuallyHidden.d.ts","sourceRoot":"","sources":["../../../../src/components/VisuallyHidden/VisuallyHidden.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,cAAc,6GAa1B,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ElementType, HTMLAttributes, ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for `<VisuallyHidden>` — the a11y primitive.
|
|
4
|
+
*
|
|
5
|
+
* Hides content visually (zero pixels rendered) while keeping it
|
|
6
|
+
* accessible to assistive technology (screen readers, voice control).
|
|
7
|
+
* The canonical use case: icon-only buttons that need an audible label
|
|
8
|
+
* for non-visual users.
|
|
9
|
+
*
|
|
10
|
+
* <button>
|
|
11
|
+
* <CloseIcon />
|
|
12
|
+
* <VisuallyHidden>Close dialog</VisuallyHidden>
|
|
13
|
+
* </button>
|
|
14
|
+
*
|
|
15
|
+
* Implementation uses Tailwind's `sr-only` utility, which sets
|
|
16
|
+
* `position: absolute; width: 1px; height: 1px; padding: 0;
|
|
17
|
+
* margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
|
|
18
|
+
* white-space: nowrap; border-width: 0;` — the canonical
|
|
19
|
+
* "visually-hidden but screen-reader-accessible" pattern. Better
|
|
20
|
+
* than `display: none` (removes from a11y tree) and better than
|
|
21
|
+
* `visibility: hidden` (also removes from a11y tree).
|
|
22
|
+
*/
|
|
23
|
+
export interface VisuallyHiddenProps extends Omit<HTMLAttributes<HTMLElement>, 'className'> {
|
|
24
|
+
/**
|
|
25
|
+
* The text or markup hidden from sighted users but read by AT.
|
|
26
|
+
* Most often a string label.
|
|
27
|
+
*/
|
|
28
|
+
children?: ReactElement | string | number;
|
|
29
|
+
/**
|
|
30
|
+
* Override the rendered HTML tag. Defaults to `'span'` — inline
|
|
31
|
+
* placement is the most common case (label inside a button or link).
|
|
32
|
+
* Use `as="div"` when the hidden content is block-level, but be
|
|
33
|
+
* aware: nesting a block inside an inline parent is invalid HTML.
|
|
34
|
+
*/
|
|
35
|
+
as?: ElementType;
|
|
36
|
+
/**
|
|
37
|
+
* Utility classes appended to `sr-only`. RARELY needed for this
|
|
38
|
+
* primitive (it's just hidden text) — kept for API parity.
|
|
39
|
+
*/
|
|
40
|
+
sx?: string;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=visuallyHidden.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visuallyHidden.types.d.ts","sourceRoot":"","sources":["../../../../src/components/VisuallyHidden/visuallyHidden.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,mBACf,SAAQ,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACtD;;;OAGG;IACH,QAAQ,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;IAE1C;;;;;OAKG;IACH,EAAE,CAAC,EAAE,WAAW,CAAC;IAEjB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACb"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -71,6 +71,28 @@ export { confirmDialogVariants } from './components/ConfirmDialog/confirmDialog.
|
|
|
71
71
|
export { SnackbarProvider, useSnackbar, } from './components/Snackbar/Snackbar.js';
|
|
72
72
|
export type { SnackbarProviderProps, SnackbarApi, SnackbarOptions, SnackbarRecord, SnackbarSeverity, SnackbarPosition, SnackbarSlotProps, } from './components/Snackbar/snackbar.types.js';
|
|
73
73
|
export { snackbarVariants } from './components/Snackbar/snackbar.variants.js';
|
|
74
|
+
export { Typography } from './components/Typography/Typography.js';
|
|
75
|
+
export type { TypographyProps } from './components/Typography/typography.types.js';
|
|
76
|
+
export { typographyVariants } from './components/Typography/typography.variants.js';
|
|
77
|
+
export { Box } from './components/Box/Box.js';
|
|
78
|
+
export type { BoxProps } from './components/Box/box.types.js';
|
|
79
|
+
export { boxVariants } from './components/Box/box.variants.js';
|
|
80
|
+
export { Stack } from './components/Stack/Stack.js';
|
|
81
|
+
export type { StackProps } from './components/Stack/stack.types.js';
|
|
82
|
+
export { stackVariants } from './components/Stack/stack.variants.js';
|
|
83
|
+
export { Grid } from './components/Grid/Grid.js';
|
|
84
|
+
export type { GridProps, GridContainerProps, GridItemProps, ColSpan, GridSpacingStep, } from './components/Grid/grid.types.js';
|
|
85
|
+
export { gridVariants } from './components/Grid/grid.variants.js';
|
|
86
|
+
export { Container } from './components/Container/Container.js';
|
|
87
|
+
export type { ContainerProps } from './components/Container/container.types.js';
|
|
88
|
+
export { containerVariants } from './components/Container/container.variants.js';
|
|
89
|
+
export { Divider } from './components/Divider/Divider.js';
|
|
90
|
+
export type { DividerProps } from './components/Divider/divider.types.js';
|
|
91
|
+
export { dividerVariants, dividerLineVariants, } from './components/Divider/divider.variants.js';
|
|
92
|
+
export { AspectRatio } from './components/AspectRatio/AspectRatio.js';
|
|
93
|
+
export type { AspectRatioProps } from './components/AspectRatio/aspectRatio.types.js';
|
|
94
|
+
export { VisuallyHidden } from './components/VisuallyHidden/VisuallyHidden.js';
|
|
95
|
+
export type { VisuallyHiddenProps } from './components/VisuallyHidden/visuallyHidden.types.js';
|
|
74
96
|
export { useAccessState } from './hooks/useAccessState.js';
|
|
75
97
|
export { cn } from './utils/cn.js';
|
|
76
98
|
export { tv } from 'tailwind-variants';
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,YAAY,EACV,cAAc,EACd,kBAAkB,GACnB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AAEjF,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,YAAY,EACV,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;AACjD,YAAY,EACV,SAAS,EACT,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,eAAe,GAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAOlE,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,YAAY,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AAEjF,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,YAAY,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EACL,eAAe,EACf,mBAAmB,GACpB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,YAAY,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AAEtF,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAC/E,YAAY,EAAE,mBAAmB,EAAE,MAAM,qDAAqD,CAAC;AAG/F,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAInC,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvC,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,OAAO,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashforge/tw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-beta",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.esm.js",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"tailwind-variants": "^3.1.1",
|
|
27
27
|
"vitest": "*",
|
|
28
28
|
"@dashforge/forms": "0.2.3-beta",
|
|
29
|
-
"@dashforge/
|
|
30
|
-
"@dashforge/
|
|
29
|
+
"@dashforge/rbac": "0.2.3-beta",
|
|
30
|
+
"@dashforge/ui-core": "0.2.3-beta"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { describe, it, expect } from 'vitest';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
|
+
import { AspectRatio } from './AspectRatio.js';
|
|
5
|
+
|
|
6
|
+
describe('<AspectRatio>', () => {
|
|
7
|
+
// ─── Default rendering ──────────────────────────────────────────────
|
|
8
|
+
describe('default rendering', () => {
|
|
9
|
+
it('renders a <div> by default', () => {
|
|
10
|
+
const { container } = render(<AspectRatio>x</AspectRatio>);
|
|
11
|
+
expect(container.firstElementChild?.tagName).toBe('DIV');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('default ratio is 1 (square)', () => {
|
|
15
|
+
const { container } = render(<AspectRatio>x</AspectRatio>);
|
|
16
|
+
const el = container.firstElementChild as HTMLElement;
|
|
17
|
+
expect(el.style.aspectRatio).toBe('1 / 1');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('always has w-full baseline', () => {
|
|
21
|
+
const { container } = render(<AspectRatio>x</AspectRatio>);
|
|
22
|
+
expect(container.firstElementChild?.className).toContain('w-full');
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// ─── ratio prop ─────────────────────────────────────────────────────
|
|
27
|
+
describe('ratio', () => {
|
|
28
|
+
it('numeric ratio 16/9 → "1.7777… / 1"', () => {
|
|
29
|
+
const { container } = render(<AspectRatio ratio={16 / 9}>x</AspectRatio>);
|
|
30
|
+
const el = container.firstElementChild as HTMLElement;
|
|
31
|
+
// 16/9 ≈ 1.7777, formatted as "<number> / 1"
|
|
32
|
+
expect(el.style.aspectRatio).toMatch(/^1\.\d+ \/ 1$/);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('numeric ratio 4/3', () => {
|
|
36
|
+
const { container } = render(<AspectRatio ratio={4 / 3}>x</AspectRatio>);
|
|
37
|
+
const el = container.firstElementChild as HTMLElement;
|
|
38
|
+
expect(el.style.aspectRatio).toMatch(/^1\.\d+ \/ 1$/);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('string ratio "16 / 9" passes through', () => {
|
|
42
|
+
const { container } = render(<AspectRatio ratio="16 / 9">x</AspectRatio>);
|
|
43
|
+
const el = container.firstElementChild as HTMLElement;
|
|
44
|
+
expect(el.style.aspectRatio).toBe('16 / 9');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('string ratio "21/9" passes through (ultrawide)', () => {
|
|
48
|
+
const { container } = render(<AspectRatio ratio="21/9">x</AspectRatio>);
|
|
49
|
+
const el = container.firstElementChild as HTMLElement;
|
|
50
|
+
expect(el.style.aspectRatio).toBe('21/9');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// ─── Override ───────────────────────────────────────────────────────
|
|
55
|
+
describe('override', () => {
|
|
56
|
+
it('sx adds utility classes', () => {
|
|
57
|
+
const { container } = render(
|
|
58
|
+
<AspectRatio ratio={16 / 9} sx="rounded-xl overflow-hidden">
|
|
59
|
+
x
|
|
60
|
+
</AspectRatio>,
|
|
61
|
+
);
|
|
62
|
+
const cls = container.firstElementChild?.className ?? '';
|
|
63
|
+
expect(cls).toContain('rounded-xl');
|
|
64
|
+
expect(cls).toContain('overflow-hidden');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('user style merges with aspect-ratio', () => {
|
|
68
|
+
const { container } = render(
|
|
69
|
+
<AspectRatio ratio={1} style={{ backgroundColor: 'red' }}>x</AspectRatio>,
|
|
70
|
+
);
|
|
71
|
+
const el = container.firstElementChild as HTMLElement;
|
|
72
|
+
expect(el.style.backgroundColor).toBe('red');
|
|
73
|
+
expect(el.style.aspectRatio).toBe('1 / 1');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('user style aspect-ratio overrides the prop (last wins)', () => {
|
|
77
|
+
const { container } = render(
|
|
78
|
+
<AspectRatio ratio={1} style={{ aspectRatio: '2 / 1' }}>x</AspectRatio>,
|
|
79
|
+
);
|
|
80
|
+
const el = container.firstElementChild as HTMLElement;
|
|
81
|
+
// Inline style merge — user's later spread wins
|
|
82
|
+
expect(el.style.aspectRatio).toBe('2 / 1');
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// ─── Polymorphism ───────────────────────────────────────────────────
|
|
87
|
+
describe('polymorphism', () => {
|
|
88
|
+
it('as="figure" renders <figure>', () => {
|
|
89
|
+
const { container } = render(
|
|
90
|
+
<AspectRatio as="figure" ratio={1}>x</AspectRatio>,
|
|
91
|
+
);
|
|
92
|
+
expect(container.firstElementChild?.tagName).toBe('FIGURE');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('as="picture" works for responsive image markup', () => {
|
|
96
|
+
const { container } = render(
|
|
97
|
+
<AspectRatio as="picture" ratio={16 / 9}>
|
|
98
|
+
<img src="x.jpg" alt="" />
|
|
99
|
+
</AspectRatio>,
|
|
100
|
+
);
|
|
101
|
+
expect(container.firstElementChild?.tagName).toBe('PICTURE');
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// ─── Child rendering ────────────────────────────────────────────────
|
|
106
|
+
describe('child rendering', () => {
|
|
107
|
+
it('renders an <img> child', () => {
|
|
108
|
+
const { container } = render(
|
|
109
|
+
<AspectRatio ratio={16 / 9}>
|
|
110
|
+
<img src="hero.jpg" alt="hero" className="w-full h-full object-cover" />
|
|
111
|
+
</AspectRatio>,
|
|
112
|
+
);
|
|
113
|
+
const img = container.querySelector('img');
|
|
114
|
+
expect(img?.getAttribute('src')).toBe('hero.jpg');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('renders multiple children (e.g. overlay pattern)', () => {
|
|
118
|
+
const { container } = render(
|
|
119
|
+
<AspectRatio ratio={16 / 9}>
|
|
120
|
+
<img src="hero.jpg" alt="hero" />
|
|
121
|
+
<div className="absolute inset-0 bg-black/40" />
|
|
122
|
+
</AspectRatio>,
|
|
123
|
+
);
|
|
124
|
+
expect(container.firstElementChild?.children.length).toBe(2);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// ─── Pass-through ───────────────────────────────────────────────────
|
|
129
|
+
it('forwards data-* + aria-*', () => {
|
|
130
|
+
const { container } = render(
|
|
131
|
+
<AspectRatio data-testid="ar" aria-label="hero">x</AspectRatio>,
|
|
132
|
+
);
|
|
133
|
+
const el = container.firstElementChild;
|
|
134
|
+
expect(el?.getAttribute('data-testid')).toBe('ar');
|
|
135
|
+
expect(el?.getAttribute('aria-label')).toBe('hero');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// ─── F11-bis edge cases ─────────────────────────────────────────────
|
|
139
|
+
describe('extreme ratio values', () => {
|
|
140
|
+
it('ratio="21 / 9" (ultrawide cinema) passes through verbatim', () => {
|
|
141
|
+
const { container } = render(<AspectRatio ratio="21 / 9">x</AspectRatio>);
|
|
142
|
+
expect((container.firstElementChild as HTMLElement).style.aspectRatio).toBe('21 / 9');
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('ratio="9 / 16" (portrait video) passes through verbatim', () => {
|
|
146
|
+
const { container } = render(<AspectRatio ratio="9 / 16">x</AspectRatio>);
|
|
147
|
+
expect((container.firstElementChild as HTMLElement).style.aspectRatio).toBe('9 / 16');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('numeric tiny ratio (0.5) formats as "0.5 / 1"', () => {
|
|
151
|
+
const { container } = render(<AspectRatio ratio={0.5}>x</AspectRatio>);
|
|
152
|
+
expect((container.firstElementChild as HTMLElement).style.aspectRatio).toBe('0.5 / 1');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('numeric large ratio (3) formats as "3 / 1"', () => {
|
|
156
|
+
const { container } = render(<AspectRatio ratio={3}>x</AspectRatio>);
|
|
157
|
+
expect((container.firstElementChild as HTMLElement).style.aspectRatio).toBe('3 / 1');
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
describe('rounded clipped media pattern (the #1 doc gotcha)', () => {
|
|
162
|
+
it('rounded + overflow-hidden both end up on the className', () => {
|
|
163
|
+
const { container } = render(
|
|
164
|
+
<AspectRatio ratio={16 / 9} sx="rounded-2xl overflow-hidden">
|
|
165
|
+
<img src="x.jpg" alt="" className="w-full h-full object-cover" />
|
|
166
|
+
</AspectRatio>,
|
|
167
|
+
);
|
|
168
|
+
const cls = container.firstElementChild?.className ?? '';
|
|
169
|
+
expect(cls).toContain('rounded-2xl');
|
|
170
|
+
expect(cls).toContain('overflow-hidden');
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|