@cognitap/radiant 0.0.77 → 0.0.79
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 +36 -2
- package/README.md +6 -3
- package/RELEASE_POLICY.md +8 -19
- package/dist/library/charts/Charts.d.ts.map +1 -1
- package/dist/library/charts/Charts.js +6 -2
- package/dist/library/charts/Charts.js.map +1 -1
- package/dist/library/components/Accordion/Accordion.js +1 -1
- package/dist/library/components/Accordion/Accordion.js.map +1 -1
- package/dist/library/components/Alert/Alert.js +1 -1
- package/dist/library/components/Alert/Alert.js.map +1 -1
- package/dist/library/components/AppShell/AppShell.d.ts.map +1 -1
- package/dist/library/components/AppShell/AppShell.js +7 -6
- package/dist/library/components/AppShell/AppShell.js.map +1 -1
- package/dist/library/components/AspectRatio/AspectRatio.js +1 -1
- package/dist/library/components/AspectRatio/AspectRatio.js.map +1 -1
- package/dist/library/components/Avatar/Avatar.js +1 -1
- package/dist/library/components/Avatar/Avatar.js.map +1 -1
- package/dist/library/components/Badge/Badge.js +1 -1
- package/dist/library/components/Badge/Badge.js.map +1 -1
- package/dist/library/components/Breadcrumb/Breadcrumb.d.ts +2 -1
- package/dist/library/components/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/library/components/Breadcrumb/Breadcrumb.js +5 -10
- package/dist/library/components/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/library/components/Button/Button.js +1 -1
- package/dist/library/components/Button/Button.js.map +1 -1
- package/dist/library/components/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/library/components/ButtonGroup/ButtonGroup.js.map +1 -1
- package/dist/library/components/Card/Card.js +1 -1
- package/dist/library/components/Card/Card.js.map +1 -1
- package/dist/library/components/Carousel/Carousel.d.ts.map +1 -1
- package/dist/library/components/Carousel/Carousel.js +11 -9
- package/dist/library/components/Carousel/Carousel.js.map +1 -1
- package/dist/library/components/Checkbox/Checkbox.d.ts +3 -1
- package/dist/library/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/library/components/Checkbox/Checkbox.js +8 -8
- package/dist/library/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/library/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/dist/library/components/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/dist/library/components/CodeBlock/CodeBlock.js +3 -3
- package/dist/library/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/library/components/Collapsible/Collapsible.d.ts.map +1 -1
- package/dist/library/components/Collapsible/Collapsible.js +4 -6
- package/dist/library/components/Collapsible/Collapsible.js.map +1 -1
- package/dist/library/components/Combobox/Combobox.d.ts +9 -1
- package/dist/library/components/Combobox/Combobox.d.ts.map +1 -1
- package/dist/library/components/Combobox/Combobox.js +14 -13
- package/dist/library/components/Combobox/Combobox.js.map +1 -1
- package/dist/library/components/Combobox/comboboxStyles.d.ts.map +1 -1
- package/dist/library/components/Combobox/comboboxStyles.js +5 -2
- package/dist/library/components/Combobox/comboboxStyles.js.map +1 -1
- package/dist/library/components/Command/Command.d.ts +1 -4
- package/dist/library/components/Command/Command.d.ts.map +1 -1
- package/dist/library/components/Command/Command.js +3 -9
- package/dist/library/components/Command/Command.js.map +1 -1
- package/dist/library/components/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/library/components/ContextMenu/ContextMenu.js +3 -2
- package/dist/library/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/library/components/Dialog/Dialog.d.ts +3 -0
- package/dist/library/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/library/components/Dialog/Dialog.js +9 -10
- package/dist/library/components/Dialog/Dialog.js.map +1 -1
- package/dist/library/components/Drawer/Drawer.js +1 -1
- package/dist/library/components/Drawer/Drawer.js.map +1 -1
- package/dist/library/components/EmptyState/EmptyState.js +1 -1
- package/dist/library/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/library/components/Field/Field.js +1 -1
- package/dist/library/components/Field/Field.js.map +1 -1
- package/dist/library/components/Fieldset/Fieldset.d.ts +1 -1
- package/dist/library/components/Fieldset/Fieldset.d.ts.map +1 -1
- package/dist/library/components/Fieldset/Fieldset.js +3 -3
- package/dist/library/components/Fieldset/Fieldset.js.map +1 -1
- package/dist/library/components/FileInput/FileInput.d.ts +3 -1
- package/dist/library/components/FileInput/FileInput.d.ts.map +1 -1
- package/dist/library/components/FileInput/FileInput.js +6 -4
- package/dist/library/components/FileInput/FileInput.js.map +1 -1
- package/dist/library/components/Form/Form.d.ts.map +1 -1
- package/dist/library/components/Form/Form.js +16 -11
- package/dist/library/components/Form/Form.js.map +1 -1
- package/dist/library/components/HoverCard/HoverCard.d.ts +1 -0
- package/dist/library/components/HoverCard/HoverCard.d.ts.map +1 -1
- package/dist/library/components/HoverCard/HoverCard.js +2 -1
- package/dist/library/components/HoverCard/HoverCard.js.map +1 -1
- package/dist/library/components/InlineCode/InlineCode.js +1 -1
- package/dist/library/components/InlineCode/InlineCode.js.map +1 -1
- package/dist/library/components/Input/Input.d.ts +3 -1
- package/dist/library/components/Input/Input.d.ts.map +1 -1
- package/dist/library/components/Input/Input.js +7 -12
- package/dist/library/components/Input/Input.js.map +1 -1
- package/dist/library/components/InputGroup/InputGroup.d.ts.map +1 -1
- package/dist/library/components/InputGroup/InputGroup.js +3 -2
- package/dist/library/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/library/components/Kbd/Kbd.js +1 -1
- package/dist/library/components/Kbd/Kbd.js.map +1 -1
- package/dist/library/components/Link/Link.d.ts +4 -2
- package/dist/library/components/Link/Link.d.ts.map +1 -1
- package/dist/library/components/Link/Link.js +7 -4
- package/dist/library/components/Link/Link.js.map +1 -1
- package/dist/library/components/Menu/Menu.d.ts +13 -3
- package/dist/library/components/Menu/Menu.d.ts.map +1 -1
- package/dist/library/components/Menu/Menu.js +24 -9
- package/dist/library/components/Menu/Menu.js.map +1 -1
- package/dist/library/components/Menubar/Menubar.d.ts.map +1 -1
- package/dist/library/components/Menubar/Menubar.js +2 -2
- package/dist/library/components/Menubar/Menubar.js.map +1 -1
- package/dist/library/components/Meter/Meter.js +1 -1
- package/dist/library/components/Meter/Meter.js.map +1 -1
- package/dist/library/components/NativeSelect/NativeSelect.d.ts.map +1 -1
- package/dist/library/components/NativeSelect/NativeSelect.js +3 -2
- package/dist/library/components/NativeSelect/NativeSelect.js.map +1 -1
- package/dist/library/components/NavLink/NavLink.d.ts.map +1 -1
- package/dist/library/components/NavLink/NavLink.js +6 -4
- package/dist/library/components/NavLink/NavLink.js.map +1 -1
- package/dist/library/components/NavigationMenu/NavigationMenu.d.ts +1 -1
- package/dist/library/components/NavigationMenu/NavigationMenu.d.ts.map +1 -1
- package/dist/library/components/NavigationMenu/NavigationMenu.js +11 -4
- package/dist/library/components/NavigationMenu/NavigationMenu.js.map +1 -1
- package/dist/library/components/NumberField/NumberField.d.ts.map +1 -1
- package/dist/library/components/NumberField/NumberField.js +2 -2
- package/dist/library/components/NumberField/NumberField.js.map +1 -1
- package/dist/library/components/OTPField/OTPField.d.ts.map +1 -1
- package/dist/library/components/OTPField/OTPField.js +3 -2
- package/dist/library/components/OTPField/OTPField.js.map +1 -1
- package/dist/library/components/Pagination/Pagination.d.ts +2 -1
- package/dist/library/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/library/components/Pagination/Pagination.js +5 -7
- package/dist/library/components/Pagination/Pagination.js.map +1 -1
- package/dist/library/components/PasswordInput/PasswordInput.js +1 -1
- package/dist/library/components/PasswordInput/PasswordInput.js.map +1 -1
- package/dist/library/components/Popover/Popover.d.ts.map +1 -1
- package/dist/library/components/Popover/Popover.js +5 -3
- package/dist/library/components/Popover/Popover.js.map +1 -1
- package/dist/library/components/Progress/Progress.js +1 -1
- package/dist/library/components/Progress/Progress.js.map +1 -1
- package/dist/library/components/RadioGroup/RadioGroup.d.ts +4 -2
- package/dist/library/components/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/dist/library/components/RadioGroup/RadioGroup.js +10 -11
- package/dist/library/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/library/components/Resizable/Resizable.d.ts.map +1 -1
- package/dist/library/components/Resizable/Resizable.js +3 -2
- package/dist/library/components/Resizable/Resizable.js.map +1 -1
- package/dist/library/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/library/components/ScrollArea/ScrollArea.js +3 -2
- package/dist/library/components/ScrollArea/ScrollArea.js.map +1 -1
- package/dist/library/components/Select/Select.d.ts +7 -0
- package/dist/library/components/Select/Select.d.ts.map +1 -1
- package/dist/library/components/Select/Select.js +12 -11
- package/dist/library/components/Select/Select.js.map +1 -1
- package/dist/library/components/Select/selectStyles.d.ts.map +1 -1
- package/dist/library/components/Select/selectStyles.js +3 -1
- package/dist/library/components/Select/selectStyles.js.map +1 -1
- package/dist/library/components/Separator/Separator.js +1 -1
- package/dist/library/components/Separator/Separator.js.map +1 -1
- package/dist/library/components/Skeleton/Skeleton.js +1 -1
- package/dist/library/components/Skeleton/Skeleton.js.map +1 -1
- package/dist/library/components/Slider/Slider.d.ts +3 -1
- package/dist/library/components/Slider/Slider.d.ts.map +1 -1
- package/dist/library/components/Slider/Slider.js +7 -9
- package/dist/library/components/Slider/Slider.js.map +1 -1
- package/dist/library/components/Spinner/Spinner.js +1 -1
- package/dist/library/components/Spinner/Spinner.js.map +1 -1
- package/dist/library/components/Switch/Switch.d.ts +3 -1
- package/dist/library/components/Switch/Switch.d.ts.map +1 -1
- package/dist/library/components/Switch/Switch.js +7 -8
- package/dist/library/components/Switch/Switch.js.map +1 -1
- package/dist/library/components/Table/Table.d.ts.map +1 -1
- package/dist/library/components/Table/Table.js +3 -2
- package/dist/library/components/Table/Table.js.map +1 -1
- package/dist/library/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/library/components/Tabs/Tabs.js +9 -7
- package/dist/library/components/Tabs/Tabs.js.map +1 -1
- package/dist/library/components/Tag/Tag.js +1 -1
- package/dist/library/components/Tag/Tag.js.map +1 -1
- package/dist/library/components/TagsInput/TagsInput.d.ts +3 -1
- package/dist/library/components/TagsInput/TagsInput.d.ts.map +1 -1
- package/dist/library/components/TagsInput/TagsInput.js +9 -6
- package/dist/library/components/TagsInput/TagsInput.js.map +1 -1
- package/dist/library/components/Textarea/Textarea.d.ts +3 -1
- package/dist/library/components/Textarea/Textarea.d.ts.map +1 -1
- package/dist/library/components/Textarea/Textarea.js +7 -8
- package/dist/library/components/Textarea/Textarea.js.map +1 -1
- package/dist/library/components/ThemeScope/ThemeScope.js +1 -1
- package/dist/library/components/ThemeScope/ThemeScope.js.map +1 -1
- package/dist/library/components/Toast/Toast.d.ts +2 -1
- package/dist/library/components/Toast/Toast.d.ts.map +1 -1
- package/dist/library/components/Toast/Toast.js +22 -9
- package/dist/library/components/Toast/Toast.js.map +1 -1
- package/dist/library/components/ToggleGroup/ToggleGroup.js +3 -1
- package/dist/library/components/ToggleGroup/ToggleGroup.js.map +1 -1
- package/dist/library/components/Toolbar/Toolbar.js +1 -1
- package/dist/library/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/library/components/Tooltip/Tooltip.d.ts +1 -0
- package/dist/library/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/library/components/Tooltip/Tooltip.js +2 -2
- package/dist/library/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/library/components/shared/actionStyles.d.ts.map +1 -1
- package/dist/library/components/shared/actionStyles.js +3 -1
- package/dist/library/components/shared/actionStyles.js.map +1 -1
- package/dist/library/components/shared/focusStyles.d.ts +13 -0
- package/dist/library/components/shared/focusStyles.d.ts.map +1 -0
- package/dist/library/components/shared/focusStyles.js +17 -0
- package/dist/library/components/shared/focusStyles.js.map +1 -0
- package/dist/library/index.d.ts +1 -1
- package/dist/library/index.d.ts.map +1 -1
- package/dist/library/index.js.map +1 -1
- package/dist/library/motion/MotionLink.js +1 -1
- package/dist/library/motion/MotionLink.js.map +1 -1
- package/dist/library/react/useComboboxPopup.d.ts.map +1 -1
- package/dist/library/react/useComboboxPopup.js +45 -6
- package/dist/library/react/useComboboxPopup.js.map +1 -1
- package/dist/library/react/useRovingFocus.d.ts.map +1 -1
- package/dist/library/react/useRovingFocus.js +76 -11
- package/dist/library/react/useRovingFocus.js.map +1 -1
- package/dist/library/react/useToastTimer.d.ts.map +1 -1
- package/dist/library/react/useToastTimer.js +29 -10
- package/dist/library/react/useToastTimer.js.map +1 -1
- package/dist/library/styles.css +1 -1
- package/dist/library/themes/components.d.ts +12 -0
- package/dist/library/themes/components.d.ts.map +1 -1
- package/dist/library/themes/components.js +15 -3
- package/dist/library/themes/components.js.map +1 -1
- package/docs/accessibility.md +23 -111
- package/docs/architecture.md +48 -228
- package/docs/motion.md +65 -130
- package/docs/theming.md +51 -422
- package/package.json +21 -13
- package/src/charts/Charts.tsx +6 -3
- package/src/components/Accordion/Accordion.tsx +1 -1
- package/src/components/Alert/Alert.tsx +1 -1
- package/src/components/AppShell/AppShell.tsx +10 -6
- package/src/components/AspectRatio/AspectRatio.tsx +1 -1
- package/src/components/Avatar/Avatar.tsx +1 -1
- package/src/components/Badge/Badge.tsx +1 -1
- package/src/components/Breadcrumb/Breadcrumb.tsx +6 -10
- package/src/components/Button/Button.tsx +1 -1
- package/src/components/ButtonGroup/ButtonGroup.tsx +1 -1
- package/src/components/Card/Card.tsx +1 -1
- package/src/components/Carousel/Carousel.tsx +14 -9
- package/src/components/Checkbox/Checkbox.tsx +10 -7
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +1 -1
- package/src/components/CodeBlock/CodeBlock.tsx +3 -3
- package/src/components/Collapsible/Collapsible.tsx +4 -6
- package/src/components/Combobox/Combobox.tsx +72 -16
- package/src/components/Combobox/comboboxStyles.ts +5 -2
- package/src/components/Command/Command.tsx +3 -10
- package/src/components/ContextMenu/ContextMenu.tsx +3 -5
- package/src/components/Dialog/Dialog.tsx +30 -14
- package/src/components/Drawer/Drawer.tsx +1 -1
- package/src/components/EmptyState/EmptyState.tsx +1 -1
- package/src/components/Field/Field.tsx +1 -1
- package/src/components/Fieldset/Fieldset.tsx +4 -4
- package/src/components/FileInput/FileInput.tsx +9 -3
- package/src/components/Form/Form.tsx +14 -10
- package/src/components/HoverCard/HoverCard.tsx +6 -2
- package/src/components/InlineCode/InlineCode.tsx +1 -1
- package/src/components/Input/Input.tsx +14 -13
- package/src/components/InputGroup/InputGroup.tsx +5 -3
- package/src/components/Kbd/Kbd.tsx +1 -1
- package/src/components/Link/Link.tsx +10 -4
- package/src/components/Menu/Menu.tsx +52 -10
- package/src/components/Menubar/Menubar.tsx +2 -1
- package/src/components/Meter/Meter.tsx +1 -1
- package/src/components/NativeSelect/NativeSelect.tsx +4 -2
- package/src/components/NavLink/NavLink.tsx +9 -6
- package/src/components/NavigationMenu/NavigationMenu.tsx +15 -12
- package/src/components/NumberField/NumberField.tsx +2 -1
- package/src/components/OTPField/OTPField.tsx +5 -2
- package/src/components/Pagination/Pagination.tsx +6 -8
- package/src/components/PasswordInput/PasswordInput.tsx +1 -1
- package/src/components/Popover/Popover.tsx +5 -2
- package/src/components/Progress/Progress.tsx +1 -1
- package/src/components/RadioGroup/RadioGroup.tsx +14 -8
- package/src/components/Resizable/Resizable.tsx +5 -3
- package/src/components/ScrollArea/ScrollArea.tsx +3 -2
- package/src/components/Select/Select.tsx +28 -14
- package/src/components/Select/selectStyles.ts +3 -1
- package/src/components/Separator/Separator.tsx +1 -1
- package/src/components/Skeleton/Skeleton.tsx +1 -1
- package/src/components/Slider/Slider.tsx +9 -8
- package/src/components/Spinner/Spinner.tsx +1 -1
- package/src/components/Switch/Switch.tsx +9 -7
- package/src/components/Table/Table.tsx +4 -2
- package/src/components/Tabs/Tabs.tsx +9 -8
- package/src/components/Tag/Tag.tsx +1 -1
- package/src/components/TagsInput/TagsInput.tsx +11 -4
- package/src/components/Textarea/Textarea.tsx +9 -7
- package/src/components/ThemeScope/ThemeScope.tsx +1 -1
- package/src/components/Toast/Toast.tsx +27 -12
- package/src/components/ToggleGroup/ToggleGroup.tsx +3 -1
- package/src/components/Toolbar/Toolbar.tsx +1 -1
- package/src/components/Tooltip/Tooltip.tsx +3 -2
- package/src/components/shared/actionStyles.ts +3 -1
- package/src/components/shared/focusStyles.ts +28 -0
- package/src/css.d.ts +2 -0
- package/src/index.ts +1 -0
- package/src/motion/MotionLink.tsx +1 -1
- package/src/react/useComboboxPopup.ts +38 -6
- package/src/react/useRovingFocus.ts +73 -8
- package/src/react/useToastTimer.ts +25 -10
- package/src/styles.d.ts +1 -0
- package/src/themes/baseline.css +1 -1
- package/src/themes/components.ts +15 -3
- package/src/typography.css +17 -12
- package/dist/library/cn.d.ts +0 -3
- package/dist/library/cn.d.ts.map +0 -1
- package/dist/library/cn.js +0 -370
- package/dist/library/cn.js.map +0 -1
- package/src/cn.ts +0 -372
package/docs/theming.md
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
# Theming
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
component overrides are deliberate exceptions. For how this fits the rest of the
|
|
5
|
-
library, see [architecture](architecture.md).
|
|
3
|
+
Shared tokens set the design system. Component overrides are per-family exceptions. Keep the contracts in [architecture](architecture.md#customization-limits).
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
light and dark baseline without a provider. Tailwind applications can use the
|
|
9
|
-
[source route](../README.md#with-tailwind) instead; both read the same theme
|
|
10
|
-
variables.
|
|
5
|
+
## Setup
|
|
11
6
|
|
|
12
|
-
|
|
7
|
+
Import `@cognitap/radiant/styles.css` once, or `@cognitap/radiant/tailwind.css` in a Tailwind build (see the [README](../README.md#with-tailwind)). Components then use the neutral light and dark baseline, with no provider.
|
|
8
|
+
|
|
9
|
+
## Define a theme
|
|
13
10
|
|
|
14
11
|
```tsx
|
|
15
12
|
import { defineTheme } from '@cognitap/radiant'
|
|
@@ -32,20 +29,13 @@ const garden = defineTheme({
|
|
|
32
29
|
})
|
|
33
30
|
```
|
|
34
31
|
|
|
35
|
-
`id` is a
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
runtime. Values are CSS strings, weights may be numbers, and opacities are
|
|
41
|
-
numbers from 0 to 1. Radiant does not check CSS grammar or contrast:
|
|
42
|
-
`var(--brand)` is accepted as is.
|
|
32
|
+
- `id` is a lowercase slug. `name` is the display label.
|
|
33
|
+
- Every field is a typed partial of the library defaults. Unknown keys fail typechecking and throw at runtime.
|
|
34
|
+
- The returned `Theme` is frozen and JSON-serializable.
|
|
35
|
+
- Each mode resolves library defaults, then common `tokens` and `components`, then `modes.<mode>`. A shared color has to work in both modes.
|
|
36
|
+
- Token paths are in [`src/themes/tokens.ts`](../src/themes/tokens.ts). Component override keys are in [`src/themes/components.ts`](../src/themes/components.ts).
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
values**. Put a color in common `tokens` only if it works in both modes;
|
|
46
|
-
otherwise give its dark value too.
|
|
47
|
-
|
|
48
|
-
## Apply it
|
|
38
|
+
## Apply a theme
|
|
49
39
|
|
|
50
40
|
```tsx
|
|
51
41
|
import { Button, ThemeScope, defaultTheme } from '@cognitap/radiant'
|
|
@@ -61,429 +51,68 @@ import { Button, ThemeScope, defaultTheme } from '@cognitap/radiant'
|
|
|
61
51
|
</ThemeScope>
|
|
62
52
|
```
|
|
63
53
|
|
|
64
|
-
`ThemeScope`
|
|
65
|
-
canvas, foreground and body text for its subtree only. It never touches the
|
|
66
|
-
document, loads fonts or stores a preference.
|
|
67
|
-
|
|
68
|
-
- **`theme`** starts fresh from the library defaults. Nothing from an outer
|
|
69
|
-
theme leaks in, so `defaultTheme` fully resets a subtree, including button
|
|
70
|
-
effects.
|
|
71
|
-
- **`mode`** is `light`, `dark` or `system`, independent of the theme. `system`
|
|
72
|
-
uses a CSS media query, so server and client markup match.
|
|
73
|
-
- **Omit either** to inherit it. At the root the stylesheet defaults to
|
|
74
|
-
`system`.
|
|
75
|
-
- **Inline `style`** on a scope wins over its generated values. Theme variables
|
|
76
|
-
set inline on a scope survive nested mode-only scopes. A new named theme
|
|
77
|
-
clears them.
|
|
78
|
-
|
|
79
|
-
A mode-only scope recomputes the current theme, so it does not keep token
|
|
80
|
-
overrides from a stylesheet rule or plain wrapper above it. Put overrides that
|
|
81
|
-
must survive a mode switch in the theme or in a scope's inline `style`.
|
|
82
|
-
|
|
83
|
-
A native Dialog stays in the scope where it renders.
|
|
84
|
-
|
|
85
|
-
## Override one component
|
|
54
|
+
`ThemeScope` renders a `div`. It sets custom properties and paints canvas, foreground, and body text on that subtree. Document color, font loading, and storage stay outside the scope.
|
|
86
55
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
`
|
|
90
|
-
|
|
56
|
+
| Prop | Behavior |
|
|
57
|
+
| ------------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
58
|
+
| `theme` | Starts from library defaults, so a nested `defaultTheme` resets an outer theme |
|
|
59
|
+
| `mode` | `'light'`, `'dark'`, or `'system'`; `'system'` follows `prefers-color-scheme` in CSS so server and client HTML match |
|
|
60
|
+
| Omitted `theme` or `mode` | Inherits from the parent scope |
|
|
61
|
+
| `style` | Overrides the generated custom properties and survives nested mode-only scopes |
|
|
91
62
|
|
|
92
|
-
|
|
93
|
-
`field`, `input`, `textarea`, `slider`, `select`, `combobox`, `checkbox`, `switch`, `radio`, `radioGroup`, `dialog`, `popover`, `tooltip`, `menu`, `alert`, `toast`, `progress`, `collapsible`,
|
|
94
|
-
`accordion`, `tabs` and `card`. Every key is listed in
|
|
95
|
-
[`src/themes/components.ts`](../src/themes/components.ts). Set fonts, uppercase,
|
|
96
|
-
shadows and press motion for every action through the [roles](#roles); use
|
|
97
|
-
`components.button` only when Button alone should differ.
|
|
98
|
-
`radioGroup.gap` spaces the options, and `radio.labelGap` spaces one option's
|
|
99
|
-
label.
|
|
63
|
+
## CSS variables
|
|
100
64
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
| Path | CSS variable |
|
|
104
|
-
| ------------------------------ | ----------------------------- |
|
|
105
|
-
| `tokens.color.accent` | `--rad-color-accent` |
|
|
106
|
-
| `tokens.control.medium.height` | `--rad-control-medium-height` |
|
|
107
|
-
| `components.button.radius` | `--rad-button-radius` |
|
|
108
|
-
| `components.radioGroup.gap` | `--rad-radio-group-gap` |
|
|
109
|
-
|
|
110
|
-
For a one-off change, set the variable in `style`. `ThemeStyle` types it:
|
|
65
|
+
A value resolves as the component override, then the shared token, then the baseline. An override stays on its own component. Each key becomes a kebab-case `--rad-` property: `tokens.control.medium.height` is `--rad-control-medium-height`, and `components.radioGroup.gap` is `--rad-radio-group-gap`. Names starting with `--_` are internal.
|
|
111
66
|
|
|
112
67
|
```tsx
|
|
113
68
|
import { Button, type ThemeStyle } from '@cognitap/radiant'
|
|
114
69
|
|
|
115
70
|
const local: ThemeStyle = { '--rad-button-radius': '1rem' }
|
|
116
71
|
|
|
117
|
-
|
|
72
|
+
export function Save() {
|
|
73
|
+
return <Button style={local}>Save</Button>
|
|
74
|
+
}
|
|
118
75
|
```
|
|
119
76
|
|
|
120
|
-
Use `ThemeComponentOverrides` to type reusable override objects. Theme values
|
|
121
|
-
are inline custom properties, so a stylesheet rule on the same element cannot
|
|
122
|
-
override them; use `style`, or set the variable on a descendant. Caller classes
|
|
123
|
-
merge after the defaults. Variables starting with `--_` are internal.
|
|
124
|
-
|
|
125
|
-
Some defaults to know:
|
|
126
|
-
|
|
127
|
-
- Checkbox caps an inherited radius at a quarter of its size, so it stays a
|
|
128
|
-
box. An explicit `components.checkbox.radius` still wins.
|
|
129
|
-
- Radio stays circular under any control shape.
|
|
130
|
-
- Input, Textarea, Checkbox, Switch and Radio outlines mix border and foreground colors, so
|
|
131
|
-
controls have more contrast than passive dividers.
|
|
132
|
-
- Disabled opacity applies once, not again on a disabled child.
|
|
133
|
-
- A pressed Button mixes 20% of its text color into its fill, over
|
|
134
|
-
`control.selected` when the theme sets it. `components.button.selectedLayer`
|
|
135
|
-
sets the amount.
|
|
136
|
-
|
|
137
|
-
Restyling must keep components usable. See
|
|
138
|
-
[what customization must keep](architecture.md#what-customization-must-keep).
|
|
139
|
-
|
|
140
77
|
## Roles
|
|
141
78
|
|
|
142
|
-
|
|
143
|
-
component plays one **role**, and each role reads one token group, so one
|
|
144
|
-
setting restyles every family that plays it. Overrides stay for exceptions.
|
|
145
|
-
|
|
146
|
-
| Role | Token group | Parts |
|
|
147
|
-
| --------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
148
|
-
| Action | `control.action` | Button and the parts built on it, Link's button variants, ButtonGroup; the voice of tabs, chips and Table column headers |
|
|
149
|
-
| Field | `control.field` | Input, Textarea, NativeSelect, InputGroup, OTP slots, Select, Combobox and TagsInput |
|
|
150
|
-
| Indicator | `control.indicator` | Checkbox and Radio boxes, the Switch track, Switch and Slider thumbs |
|
|
151
|
-
| Track | `control.track` | ToggleGroup and Tabs lists, Progress, Meter, Skeleton, Slider and ScrollArea rails, Resizable hover, the Menubar border |
|
|
152
|
-
| Selected | `control.selected` | Pressed toggles, the ToggleGroup indicator, the selected tab, NavLink, the current page, Carousel indicator, chosen option, open menu |
|
|
153
|
-
| Surface | `surface` | Card, Alert, Collapsible, Accordion, TableContainer, EmptyState, CodeBlock, Carousel, Sidebar, Separator, Tabs content |
|
|
154
|
-
| Overlay | `surface.overlay*`, `surface.backdropFilter` | Popover, HoverCard, Menu, listboxes, Tooltip, Dialog, Drawer, NavigationMenu viewport; Toast's shadow |
|
|
155
|
-
| Item | `control.item` | Highlighted rows in menus, listboxes and Command |
|
|
79
|
+
Each part reads one token role.
|
|
156
80
|
|
|
157
|
-
|
|
158
|
-
|
|
81
|
+
| Role | Token group | Parts |
|
|
82
|
+
| --------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
83
|
+
| Action | `control.action` | `Button` and parts built on it, button-styled `Link`, `ButtonGroup`, and the typography of tabs and headers |
|
|
84
|
+
| Field | `control.field` | `Input`, `Textarea`, `NativeSelect`, `InputGroup`, `OTPField` slots, `Select`, `Combobox`, `TagsInput` |
|
|
85
|
+
| Indicator | `control.indicator` | `Checkbox` and `Radio` boxes, `Switch` track, `Switch` and `Slider` thumbs |
|
|
86
|
+
| Track | `control.track` | `ToggleGroup` and `Tabs` lists, `Progress`, `Meter`, `Skeleton`, `Slider` and `ScrollArea` rails, `Menubar` |
|
|
87
|
+
| Selected | `control.selected` | Pressed toggles, `ToggleGroup` indicator, active tab, `NavLink`, current page, chosen option, open menu |
|
|
88
|
+
| Surface | `surface` | `Card`, `Alert`, `Collapsible`, `Accordion`, `TableContainer`, `EmptyState`, `CodeBlock`, `Sidebar` |
|
|
89
|
+
| Overlay | `surface.overlay*`, `surface.backdropFilter` | `Popover`, `HoverCard`, `Menu`, listboxes, `Tooltip`, `Dialog`, `Drawer`, `NavigationMenu` viewport |
|
|
90
|
+
| Item | `control.item` | Highlighted rows in menus, listboxes, and `Command` |
|
|
159
91
|
|
|
160
|
-
|
|
161
|
-
Textarea, draw ScrollArea's `thumbColor` at 45% on a clear track. Forced colors
|
|
162
|
-
keep system scrollbars.
|
|
92
|
+
Shared geometry:
|
|
163
93
|
|
|
164
|
-
|
|
94
|
+
- Inset parts subtract their inset from the parent radius. Thin parts cap the radius at half their height. `Checkbox` caps it at a quarter of its size, and `Radio` stays circular.
|
|
95
|
+
- Buttons inside a field or chip (`NumberField` steppers, `PasswordInput` toggle, `Tag` remove) stay flat and inherit the field's typography.
|
|
96
|
+
- Keyboard focus reads the family's `focus*` overrides, then `tokens.focus`. Menu, listbox, and `Command` items show focus with the item highlight.
|
|
97
|
+
- Native scroll containers draw `ScrollArea`'s `thumbColor` at 45% opacity on a transparent track, and use system scrollbars under `forced-colors`.
|
|
165
98
|
|
|
166
|
-
|
|
167
|
-
radius minus the inset, and the parent's corner shape.
|
|
168
|
-
- **Capped corners.** Thin parts cap their radius at half their thickness, so
|
|
169
|
-
a large radius gives pills and `0px` gives bars. Only parts that are round
|
|
170
|
-
by meaning, such as Radio, always stay round.
|
|
171
|
-
- **One depth language.** `action.shadow`, `field.shadow`, `indicator.shadow`,
|
|
172
|
-
`track.shadow` and the surface shadows should read as one material: hard
|
|
173
|
-
offsets, bevels, glows or nothing.
|
|
174
|
-
- **One press.** `motion.pressScale`, `pressShiftX`, `pressShiftY` and
|
|
175
|
-
`hoverLift` move every pressable, and `action.radiusPressed` reshapes it.
|
|
176
|
-
- **Inline actions.** Buttons inside a field or chip, such as NumberField's
|
|
177
|
-
steppers, PasswordInput's toggle and Tag's remove, stay flat and take the
|
|
178
|
-
field's voice. A Select trigger is a field, not a Button.
|
|
179
|
-
- **Chips.** Badge, Tag, Kbd and Avatar take the control radius, corner shape
|
|
180
|
-
and border, capped at half their height. Avatar stays round unless the
|
|
181
|
-
control radius is `0px`.
|
|
182
|
-
- **One voice.** `action.fontFamily`, `fontWeight`, `textTransform` and
|
|
183
|
-
`letterSpacing` set how actions and Table column headers read. Labels and
|
|
184
|
-
values keep their roles.
|
|
185
|
-
- **One selection.** `control.selected` draws the chosen member of every set.
|
|
186
|
-
An underline is an inset bottom shadow on a transparent background.
|
|
99
|
+
## Presets
|
|
187
100
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
## Example themes and fonts
|
|
191
|
-
|
|
192
|
-
The core entry ships one theme, `defaultTheme`. The other presets are examples
|
|
193
|
-
to copy or start from, published separately at `@cognitap/radiant/examples`.
|
|
194
|
-
Its readonly `themes` registry lists them, each is a named export, and
|
|
195
|
-
`themeDefinitions` holds the definition behind each theme in the same order.
|
|
196
|
-
Pass a definition to `themeDocumentFromDefinition` to edit it as a document;
|
|
197
|
-
the theme workshop starts from these.
|
|
198
|
-
|
|
199
|
-
```tsx
|
|
200
|
-
import { jelly } from '@cognitap/radiant/examples'
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
| ID | Name | Export | Fonts | Language |
|
|
204
|
-
| --------------- | ------------- | --------------------- | -------------------------------------- | --------------------------------------------------- |
|
|
205
|
-
| `radiant` | Radiant | `radiant` | Inter | Calm product UI, raised white selection |
|
|
206
|
-
| `default` | Default | `defaultTheme` (core) | System sans | The neutral baseline |
|
|
207
|
-
| `soft-squircle` | Soft squircle | `soft` | Nunito | Squircles, filled wells, diffuse shadows |
|
|
208
|
-
| `sharp-3d` | Sharp 3D | `sharp` | System sans; Archivo Black for actions | Neo-brutalist ink outlines and hard offset shadows |
|
|
209
|
-
| `glass` | Glass | `glass` | Manrope | Frosted translucent layers over a gradient |
|
|
210
|
-
| `jelly` | Jelly | `jelly` | Baloo 2 | Clay bevels, pressed-in wells, springy presses |
|
|
211
|
-
| `ticket` | Ticket | `ticket` | Barlow Condensed | Notched controls, scooped dashed stubs, inked picks |
|
|
212
|
-
| `neon` | Neon | `neon` | IBM Plex Mono | Bevel-cut corners and glows on a grid |
|
|
213
|
-
| `editorial` | Editorial | `editorial` | Source Serif 4 | Serif on paper, hairlines, underlined selection |
|
|
214
|
-
|
|
215
|
-
Choosing a theme never downloads a font. Load the families yourself with weights
|
|
216
|
-
400, 600 and 700, and Archivo Black 400 for Sharp 3D. Every family falls back
|
|
217
|
-
to a system family.
|
|
218
|
-
|
|
219
|
-
Glass uses a gradient canvas and translucent surfaces, and
|
|
220
|
-
`surface.backdropFilter` frosts every floating panel. `surface.backdrop` paints
|
|
221
|
-
the overlay behind a dialog. Shapes use CSS `corner-shape`; browsers without it
|
|
222
|
-
show ordinary rounded corners.
|
|
101
|
+
`defaultTheme` ships in `@cognitap/radiant`. Example themes in `@cognitap/radiant/examples` are `radiant`, `soft`, `sharp`, `glass`, `jelly`, `ticket`, `neon`, and `editorial`, also collected in the `themes` and `themeDefinitions` arrays. Themes name font families and do not download them. Load those families in the app, or they fall back to system fonts.
|
|
223
102
|
|
|
224
103
|
## Typography
|
|
225
104
|
|
|
226
|
-
|
|
227
|
-
Headings, UI and Code fonts, 16 text styles, and separate prose and UI rhythms.
|
|
228
|
-
|
|
229
|
-
```tsx
|
|
230
|
-
import { ThemeScope, compileThemeDocument, defineThemeDocument } from '@cognitap/radiant'
|
|
231
|
-
|
|
232
|
-
const theme = compileThemeDocument(defineThemeDocument({
|
|
233
|
-
kind: 'radiant-theme', version: 1, id: 'publication', name: 'Publication',
|
|
234
|
-
sections: { typography: { typesetting: {
|
|
235
|
-
preset: 'source-serif',
|
|
236
|
-
prose: { paragraphSpacing: 1.4 },
|
|
237
|
-
styles: { 'prose-title': { weight: 650 } }
|
|
238
|
-
} } }
|
|
239
|
-
}))
|
|
240
|
-
|
|
241
|
-
<ThemeScope theme={theme}>
|
|
242
|
-
<article data-rad-prose="" data-rad-type-container="">
|
|
243
|
-
<h1>Title</h1>
|
|
244
|
-
<p data-rad-text="prose-lead">Lead paragraph.</p>
|
|
245
|
-
</article>
|
|
246
|
-
</ThemeScope>
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
`preset` is `inter` (default), `source-serif` or `plex`. Each of `fonts.body`,
|
|
250
|
-
`headings`, `ui` and `code` takes a CSS `family` and an optional `profile`
|
|
251
|
-
(`inter`, `source-serif-4`, `plex-sans`, `plex-mono` or `manual`). A profile is
|
|
252
|
-
your claim about the font; Radiant does not detect it.
|
|
253
|
-
|
|
254
|
-
| Setting | Range | Default |
|
|
255
|
-
| -------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------- |
|
|
256
|
-
| `prose.size` | 12–40px | Inter/Plex 20, Serif 21, manual 20 |
|
|
257
|
-
| `prose.lineHeight` | 1–3 | Inter/Plex 1.6, Serif/manual 1.65 |
|
|
258
|
-
| `prose.paragraphSpacing` | 0–4em | 1.25em |
|
|
259
|
-
| `prose.measure` | 20–120ch | Inter/manual 64, Serif/Plex 62 |
|
|
260
|
-
| `prose.headingScale` | 1.1–1.5 | 1.25 |
|
|
261
|
-
| `ui.size`, `ui.lineHeight` | 12–32px, 1–3 | 16px / 1.5 |
|
|
262
|
-
| `styles[role]` | `narrow` 8–256px, `wide` 8–512px, weight 1–1000, leading 0.8–3, tracking −0.2–0.5em, measure 0–120ch | From the preset |
|
|
263
|
-
|
|
264
|
-
Explicit `typography.values` override the recipe, and mode values override
|
|
265
|
-
both. Out-of-profile weights produce `warnings` rather than being clamped.
|
|
266
|
-
To reset a style, omit it and **replace** the typography section; a merge cannot
|
|
267
|
-
delete a key. `generateTypography` and the presets are also exported from the
|
|
268
|
-
React-free `@cognitap/radiant/typography` entry.
|
|
269
|
-
|
|
270
|
-
HTML hooks:
|
|
271
|
-
|
|
272
|
-
- `data-rad-text="<role>"` applies one of the 16 styles listed in
|
|
273
|
-
`typographyRoles`. It does not change heading levels or ARIA.
|
|
274
|
-
- `data-rad-prose` styles the container's **direct** headings, paragraphs,
|
|
275
|
-
lists, quotes and code blocks. `data-rad-not-prose` on a child opts it out.
|
|
276
|
-
- `data-rad-type-container` makes heading sizes scale with the column's width,
|
|
277
|
-
between 24rem and 56rem. Body and UI sizes stay fixed.
|
|
278
|
-
|
|
279
|
-
The hooks have low specificity, so utilities, your CSS and inline styles win.
|
|
280
|
-
Load real italic and bold faces; synthetic styles are turned off.
|
|
281
|
-
|
|
282
|
-
Components use the UI roles:
|
|
283
|
-
|
|
284
|
-
| Text | Role |
|
|
285
|
-
| --------------------------------------------------------------------------- | ------------------------- |
|
|
286
|
-
| ThemeScope, Card, DialogContent, Field, disclosure body | `ui-body` |
|
|
287
|
-
| CardTitle, DialogTitle | `ui-title` |
|
|
288
|
-
| Field label, disclosure triggers, Button, Checkbox, Switch and Radio labels | `ui-label` |
|
|
289
|
-
| Input, Textarea | `ui-body` |
|
|
290
|
-
| Field help and error, CardDescription, DialogDescription | `ui-supporting` |
|
|
291
|
-
| Inline Link | Inherits surrounding text |
|
|
292
|
-
|
|
293
|
-
Controls keep their own font size from `control.<size>.fontSize`, so changing
|
|
294
|
-
the UI role size does not resize buttons or inputs.
|
|
295
|
-
|
|
296
|
-
## Colors
|
|
297
|
-
|
|
298
|
-
`generateColorWall` builds 18 palettes of 11 shades (50–950) from one brand
|
|
299
|
-
color. `recommendColorPalette` picks a working set from that wall, maps it to
|
|
300
|
-
light and dark color roles, and reports contrast checks. Both are pure,
|
|
301
|
-
deterministic and exported from the React-free `@cognitap/radiant/color` entry.
|
|
302
|
-
|
|
303
|
-
```ts
|
|
304
|
-
import { generateColorWall, recommendColorPalette } from '@cognitap/radiant/color'
|
|
305
|
-
import { updateThemeAppearance, compileThemeDocument } from '@cognitap/radiant'
|
|
306
|
-
|
|
307
|
-
const wall = generateColorWall({ brand: '#7C3AED', wallPreset: 'expressive' })
|
|
308
|
-
const palette = recommendColorPalette(wall, { working: { support: 'teal' } })
|
|
309
|
-
const failures = palette.checks.filter(check => check.pass === false)
|
|
310
|
-
|
|
311
|
-
const theme = compileThemeDocument(
|
|
312
|
-
updateThemeAppearance(document, {
|
|
313
|
-
palette,
|
|
314
|
-
geometry: { values: { spacing: 1.25, controlRadius: 8 } }
|
|
315
|
-
})
|
|
316
|
-
)
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
| Wall input | Default | Range |
|
|
320
|
-
| ---------------- | ----------- | --------------------------------------------------- |
|
|
321
|
-
| `brand` | Required | Six-digit sRGB hex |
|
|
322
|
-
| `fidelity` | `anchored` | `anchored` keeps the exact brand color as one shade |
|
|
323
|
-
| `wallPreset` | `balanced` | `classic`, `balanced`, `expressive` |
|
|
324
|
-
| `rampPreset` | `balanced` | Same values, for the brand palette only |
|
|
325
|
-
| `vividness` | From preset | 0–1, other palettes |
|
|
326
|
-
| `brandVividness` | From preset | 0–1, brand palette |
|
|
327
|
-
| `lightness` | `hue-aware` | `hue-aware` or `shared` |
|
|
328
|
-
| `distribution` | `1` | 0.75–1.35 |
|
|
329
|
-
| `neutralTint` | From preset | 0–0.035 |
|
|
330
|
-
| `hueAlignment` | From preset | 0–1 |
|
|
331
|
-
| `neutralHue` | `255` | Degrees, used when the brand is nearly gray |
|
|
332
|
-
|
|
333
|
-
`wall.input` holds every effective setting, so passing it back reproduces the
|
|
334
|
-
same wall.
|
|
335
|
-
|
|
336
|
-
By default the working set is Brand (primary), the family nearest the brand
|
|
337
|
-
hue plus 150° (support), Neutral, Emerald (success), Amber (warning) and Red
|
|
338
|
-
(danger). Text must reach 4.5:1 against its background. Borders, focus rings and
|
|
339
|
-
the checked fill must reach 3:1. Disabled pairs are reported but not
|
|
340
|
-
required to pass. The checks cover these base pairs only. Recheck gradients,
|
|
341
|
-
translucency and overrides in the browser.
|
|
342
|
-
|
|
343
|
-
`updateThemeAppearance` applies a palette and geometry together without
|
|
344
|
-
touching component overrides:
|
|
345
|
-
|
|
346
|
-
| Geometry | Range | Changes |
|
|
347
|
-
| ------------------------------------------ | --------------------------- | ------------------------------------------ |
|
|
348
|
-
| `spacing` | 0.5–2 | All spacing gaps, surface padding and gap |
|
|
349
|
-
| `density` | 0.75–1.5 | Control height, padding and indicator size |
|
|
350
|
-
| `controlRadius` | 0–32px | Control radius |
|
|
351
|
-
| `surfaceRadius` | 0–48px | Card, Dialog and Collapsible radius |
|
|
352
|
-
| `controlBorderWidth`, `surfaceBorderWidth` | 0–4px | Border widths |
|
|
353
|
-
| `borderStyle` | `solid`, `dashed`, `dotted` | Control and surface borders |
|
|
354
|
-
| `elevation` | 0–3 | Surface and overlay shadows |
|
|
355
|
-
| `backdropOpacity` | 0–0.9 | Modal overlay |
|
|
356
|
-
|
|
357
|
-
Scales apply to the baseline, so applying `spacing: 1.25` twice gives the same
|
|
358
|
-
result. Values out of range throw instead of being clamped.
|
|
359
|
-
|
|
360
|
-
## Theme documents
|
|
361
|
-
|
|
362
|
-
`ThemeDocument` is the editable, versioned form of a theme, used by the docs
|
|
363
|
-
site's theme workshop. It keeps the authored values plus metadata such as
|
|
364
|
-
palettes and font descriptors. `compileThemeDocument` turns it into a `Theme`
|
|
365
|
-
for `ThemeScope`.
|
|
366
|
-
|
|
367
|
-
| Function | Does |
|
|
368
|
-
| ----------------------------------------------- | --------------------------------------------------------------- |
|
|
369
|
-
| `themeDocumentFromDefinition(definition)` | Wraps a `defineTheme` input, keeping only explicit values |
|
|
370
|
-
| `updateThemeDocument(doc, sections)` | Deep-merges the given sections; arrays are replaced whole |
|
|
371
|
-
| `updateThemeDocument(doc, sections, 'replace')` | Replaces each given section; `{ color: {} }` resets color |
|
|
372
|
-
| `exportThemeSections(doc, ['color'])` | Exports chosen sections without the theme's identity |
|
|
373
|
-
| `parseThemeDocument(json)` | Validates a full document or a section export from `JSON.parse` |
|
|
374
|
-
|
|
375
|
-
Sections match the token groups plus `components`. Updating a section never
|
|
376
|
-
touches `components`, so per-component exceptions survive. Font descriptors
|
|
377
|
-
record requirements only; your application loads the fonts. Parsing rejects
|
|
378
|
-
unknown fields and unsupported versions with the failing path.
|
|
105
|
+
`@cognitap/radiant/typography`, also exported from the root, compiles a typesetting preset (`'inter'`, `'source-serif'`, or `'plex'`) into 16 text roles (`typographyRoles`) and prose and UI flow variables. Set it at `sections.typography.typesetting`, with `prose` and `styles` overrides, and compile the document.
|
|
379
106
|
|
|
380
|
-
|
|
107
|
+
| Attribute | Effect |
|
|
108
|
+
| ------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
109
|
+
| `data-rad-text="<role>"` | Sets one text role. The element keeps its own semantics |
|
|
110
|
+
| `data-rad-prose` | Styles direct child headings, paragraphs, lists, blockquotes, and code. `data-rad-not-prose` opts a child out |
|
|
111
|
+
| `data-rad-type-container` | Heading sizes scale with container width from `24rem` to `56rem` |
|
|
381
112
|
|
|
382
|
-
|
|
383
|
-
[`src/themes/tokens.ts`](../src/themes/tokens.ts). `surface.canvas` and
|
|
384
|
-
`surface.backdrop` accept any CSS background, including gradients.
|
|
113
|
+
## Color
|
|
385
114
|
|
|
386
|
-
|
|
387
|
-
| ----------------------------------- | ------------------------------------ | ------------------------------------ |
|
|
388
|
-
| `color.surface` | `oklch(1 0 0)` | `oklch(0.21 0.006 286)` |
|
|
389
|
-
| `color.foreground` | `oklch(0.21 0.006 286)` | `oklch(0.985 0 0)` |
|
|
390
|
-
| `color.mutedForeground` | `oklch(0.45 0.01 286)` | `oklch(0.75 0.01 286)` |
|
|
391
|
-
| `color.border` | `oklch(0.885 0.005 286)` | `oklch(0.4 0.008 286)` |
|
|
392
|
-
| `color.placeholder` | `oklch(0.5 0.01 286)` | `oklch(0.7 0.01 286)` |
|
|
393
|
-
| `color.disabledBackground` | `oklch(0.96 0.005 286)` | `oklch(0.26 0.006 286)` |
|
|
394
|
-
| `color.disabledBorder` | `oklch(0.88 0.005 286)` | `oklch(0.38 0.006 286)` |
|
|
395
|
-
| `color.invalid` | `oklch(0.56 0.19 25)` | `oklch(0.75 0.16 25)` |
|
|
396
|
-
| `color.focus` | `oklch(0.55 0.13 255)` | `oklch(0.75 0.13 255)` |
|
|
397
|
-
| `color.accent` | `oklch(0.21 0.006 286)` | `oklch(0.92 0.005 286)` |
|
|
398
|
-
| `color.accentForeground` | `oklch(0.985 0 0)` | `oklch(0.21 0.006 286)` |
|
|
399
|
-
| `color.neutral` | `oklch(0.955 0.004 286)` | `oklch(0.3 0.006 286)` |
|
|
400
|
-
| `color.neutralForeground` | `oklch(0.21 0.006 286)` | `oklch(0.985 0 0)` |
|
|
401
|
-
| `color.warning` | `oklch(0.8 0.14 78)` | Same |
|
|
402
|
-
| `color.warningForeground` | `oklch(0.3 0.07 55)` | Same |
|
|
403
|
-
| `color.danger` | `oklch(0.56 0.19 25)` | `oklch(0.72 0.17 25)` |
|
|
404
|
-
| `color.dangerForeground` | `oklch(0.99 0 0)` | `oklch(0.2 0.04 25)` |
|
|
405
|
-
| `typography.family` | `system-ui, sans-serif` | Same |
|
|
406
|
-
| `typography.bodySize` | `0.875rem` | Same |
|
|
407
|
-
| `typography.smallSize` | `0.8125rem` | Same |
|
|
408
|
-
| `typography.headingSize` | `1.125rem` | Same |
|
|
409
|
-
| `typography.bodyWeight` | `400` | Same |
|
|
410
|
-
| `typography.labelWeight` | `550` | Same |
|
|
411
|
-
| `typography.headingWeight` | `600` | Same |
|
|
412
|
-
| `typography.letterSpacing` | `-0.011em` | Same |
|
|
413
|
-
| `control.small.height` | `2rem` | Same |
|
|
414
|
-
| `control.small.paddingInline` | `0.75rem` | Same |
|
|
415
|
-
| `control.small.fontSize` | `0.8125rem` | Same |
|
|
416
|
-
| `control.small.indicatorSize` | `1rem` | Same |
|
|
417
|
-
| `control.medium.height` | `2.5rem` | Same |
|
|
418
|
-
| `control.medium.paddingInline` | `1rem` | Same |
|
|
419
|
-
| `control.medium.fontSize` | `0.875rem` | Same |
|
|
420
|
-
| `control.medium.indicatorSize` | `1.125rem` | Same |
|
|
421
|
-
| `control.large.height` | `3rem` | Same |
|
|
422
|
-
| `control.large.paddingInline` | `1.375rem` | Same |
|
|
423
|
-
| `control.large.fontSize` | `0.9375rem` | Same |
|
|
424
|
-
| `control.large.indicatorSize` | `1.25rem` | Same |
|
|
425
|
-
| `control.radius` | `0.5rem` | Same |
|
|
426
|
-
| `control.cornerShape` | `round` | Same |
|
|
427
|
-
| `control.borderWidth` | `1px` | Same |
|
|
428
|
-
| `control.borderStyle` | `solid` | Same |
|
|
429
|
-
| `control.action.fontFamily` | UI label family | Same |
|
|
430
|
-
| `control.action.fontWeight` | UI label weight | Same |
|
|
431
|
-
| `control.action.textTransform` | `none` | Same |
|
|
432
|
-
| `control.action.letterSpacing` | UI label tracking | Same |
|
|
433
|
-
| `control.action.borderColor` | Unset: each variant's edge | Same |
|
|
434
|
-
| `control.action.shadow` | `0 1px 2px 0 rgb(0 0 0 / 0.06)` | Same |
|
|
435
|
-
| `control.action.shadowPressed` | `0 1px 2px 0 rgb(0 0 0 / 0.06)` | Same |
|
|
436
|
-
| `control.action.highlight` | `0` (0–1) | Same |
|
|
437
|
-
| `control.action.sheen` | `0` (0–1) | Same |
|
|
438
|
-
| `control.action.radiusPressed` | Unset: keeps the rest radius | Same |
|
|
439
|
-
| `control.action.cornerShapePressed` | Unset: keeps the rest shape | Same |
|
|
440
|
-
| `control.field.background` | `color.surface` | Same |
|
|
441
|
-
| `control.field.borderColor` | Unset: the control outline | Same |
|
|
442
|
-
| `control.field.shadow` | `none` | Same |
|
|
443
|
-
| `control.field.backdropFilter` | `none` | Same |
|
|
444
|
-
| `control.indicator.shadow` | `none` | Same |
|
|
445
|
-
| `control.indicator.checkedShadow` | `none` | Same |
|
|
446
|
-
| `control.indicator.thumbShadow` | `none` | Same |
|
|
447
|
-
| `control.track.background` | Unset: each track's own fill | Same |
|
|
448
|
-
| `control.track.borderWidth` | Unset: each track's own edge | Same |
|
|
449
|
-
| `control.track.shadow` | `none` | Same |
|
|
450
|
-
| `control.selected.background` | Unset | Same |
|
|
451
|
-
| `control.selected.foreground` | Unset | Same |
|
|
452
|
-
| `control.selected.borderColor` | Unset | Same |
|
|
453
|
-
| `control.selected.shadow` | Unset | Same |
|
|
454
|
-
| `control.item.highlightBackground` | Unset | Same |
|
|
455
|
-
| `control.item.highlightForeground` | Unset | Same |
|
|
456
|
-
| `surface.canvas` | `oklch(1 0 0)` | `oklch(0.16 0.006 286)` |
|
|
457
|
-
| `surface.radius` | `0.75rem` | Same |
|
|
458
|
-
| `surface.cornerShape` | `round` | Same |
|
|
459
|
-
| `surface.borderWidth` | `1px` | Same |
|
|
460
|
-
| `surface.borderStyle` | `solid` | Same |
|
|
461
|
-
| `surface.padding` | `1.5rem` | Same |
|
|
462
|
-
| `surface.gap` | `1rem` | Same |
|
|
463
|
-
| `surface.shadow` | `0 1px 2px 0 rgb(0 0 0 / 0.06)` | `0 1px 2px 0 rgb(0 0 0 / 0.25)` |
|
|
464
|
-
| `surface.overlayShadow` | `0 24px 64px -16px rgb(0 0 0 / 0.3)` | `0 24px 64px -16px rgb(0 0 0 / 0.6)` |
|
|
465
|
-
| `surface.backdrop` | `rgb(0 0 0 / 0.45)` | `rgb(0 0 0 / 0.65)` |
|
|
466
|
-
| `surface.backdropFilter` | `none` | Same |
|
|
467
|
-
| `surface.overlayBackground` | `color.surface` | Same |
|
|
468
|
-
| `focus.width` | `2px` | Same |
|
|
469
|
-
| `focus.offset` | `2px` | Same |
|
|
470
|
-
| `focus.style` | `solid` | Same |
|
|
471
|
-
| `motion.pressDuration` | `80ms` | Same |
|
|
472
|
-
| `motion.pressEase` | `cubic-bezier(0.3, 0, 0, 1)` | Same |
|
|
473
|
-
| `motion.releaseDuration` | `160ms` | Same |
|
|
474
|
-
| `motion.releaseEase` | `cubic-bezier(0.2, 0.8, 0.2, 1)` | Same |
|
|
475
|
-
| `motion.colorDuration` | `150ms` | Same |
|
|
476
|
-
| `motion.disclosureDuration` | `150ms` | Same |
|
|
477
|
-
| `motion.pressScale` | `0.97` | Same |
|
|
478
|
-
| `motion.pressShiftX` | `0px` | Same |
|
|
479
|
-
| `motion.pressShiftY` | `0px` | Same |
|
|
480
|
-
| `motion.hoverLift` | `0px` | Same |
|
|
481
|
-
| `spacing.labelGap` | `0.5rem` | Same |
|
|
482
|
-
| `spacing.fieldGap` | `0.375rem` | Same |
|
|
483
|
-
| `spacing.groupGap` | `0.75rem` | Same |
|
|
484
|
-
| `spacing.headerGap` | `0.375rem` | Same |
|
|
485
|
-
| `spacing.footerGap` | `0.5rem` | Same |
|
|
486
|
-
| `state.disabledOpacity` | `0.5` | Same |
|
|
115
|
+
`@cognitap/radiant/color` exports two pure functions:
|
|
487
116
|
|
|
488
|
-
|
|
489
|
-
|
|
117
|
+
- `generateColorWall({ brand, wallPreset })` builds 18 palettes of 11 shades (`50` to `950`) from a six-digit hex brand color.
|
|
118
|
+
- `recommendColorPalette(wall, options)` maps `brand`, `support`, `neutral`, `success`, `warning`, and `danger` to light and dark color tokens. `checks` require 4.5:1 for text and 3:1 for borders, focus rings, and checked fills.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cognitap/radiant",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.79",
|
|
4
4
|
"description": "React interaction components and presentation primitives",
|
|
5
5
|
"homepage": "https://radiant-docs.pages.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -37,8 +37,14 @@
|
|
|
37
37
|
"types": "./dist/library/index.d.ts",
|
|
38
38
|
"default": "./dist/library/index.js"
|
|
39
39
|
},
|
|
40
|
-
"./styles.css":
|
|
41
|
-
|
|
40
|
+
"./styles.css": {
|
|
41
|
+
"types": "./src/css.d.ts",
|
|
42
|
+
"default": "./dist/library/styles.css"
|
|
43
|
+
},
|
|
44
|
+
"./reset.css": {
|
|
45
|
+
"types": "./src/css.d.ts",
|
|
46
|
+
"default": "./dist/library/reset.css"
|
|
47
|
+
},
|
|
42
48
|
"./tailwind.css": "./src/styles.css",
|
|
43
49
|
"./color": {
|
|
44
50
|
"types": "./dist/library/color/index.d.ts",
|
|
@@ -76,6 +82,7 @@
|
|
|
76
82
|
"motion": "14.7.1"
|
|
77
83
|
},
|
|
78
84
|
"devDependencies": {
|
|
85
|
+
"@cognitap/galactica": "0.2.3",
|
|
79
86
|
"@storybook/addon-a11y": "10.6.1",
|
|
80
87
|
"@storybook/addon-docs": "10.6.1",
|
|
81
88
|
"@storybook/addon-vitest": "10.6.1",
|
|
@@ -103,6 +110,7 @@
|
|
|
103
110
|
},
|
|
104
111
|
"peerDependencies": {
|
|
105
112
|
"react": "^19.3.0",
|
|
113
|
+
"react-dom": "^19.3.0",
|
|
106
114
|
"tailwindcss": "^4.3.3"
|
|
107
115
|
},
|
|
108
116
|
"peerDependenciesMeta": {
|
|
@@ -121,25 +129,25 @@
|
|
|
121
129
|
"storybook": "pnpm theme:generate && storybook dev --host 127.0.0.1 --port 6006 --no-open --disable-telemetry",
|
|
122
130
|
"build": "rimraf dist/library && pnpm build:js && pnpm build:css",
|
|
123
131
|
"build:js": "tsc -p tsconfig.build.json",
|
|
124
|
-
"build:css": "pnpm theme:generate && tailwindcss -i styles/library.css -o dist/library/styles.css --minify && tailwindcss -i styles/reset.css -o dist/library/reset.css --minify && node scripts/preserve-css-layer-order.
|
|
132
|
+
"build:css": "pnpm theme:generate && tailwindcss -i styles/library.css -o dist/library/styles.css --minify && tailwindcss -i styles/reset.css -o dist/library/reset.css --minify && node scripts/preserve-css-layer-order.ts",
|
|
125
133
|
"watch": "pnpm run --parallel '/^watch:/'",
|
|
126
134
|
"watch:js": "tsc -p tsconfig.build.json --watch --preserveWatchOutput",
|
|
127
135
|
"watch:styles": "pnpm theme:generate && tailwindcss -i styles/library.css -o dist/library/styles.css --watch=always",
|
|
128
136
|
"build:storybook": "pnpm theme:generate && storybook build --output-dir dist/storybook --disable-telemetry",
|
|
129
137
|
"test": "pnpm build && node --test tests/*.test.mjs && node scripts/pack-and-test.ts",
|
|
130
138
|
"test:package": "pnpm build && node scripts/pack-and-test.ts",
|
|
131
|
-
"typecheck": "pnpm build:js && tsc --noEmit
|
|
132
|
-
"typecheck:contracts": "tsc -p docs/contracts/tsconfig.json",
|
|
139
|
+
"typecheck": "pnpm build:js && tsc --noEmit",
|
|
133
140
|
"lint": "oxlint --deny-warnings",
|
|
134
141
|
"format": "oxfmt",
|
|
135
142
|
"format:check": "oxfmt --check",
|
|
136
|
-
"check
|
|
137
|
-
"
|
|
138
|
-
"check": "pnpm check:
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
"theme:
|
|
142
|
-
"
|
|
143
|
+
"docs:check": "node scripts/check-docs.ts",
|
|
144
|
+
"check": "pnpm check:library && pnpm check:storybook",
|
|
145
|
+
"check:library": "pnpm theme:check && pnpm format:check && pnpm lint && pnpm build && tsc --noEmit && pnpm docs:check && node --test tests/*.test.mjs && node scripts/pack-and-test.ts",
|
|
146
|
+
"check:storybook": "pnpm build:storybook && pnpm test:browser --project=storybook-radiant-light --project=storybook-radiant-dark",
|
|
147
|
+
"release:prepare": "node scripts/prepare-release.ts",
|
|
148
|
+
"theme:generate": "node scripts/generate-theme-css.ts",
|
|
149
|
+
"theme:check": "node scripts/generate-theme-css.ts --check",
|
|
150
|
+
"watch:theme": "node scripts/generate-theme-css.ts --watch",
|
|
143
151
|
"test:browser": "pnpm theme:generate && vitest run"
|
|
144
152
|
}
|
|
145
153
|
}
|