@becket-ui/tokens 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/preset.d.ts +7 -0
- package/dist/preset.js +1846 -0
- package/dist/preset.js.map +1 -0
- package/index.css +3033 -0
- package/index.d.ts +10 -0
- package/index.mjs +13 -0
- package/package.json +108 -0
- package/styled-system/css/conditions.mjs +36 -0
- package/styled-system/css/css.d.ts +22 -0
- package/styled-system/css/css.mjs +45 -0
- package/styled-system/css/cva.d.ts +6 -0
- package/styled-system/css/cva.mjs +87 -0
- package/styled-system/css/cx.d.ts +5 -0
- package/styled-system/css/cx.mjs +15 -0
- package/styled-system/css/index.d.ts +5 -0
- package/styled-system/css/index.mjs +4 -0
- package/styled-system/css/sva.d.ts +4 -0
- package/styled-system/css/sva.mjs +46 -0
- package/styled-system/helpers.mjs +328 -0
- package/styled-system/jsx/aspect-ratio.d.ts +10 -0
- package/styled-system/jsx/aspect-ratio.mjs +14 -0
- package/styled-system/jsx/bleed.d.ts +10 -0
- package/styled-system/jsx/bleed.mjs +14 -0
- package/styled-system/jsx/box.d.ts +10 -0
- package/styled-system/jsx/box.mjs +14 -0
- package/styled-system/jsx/center.d.ts +10 -0
- package/styled-system/jsx/center.mjs +14 -0
- package/styled-system/jsx/circle.d.ts +10 -0
- package/styled-system/jsx/circle.mjs +14 -0
- package/styled-system/jsx/container.d.ts +10 -0
- package/styled-system/jsx/container.mjs +14 -0
- package/styled-system/jsx/cq.d.ts +10 -0
- package/styled-system/jsx/cq.mjs +14 -0
- package/styled-system/jsx/create-style-context.d.ts +54 -0
- package/styled-system/jsx/create-style-context.mjs +121 -0
- package/styled-system/jsx/divider.d.ts +10 -0
- package/styled-system/jsx/divider.mjs +14 -0
- package/styled-system/jsx/factory-helper.mjs +22 -0
- package/styled-system/jsx/factory.d.ts +3 -0
- package/styled-system/jsx/factory.mjs +89 -0
- package/styled-system/jsx/flex.d.ts +10 -0
- package/styled-system/jsx/flex.mjs +14 -0
- package/styled-system/jsx/float.d.ts +10 -0
- package/styled-system/jsx/float.mjs +14 -0
- package/styled-system/jsx/grid-item.d.ts +10 -0
- package/styled-system/jsx/grid-item.mjs +14 -0
- package/styled-system/jsx/grid.d.ts +10 -0
- package/styled-system/jsx/grid.mjs +14 -0
- package/styled-system/jsx/hstack.d.ts +10 -0
- package/styled-system/jsx/hstack.mjs +14 -0
- package/styled-system/jsx/index.d.ts +25 -0
- package/styled-system/jsx/index.mjs +23 -0
- package/styled-system/jsx/is-valid-prop.d.ts +11 -0
- package/styled-system/jsx/is-valid-prop.mjs +17 -0
- package/styled-system/jsx/link-overlay.d.ts +10 -0
- package/styled-system/jsx/link-overlay.mjs +14 -0
- package/styled-system/jsx/spacer.d.ts +10 -0
- package/styled-system/jsx/spacer.mjs +14 -0
- package/styled-system/jsx/square.d.ts +10 -0
- package/styled-system/jsx/square.mjs +14 -0
- package/styled-system/jsx/stack.d.ts +10 -0
- package/styled-system/jsx/stack.mjs +14 -0
- package/styled-system/jsx/visually-hidden.d.ts +10 -0
- package/styled-system/jsx/visually-hidden.mjs +14 -0
- package/styled-system/jsx/vstack.d.ts +10 -0
- package/styled-system/jsx/vstack.mjs +14 -0
- package/styled-system/jsx/wrap.d.ts +10 -0
- package/styled-system/jsx/wrap.mjs +14 -0
- package/styled-system/patterns/aspect-ratio.d.ts +20 -0
- package/styled-system/patterns/aspect-ratio.mjs +38 -0
- package/styled-system/patterns/bleed.d.ts +21 -0
- package/styled-system/patterns/bleed.mjs +24 -0
- package/styled-system/patterns/box.d.ts +20 -0
- package/styled-system/patterns/box.mjs +15 -0
- package/styled-system/patterns/center.d.ts +20 -0
- package/styled-system/patterns/center.mjs +21 -0
- package/styled-system/patterns/circle.d.ts +20 -0
- package/styled-system/patterns/circle.mjs +25 -0
- package/styled-system/patterns/container.d.ts +20 -0
- package/styled-system/patterns/container.mjs +21 -0
- package/styled-system/patterns/cq.d.ts +21 -0
- package/styled-system/patterns/cq.mjs +21 -0
- package/styled-system/patterns/divider.d.ts +22 -0
- package/styled-system/patterns/divider.mjs +25 -0
- package/styled-system/patterns/flex.d.ts +26 -0
- package/styled-system/patterns/flex.mjs +26 -0
- package/styled-system/patterns/float.d.ts +23 -0
- package/styled-system/patterns/float.mjs +52 -0
- package/styled-system/patterns/grid-item.d.ts +25 -0
- package/styled-system/patterns/grid-item.mjs +25 -0
- package/styled-system/patterns/grid.d.ts +24 -0
- package/styled-system/patterns/grid.mjs +27 -0
- package/styled-system/patterns/hstack.d.ts +21 -0
- package/styled-system/patterns/hstack.mjs +24 -0
- package/styled-system/patterns/index.d.ts +21 -0
- package/styled-system/patterns/index.mjs +20 -0
- package/styled-system/patterns/link-overlay.d.ts +20 -0
- package/styled-system/patterns/link-overlay.mjs +24 -0
- package/styled-system/patterns/spacer.d.ts +20 -0
- package/styled-system/patterns/spacer.mjs +25 -0
- package/styled-system/patterns/square.d.ts +20 -0
- package/styled-system/patterns/square.mjs +24 -0
- package/styled-system/patterns/stack.d.ts +23 -0
- package/styled-system/patterns/stack.mjs +24 -0
- package/styled-system/patterns/visually-hidden.d.ts +20 -0
- package/styled-system/patterns/visually-hidden.mjs +18 -0
- package/styled-system/patterns/vstack.d.ts +21 -0
- package/styled-system/patterns/vstack.mjs +24 -0
- package/styled-system/patterns/wrap.d.ts +24 -0
- package/styled-system/patterns/wrap.mjs +25 -0
- package/styled-system/recipes/badge.d.ts +48 -0
- package/styled-system/recipes/badge.mjs +91 -0
- package/styled-system/recipes/button.d.ts +52 -0
- package/styled-system/recipes/button.mjs +122 -0
- package/styled-system/recipes/card.d.ts +44 -0
- package/styled-system/recipes/card.mjs +76 -0
- package/styled-system/recipes/checkbox.d.ts +36 -0
- package/styled-system/recipes/checkbox.mjs +62 -0
- package/styled-system/recipes/create-recipe.mjs +82 -0
- package/styled-system/recipes/dialog.d.ts +33 -0
- package/styled-system/recipes/dialog.mjs +53 -0
- package/styled-system/recipes/drawer.d.ts +36 -0
- package/styled-system/recipes/drawer.mjs +62 -0
- package/styled-system/recipes/field.d.ts +40 -0
- package/styled-system/recipes/field.mjs +61 -0
- package/styled-system/recipes/heading.d.ts +40 -0
- package/styled-system/recipes/heading.mjs +54 -0
- package/styled-system/recipes/hide.d.ts +38 -0
- package/styled-system/recipes/hide.mjs +246 -0
- package/styled-system/recipes/index.d.ts +23 -0
- package/styled-system/recipes/index.mjs +22 -0
- package/styled-system/recipes/link.d.ts +40 -0
- package/styled-system/recipes/link.mjs +36 -0
- package/styled-system/recipes/menu.d.ts +33 -0
- package/styled-system/recipes/menu.mjs +45 -0
- package/styled-system/recipes/radio.d.ts +36 -0
- package/styled-system/recipes/radio.mjs +70 -0
- package/styled-system/recipes/select-recipe.d.ts +40 -0
- package/styled-system/recipes/select-recipe.mjs +37 -0
- package/styled-system/recipes/separator.d.ts +36 -0
- package/styled-system/recipes/separator.mjs +31 -0
- package/styled-system/recipes/spinner.d.ts +36 -0
- package/styled-system/recipes/spinner.mjs +32 -0
- package/styled-system/recipes/switch-recipe.d.ts +40 -0
- package/styled-system/recipes/switch-recipe.mjs +93 -0
- package/styled-system/recipes/table.d.ts +36 -0
- package/styled-system/recipes/table.mjs +70 -0
- package/styled-system/recipes/tabs.d.ts +33 -0
- package/styled-system/recipes/tabs.mjs +45 -0
- package/styled-system/recipes/tag.d.ts +48 -0
- package/styled-system/recipes/tag.mjs +89 -0
- package/styled-system/recipes/text-field-recipe.d.ts +40 -0
- package/styled-system/recipes/text-field-recipe.mjs +37 -0
- package/styled-system/recipes/textarea-recipe.d.ts +40 -0
- package/styled-system/recipes/textarea-recipe.mjs +37 -0
- package/styled-system/recipes/tooltip.d.ts +36 -0
- package/styled-system/recipes/tooltip.mjs +33 -0
- package/styled-system/styles.css +2986 -0
- package/styled-system/tokens/index.d.ts +9 -0
- package/styled-system/tokens/index.mjs +2128 -0
- package/styled-system/tokens/tokens.d.ts +63 -0
- package/styled-system/types/composition.d.ts +227 -0
- package/styled-system/types/conditions.d.ts +310 -0
- package/styled-system/types/csstype.d.ts +22570 -0
- package/styled-system/types/global.d.ts +20 -0
- package/styled-system/types/index.d.ts +8 -0
- package/styled-system/types/jsx.d.ts +69 -0
- package/styled-system/types/parts.d.ts +8 -0
- package/styled-system/types/pattern.d.ts +78 -0
- package/styled-system/types/prop-type.d.ts +251 -0
- package/styled-system/types/recipe.d.ts +181 -0
- package/styled-system/types/selectors.d.ts +59 -0
- package/styled-system/types/static-css.d.ts +56 -0
- package/styled-system/types/style-props.d.ts +8089 -0
- package/styled-system/types/system-types.d.ts +151 -0
- package/theme/index.d.ts +56 -0
- package/theme/index.mjs +168 -0
- package/theme.example.css +68 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { ConditionalValue, Nested } from './conditions';
|
|
3
|
+
import type { AtRule, Globals, PropertiesFallback } from './csstype';
|
|
4
|
+
import type { SystemProperties, CssVarProperties } from './style-props';
|
|
5
|
+
|
|
6
|
+
type String = string & {}
|
|
7
|
+
type Number = number & {}
|
|
8
|
+
|
|
9
|
+
export type Pretty<T> = { [K in keyof T]: T[K] } & {}
|
|
10
|
+
|
|
11
|
+
export type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never
|
|
12
|
+
|
|
13
|
+
export type DistributiveUnion<T, U> = {
|
|
14
|
+
[K in keyof T]: K extends keyof U ? U[K] | T[K] : T[K]
|
|
15
|
+
} & DistributiveOmit<U, keyof T>
|
|
16
|
+
|
|
17
|
+
export type Assign<T, U> = {
|
|
18
|
+
[K in keyof T]: K extends keyof U ? U[K] : T[K]
|
|
19
|
+
} & U
|
|
20
|
+
|
|
21
|
+
/* -----------------------------------------------------------------------------
|
|
22
|
+
* Native css properties
|
|
23
|
+
* -----------------------------------------------------------------------------*/
|
|
24
|
+
|
|
25
|
+
type CornerShapeValue = 'round' | 'square' | 'bevel' | 'scoop' | 'notch' | 'squircle' | `superellipse(${number})`
|
|
26
|
+
|
|
27
|
+
export interface ModernCssProperties {
|
|
28
|
+
/**
|
|
29
|
+
* Controls whether the entire element should be draggable instead of its contents.
|
|
30
|
+
*/
|
|
31
|
+
WebkitUserDrag?: Globals | 'auto' | 'element' | 'none'
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Specifies whether an element can be used to drag the entire app window (Electron).
|
|
35
|
+
*/
|
|
36
|
+
WebkitAppRegion?: Globals | 'drag' | 'no-drag'
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Sets the horizontal spacing between table borders.
|
|
40
|
+
*/
|
|
41
|
+
WebkitBorderHorizontalSpacing?: Globals | String | Number
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Sets the vertical spacing between table borders.
|
|
45
|
+
*/
|
|
46
|
+
WebkitBorderVerticalSpacing?: Globals | String | Number
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Controls the display of text content for security purposes (e.g., password fields).
|
|
50
|
+
*/
|
|
51
|
+
WebkitTextSecurity?: Globals | 'none' | 'circle' | 'disc' | 'square'
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Specifies the shape of a box's corners within the area defined by the border-radius property.
|
|
55
|
+
* @experimental
|
|
56
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/corner-shape
|
|
57
|
+
*/
|
|
58
|
+
cornerShape?:
|
|
59
|
+
| Globals
|
|
60
|
+
| CornerShapeValue
|
|
61
|
+
| `${CornerShapeValue} ${CornerShapeValue}`
|
|
62
|
+
| `${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue}`
|
|
63
|
+
| `${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue}`
|
|
64
|
+
| String
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type CssProperty = keyof PropertiesFallback
|
|
68
|
+
|
|
69
|
+
export interface CssProperties extends PropertiesFallback<String | Number>, CssVarProperties, ModernCssProperties {}
|
|
70
|
+
|
|
71
|
+
export interface CssKeyframes {
|
|
72
|
+
[name: string]: {
|
|
73
|
+
[time: string]: CssProperties
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* -----------------------------------------------------------------------------
|
|
78
|
+
* Conditional css properties
|
|
79
|
+
* -----------------------------------------------------------------------------*/
|
|
80
|
+
|
|
81
|
+
interface GenericProperties {
|
|
82
|
+
[key: string]: ConditionalValue<String | Number | boolean>
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* -----------------------------------------------------------------------------
|
|
86
|
+
* Native css props
|
|
87
|
+
* -----------------------------------------------------------------------------*/
|
|
88
|
+
|
|
89
|
+
export type NestedCssProperties = Nested<CssProperties>
|
|
90
|
+
|
|
91
|
+
export type SystemStyleObject = Omit<Nested<SystemProperties & CssVarProperties>, 'base'>
|
|
92
|
+
|
|
93
|
+
export interface GlobalStyleObject {
|
|
94
|
+
[selector: string]: SystemStyleObject
|
|
95
|
+
}
|
|
96
|
+
export interface ExtendableGlobalStyleObject {
|
|
97
|
+
[selector: string]: SystemStyleObject | undefined
|
|
98
|
+
extend?: GlobalStyleObject | undefined
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* -----------------------------------------------------------------------------
|
|
102
|
+
* Composition (text styles, layer styles)
|
|
103
|
+
* -----------------------------------------------------------------------------*/
|
|
104
|
+
|
|
105
|
+
type FilterStyleObject<P extends string> = {
|
|
106
|
+
[K in P]?: K extends keyof SystemStyleObject ? SystemStyleObject[K] : unknown
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type CompositionStyleObject<Property extends string> = Nested<FilterStyleObject<Property> & CssVarProperties>
|
|
110
|
+
|
|
111
|
+
/* -----------------------------------------------------------------------------
|
|
112
|
+
* Font face
|
|
113
|
+
* -----------------------------------------------------------------------------*/
|
|
114
|
+
|
|
115
|
+
export type GlobalFontfaceRule = Omit<AtRule.FontFaceFallback, 'src'> & Required<Pick<AtRule.FontFaceFallback, 'src'>>
|
|
116
|
+
|
|
117
|
+
export type FontfaceRule = Omit<GlobalFontfaceRule, 'fontFamily'>
|
|
118
|
+
|
|
119
|
+
export interface GlobalFontface {
|
|
120
|
+
[name: string]: FontfaceRule | FontfaceRule[]
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface ExtendableGlobalFontface {
|
|
124
|
+
[name: string]: FontfaceRule | FontfaceRule[] | GlobalFontface | undefined
|
|
125
|
+
extend?: GlobalFontface | undefined
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* -----------------------------------------------------------------------------
|
|
129
|
+
* Jsx style props
|
|
130
|
+
* -----------------------------------------------------------------------------*/
|
|
131
|
+
interface WithCss {
|
|
132
|
+
css?: SystemStyleObject | SystemStyleObject[]
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export type JsxStyleProps = SystemStyleObject & WithCss
|
|
136
|
+
|
|
137
|
+
export interface PatchedHTMLProps {
|
|
138
|
+
htmlWidth?: string | number
|
|
139
|
+
htmlHeight?: string | number
|
|
140
|
+
htmlTranslate?: 'yes' | 'no' | undefined
|
|
141
|
+
htmlContent?: string
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export type OmittedHTMLProps = 'color' | 'translate' | 'transition' | 'width' | 'height' | 'content'
|
|
145
|
+
|
|
146
|
+
type WithHTMLProps<T> = DistributiveOmit<T, OmittedHTMLProps> & PatchedHTMLProps
|
|
147
|
+
|
|
148
|
+
export type JsxHTMLProps<T extends Record<string, any>, P extends Record<string, any> = {}> = Assign<
|
|
149
|
+
WithHTMLProps<T>,
|
|
150
|
+
P
|
|
151
|
+
>
|
package/theme/index.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export type BecketColorValue = string | { dark?: string; light?: string };
|
|
2
|
+
|
|
3
|
+
export type BecketThemeColors = {
|
|
4
|
+
primary?: string;
|
|
5
|
+
secondary?: string;
|
|
6
|
+
tertiary?: string;
|
|
7
|
+
primaryHover?: string;
|
|
8
|
+
background?: BecketColorValue;
|
|
9
|
+
text?: BecketColorValue;
|
|
10
|
+
muted?: BecketColorValue;
|
|
11
|
+
border?: BecketColorValue;
|
|
12
|
+
/** @deprecated Prefer `background: { light }`. */
|
|
13
|
+
lightBackground?: string;
|
|
14
|
+
/** @deprecated Prefer `text: { light }`. */
|
|
15
|
+
lightText?: string;
|
|
16
|
+
danger?: string;
|
|
17
|
+
warning?: string;
|
|
18
|
+
success?: string;
|
|
19
|
+
neutral?: Partial<
|
|
20
|
+
Record<'50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900', string>
|
|
21
|
+
>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type BecketThemeRadii = Partial<
|
|
25
|
+
Record<'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full', string>
|
|
26
|
+
>;
|
|
27
|
+
|
|
28
|
+
export type BecketThemeFontSizes = Partial<
|
|
29
|
+
Record<'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl', string>
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
export type BecketThemeSpacing = Partial<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl', string>>;
|
|
33
|
+
|
|
34
|
+
export type BecketDensityBox = { px?: string; py?: string };
|
|
35
|
+
|
|
36
|
+
export type BecketThemeDensity = {
|
|
37
|
+
button?: Partial<Record<'sm' | 'md', BecketDensityBox>>;
|
|
38
|
+
field?: Partial<Record<'sm' | 'md' | 'lg', BecketDensityBox>>;
|
|
39
|
+
tag?: Partial<Record<'sm' | 'md' | 'lg', BecketDensityBox>>;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type BecketTheme = {
|
|
43
|
+
colors?: BecketThemeColors;
|
|
44
|
+
radii?: BecketThemeRadii;
|
|
45
|
+
fontSizes?: BecketThemeFontSizes;
|
|
46
|
+
spacing?: BecketThemeSpacing;
|
|
47
|
+
sizes?: { field?: string };
|
|
48
|
+
fonts?: { sans?: string; mono?: string };
|
|
49
|
+
density?: BecketThemeDensity;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** Unlayered `:root` / light-theme CSS. Import or inject after `@becket-ui/tokens/index.css`. */
|
|
53
|
+
export function defineBecketTheme(config?: BecketTheme): string;
|
|
54
|
+
|
|
55
|
+
export const BECKET_PUBLIC_COLOR_KEYS: readonly string[];
|
|
56
|
+
export const BECKET_PUBLIC_NEUTRAL_STEPS: readonly string[];
|
package/theme/index.mjs
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/** Public CSS-variable theming. No Panda, no theme provider. */
|
|
2
|
+
|
|
3
|
+
const PREFIX = '--beckui--';
|
|
4
|
+
|
|
5
|
+
const COLOR_FLAT = [
|
|
6
|
+
'primary',
|
|
7
|
+
'secondary',
|
|
8
|
+
'tertiary',
|
|
9
|
+
'primaryHover',
|
|
10
|
+
'lightBackground',
|
|
11
|
+
'lightText',
|
|
12
|
+
'danger',
|
|
13
|
+
'warning',
|
|
14
|
+
'success',
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const COLOR_THEMED = ['background', 'text', 'muted', 'border'];
|
|
18
|
+
const NEUTRAL_STEPS = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900'];
|
|
19
|
+
const RADII = ['none', 'sm', 'md', 'lg', 'xl', 'full'];
|
|
20
|
+
const FONT_SIZES = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl'];
|
|
21
|
+
const SPACING = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
22
|
+
const FONTS = ['sans', 'mono'];
|
|
23
|
+
const DENSITY_SIZES = {
|
|
24
|
+
button: ['sm', 'md'],
|
|
25
|
+
field: ['sm', 'md', 'lg'],
|
|
26
|
+
tag: ['sm', 'md', 'lg'],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function kebab(value) {
|
|
30
|
+
return value.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function cssVar(parts) {
|
|
34
|
+
return `${PREFIX}${parts.map(kebab).join('-')}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function assertAllowedKeys(object, allowed, label) {
|
|
38
|
+
for (const key of Object.keys(object)) {
|
|
39
|
+
if (!allowed.includes(key)) {
|
|
40
|
+
throw new Error(`Unknown Becket theme key "${label}.${key}"`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function pushDecl(decls, name, value) {
|
|
46
|
+
if (value == null || value === '') return;
|
|
47
|
+
decls.push(` ${name}: ${value};`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function pushThemed(rootDecls, lightDecls, name, value) {
|
|
51
|
+
if (value == null || value === '') return;
|
|
52
|
+
if (typeof value === 'object') {
|
|
53
|
+
if (value.dark) pushDecl(rootDecls, name, value.dark);
|
|
54
|
+
if (value.light) pushDecl(lightDecls, name, value.light);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
pushDecl(rootDecls, name, value);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function colorDecls(colors, rootDecls, lightDecls) {
|
|
61
|
+
assertAllowedKeys(colors, [...COLOR_FLAT, ...COLOR_THEMED, 'neutral'], 'colors');
|
|
62
|
+
|
|
63
|
+
for (const key of COLOR_FLAT) {
|
|
64
|
+
const value = colors[key];
|
|
65
|
+
if (value == null) continue;
|
|
66
|
+
if (typeof value === 'object') {
|
|
67
|
+
throw new Error(`colors.${key} must be a CSS color string`);
|
|
68
|
+
}
|
|
69
|
+
pushDecl(rootDecls, cssVar(['colors', key]), value);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
for (const key of COLOR_THEMED) {
|
|
73
|
+
pushThemed(rootDecls, lightDecls, cssVar(['colors', key]), colors[key]);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (colors.neutral) {
|
|
77
|
+
assertAllowedKeys(colors.neutral, NEUTRAL_STEPS, 'colors.neutral');
|
|
78
|
+
for (const step of NEUTRAL_STEPS) {
|
|
79
|
+
pushDecl(rootDecls, cssVar(['colors', 'neutral', step]), colors.neutral[step]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function densityDecls(density, decls) {
|
|
85
|
+
assertAllowedKeys(density, ['button', 'field', 'tag'], 'density');
|
|
86
|
+
for (const component of Object.keys(DENSITY_SIZES)) {
|
|
87
|
+
const sizes = density[component];
|
|
88
|
+
if (!sizes) continue;
|
|
89
|
+
const allowed = DENSITY_SIZES[component];
|
|
90
|
+
assertAllowedKeys(sizes, allowed, `density.${component}`);
|
|
91
|
+
for (const size of allowed) {
|
|
92
|
+
const box = sizes[size];
|
|
93
|
+
if (!box) continue;
|
|
94
|
+
assertAllowedKeys(box, ['px', 'py'], `density.${component}.${size}`);
|
|
95
|
+
if (box.px) decls.push(` --beckui-${component}-px-${size}: ${box.px};`);
|
|
96
|
+
if (box.py) decls.push(` --beckui-${component}-py-${size}: ${box.py};`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function sheet(selector, decls) {
|
|
102
|
+
if (!decls.length) return '';
|
|
103
|
+
return `${selector} {\n${decls.join('\n')}\n}\n`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Emit unlayered `:root` / `html[data-theme='light']` overrides. Import or
|
|
108
|
+
* inject **after** `@becket-ui/tokens/index.css` so these win over `@layer tokens`.
|
|
109
|
+
*
|
|
110
|
+
* @param {import('./index.d.ts').BecketTheme} config
|
|
111
|
+
* @returns {string}
|
|
112
|
+
*/
|
|
113
|
+
export function defineBecketTheme(config = {}) {
|
|
114
|
+
assertAllowedKeys(
|
|
115
|
+
config,
|
|
116
|
+
['colors', 'radii', 'fontSizes', 'spacing', 'sizes', 'fonts', 'density'],
|
|
117
|
+
'theme',
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const rootDecls = [];
|
|
121
|
+
const lightDecls = [];
|
|
122
|
+
|
|
123
|
+
if (config.colors) colorDecls(config.colors, rootDecls, lightDecls);
|
|
124
|
+
|
|
125
|
+
if (config.radii) {
|
|
126
|
+
assertAllowedKeys(config.radii, RADII, 'radii');
|
|
127
|
+
for (const key of RADII) {
|
|
128
|
+
pushDecl(rootDecls, cssVar(['radii', key]), config.radii[key]);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (config.fontSizes) {
|
|
133
|
+
assertAllowedKeys(config.fontSizes, FONT_SIZES, 'fontSizes');
|
|
134
|
+
for (const key of FONT_SIZES) {
|
|
135
|
+
pushDecl(rootDecls, cssVar(['font-sizes', key]), config.fontSizes[key]);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (config.spacing) {
|
|
140
|
+
assertAllowedKeys(config.spacing, SPACING, 'spacing');
|
|
141
|
+
for (const key of SPACING) {
|
|
142
|
+
pushDecl(rootDecls, cssVar(['spacing', key]), config.spacing[key]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (config.sizes) {
|
|
147
|
+
assertAllowedKeys(config.sizes, ['field'], 'sizes');
|
|
148
|
+
pushDecl(rootDecls, cssVar(['sizes', 'field']), config.sizes.field);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (config.fonts) {
|
|
152
|
+
assertAllowedKeys(config.fonts, FONTS, 'fonts');
|
|
153
|
+
for (const key of FONTS) {
|
|
154
|
+
pushDecl(rootDecls, cssVar(['fonts', key]), config.fonts[key]);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (config.density) densityDecls(config.density, rootDecls);
|
|
159
|
+
|
|
160
|
+
const css = `${sheet(':root', rootDecls)}${sheet("html[data-theme='light']", lightDecls)}`;
|
|
161
|
+
if (!css) {
|
|
162
|
+
return '/* defineBecketTheme: empty config, Becket defaults unchanged */\n';
|
|
163
|
+
}
|
|
164
|
+
return css;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export const BECKET_PUBLIC_COLOR_KEYS = [...COLOR_FLAT, ...COLOR_THEMED];
|
|
168
|
+
export const BECKET_PUBLIC_NEUTRAL_STEPS = NEUTRAL_STEPS;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Becket public theme contract (copy, then import AFTER index.css).
|
|
3
|
+
*
|
|
4
|
+
* import '@becket-ui/tokens/index.css';
|
|
5
|
+
* import './becket-theme.css'; // this file, renamed
|
|
6
|
+
*
|
|
7
|
+
* Or generate the same vars with:
|
|
8
|
+
* import { defineBecketTheme } from '@becket-ui/tokens/theme';
|
|
9
|
+
*
|
|
10
|
+
* Unlayered :root wins over @layer tokens. Do not depend on Panda leftover
|
|
11
|
+
* names (rose-500, spacing-11, sizes-md, …) — those are not public API.
|
|
12
|
+
*
|
|
13
|
+
* Light/dark: `background` / `text` / `muted` are semantic. Override them on
|
|
14
|
+
* :root (dark) and html[data-theme='light'] (light), or pass { dark, light }
|
|
15
|
+
* to defineBecketTheme. lightBackground / lightText still exist as aliases.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
:root {
|
|
19
|
+
/* Brand aliases — override these to recolor the kit */
|
|
20
|
+
/* --beckui--colors-primary: oklch(0.75 0.15 78); */
|
|
21
|
+
/* --beckui--colors-secondary: oklch(0.70 0.13 125); */
|
|
22
|
+
/* --beckui--colors-tertiary: oklch(0.60 0.16 48); */
|
|
23
|
+
/* --beckui--colors-primary-hover follows primary via color-mix */
|
|
24
|
+
|
|
25
|
+
/* Semantic surfaces (dark = :root default) */
|
|
26
|
+
/* --beckui--colors-background: var(--beckui--colors-neutral-900); */
|
|
27
|
+
/* --beckui--colors-text: var(--beckui--colors-neutral-50); */
|
|
28
|
+
/* --beckui--colors-muted: var(--beckui--colors-neutral-300); */
|
|
29
|
+
/* --beckui--colors-border: var(--beckui--colors-neutral-200); */
|
|
30
|
+
|
|
31
|
+
/* Neutral scale 50–900 */
|
|
32
|
+
/* --beckui--colors-neutral-50: oklch(0.96 0.012 78); */
|
|
33
|
+
/* --beckui--colors-neutral-900: oklch(0.22 0.015 60); */
|
|
34
|
+
|
|
35
|
+
/* Status — never aliases of primary */
|
|
36
|
+
/* --beckui--colors-danger: oklch(0.62 0.20 25); */
|
|
37
|
+
/* --beckui--colors-warning: oklch(0.78 0.14 95); */
|
|
38
|
+
/* --beckui--colors-success: oklch(0.68 0.16 145); */
|
|
39
|
+
|
|
40
|
+
/* Type + layout spacing (Stack gap). Do not use these to densify buttons. */
|
|
41
|
+
/* --beckui--fonts-sans: 'Inter', 'Roboto', 'Helvetica Neue', Arial, sans-serif; */
|
|
42
|
+
/* --beckui--fonts-mono: 'JetBrains Mono', 'Menlo', 'Consolas', 'monospace'; */
|
|
43
|
+
/* --beckui--font-sizes-sm: 0.875rem; */
|
|
44
|
+
/* --beckui--font-sizes-md: 1rem; */
|
|
45
|
+
/* --beckui--spacing-xs: var(--beckui--spacing-1); */
|
|
46
|
+
/* --beckui--spacing-sm: var(--beckui--spacing-2); */
|
|
47
|
+
/* --beckui--spacing-md: var(--beckui--spacing-3); */
|
|
48
|
+
/* --beckui--spacing-lg: var(--beckui--spacing-5); */
|
|
49
|
+
/* --beckui--spacing-xl: var(--beckui--spacing-8); */
|
|
50
|
+
/* --beckui--radii-sm: 4px; */
|
|
51
|
+
/* --beckui--radii-md: 8px; */
|
|
52
|
+
/* --beckui--radii-lg: 12px; */
|
|
53
|
+
/* --beckui--sizes-field: 12.5rem; */
|
|
54
|
+
|
|
55
|
+
/* Component density (not Stack gap) */
|
|
56
|
+
/* --beckui-button-px-md: 1rem; */
|
|
57
|
+
/* --beckui-button-py-md: 0.5rem; */
|
|
58
|
+
/* --beckui-field-px-md: 0.75rem; */
|
|
59
|
+
/* --beckui-field-py-md: 0.5rem; */
|
|
60
|
+
/* --beckui-tag-px-md: 0.75rem; */
|
|
61
|
+
/* --beckui-tag-py-md: 0.25rem; */
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
html[data-theme='light'] {
|
|
65
|
+
/* --beckui--colors-background: var(--beckui--colors-neutral-50); */
|
|
66
|
+
/* --beckui--colors-text: var(--beckui--colors-neutral-900); */
|
|
67
|
+
/* --beckui--colors-muted: var(--beckui--colors-neutral-600); */
|
|
68
|
+
}
|