@panneau/ui 5.0.0-alpha.1 → 5.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +263 -6
- package/bin/check-theme.js +5 -0
- package/dist/alert/Alert.css +28 -42
- package/dist/alert/Alert.d.ts +18 -4
- package/dist/alert/Alert.d.ts.map +1 -1
- package/dist/alert/Alert.js +4 -3
- package/dist/alert/Alert.js.map +1 -1
- package/dist/alert/Alert.module.js +14 -16
- package/dist/alert/Alert.module.js.map +1 -1
- package/dist/alert/tokens.d.ts +3 -0
- package/dist/alert/tokens.d.ts.map +1 -0
- package/dist/alert/tokens.js +21 -0
- package/dist/alert/tokens.js.map +1 -0
- package/dist/badge/Badge.css +24 -36
- package/dist/badge/Badge.d.ts +18 -3
- package/dist/badge/Badge.d.ts.map +1 -1
- package/dist/badge/Badge.js +3 -2
- package/dist/badge/Badge.js.map +1 -1
- package/dist/badge/Badge.module.js +9 -13
- package/dist/badge/Badge.module.js.map +1 -1
- package/dist/badge/tokens.d.ts +3 -0
- package/dist/badge/tokens.d.ts.map +1 -0
- package/dist/badge/tokens.js +23 -0
- package/dist/badge/tokens.js.map +1 -0
- package/dist/button/Button.css +58 -42
- package/dist/button/Button.d.ts +30 -3
- package/dist/button/Button.d.ts.map +1 -1
- package/dist/button/Button.js +27 -2
- package/dist/button/Button.js.map +1 -1
- package/dist/button/Button.module.js +14 -14
- package/dist/button/Button.module.js.map +1 -1
- package/dist/button/tokens.d.ts +3 -0
- package/dist/button/tokens.d.ts.map +1 -0
- package/dist/button/tokens.js +25 -0
- package/dist/button/tokens.js.map +1 -0
- package/dist/card/Card.css +27 -20
- package/dist/card/Card.js +1 -1
- package/dist/card/Card.js.map +1 -1
- package/dist/card/Card.module.js +5 -5
- package/dist/card/Card.module.js.map +1 -1
- package/dist/card/tokens.d.ts +3 -0
- package/dist/card/tokens.d.ts.map +1 -0
- package/dist/card/tokens.js +31 -0
- package/dist/card/tokens.js.map +1 -0
- package/dist/checkbox/Checkbox.css +22 -21
- package/dist/checkbox/Checkbox.d.ts.map +1 -1
- package/dist/checkbox/Checkbox.js +1 -0
- package/dist/checkbox/Checkbox.js.map +1 -1
- package/dist/checkbox/Checkbox.module.js +4 -4
- package/dist/checkbox/Checkbox.module.js.map +1 -1
- package/dist/checkbox/ChoiceChrome.d.ts +3 -1
- package/dist/checkbox/ChoiceChrome.d.ts.map +1 -1
- package/dist/checkbox/ChoiceChrome.js +2 -2
- package/dist/checkbox/ChoiceChrome.js.map +1 -1
- package/dist/checkbox/tokens.d.ts +3 -0
- package/dist/checkbox/tokens.d.ts.map +1 -0
- package/dist/checkbox/tokens.js +21 -0
- package/dist/checkbox/tokens.js.map +1 -0
- package/dist/combo-box/ComboBox.css +4 -4
- package/dist/combo-box/ComboBox.js +1 -1
- package/dist/combo-box/ComboBox.js.map +1 -1
- package/dist/combo-box/ComboBox.module.js +3 -3
- package/dist/container/Container.css +32 -0
- package/dist/container/Container.d.ts +15 -0
- package/dist/container/Container.d.ts.map +1 -0
- package/dist/container/Container.js +18 -0
- package/dist/container/Container.js.map +1 -0
- package/dist/container/Container.module.js +20 -0
- package/dist/container/Container.module.js.map +1 -0
- package/dist/container/tokens.d.ts +3 -0
- package/dist/container/tokens.d.ts.map +1 -0
- package/dist/container/tokens.js +19 -0
- package/dist/container/tokens.js.map +1 -0
- package/dist/date-picker/DatePicker.css +30 -30
- package/dist/date-picker/DatePicker.js +1 -1
- package/dist/date-picker/DatePicker.js.map +1 -1
- package/dist/date-picker/DatePicker.module.js +11 -11
- package/dist/date-picker/DatePicker.module.js.map +1 -1
- package/dist/date-picker/calendarTokens.d.ts +3 -0
- package/dist/date-picker/calendarTokens.d.ts.map +1 -0
- package/dist/date-picker/calendarTokens.js +17 -0
- package/dist/date-picker/calendarTokens.js.map +1 -0
- package/dist/dialog/Dialog.css +40 -36
- package/dist/dialog/Dialog.js +1 -1
- package/dist/dialog/Dialog.js.map +1 -1
- package/dist/dialog/Dialog.module.js +11 -11
- package/dist/dialog/Dialog.module.js.map +1 -1
- package/dist/dialog/tokens.d.ts +3 -0
- package/dist/dialog/tokens.d.ts.map +1 -0
- package/dist/dialog/tokens.js +29 -0
- package/dist/dialog/tokens.js.map +1 -0
- package/dist/disclosure/Disclosure.css +12 -12
- package/dist/disclosure/Disclosure.d.ts.map +1 -1
- package/dist/disclosure/Disclosure.js +1 -1
- package/dist/disclosure/Disclosure.js.map +1 -1
- package/dist/disclosure/Disclosure.module.js +7 -7
- package/dist/disclosure/Disclosure.module.js.map +1 -1
- package/dist/disclosure/tokens.d.ts +3 -0
- package/dist/disclosure/tokens.d.ts.map +1 -0
- package/dist/disclosure/tokens.js +15 -0
- package/dist/disclosure/tokens.js.map +1 -0
- package/dist/divider/Divider.css +17 -0
- package/dist/divider/Divider.d.ts +8 -0
- package/dist/divider/Divider.d.ts.map +1 -0
- package/dist/divider/Divider.js +21 -0
- package/dist/divider/Divider.js.map +1 -0
- package/dist/divider/Divider.module.js +12 -0
- package/dist/divider/Divider.module.js.map +1 -0
- package/dist/divider/tokens.d.ts +3 -0
- package/dist/divider/tokens.d.ts.map +1 -0
- package/dist/divider/tokens.js +13 -0
- package/dist/divider/tokens.js.map +1 -0
- package/dist/field/Field.css +40 -37
- package/dist/field/Field.module.js +11 -11
- package/dist/field/Field.module.js.map +1 -1
- package/dist/field/Fieldset.js +1 -1
- package/dist/field/Fieldset.js.map +1 -1
- package/dist/field/inputTokens.d.ts +3 -0
- package/dist/field/inputTokens.d.ts.map +1 -0
- package/dist/field/inputTokens.js +21 -0
- package/dist/field/inputTokens.js.map +1 -0
- package/dist/field/tokens.d.ts +3 -0
- package/dist/field/tokens.d.ts.map +1 -0
- package/dist/field/tokens.js +15 -0
- package/dist/field/tokens.js.map +1 -0
- package/dist/grid/Grid.css +174 -0
- package/dist/grid/Grid.d.ts +28 -0
- package/dist/grid/Grid.d.ts.map +1 -0
- package/dist/grid/Grid.js +31 -0
- package/dist/grid/Grid.js.map +1 -0
- package/dist/grid/Grid.module.js +12 -0
- package/dist/grid/Grid.module.js.map +1 -0
- package/dist/grid/GridItem.css +59 -0
- package/dist/grid/GridItem.module.js +7 -0
- package/dist/grid/GridItem.module.js.map +1 -0
- package/dist/grid/tokens.d.ts +3 -0
- package/dist/grid/tokens.d.ts.map +1 -0
- package/dist/grid/tokens.js +10 -0
- package/dist/grid/tokens.js.map +1 -0
- package/dist/heading/Heading.css +52 -0
- package/dist/heading/Heading.d.ts +17 -0
- package/dist/heading/Heading.d.ts.map +1 -0
- package/dist/heading/Heading.js +17 -0
- package/dist/heading/Heading.js.map +1 -0
- package/dist/heading/Heading.module.js +16 -0
- package/dist/heading/Heading.module.js.map +1 -0
- package/dist/heading/tokens.d.ts +6 -0
- package/dist/heading/tokens.d.ts.map +1 -0
- package/dist/heading/tokens.js +66 -0
- package/dist/heading/tokens.js.map +1 -0
- package/dist/icon/Icon.css +1 -1
- package/dist/icon/Icon.js +1 -1
- package/dist/icon/Icon.js.map +1 -1
- package/dist/icon/Icon.module.js +1 -1
- package/dist/icon-button/IconButton.css +2 -2
- package/dist/icon-button/IconButton.d.ts +1 -1
- package/dist/icon-button/IconButton.d.ts.map +1 -1
- package/dist/icon-button/IconButton.js +3 -3
- package/dist/icon-button/IconButton.js.map +1 -1
- package/dist/icon-button/IconButton.module.js +2 -2
- package/dist/index.d.ts +25 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -2
- package/dist/inline/Inline.css +142 -0
- package/dist/inline/Inline.d.ts +17 -0
- package/dist/inline/Inline.d.ts.map +1 -0
- package/dist/inline/Inline.js +21 -0
- package/dist/inline/Inline.js.map +1 -0
- package/dist/inline/Inline.module.js +12 -0
- package/dist/inline/Inline.module.js.map +1 -0
- package/dist/inline/tokens.d.ts +3 -0
- package/dist/inline/tokens.d.ts.map +1 -0
- package/dist/inline/tokens.js +10 -0
- package/dist/inline/tokens.js.map +1 -0
- package/dist/layout/responsive.d.ts +38 -0
- package/dist/layout/responsive.d.ts.map +1 -0
- package/dist/layout/responsive.js +49 -0
- package/dist/layout/responsive.js.map +1 -0
- package/dist/menu/Menu.js +2 -2
- package/dist/menu/Menu.js.map +1 -1
- package/dist/number-input/NumberInput.css +12 -12
- package/dist/number-input/NumberInput.js +1 -1
- package/dist/number-input/NumberInput.js.map +1 -1
- package/dist/number-input/NumberInput.module.js +4 -4
- package/dist/number-input/NumberInput.module.js.map +1 -1
- package/dist/number-input/tokens.d.ts +3 -0
- package/dist/number-input/tokens.d.ts.map +1 -0
- package/dist/number-input/tokens.js +10 -0
- package/dist/number-input/tokens.js.map +1 -0
- package/dist/popover/Popover.css +13 -12
- package/dist/popover/Popover.js +2 -2
- package/dist/popover/Popover.js.map +1 -1
- package/dist/popover/Popover.module.js +3 -3
- package/dist/popover/Popover.module.js.map +1 -1
- package/dist/popover/tokens.d.ts +3 -0
- package/dist/popover/tokens.d.ts.map +1 -0
- package/dist/popover/tokens.js +19 -0
- package/dist/popover/tokens.js.map +1 -0
- package/dist/prose/Prose.css +141 -0
- package/dist/prose/Prose.d.ts +11 -0
- package/dist/prose/Prose.d.ts.map +1 -0
- package/dist/prose/Prose.js +18 -0
- package/dist/prose/Prose.js.map +1 -0
- package/dist/prose/Prose.module.js +8 -0
- package/dist/prose/Prose.module.js.map +1 -0
- package/dist/prose/tokens.d.ts +3 -0
- package/dist/prose/tokens.d.ts.map +1 -0
- package/dist/prose/tokens.js +33 -0
- package/dist/prose/tokens.js.map +1 -0
- package/dist/radio-group/RadioGroup.css +21 -20
- package/dist/radio-group/RadioGroup.d.ts.map +1 -1
- package/dist/radio-group/RadioGroup.js +2 -2
- package/dist/radio-group/RadioGroup.js.map +1 -1
- package/dist/radio-group/RadioGroup.module.js +6 -6
- package/dist/radio-group/RadioGroup.module.js.map +1 -1
- package/dist/radio-group/tokens.d.ts +3 -0
- package/dist/radio-group/tokens.d.ts.map +1 -0
- package/dist/radio-group/tokens.js +19 -0
- package/dist/radio-group/tokens.js.map +1 -0
- package/dist/root/PanneauRoot.css +243 -20
- package/dist/root/PanneauRoot.d.ts +28 -4
- package/dist/root/PanneauRoot.d.ts.map +1 -1
- package/dist/root/PanneauRoot.js +104 -21
- package/dist/root/PanneauRoot.js.map +1 -1
- package/dist/root/PanneauRoot.module.js +11 -3
- package/dist/root/PanneauRoot.module.js.map +1 -1
- package/dist/root/ThemeScope.d.ts +24 -0
- package/dist/root/ThemeScope.d.ts.map +1 -0
- package/dist/root/ThemeScope.js +49 -0
- package/dist/root/ThemeScope.js.map +1 -0
- package/dist/select/ListBox.css +23 -22
- package/dist/select/ListBox.module.js +12 -12
- package/dist/select/ListBox.module.js.map +1 -1
- package/dist/select/Select.js +1 -1
- package/dist/select/Select.js.map +1 -1
- package/dist/select/listBoxTokens.d.ts +3 -0
- package/dist/select/listBoxTokens.d.ts.map +1 -0
- package/dist/select/listBoxTokens.js +19 -0
- package/dist/select/listBoxTokens.js.map +1 -0
- package/dist/spinner/Spinner.css +8 -8
- package/dist/spinner/Spinner.js +1 -1
- package/dist/spinner/Spinner.js.map +1 -1
- package/dist/spinner/Spinner.module.js +5 -5
- package/dist/spinner/Spinner.module.js.map +1 -1
- package/dist/spinner/tokens.d.ts +3 -0
- package/dist/spinner/tokens.d.ts.map +1 -0
- package/dist/spinner/tokens.js +10 -0
- package/dist/spinner/tokens.js.map +1 -0
- package/dist/stack/Stack.css +135 -0
- package/dist/stack/Stack.d.ts +15 -0
- package/dist/stack/Stack.d.ts.map +1 -0
- package/dist/stack/Stack.js +21 -0
- package/dist/stack/Stack.js.map +1 -0
- package/dist/stack/Stack.module.js +8 -0
- package/dist/stack/Stack.module.js.map +1 -0
- package/dist/stack/tokens.d.ts +3 -0
- package/dist/stack/tokens.d.ts.map +1 -0
- package/dist/stack/tokens.js +10 -0
- package/dist/stack/tokens.js.map +1 -0
- package/dist/switch/Switch.css +34 -25
- package/dist/switch/Switch.d.ts.map +1 -1
- package/dist/switch/Switch.js +1 -0
- package/dist/switch/Switch.js.map +1 -1
- package/dist/switch/Switch.module.js +4 -4
- package/dist/switch/Switch.module.js.map +1 -1
- package/dist/switch/tokens.d.ts +3 -0
- package/dist/switch/tokens.d.ts.map +1 -0
- package/dist/switch/tokens.js +25 -0
- package/dist/switch/tokens.js.map +1 -0
- package/dist/tabs/Tabs.css +24 -23
- package/dist/tabs/Tabs.js +4 -4
- package/dist/tabs/Tabs.js.map +1 -1
- package/dist/tabs/Tabs.module.js +4 -4
- package/dist/tabs/Tabs.module.js.map +1 -1
- package/dist/tabs/tokens.d.ts +3 -0
- package/dist/tabs/tokens.d.ts.map +1 -0
- package/dist/tabs/tokens.js +25 -0
- package/dist/tabs/tokens.js.map +1 -0
- package/dist/text/Text.css +74 -0
- package/dist/text/Text.d.ts +27 -0
- package/dist/text/Text.d.ts.map +1 -0
- package/dist/text/Text.js +16 -0
- package/dist/text/Text.js.map +1 -0
- package/dist/text/Text.module.js +30 -0
- package/dist/text/Text.module.js.map +1 -0
- package/dist/text/tokens.d.ts +3 -0
- package/dist/text/tokens.d.ts.map +1 -0
- package/dist/text/tokens.js +10 -0
- package/dist/text/tokens.js.map +1 -0
- package/dist/text-area/TextArea.css +1 -1
- package/dist/text-area/TextArea.js +1 -1
- package/dist/text-area/TextArea.js.map +1 -1
- package/dist/text-area/TextArea.module.js +1 -1
- package/dist/text-input/TextInput.js +1 -1
- package/dist/text-input/TextInput.js.map +1 -1
- package/dist/theme/Tone.css +70 -0
- package/dist/theme/Tone.module.js +20 -0
- package/dist/theme/Tone.module.js.map +1 -0
- package/dist/theme/bootstrap.d.ts +10 -0
- package/dist/theme/bootstrap.d.ts.map +1 -1
- package/dist/theme/bootstrap.js +48 -5
- package/dist/theme/bootstrap.js.map +1 -1
- package/dist/theme/chartColors.d.ts +23 -0
- package/dist/theme/chartColors.d.ts.map +1 -0
- package/dist/theme/chartColors.js +27 -0
- package/dist/theme/chartColors.js.map +1 -0
- package/dist/theme/checkTheme.d.ts +39 -0
- package/dist/theme/checkTheme.d.ts.map +1 -0
- package/dist/theme/checkTheme.js +132 -0
- package/dist/theme/checkTheme.js.map +1 -0
- package/dist/theme/cli.d.ts +14 -0
- package/dist/theme/cli.d.ts.map +1 -0
- package/dist/theme/cli.js +61 -0
- package/dist/theme/cli.js.map +1 -0
- package/dist/theme/color.d.ts +30 -0
- package/dist/theme/color.d.ts.map +1 -0
- package/dist/theme/color.js +94 -0
- package/dist/theme/color.js.map +1 -0
- package/dist/theme/colorVision.d.ts +23 -0
- package/dist/theme/colorVision.d.ts.map +1 -0
- package/dist/theme/colorVision.js +140 -0
- package/dist/theme/colorVision.js.map +1 -0
- package/dist/theme/componentTokens.d.ts +24 -0
- package/dist/theme/componentTokens.d.ts.map +1 -0
- package/dist/theme/componentTokens.js +20 -0
- package/dist/theme/componentTokens.js.map +1 -0
- package/dist/theme/components.d.ts +38 -0
- package/dist/theme/components.d.ts.map +1 -0
- package/dist/theme/components.js +65 -0
- package/dist/theme/components.js.map +1 -0
- package/dist/theme/defineTheme.d.ts +85 -0
- package/dist/theme/defineTheme.d.ts.map +1 -0
- package/dist/theme/defineTheme.js +130 -0
- package/dist/theme/defineTheme.js.map +1 -0
- package/dist/theme/fonts.d.ts +32 -0
- package/dist/theme/fonts.d.ts.map +1 -0
- package/dist/theme/fonts.js +36 -0
- package/dist/theme/fonts.js.map +1 -0
- package/dist/theme/index.d.ts +13 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +10 -0
- package/dist/theme/semanticTokens.d.ts +9 -0
- package/dist/theme/semanticTokens.d.ts.map +1 -0
- package/dist/theme/semanticTokens.js +110 -0
- package/dist/theme/semanticTokens.js.map +1 -0
- package/dist/theme/theme.d.ts +61 -7
- package/dist/theme/theme.d.ts.map +1 -1
- package/dist/theme/theme.js +100 -10
- package/dist/theme/theme.js.map +1 -1
- package/dist/theme/toneClass.d.ts +8 -0
- package/dist/theme/toneClass.d.ts.map +1 -0
- package/dist/theme/toneClass.js +15 -0
- package/dist/theme/toneClass.js.map +1 -0
- package/dist/theme/tones.d.ts +89 -0
- package/dist/theme/tones.d.ts.map +1 -0
- package/dist/theme/tones.js +127 -0
- package/dist/theme/tones.js.map +1 -0
- package/dist/time-input/TimeInput.js +1 -1
- package/dist/time-input/TimeInput.js.map +1 -1
- package/dist/toast/Toast.css +22 -44
- package/dist/toast/Toast.d.ts +5 -3
- package/dist/toast/Toast.d.ts.map +1 -1
- package/dist/toast/Toast.js +4 -3
- package/dist/toast/Toast.js.map +1 -1
- package/dist/toast/Toast.module.js +10 -16
- package/dist/toast/Toast.module.js.map +1 -1
- package/dist/toast/tokens.d.ts +3 -0
- package/dist/toast/tokens.d.ts.map +1 -0
- package/dist/toast/tokens.js +21 -0
- package/dist/toast/tokens.js.map +1 -0
- package/dist/tooltip/Tooltip.css +12 -11
- package/dist/tooltip/Tooltip.js +1 -1
- package/dist/tooltip/Tooltip.js.map +1 -1
- package/dist/tooltip/Tooltip.module.js +2 -2
- package/dist/tooltip/Tooltip.module.js.map +1 -1
- package/dist/tooltip/tokens.d.ts +3 -0
- package/dist/tooltip/tokens.d.ts.map +1 -0
- package/dist/tooltip/tokens.js +21 -0
- package/dist/tooltip/tokens.js.map +1 -0
- package/dist/utils/cx.d.ts +1 -1
- package/dist/utils/cx.d.ts.map +1 -1
- package/dist/utils/cx.js +2 -2
- package/dist/utils/cx.js.map +1 -1
- package/package.json +15 -3
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** A font face of a theme, written as an `@font-face` rule. */
|
|
2
|
+
export type ThemeFontFace = {
|
|
3
|
+
/** The family name that font tokens use: `'Geist'`. */
|
|
4
|
+
family: string;
|
|
5
|
+
/** The `src` descriptor: `url(/fonts/geist.woff2) format('woff2')`. */
|
|
6
|
+
src: string;
|
|
7
|
+
/** A weight or a range of a variable font: `400`, `400 700`. */
|
|
8
|
+
weight?: string;
|
|
9
|
+
/** `normal` or `italic`. */
|
|
10
|
+
style?: string;
|
|
11
|
+
/** Defaults to `swap`. */
|
|
12
|
+
display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
|
|
13
|
+
unicodeRange?: string;
|
|
14
|
+
};
|
|
15
|
+
/** A hosted stylesheet that declares font faces: Google Fonts, Adobe Fonts, a site's own. */
|
|
16
|
+
export type ThemeFontStylesheet = {
|
|
17
|
+
stylesheet: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A font of a theme: a face, or a stylesheet that declares faces. `PanneauRoot` adds them to the
|
|
21
|
+
* page once, however many roots use the theme. Font faces are global by nature, unlike tokens.
|
|
22
|
+
*/
|
|
23
|
+
export type ThemeFont = ThemeFontFace | ThemeFontStylesheet;
|
|
24
|
+
/**
|
|
25
|
+
* The `@font-face` rules of the fonts of a theme. Faces with a value that could break out of the
|
|
26
|
+
* rule are ignored: `{`, `}` or `<` anywhere, `;` outside of `src` (which can hold data URLs), and
|
|
27
|
+
* quotes or backslashes in the family.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getFontFaceCss(fonts?: readonly ThemeFont[]): string;
|
|
30
|
+
/** The URLs of the font stylesheets of a theme, without duplicates. */
|
|
31
|
+
export declare function getFontStylesheets(fonts?: readonly ThemeFont[]): string[];
|
|
32
|
+
//# sourceMappingURL=fonts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/theme/fonts.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,MAAM,aAAa,GAAG;IACxB,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,GAAG,EAAE,MAAM,CAAC;IACZ,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,6FAA6F;AAC7F,MAAM,MAAM,mBAAmB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,mBAAmB,CAAC;AAW5D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,GAAE,SAAS,SAAS,EAAO,GAAG,MAAM,CAsBvE;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,KAAK,GAAE,SAAS,SAAS,EAAO,GAAG,MAAM,EAAE,CAU7E"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/theme/fonts.ts
|
|
2
|
+
/** Values that could break out of an `@font-face` rule, or out of the family name. */
|
|
3
|
+
var UNSAFE = /[{}<]/;
|
|
4
|
+
var UNSAFE_FAMILY = /[{}<;"\\]/;
|
|
5
|
+
var UNSAFE_DESCRIPTOR = /[{}<;]/;
|
|
6
|
+
function isFace(font) {
|
|
7
|
+
return "family" in font && "src" in font;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The `@font-face` rules of the fonts of a theme. Faces with a value that could break out of the
|
|
11
|
+
* rule are ignored: `{`, `}` or `<` anywhere, `;` outside of `src` (which can hold data URLs), and
|
|
12
|
+
* quotes or backslashes in the family.
|
|
13
|
+
*/
|
|
14
|
+
function getFontFaceCss(fonts = []) {
|
|
15
|
+
return fonts.filter(isFace).filter((face) => !UNSAFE_FAMILY.test(face.family) && !UNSAFE.test(face.src) && [
|
|
16
|
+
face.weight,
|
|
17
|
+
face.style,
|
|
18
|
+
face.display,
|
|
19
|
+
face.unicodeRange
|
|
20
|
+
].every((value) => value === void 0 || !UNSAFE_DESCRIPTOR.test(value))).map((face) => [
|
|
21
|
+
`@font-face{font-family:"${face.family}";src:${face.src};`,
|
|
22
|
+
face.weight !== void 0 ? `font-weight:${face.weight};` : "",
|
|
23
|
+
face.style !== void 0 ? `font-style:${face.style};` : "",
|
|
24
|
+
`font-display:${face.display ?? "swap"};`,
|
|
25
|
+
face.unicodeRange !== void 0 ? `unicode-range:${face.unicodeRange};` : "",
|
|
26
|
+
"}"
|
|
27
|
+
].join("")).join("");
|
|
28
|
+
}
|
|
29
|
+
/** The URLs of the font stylesheets of a theme, without duplicates. */
|
|
30
|
+
function getFontStylesheets(fonts = []) {
|
|
31
|
+
return [...new Set(fonts.flatMap((font) => "stylesheet" in font && typeof font.stylesheet === "string" ? [font.stylesheet] : []))];
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { getFontFaceCss, getFontStylesheets };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=fonts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.js","names":[],"sources":["../../src/theme/fonts.ts"],"sourcesContent":["/** A font face of a theme, written as an `@font-face` rule. */\nexport type ThemeFontFace = {\n /** The family name that font tokens use: `'Geist'`. */\n family: string;\n /** The `src` descriptor: `url(/fonts/geist.woff2) format('woff2')`. */\n src: string;\n /** A weight or a range of a variable font: `400`, `400 700`. */\n weight?: string;\n /** `normal` or `italic`. */\n style?: string;\n /** Defaults to `swap`. */\n display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';\n unicodeRange?: string;\n};\n\n/** A hosted stylesheet that declares font faces: Google Fonts, Adobe Fonts, a site's own. */\nexport type ThemeFontStylesheet = {\n stylesheet: string;\n};\n\n/**\n * A font of a theme: a face, or a stylesheet that declares faces. `PanneauRoot` adds them to the\n * page once, however many roots use the theme. Font faces are global by nature, unlike tokens.\n */\nexport type ThemeFont = ThemeFontFace | ThemeFontStylesheet;\n\n/** Values that could break out of an `@font-face` rule, or out of the family name. */\nconst UNSAFE = /[{}<]/;\nconst UNSAFE_FAMILY = /[{}<;\"\\\\]/;\nconst UNSAFE_DESCRIPTOR = /[{}<;]/;\n\nfunction isFace(font: ThemeFont): font is ThemeFontFace {\n return 'family' in font && 'src' in font;\n}\n\n/**\n * The `@font-face` rules of the fonts of a theme. Faces with a value that could break out of the\n * rule are ignored: `{`, `}` or `<` anywhere, `;` outside of `src` (which can hold data URLs), and\n * quotes or backslashes in the family.\n */\nexport function getFontFaceCss(fonts: readonly ThemeFont[] = []): string {\n return fonts\n .filter(isFace)\n .filter(\n (face) =>\n !UNSAFE_FAMILY.test(face.family) &&\n !UNSAFE.test(face.src) &&\n [face.weight, face.style, face.display, face.unicodeRange].every(\n (value) => value === undefined || !UNSAFE_DESCRIPTOR.test(value),\n ),\n )\n .map((face) =>\n [\n `@font-face{font-family:\"${face.family}\";src:${face.src};`,\n face.weight !== undefined ? `font-weight:${face.weight};` : '',\n face.style !== undefined ? `font-style:${face.style};` : '',\n `font-display:${face.display ?? 'swap'};`,\n face.unicodeRange !== undefined ? `unicode-range:${face.unicodeRange};` : '',\n '}',\n ].join(''),\n )\n .join('');\n}\n\n/** The URLs of the font stylesheets of a theme, without duplicates. */\nexport function getFontStylesheets(fonts: readonly ThemeFont[] = []): string[] {\n return [\n ...new Set(\n fonts.flatMap((font) =>\n 'stylesheet' in font && typeof font.stylesheet === 'string'\n ? [font.stylesheet]\n : [],\n ),\n ),\n ];\n}\n"],"mappings":";;AA2BA,IAAM,SAAS;AACf,IAAM,gBAAgB;AACtB,IAAM,oBAAoB;AAE1B,SAAS,OAAO,MAAwC;CACpD,OAAO,YAAY,QAAQ,SAAS;AACxC;;;;;;AAOA,SAAgB,eAAe,QAA8B,CAAA,GAAY;CACrE,OAAO,MACF,OAAO,MAAM,CAAC,CACd,QACI,SACG,CAAC,cAAc,KAAK,KAAK,MAAM,KAC/B,CAAC,OAAO,KAAK,KAAK,GAAG,KACrB;EAAC,KAAK;EAAQ,KAAK;EAAO,KAAK;EAAS,KAAK;CAAY,CAAC,CAAC,OACtD,UAAU,UAAU,KAAA,KAAa,CAAC,kBAAkB,KAAK,KAAK,CACnE,CACR,CAAC,CACA,KAAK,SACF;EACI,2BAA2B,KAAK,OAAM,QAAS,KAAK,IAAG;EACvD,KAAK,WAAW,KAAA,IAAY,eAAe,KAAK,OAAM,KAAM;EAC5D,KAAK,UAAU,KAAA,IAAY,cAAc,KAAK,MAAK,KAAM;EACzD,gBAAgB,KAAK,WAAW,OAAM;EACtC,KAAK,iBAAiB,KAAA,IAAY,iBAAiB,KAAK,aAAY,KAAM;EAC1E;CAAG,CACN,CAAC,KAAK,EAAE,CACb,CAAC,CACA,KAAK,EAAE;AAChB;;AAGA,SAAgB,mBAAmB,QAA8B,CAAA,GAAc;CAC3E,OAAO,CACH,GAAG,IAAI,IACH,MAAM,SAAS,SACX,gBAAgB,QAAQ,OAAO,KAAK,eAAe,WAC7C,CAAC,KAAK,UAAU,IAChB,CAAA,CACV,CACJ,CAAC;AAET"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { bootstrapTheme, bootstrapTone } from './bootstrap';
|
|
2
|
+
export { CHART_CATEGORICAL_COUNT, CHART_SEQUENTIAL_COUNT, chartColors } from './chartColors';
|
|
3
|
+
export { type ThemeContrastCheck, type ThemeReport, checkTheme } from './checkTheme';
|
|
4
|
+
export { type ColorDifferenceCheck, type ColorVisionDeficiency, checkColorDifferences, } from './colorVision';
|
|
5
|
+
export { type Rgb } from './color';
|
|
6
|
+
export { type ComponentTokens, defineComponentTokens } from './componentTokens';
|
|
7
|
+
export { type ComponentTokenName, componentTokens } from './components';
|
|
8
|
+
export { type PaletteTokenName, type PanneauTokens, type ThemeDefinition, type ThemeTokens, type TokenName, defineTheme, findUnknownTokens, mergeThemes, } from './defineTheme';
|
|
9
|
+
export { type ThemeFont, type ThemeFontFace, type ThemeFontStylesheet } from './fonts';
|
|
10
|
+
export { SEMANTIC_TOKENS, type SemanticTokenName } from './semanticTokens';
|
|
11
|
+
export { type ColorScheme, type Density, type Theme } from './theme';
|
|
12
|
+
export { BUILT_IN_TONES, type PanneauTones, type Tone, type ToneInput, type ToneSurfaces, type ToneValues, deriveTone, toneClassName, } from './tones';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EACH,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,qBAAqB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,KAAK,eAAe,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,KAAK,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,WAAW,EACX,iBAAiB,EACjB,WAAW,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EACH,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,UAAU,EACV,aAAa,GAChB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BUILT_IN_TONES, deriveTone, toneClassName } from "./tones.js";
|
|
2
|
+
import { bootstrapTheme, bootstrapTone } from "./bootstrap.js";
|
|
3
|
+
import { CHART_CATEGORICAL_COUNT, CHART_SEQUENTIAL_COUNT, chartColors } from "./chartColors.js";
|
|
4
|
+
import { checkColorDifferences } from "./colorVision.js";
|
|
5
|
+
import { checkTheme } from "./checkTheme.js";
|
|
6
|
+
import { defineComponentTokens } from "./componentTokens.js";
|
|
7
|
+
import { componentTokens } from "./components.js";
|
|
8
|
+
import { SEMANTIC_TOKENS } from "./semanticTokens.js";
|
|
9
|
+
import { defineTheme, findUnknownTokens, mergeThemes } from "./defineTheme.js";
|
|
10
|
+
export { BUILT_IN_TONES, CHART_CATEGORICAL_COUNT, CHART_SEQUENTIAL_COUNT, SEMANTIC_TOKENS, bootstrapTheme, bootstrapTone, chartColors, checkColorDifferences, checkTheme, componentTokens, defineComponentTokens, defineTheme, deriveTone, findUnknownTokens, mergeThemes, toneClassName };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The semantic tokens of Panneau, without the leading `--`: what the default theme defines on the
|
|
3
|
+
* root (`PanneauRoot.module.css`), and what a theme sets to restyle every component at once
|
|
4
|
+
* (decision 0024). A test keeps this list in sync with the stylesheet.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SEMANTIC_TOKENS: readonly ["panneau-color-bg", "panneau-color-surface", "panneau-color-surface-sunken", "panneau-color-surface-raised", "panneau-color-hover", "panneau-color-pressed", "panneau-color-backdrop", "panneau-color-text", "panneau-color-text-muted", "panneau-color-link", "panneau-color-border", "panneau-color-border-control", "panneau-color-accent", "panneau-color-accent-hover", "panneau-color-accent-text", "panneau-color-accent-subtle", "panneau-color-focus", "panneau-color-danger", "panneau-color-danger-subtle", "panneau-color-danger-border", "panneau-color-danger-solid", "panneau-color-danger-solid-hover", "panneau-color-danger-solid-text", "panneau-color-success", "panneau-color-success-subtle", "panneau-color-success-border", "panneau-color-success-solid", "panneau-color-success-solid-hover", "panneau-color-success-solid-text", "panneau-color-warning", "panneau-color-warning-subtle", "panneau-color-warning-border", "panneau-color-warning-solid", "panneau-color-warning-solid-hover", "panneau-color-warning-solid-text", "panneau-color-info", "panneau-color-info-subtle", "panneau-color-info-border", "panneau-color-info-solid", "panneau-color-info-solid-hover", "panneau-color-info-solid-text", "panneau-chart-categorical-1", "panneau-chart-categorical-2", "panneau-chart-categorical-3", "panneau-chart-categorical-4", "panneau-chart-categorical-5", "panneau-chart-categorical-6", "panneau-chart-categorical-7", "panneau-chart-categorical-8", "panneau-chart-sequential-1", "panneau-chart-sequential-2", "panneau-chart-sequential-3", "panneau-chart-sequential-4", "panneau-chart-sequential-5", "panneau-chart-diverging-negative", "panneau-chart-diverging-neutral", "panneau-chart-diverging-positive", "panneau-font-family-body", "panneau-font-family-heading", "panneau-font-family-display", "panneau-font-family-mono", "panneau-font-family", "panneau-font-numeric", "panneau-font-size-xs", "panneau-font-size-sm", "panneau-font-size-md", "panneau-font-size-lg", "panneau-font-size-xl", "panneau-font-size-control", "panneau-line-height", "panneau-line-height-tight", "panneau-font-weight-normal", "panneau-font-weight-medium", "panneau-font-weight-bold", "panneau-space-1", "panneau-space-2", "panneau-space-3", "panneau-space-4", "panneau-space-5", "panneau-space-6", "panneau-space-8", "panneau-space-10", "panneau-radius-sm", "panneau-radius-md", "panneau-radius-lg", "panneau-radius-full", "panneau-border-width", "panneau-shadow-sm", "panneau-shadow-md", "panneau-shadow-lg", "panneau-control-height", "panneau-control-height-sm", "panneau-control-padding-x", "panneau-row-padding-y", "panneau-focus-width", "panneau-duration", "panneau-z-overlay", "panneau-z-toast"];
|
|
7
|
+
/** The name of a semantic token, without the leading `--`. */
|
|
8
|
+
export type SemanticTokenName = (typeof SEMANTIC_TOKENS)[number];
|
|
9
|
+
//# sourceMappingURL=semanticTokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semanticTokens.d.ts","sourceRoot":"","sources":["../../src/theme/semanticTokens.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,eAAe,4nFAmGlB,CAAC;AAEX,8DAA8D;AAC9D,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
//#region src/theme/semanticTokens.ts
|
|
2
|
+
/**
|
|
3
|
+
* The semantic tokens of Panneau, without the leading `--`: what the default theme defines on the
|
|
4
|
+
* root (`PanneauRoot.module.css`), and what a theme sets to restyle every component at once
|
|
5
|
+
* (decision 0024). A test keeps this list in sync with the stylesheet.
|
|
6
|
+
*/
|
|
7
|
+
var SEMANTIC_TOKENS = [
|
|
8
|
+
"panneau-color-bg",
|
|
9
|
+
"panneau-color-surface",
|
|
10
|
+
"panneau-color-surface-sunken",
|
|
11
|
+
"panneau-color-surface-raised",
|
|
12
|
+
"panneau-color-hover",
|
|
13
|
+
"panneau-color-pressed",
|
|
14
|
+
"panneau-color-backdrop",
|
|
15
|
+
"panneau-color-text",
|
|
16
|
+
"panneau-color-text-muted",
|
|
17
|
+
"panneau-color-link",
|
|
18
|
+
"panneau-color-border",
|
|
19
|
+
"panneau-color-border-control",
|
|
20
|
+
"panneau-color-accent",
|
|
21
|
+
"panneau-color-accent-hover",
|
|
22
|
+
"panneau-color-accent-text",
|
|
23
|
+
"panneau-color-accent-subtle",
|
|
24
|
+
"panneau-color-focus",
|
|
25
|
+
"panneau-color-danger",
|
|
26
|
+
"panneau-color-danger-subtle",
|
|
27
|
+
"panneau-color-danger-border",
|
|
28
|
+
"panneau-color-danger-solid",
|
|
29
|
+
"panneau-color-danger-solid-hover",
|
|
30
|
+
"panneau-color-danger-solid-text",
|
|
31
|
+
"panneau-color-success",
|
|
32
|
+
"panneau-color-success-subtle",
|
|
33
|
+
"panneau-color-success-border",
|
|
34
|
+
"panneau-color-success-solid",
|
|
35
|
+
"panneau-color-success-solid-hover",
|
|
36
|
+
"panneau-color-success-solid-text",
|
|
37
|
+
"panneau-color-warning",
|
|
38
|
+
"panneau-color-warning-subtle",
|
|
39
|
+
"panneau-color-warning-border",
|
|
40
|
+
"panneau-color-warning-solid",
|
|
41
|
+
"panneau-color-warning-solid-hover",
|
|
42
|
+
"panneau-color-warning-solid-text",
|
|
43
|
+
"panneau-color-info",
|
|
44
|
+
"panneau-color-info-subtle",
|
|
45
|
+
"panneau-color-info-border",
|
|
46
|
+
"panneau-color-info-solid",
|
|
47
|
+
"panneau-color-info-solid-hover",
|
|
48
|
+
"panneau-color-info-solid-text",
|
|
49
|
+
"panneau-chart-categorical-1",
|
|
50
|
+
"panneau-chart-categorical-2",
|
|
51
|
+
"panneau-chart-categorical-3",
|
|
52
|
+
"panneau-chart-categorical-4",
|
|
53
|
+
"panneau-chart-categorical-5",
|
|
54
|
+
"panneau-chart-categorical-6",
|
|
55
|
+
"panneau-chart-categorical-7",
|
|
56
|
+
"panneau-chart-categorical-8",
|
|
57
|
+
"panneau-chart-sequential-1",
|
|
58
|
+
"panneau-chart-sequential-2",
|
|
59
|
+
"panneau-chart-sequential-3",
|
|
60
|
+
"panneau-chart-sequential-4",
|
|
61
|
+
"panneau-chart-sequential-5",
|
|
62
|
+
"panneau-chart-diverging-negative",
|
|
63
|
+
"panneau-chart-diverging-neutral",
|
|
64
|
+
"panneau-chart-diverging-positive",
|
|
65
|
+
"panneau-font-family-body",
|
|
66
|
+
"panneau-font-family-heading",
|
|
67
|
+
"panneau-font-family-display",
|
|
68
|
+
"panneau-font-family-mono",
|
|
69
|
+
"panneau-font-family",
|
|
70
|
+
"panneau-font-numeric",
|
|
71
|
+
"panneau-font-size-xs",
|
|
72
|
+
"panneau-font-size-sm",
|
|
73
|
+
"panneau-font-size-md",
|
|
74
|
+
"panneau-font-size-lg",
|
|
75
|
+
"panneau-font-size-xl",
|
|
76
|
+
"panneau-font-size-control",
|
|
77
|
+
"panneau-line-height",
|
|
78
|
+
"panneau-line-height-tight",
|
|
79
|
+
"panneau-font-weight-normal",
|
|
80
|
+
"panneau-font-weight-medium",
|
|
81
|
+
"panneau-font-weight-bold",
|
|
82
|
+
"panneau-space-1",
|
|
83
|
+
"panneau-space-2",
|
|
84
|
+
"panneau-space-3",
|
|
85
|
+
"panneau-space-4",
|
|
86
|
+
"panneau-space-5",
|
|
87
|
+
"panneau-space-6",
|
|
88
|
+
"panneau-space-8",
|
|
89
|
+
"panneau-space-10",
|
|
90
|
+
"panneau-radius-sm",
|
|
91
|
+
"panneau-radius-md",
|
|
92
|
+
"panneau-radius-lg",
|
|
93
|
+
"panneau-radius-full",
|
|
94
|
+
"panneau-border-width",
|
|
95
|
+
"panneau-shadow-sm",
|
|
96
|
+
"panneau-shadow-md",
|
|
97
|
+
"panneau-shadow-lg",
|
|
98
|
+
"panneau-control-height",
|
|
99
|
+
"panneau-control-height-sm",
|
|
100
|
+
"panneau-control-padding-x",
|
|
101
|
+
"panneau-row-padding-y",
|
|
102
|
+
"panneau-focus-width",
|
|
103
|
+
"panneau-duration",
|
|
104
|
+
"panneau-z-overlay",
|
|
105
|
+
"panneau-z-toast"
|
|
106
|
+
];
|
|
107
|
+
//#endregion
|
|
108
|
+
export { SEMANTIC_TOKENS };
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=semanticTokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semanticTokens.js","names":[],"sources":["../../src/theme/semanticTokens.ts"],"sourcesContent":["/**\n * The semantic tokens of Panneau, without the leading `--`: what the default theme defines on the\n * root (`PanneauRoot.module.css`), and what a theme sets to restyle every component at once\n * (decision 0024). A test keeps this list in sync with the stylesheet.\n */\nexport const SEMANTIC_TOKENS = [\n 'panneau-color-bg',\n 'panneau-color-surface',\n 'panneau-color-surface-sunken',\n 'panneau-color-surface-raised',\n 'panneau-color-hover',\n 'panneau-color-pressed',\n 'panneau-color-backdrop',\n 'panneau-color-text',\n 'panneau-color-text-muted',\n 'panneau-color-link',\n 'panneau-color-border',\n 'panneau-color-border-control',\n 'panneau-color-accent',\n 'panneau-color-accent-hover',\n 'panneau-color-accent-text',\n 'panneau-color-accent-subtle',\n 'panneau-color-focus',\n 'panneau-color-danger',\n 'panneau-color-danger-subtle',\n 'panneau-color-danger-border',\n 'panneau-color-danger-solid',\n 'panneau-color-danger-solid-hover',\n 'panneau-color-danger-solid-text',\n 'panneau-color-success',\n 'panneau-color-success-subtle',\n 'panneau-color-success-border',\n 'panneau-color-success-solid',\n 'panneau-color-success-solid-hover',\n 'panneau-color-success-solid-text',\n 'panneau-color-warning',\n 'panneau-color-warning-subtle',\n 'panneau-color-warning-border',\n 'panneau-color-warning-solid',\n 'panneau-color-warning-solid-hover',\n 'panneau-color-warning-solid-text',\n 'panneau-color-info',\n 'panneau-color-info-subtle',\n 'panneau-color-info-border',\n 'panneau-color-info-solid',\n 'panneau-color-info-solid-hover',\n 'panneau-color-info-solid-text',\n 'panneau-chart-categorical-1',\n 'panneau-chart-categorical-2',\n 'panneau-chart-categorical-3',\n 'panneau-chart-categorical-4',\n 'panneau-chart-categorical-5',\n 'panneau-chart-categorical-6',\n 'panneau-chart-categorical-7',\n 'panneau-chart-categorical-8',\n 'panneau-chart-sequential-1',\n 'panneau-chart-sequential-2',\n 'panneau-chart-sequential-3',\n 'panneau-chart-sequential-4',\n 'panneau-chart-sequential-5',\n 'panneau-chart-diverging-negative',\n 'panneau-chart-diverging-neutral',\n 'panneau-chart-diverging-positive',\n 'panneau-font-family-body',\n 'panneau-font-family-heading',\n 'panneau-font-family-display',\n 'panneau-font-family-mono',\n 'panneau-font-family',\n 'panneau-font-numeric',\n 'panneau-font-size-xs',\n 'panneau-font-size-sm',\n 'panneau-font-size-md',\n 'panneau-font-size-lg',\n 'panneau-font-size-xl',\n 'panneau-font-size-control',\n 'panneau-line-height',\n 'panneau-line-height-tight',\n 'panneau-font-weight-normal',\n 'panneau-font-weight-medium',\n 'panneau-font-weight-bold',\n 'panneau-space-1',\n 'panneau-space-2',\n 'panneau-space-3',\n 'panneau-space-4',\n 'panneau-space-5',\n 'panneau-space-6',\n 'panneau-space-8',\n 'panneau-space-10',\n 'panneau-radius-sm',\n 'panneau-radius-md',\n 'panneau-radius-lg',\n 'panneau-radius-full',\n 'panneau-border-width',\n 'panneau-shadow-sm',\n 'panneau-shadow-md',\n 'panneau-shadow-lg',\n 'panneau-control-height',\n 'panneau-control-height-sm',\n 'panneau-control-padding-x',\n 'panneau-row-padding-y',\n 'panneau-focus-width',\n 'panneau-duration',\n 'panneau-z-overlay',\n 'panneau-z-toast',\n] as const;\n\n/** The name of a semantic token, without the leading `--`. */\nexport type SemanticTokenName = (typeof SEMANTIC_TOKENS)[number];\n"],"mappings":";;;;;;AAKA,IAAa,kBAAkB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAiB"}
|
package/dist/theme/theme.d.ts
CHANGED
|
@@ -1,23 +1,77 @@
|
|
|
1
|
+
import type { ThemeFont } from './fonts';
|
|
2
|
+
import { type ToneInput, type ToneSurfaces } from './tones';
|
|
1
3
|
/**
|
|
2
4
|
* A theme: design tokens, as CSS variables without the leading `--`, with optional overrides for
|
|
3
|
-
* the dark scheme
|
|
5
|
+
* the dark scheme, raw palette colors, its own tones, and named variants of components (decision
|
|
6
|
+
* 0024). A theme is plain data: the `Theme` schema of `@panneau/protocol` validates it, and plugins
|
|
7
|
+
* of `@panneau/core` register it. Write one with `defineTheme()` to check token names.
|
|
8
|
+
*
|
|
9
|
+
* It is a type rather than an interface so that it is assignable to the `Theme` of
|
|
10
|
+
* `@panneau/protocol`, which accepts properties of later versions.
|
|
4
11
|
*/
|
|
5
|
-
export
|
|
12
|
+
export type Theme = {
|
|
13
|
+
/** A name for theme pickers. */
|
|
6
14
|
label?: string;
|
|
7
15
|
/** Tokens of the light scheme, or of both schemes without `dark`: `{ 'panneau-color-accent': '#05f' }`. */
|
|
8
16
|
tokens: Record<string, string>;
|
|
9
17
|
/** Tokens that change in the dark scheme. */
|
|
10
18
|
dark?: Record<string, string>;
|
|
11
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Raw colors, written as `--panneau-palette-<name>`: tokens and tones use them with
|
|
21
|
+
* `var(--panneau-palette-<name>)`, so that a theme names its brand colors once.
|
|
22
|
+
*/
|
|
23
|
+
palette?: Record<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Tones added or redefined by the theme: one color, from which Panneau derives the others,
|
|
26
|
+
* or every value. Declare added tones in `PanneauTones` so that `tone="signal"` type-checks.
|
|
27
|
+
*/
|
|
28
|
+
tones?: Record<string, ToneInput>;
|
|
29
|
+
/**
|
|
30
|
+
* Named variants of components: token overrides that `<Badge variant="tag">` applies through
|
|
31
|
+
* its `panneau-badge-variant-tag` class. Declare them in `BadgeVariants` (and the like).
|
|
32
|
+
*/
|
|
33
|
+
components?: Record<string, {
|
|
34
|
+
variants?: Record<string, Record<string, string>>;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Tokens of each density, such as `panneau-control-height`: tokens set here change with the
|
|
38
|
+
* density of the root, while the same tokens in `tokens` would apply to every density.
|
|
39
|
+
*/
|
|
40
|
+
densities?: Partial<Record<Exclude<Density, 'auto'>, Record<string, string>>>;
|
|
41
|
+
/**
|
|
42
|
+
* Font faces and font stylesheets, which `PanneauRoot` adds to the page once. Font tokens
|
|
43
|
+
* (`panneau-font-family-heading`) then use their families.
|
|
44
|
+
*/
|
|
45
|
+
fonts?: ThemeFont[];
|
|
46
|
+
};
|
|
12
47
|
/** `auto` follows the system setting (`prefers-color-scheme`). */
|
|
13
48
|
export type ColorScheme = 'light' | 'dark' | 'auto';
|
|
49
|
+
/**
|
|
50
|
+
* How much room controls and rows take: `compact`, `comfortable`, or `touch`, with larger targets.
|
|
51
|
+
* `auto` is `touch` on coarse pointers (touch screens) and `comfortable` otherwise.
|
|
52
|
+
*/
|
|
53
|
+
export type Density = 'compact' | 'comfortable' | 'touch' | 'auto';
|
|
14
54
|
/** A short, stable hash of a string, to scope the CSS of a theme. */
|
|
15
55
|
export declare function hashString(value: string): string;
|
|
56
|
+
/** The palette of a theme, as variables: `{ 'panneau-palette-orange': '#f25c05' }`. */
|
|
57
|
+
export declare function paletteVariables(palette?: Readonly<Record<string, string>>): Record<string, string>;
|
|
58
|
+
/**
|
|
59
|
+
* Follows `var(--name)` references through the given variables (tokens, palette colors), until a
|
|
60
|
+
* value that is not one: `var(--panneau-palette-orange)` becomes `#f25c05`. A reference to a
|
|
61
|
+
* variable that isn't given is returned as is.
|
|
62
|
+
*/
|
|
63
|
+
export declare function resolveReference(value: string, variables: Readonly<Record<string, string>>): string;
|
|
64
|
+
/**
|
|
65
|
+
* The surfaces of a theme in each scheme, when it sets ones Panneau can read: tones derived from
|
|
66
|
+
* one color are made readable on them.
|
|
67
|
+
*/
|
|
68
|
+
export declare function themeSurfaces(theme: Theme): ToneSurfaces;
|
|
16
69
|
/**
|
|
17
|
-
* The CSS of a theme, scoped to the roots that carry `data-panneau-theme="<scope>"
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
70
|
+
* The CSS of a theme, scoped to the roots that carry `data-panneau-theme="<scope>"`: its palette and
|
|
71
|
+
* tokens, its densities, its tones and the variants of components. Its rules are more specific than the default
|
|
72
|
+
* tokens and the built-in tones, and dark overrides more specific than light ones. Token, tone,
|
|
73
|
+
* component and variant names must be plain identifiers, and values can't contain `{`, `}`, `;` or
|
|
74
|
+
* `<`: other entries are ignored.
|
|
21
75
|
*/
|
|
22
76
|
export declare function getThemeCss(theme: Theme, scope: string): string;
|
|
23
77
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAEH,KAAK,SAAS,EACd,KAAK,YAAY,EAIpB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;GAQG;AACH,MAAM,MAAM,KAAK,GAAG;IAChB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2GAA2G;IAC3G,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;KAAE,CAAC,CAAC;IACnF;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9E;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;CACvB,CAAC;AAEF,kEAAkE;AAClE,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC;AASnE,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMhD;AAMD,uFAAuF;AACvF,wBAAgB,gBAAgB,CAC5B,OAAO,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,GAC/C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMxB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC5B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC5C,MAAM,CAUR;AAaD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,CAgBxD;AAoBD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CA+C/D"}
|
package/dist/theme/theme.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { parseColor } from "./color.js";
|
|
2
|
+
import { TONE_VARIABLES, resolveTone, toneClassName } from "./tones.js";
|
|
1
3
|
//#region src/theme/theme.ts
|
|
2
4
|
function declarations(tokens) {
|
|
3
5
|
return Object.entries(tokens).filter(([name, value]) => /^[a-zA-Z0-9-_]+$/.test(name) && !/[{};<]/.test(value)).map(([name, value]) => `--${name}:${value};`).join("");
|
|
@@ -8,23 +10,111 @@ function hashString(value) {
|
|
|
8
10
|
for (let index = 0; index < value.length; index += 1) hash = hash * 33 ^ value.charCodeAt(index);
|
|
9
11
|
return (hash >>> 0).toString(36);
|
|
10
12
|
}
|
|
13
|
+
var NAME = /^[a-z0-9-]+$/;
|
|
14
|
+
var VARIABLE = /^var\(--([a-zA-Z0-9_-]+)\)$/;
|
|
15
|
+
/** The palette of a theme, as variables: `{ 'panneau-palette-orange': '#f25c05' }`. */
|
|
16
|
+
function paletteVariables(palette = {}) {
|
|
17
|
+
return Object.fromEntries(Object.entries(palette).filter(([name]) => NAME.test(name)).map(([name, value]) => [`panneau-palette-${name}`, value]));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Follows `var(--name)` references through the given variables (tokens, palette colors), until a
|
|
21
|
+
* value that is not one: `var(--panneau-palette-orange)` becomes `#f25c05`. A reference to a
|
|
22
|
+
* variable that isn't given is returned as is.
|
|
23
|
+
*/
|
|
24
|
+
function resolveReference(value, variables) {
|
|
25
|
+
let current = value;
|
|
26
|
+
for (let depth = 0; depth < 10; depth += 1) {
|
|
27
|
+
const name = VARIABLE.exec(current.trim())?.[1];
|
|
28
|
+
if (name === void 0 || !Object.hasOwn(variables, name)) return current;
|
|
29
|
+
current = variables[name] ?? current;
|
|
30
|
+
}
|
|
31
|
+
return current;
|
|
32
|
+
}
|
|
33
|
+
function toneDeclarations(values) {
|
|
34
|
+
return declarations(Object.fromEntries(Object.keys(TONE_VARIABLES).map((key) => [TONE_VARIABLES[key], values[key]])));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The surfaces of a theme in each scheme, when it sets ones Panneau can read: tones derived from
|
|
38
|
+
* one color are made readable on them.
|
|
39
|
+
*/
|
|
40
|
+
function themeSurfaces(theme) {
|
|
41
|
+
const palette = paletteVariables(theme.palette);
|
|
42
|
+
const surface = (tokens) => {
|
|
43
|
+
const variables = {
|
|
44
|
+
...palette,
|
|
45
|
+
...tokens
|
|
46
|
+
};
|
|
47
|
+
const value = variables["panneau-color-surface"];
|
|
48
|
+
return value !== void 0 ? parseColor(resolveReference(value, variables)) : null;
|
|
49
|
+
};
|
|
50
|
+
const light = surface(theme.tokens);
|
|
51
|
+
const dark = theme.dark?.["panneau-color-surface"] !== void 0 ? surface({
|
|
52
|
+
...theme.tokens,
|
|
53
|
+
...theme.dark
|
|
54
|
+
}) : null;
|
|
55
|
+
return {
|
|
56
|
+
...light !== null && { light },
|
|
57
|
+
...dark !== null && { dark }
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The rules of the densities of a theme. `auto` takes the comfortable values on fine pointers and
|
|
62
|
+
* the touch ones on coarse pointers, like the default theme.
|
|
63
|
+
*/
|
|
64
|
+
function densityCss(root, densities = {}) {
|
|
65
|
+
const body = (density) => declarations(densities[density] ?? {});
|
|
66
|
+
const rule = (selector, css) => css !== "" ? `${selector}{${css}}` : "";
|
|
67
|
+
const media = (query, css) => css !== "" ? `@media ${query}{${css}}` : "";
|
|
68
|
+
const selector = (density) => `${root}[data-density="${density}"]`;
|
|
69
|
+
return [
|
|
70
|
+
rule(selector("compact"), body("compact")),
|
|
71
|
+
rule(selector("comfortable"), body("comfortable")),
|
|
72
|
+
media("not (pointer: coarse)", rule(selector("auto"), body("comfortable"))),
|
|
73
|
+
rule(selector("touch"), body("touch")),
|
|
74
|
+
media("(pointer: coarse)", rule(selector("auto"), body("touch")))
|
|
75
|
+
].join("");
|
|
76
|
+
}
|
|
11
77
|
/**
|
|
12
|
-
* The CSS of a theme, scoped to the roots that carry `data-panneau-theme="<scope>"
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
78
|
+
* The CSS of a theme, scoped to the roots that carry `data-panneau-theme="<scope>"`: its palette and
|
|
79
|
+
* tokens, its densities, its tones and the variants of components. Its rules are more specific than the default
|
|
80
|
+
* tokens and the built-in tones, and dark overrides more specific than light ones. Token, tone,
|
|
81
|
+
* component and variant names must be plain identifiers, and values can't contain `{`, `}`, `;` or
|
|
82
|
+
* `<`: other entries are ignored.
|
|
16
83
|
*/
|
|
17
84
|
function getThemeCss(theme, scope) {
|
|
18
85
|
const root = `[data-panneau-theme="${scope}"]`;
|
|
19
|
-
const
|
|
20
|
-
const
|
|
86
|
+
const dark = `${root}[data-color-scheme="dark"]`;
|
|
87
|
+
const auto = `${root}[data-color-scheme="auto"]`;
|
|
88
|
+
const light = [];
|
|
89
|
+
const darkRules = [];
|
|
90
|
+
const rule = (selector, body) => body !== "" ? `${selector}{${body}}` : "";
|
|
91
|
+
const palette = paletteVariables(theme.palette);
|
|
92
|
+
const surfaces = themeSurfaces(theme);
|
|
93
|
+
light.push(rule(root, declarations({
|
|
94
|
+
...palette,
|
|
95
|
+
...theme.tokens
|
|
96
|
+
})));
|
|
97
|
+
light.push(densityCss(root, theme.densities));
|
|
98
|
+
if (theme.dark !== void 0) darkRules.push(rule("§", declarations(theme.dark)));
|
|
99
|
+
Object.entries(theme.tones ?? {}).filter(([name]) => NAME.test(name)).forEach(([name, input]) => {
|
|
100
|
+
const values = resolveTone(typeof input === "string" ? resolveReference(input, palette) : input, surfaces);
|
|
101
|
+
const selector = `.${toneClassName(name)}`;
|
|
102
|
+
light.push(rule(`${root} ${selector}`, toneDeclarations(values.light)));
|
|
103
|
+
darkRules.push(rule(`§ ${selector}`, toneDeclarations(values.dark)));
|
|
104
|
+
});
|
|
105
|
+
Object.entries(theme.components ?? {}).filter(([component]) => NAME.test(component)).forEach(([component, { variants = {} }]) => {
|
|
106
|
+
Object.entries(variants).filter(([name]) => NAME.test(name)).forEach(([name, tokens]) => {
|
|
107
|
+
light.push(rule(`${root} .panneau-${component}-variant-${name}`, declarations(tokens)));
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
const darkCss = darkRules.filter(Boolean);
|
|
21
111
|
return [
|
|
22
|
-
light
|
|
23
|
-
|
|
24
|
-
|
|
112
|
+
...light,
|
|
113
|
+
...darkCss.map((css) => css.replaceAll("§", dark)),
|
|
114
|
+
darkCss.length > 0 ? `@media (prefers-color-scheme: dark){${darkCss.map((css) => css.replaceAll("§", auto)).join("")}}` : ""
|
|
25
115
|
].join("");
|
|
26
116
|
}
|
|
27
117
|
//#endregion
|
|
28
|
-
export { getThemeCss, hashString };
|
|
118
|
+
export { getThemeCss, hashString, paletteVariables, resolveReference, themeSurfaces };
|
|
29
119
|
|
|
30
120
|
//# sourceMappingURL=theme.js.map
|
package/dist/theme/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","names":[],"sources":["../../src/theme/theme.ts"],"sourcesContent":["/**\n * A theme: design tokens, as CSS variables without the leading `--`, with optional overrides for\n * the dark scheme. It has the same shape as the `Theme` of `@panneau/core` plugins.\n */\nexport interface Theme {\n label?: string;\n /** Tokens of the light scheme, or of both schemes without `dark`: `{ 'panneau-color-accent': '#05f' }`. */\n tokens: Record<string, string>;\n /** Tokens that change in the dark scheme. */\n dark?: Record<string, string>;\n}\n\n/** `auto` follows the system setting (`prefers-color-scheme`). */\nexport type ColorScheme = 'light' | 'dark' | 'auto';\n\nfunction declarations(tokens: Record<string, string>): string {\n return Object.entries(tokens)\n .filter(([name, value]) => /^[a-zA-Z0-9-_]+$/.test(name) && !/[{};<]/.test(value))\n .map(([name, value]) => `--${name}:${value};`)\n .join('');\n}\n\n/** A short, stable hash of a string, to scope the CSS of a theme. */\nexport function hashString(value: string): string {\n let hash = 5381;\n for (let index = 0; index < value.length; index += 1) {\n hash = (hash * 33) ^ value.charCodeAt(index);\n }\n return (hash >>> 0).toString(36);\n}\n\n/**\n * The CSS of a theme, scoped to the roots that carry `data-panneau-theme=\"<scope>\"`. Its rules are\n * more specific than the default tokens, and dark overrides more specific than light ones. Token\n * names must be plain identifiers, and values can't contain `{`, `}`, `;` or `<`: other entries are\n * ignored.\n */\nexport function getThemeCss(theme: Theme, scope: string): string {\n const root = `[data-panneau-theme=\"${scope}\"]`;\n const light = declarations(theme.tokens);\n const dark = theme.dark !== undefined ? declarations(theme.dark) : '';\n return [\n light !== '' ? `${root}{${light}}` : '',\n dark !== '' ? `${root}[data-color-scheme=\"dark\"]{${dark}}` : '',\n dark !== ''\n ? `@media (prefers-color-scheme: dark){${root}[data-color-scheme=\"auto\"]{${dark}}}`\n : '',\n ].join('');\n}\n"],"mappings":";AAeA,SAAS,aAAa,QAAwC;CAC1D,OAAO,OAAO,QAAQ,MAAM,CAAC,CACxB,QAAQ,CAAC,MAAM,WAAW,mBAAmB,KAAK,IAAI,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CACjF,KAAK,CAAC,MAAM,WAAW,KAAK,KAAI,GAAI,MAAK,EAAG,CAAC,CAC7C,KAAK,EAAE;AAChB;;AAGA,SAAgB,WAAW,OAAuB;CAC9C,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS,GAC/C,OAAQ,OAAO,KAAM,MAAM,WAAW,KAAK;CAE/C,QAAQ,SAAS,EAAA,CAAG,SAAS,EAAE;AACnC;;;;;;;AAQA,SAAgB,YAAY,OAAc,OAAuB;CAC7D,MAAM,OAAO,wBAAwB,MAAK;CAC1C,MAAM,QAAQ,aAAa,MAAM,MAAM;CACvC,MAAM,OAAO,MAAM,SAAS,KAAA,IAAY,aAAa,MAAM,IAAI,IAAI;CACnE,OAAO;EACH,UAAU,KAAK,GAAG,KAAI,GAAI,MAAK,KAAM;EACrC,SAAS,KAAK,GAAG,KAAI,6BAA8B,KAAI,KAAM;EAC7D,SAAS,KACH,uCAAuC,KAAI,6BAA8B,KAAI,MAC7E;CAAE,CACX,CAAC,KAAK,EAAE;AACb"}
|
|
1
|
+
{"version":3,"file":"theme.js","names":[],"sources":["../../src/theme/theme.ts"],"sourcesContent":["import { parseColor } from './color';\nimport type { ThemeFont } from './fonts';\nimport {\n TONE_VARIABLES,\n type ToneInput,\n type ToneSurfaces,\n type ToneValues,\n resolveTone,\n toneClassName,\n} from './tones';\n\n/**\n * A theme: design tokens, as CSS variables without the leading `--`, with optional overrides for\n * the dark scheme, raw palette colors, its own tones, and named variants of components (decision\n * 0024). A theme is plain data: the `Theme` schema of `@panneau/protocol` validates it, and plugins\n * of `@panneau/core` register it. Write one with `defineTheme()` to check token names.\n *\n * It is a type rather than an interface so that it is assignable to the `Theme` of\n * `@panneau/protocol`, which accepts properties of later versions.\n */\nexport type Theme = {\n /** A name for theme pickers. */\n label?: string;\n /** Tokens of the light scheme, or of both schemes without `dark`: `{ 'panneau-color-accent': '#05f' }`. */\n tokens: Record<string, string>;\n /** Tokens that change in the dark scheme. */\n dark?: Record<string, string>;\n /**\n * Raw colors, written as `--panneau-palette-<name>`: tokens and tones use them with\n * `var(--panneau-palette-<name>)`, so that a theme names its brand colors once.\n */\n palette?: Record<string, string>;\n /**\n * Tones added or redefined by the theme: one color, from which Panneau derives the others,\n * or every value. Declare added tones in `PanneauTones` so that `tone=\"signal\"` type-checks.\n */\n tones?: Record<string, ToneInput>;\n /**\n * Named variants of components: token overrides that `<Badge variant=\"tag\">` applies through\n * its `panneau-badge-variant-tag` class. Declare them in `BadgeVariants` (and the like).\n */\n components?: Record<string, { variants?: Record<string, Record<string, string>> }>;\n /**\n * Tokens of each density, such as `panneau-control-height`: tokens set here change with the\n * density of the root, while the same tokens in `tokens` would apply to every density.\n */\n densities?: Partial<Record<Exclude<Density, 'auto'>, Record<string, string>>>;\n /**\n * Font faces and font stylesheets, which `PanneauRoot` adds to the page once. Font tokens\n * (`panneau-font-family-heading`) then use their families.\n */\n fonts?: ThemeFont[];\n};\n\n/** `auto` follows the system setting (`prefers-color-scheme`). */\nexport type ColorScheme = 'light' | 'dark' | 'auto';\n\n/**\n * How much room controls and rows take: `compact`, `comfortable`, or `touch`, with larger targets.\n * `auto` is `touch` on coarse pointers (touch screens) and `comfortable` otherwise.\n */\nexport type Density = 'compact' | 'comfortable' | 'touch' | 'auto';\n\nfunction declarations(tokens: Record<string, string>): string {\n return Object.entries(tokens)\n .filter(([name, value]) => /^[a-zA-Z0-9-_]+$/.test(name) && !/[{};<]/.test(value))\n .map(([name, value]) => `--${name}:${value};`)\n .join('');\n}\n\n/** A short, stable hash of a string, to scope the CSS of a theme. */\nexport function hashString(value: string): string {\n let hash = 5381;\n for (let index = 0; index < value.length; index += 1) {\n hash = (hash * 33) ^ value.charCodeAt(index);\n }\n return (hash >>> 0).toString(36);\n}\n\nconst NAME = /^[a-z0-9-]+$/;\n\nconst VARIABLE = /^var\\(--([a-zA-Z0-9_-]+)\\)$/;\n\n/** The palette of a theme, as variables: `{ 'panneau-palette-orange': '#f25c05' }`. */\nexport function paletteVariables(\n palette: Readonly<Record<string, string>> = {},\n): Record<string, string> {\n return Object.fromEntries(\n Object.entries(palette)\n .filter(([name]) => NAME.test(name))\n .map(([name, value]) => [`panneau-palette-${name}`, value]),\n );\n}\n\n/**\n * Follows `var(--name)` references through the given variables (tokens, palette colors), until a\n * value that is not one: `var(--panneau-palette-orange)` becomes `#f25c05`. A reference to a\n * variable that isn't given is returned as is.\n */\nexport function resolveReference(\n value: string,\n variables: Readonly<Record<string, string>>,\n): string {\n let current = value;\n for (let depth = 0; depth < 10; depth += 1) {\n const name = VARIABLE.exec(current.trim())?.[1];\n if (name === undefined || !Object.hasOwn(variables, name)) {\n return current;\n }\n current = variables[name] ?? current;\n }\n return current;\n}\n\nfunction toneDeclarations(values: ToneValues): string {\n return declarations(\n Object.fromEntries(\n (Object.keys(TONE_VARIABLES) as (keyof ToneValues)[]).map((key) => [\n TONE_VARIABLES[key],\n values[key],\n ]),\n ),\n );\n}\n\n/**\n * The surfaces of a theme in each scheme, when it sets ones Panneau can read: tones derived from\n * one color are made readable on them.\n */\nexport function themeSurfaces(theme: Theme): ToneSurfaces {\n const palette = paletteVariables(theme.palette);\n const surface = (tokens: Record<string, string>) => {\n const variables = { ...palette, ...tokens };\n const value = variables['panneau-color-surface'];\n return value !== undefined ? parseColor(resolveReference(value, variables)) : null;\n };\n const light = surface(theme.tokens);\n const dark =\n theme.dark?.['panneau-color-surface'] !== undefined\n ? surface({ ...theme.tokens, ...theme.dark })\n : null;\n return {\n ...(light !== null && { light }),\n ...(dark !== null && { dark }),\n };\n}\n\n/**\n * The rules of the densities of a theme. `auto` takes the comfortable values on fine pointers and\n * the touch ones on coarse pointers, like the default theme.\n */\nfunction densityCss(root: string, densities: Theme['densities'] = {}): string {\n const body = (density: Exclude<Density, 'auto'>) => declarations(densities[density] ?? {});\n const rule = (selector: string, css: string) => (css !== '' ? `${selector}{${css}}` : '');\n const media = (query: string, css: string) => (css !== '' ? `@media ${query}{${css}}` : '');\n const selector = (density: Density) => `${root}[data-density=\"${density}\"]`;\n return [\n rule(selector('compact'), body('compact')),\n rule(selector('comfortable'), body('comfortable')),\n media('not (pointer: coarse)', rule(selector('auto'), body('comfortable'))),\n rule(selector('touch'), body('touch')),\n media('(pointer: coarse)', rule(selector('auto'), body('touch'))),\n ].join('');\n}\n\n/**\n * The CSS of a theme, scoped to the roots that carry `data-panneau-theme=\"<scope>\"`: its palette and\n * tokens, its densities, its tones and the variants of components. Its rules are more specific than the default\n * tokens and the built-in tones, and dark overrides more specific than light ones. Token, tone,\n * component and variant names must be plain identifiers, and values can't contain `{`, `}`, `;` or\n * `<`: other entries are ignored.\n */\nexport function getThemeCss(theme: Theme, scope: string): string {\n const root = `[data-panneau-theme=\"${scope}\"]`;\n const dark = `${root}[data-color-scheme=\"dark\"]`;\n const auto = `${root}[data-color-scheme=\"auto\"]`;\n const light: string[] = [];\n const darkRules: string[] = [];\n const rule = (selector: string, body: string) => (body !== '' ? `${selector}{${body}}` : '');\n\n const palette = paletteVariables(theme.palette);\n const surfaces = themeSurfaces(theme);\n light.push(rule(root, declarations({ ...palette, ...theme.tokens })));\n light.push(densityCss(root, theme.densities));\n if (theme.dark !== undefined) {\n darkRules.push(rule('§', declarations(theme.dark)));\n }\n Object.entries(theme.tones ?? {})\n .filter(([name]) => NAME.test(name))\n .forEach(([name, input]) => {\n // A tone from a palette color derives from the color itself.\n const values = resolveTone(\n typeof input === 'string' ? resolveReference(input, palette) : input,\n surfaces,\n );\n const selector = `.${toneClassName(name)}`;\n light.push(rule(`${root} ${selector}`, toneDeclarations(values.light)));\n darkRules.push(rule(`§ ${selector}`, toneDeclarations(values.dark)));\n });\n Object.entries(theme.components ?? {})\n .filter(([component]) => NAME.test(component))\n .forEach(([component, { variants = {} }]) => {\n Object.entries(variants)\n .filter(([name]) => NAME.test(name))\n .forEach(([name, tokens]) => {\n light.push(\n rule(`${root} .panneau-${component}-variant-${name}`, declarations(tokens)),\n );\n });\n });\n\n const darkCss = darkRules.filter(Boolean);\n return [\n ...light,\n ...darkCss.map((css) => css.replaceAll('§', dark)),\n darkCss.length > 0\n ? `@media (prefers-color-scheme: dark){${darkCss.map((css) => css.replaceAll('§', auto)).join('')}}`\n : '',\n ].join('');\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Tone } from './tones';
|
|
2
|
+
/**
|
|
3
|
+
* The class of a tone, `panneau-tone-<tone>`. The built-in tones come from `Tone.module.css`, whose
|
|
4
|
+
* classes get the same stable names, so using it includes their CSS; a theme's own tones get their
|
|
5
|
+
* rules from the theme.
|
|
6
|
+
*/
|
|
7
|
+
export declare function toneClass(tone: Tone): string;
|
|
8
|
+
//# sourceMappingURL=toneClass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toneClass.d.ts","sourceRoot":"","sources":["../../src/theme/toneClass.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,EAAiB,MAAM,SAAS,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE5C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Tone_module_default from "./Tone.module.js";
|
|
2
|
+
import { toneClassName } from "./tones.js";
|
|
3
|
+
//#region src/theme/toneClass.ts
|
|
4
|
+
/**
|
|
5
|
+
* The class of a tone, `panneau-tone-<tone>`. The built-in tones come from `Tone.module.css`, whose
|
|
6
|
+
* classes get the same stable names, so using it includes their CSS; a theme's own tones get their
|
|
7
|
+
* rules from the theme.
|
|
8
|
+
*/
|
|
9
|
+
function toneClass(tone) {
|
|
10
|
+
return (Object.hasOwn(Tone_module_default, tone) ? Tone_module_default[tone] : void 0) ?? toneClassName(tone);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { toneClass };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=toneClass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toneClass.js","names":["styles"],"sources":["../../src/theme/toneClass.ts"],"sourcesContent":["import styles from './Tone.module.css';\nimport { type Tone, toneClassName } from './tones';\n\n/**\n * The class of a tone, `panneau-tone-<tone>`. The built-in tones come from `Tone.module.css`, whose\n * classes get the same stable names, so using it includes their CSS; a theme's own tones get their\n * rules from the theme.\n */\nexport function toneClass(tone: Tone): string {\n return (Object.hasOwn(styles, tone) ? styles[tone] : undefined) ?? toneClassName(tone);\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,UAAU,MAAoB;CAC1C,QAAQ,OAAO,OAAOA,qBAAQ,IAAI,IAAIA,oBAAO,QAAQ,KAAA,MAAc,cAAc,IAAI;AACzF"}
|