@cognitap/radiant 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +9 -0
- package/dist/library/Card.d.ts.map +1 -1
- package/dist/library/Card.js +8 -6
- package/dist/library/Card.js.map +1 -1
- package/dist/library/Checkbox.js +2 -2
- package/dist/library/Checkbox.js.map +1 -1
- package/dist/library/Collapsible.d.ts.map +1 -1
- package/dist/library/Collapsible.js +5 -4
- package/dist/library/Collapsible.js.map +1 -1
- package/dist/library/Dialog.d.ts.map +1 -1
- package/dist/library/Dialog.js +8 -6
- package/dist/library/Dialog.js.map +1 -1
- package/dist/library/Field.js +4 -4
- package/dist/library/Field.js.map +1 -1
- package/dist/library/Input.d.ts.map +1 -1
- package/dist/library/Input.js +4 -3
- package/dist/library/Input.js.map +1 -1
- package/dist/library/Link.d.ts.map +1 -1
- package/dist/library/Link.js +0 -1
- package/dist/library/Link.js.map +1 -1
- package/dist/library/RadioGroup.js +2 -2
- package/dist/library/RadioGroup.js.map +1 -1
- package/dist/library/ThemeScope.js +1 -1
- package/dist/library/ThemeScope.js.map +1 -1
- package/dist/library/actionStyles.js +2 -2
- package/dist/library/actionStyles.js.map +1 -1
- package/dist/library/cn.d.ts +2 -1
- package/dist/library/cn.d.ts.map +1 -1
- package/dist/library/cn.js +22 -1
- package/dist/library/cn.js.map +1 -1
- package/dist/library/index.d.ts +3 -1
- package/dist/library/index.d.ts.map +1 -1
- package/dist/library/index.js +1 -0
- package/dist/library/index.js.map +1 -1
- package/dist/library/styles.css +1 -1
- package/dist/library/themes/defineTheme.d.ts.map +1 -1
- package/dist/library/themes/defineTheme.js +5 -1
- package/dist/library/themes/defineTheme.js.map +1 -1
- package/dist/library/themes/index.d.ts +1 -1
- package/dist/library/themes/index.d.ts.map +1 -1
- package/dist/library/themes/index.js.map +1 -1
- package/dist/library/themes/themeDocument.d.ts.map +1 -1
- package/dist/library/themes/themeDocument.js +29 -4
- package/dist/library/themes/themeDocument.js.map +1 -1
- package/dist/library/themes/themeDocumentTypes.d.ts +11 -0
- package/dist/library/themes/themeDocumentTypes.d.ts.map +1 -1
- package/dist/library/themes/themeDocumentTypes.js.map +1 -1
- package/dist/library/themes/tokens.d.ts +7 -0
- package/dist/library/themes/tokens.d.ts.map +1 -1
- package/dist/library/themes/tokens.js +99 -0
- package/dist/library/themes/tokens.js.map +1 -1
- package/dist/library/typography/index.d.ts +72 -0
- package/dist/library/typography/index.d.ts.map +1 -0
- package/dist/library/typography/index.js +160 -0
- package/dist/library/typography/index.js.map +1 -0
- package/dist/library/typography/types.d.ts +78 -0
- package/dist/library/typography/types.d.ts.map +1 -0
- package/dist/library/typography/types.js +2 -0
- package/dist/library/typography/types.js.map +1 -0
- package/docs/system.md +7 -0
- package/docs/theming.md +204 -0
- package/package.json +7 -2
- package/src/Card.tsx +8 -6
- package/src/Checkbox.tsx +2 -2
- package/src/Collapsible.tsx +5 -4
- package/src/Dialog.tsx +8 -6
- package/src/Field.tsx +4 -4
- package/src/Input.tsx +4 -3
- package/src/Link.tsx +0 -1
- package/src/RadioGroup.tsx +2 -2
- package/src/ThemeScope.tsx +1 -1
- package/src/actionStyles.ts +2 -2
- package/src/cn.ts +25 -1
- package/src/index.ts +3 -0
- package/src/styles.css +1 -0
- package/src/themes/baseline.css +131 -0
- package/src/themes/defineTheme.ts +5 -1
- package/src/themes/index.ts +1 -0
- package/src/themes/themeDocument.ts +34 -4
- package/src/themes/themeDocumentTypes.ts +12 -0
- package/src/themes/tokens.ts +137 -0
- package/src/typography/index.ts +199 -0
- package/src/typography/types.ts +92 -0
- package/src/typography.css +336 -0
package/src/Dialog.tsx
CHANGED
|
@@ -16,7 +16,7 @@ const colorMotionClass =
|
|
|
16
16
|
|
|
17
17
|
const dialogVariants = cva([
|
|
18
18
|
colorMotionClass,
|
|
19
|
-
'
|
|
19
|
+
'font-[family-name:var(--rad-typography-roles-ui-body-family,system-ui,sans-serif)] tracking-[var(--rad-typography-roles-ui-body-letter-spacing,-0.011em)] text-[length:var(--rad-typography-roles-ui-body-size,0.875rem)] font-[number:var(--rad-typography-roles-ui-body-weight,400)] leading-[var(--rad-typography-roles-ui-body-line-height,1.5)]',
|
|
20
20
|
'box-border text-start antialiased',
|
|
21
21
|
'[&:not([open])]:hidden',
|
|
22
22
|
'open:m-auto open:grid open:overflow-auto open:overscroll-contain',
|
|
@@ -45,17 +45,19 @@ const dialogVariants = cva([
|
|
|
45
45
|
|
|
46
46
|
const dialogTitleVariants = cva([
|
|
47
47
|
colorMotionClass,
|
|
48
|
-
'm-0 min-w-0 break-words
|
|
49
|
-
'
|
|
50
|
-
'[
|
|
48
|
+
'm-0 min-w-0 break-words',
|
|
49
|
+
'font-[family-name:var(--rad-typography-roles-ui-title-family,system-ui,sans-serif)] tracking-[var(--rad-typography-roles-ui-title-letter-spacing,-0.015em)]',
|
|
50
|
+
'text-[length:var(--rad-dialog-title-size,var(--rad-typography-roles-ui-title-size,1.125rem))] leading-[var(--rad-typography-roles-ui-title-line-height,1.3)]',
|
|
51
|
+
'font-[number:var(--rad-dialog-title-weight,var(--rad-typography-roles-ui-title-weight,600))]',
|
|
51
52
|
'forced-colors:text-[CanvasText]'
|
|
52
53
|
])
|
|
53
54
|
|
|
54
55
|
const dialogDescriptionVariants = cva([
|
|
55
56
|
colorMotionClass,
|
|
56
|
-
'm-0 min-w-0 break-words
|
|
57
|
+
'm-0 min-w-0 break-words',
|
|
57
58
|
'[color:var(--rad-dialog-description-color,var(--rad-color-muted-foreground,oklch(0.45_0.01_286)))]',
|
|
58
|
-
'[font-
|
|
59
|
+
'font-[family-name:var(--rad-typography-roles-ui-supporting-family,system-ui,sans-serif)] font-[number:var(--rad-typography-roles-ui-supporting-weight,400)] tracking-[var(--rad-typography-roles-ui-supporting-letter-spacing,0em)]',
|
|
60
|
+
'text-[length:var(--rad-dialog-description-size,var(--rad-typography-roles-ui-supporting-size,0.8125rem))] leading-[var(--rad-typography-roles-ui-supporting-line-height,1.5)]',
|
|
59
61
|
'forced-colors:text-[CanvasText]'
|
|
60
62
|
])
|
|
61
63
|
|
package/src/Field.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import type { PartStyle } from './presentation.js'
|
|
|
10
10
|
|
|
11
11
|
const fieldVariants = cva(
|
|
12
12
|
[
|
|
13
|
-
'
|
|
13
|
+
'font-[family-name:var(--rad-typography-roles-ui-body-family,system-ui,sans-serif)] tracking-[var(--rad-typography-roles-ui-body-letter-spacing,-0.011em)] text-[length:var(--rad-typography-roles-ui-body-size,0.875rem)] font-[number:var(--rad-typography-roles-ui-body-weight,400)] leading-[var(--rad-typography-roles-ui-body-line-height,1.5)]',
|
|
14
14
|
'grid min-w-0 [gap:var(--rad-field-gap,var(--rad-spacing-field-gap,0.375rem))]',
|
|
15
15
|
// Dim controls/labels once; help and error text must stay readable.
|
|
16
16
|
'in-[[data-slot~=field][data-disabled]]:[--_rad-disabled-opacity:1]',
|
|
@@ -30,13 +30,13 @@ const fieldVariants = cva(
|
|
|
30
30
|
)
|
|
31
31
|
|
|
32
32
|
const labelClass =
|
|
33
|
-
'min-w-0 break-words p-0 [color:var(--rad-field-label-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))] [
|
|
33
|
+
'min-w-0 break-words p-0 [color:var(--rad-field-label-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))] text-[length:var(--rad-field-label-size,var(--rad-typography-roles-ui-label-size,0.875rem))] font-[number:var(--rad-field-label-weight,var(--rad-typography-roles-ui-label-weight,550))] forced-colors:text-[CanvasText] font-[family-name:var(--rad-typography-roles-ui-label-family,system-ui,sans-serif)] leading-[var(--rad-typography-roles-ui-label-line-height,1.4)] tracking-[var(--rad-typography-roles-ui-label-letter-spacing,0em)]'
|
|
34
34
|
|
|
35
35
|
const descriptionClass =
|
|
36
|
-
'min-w-0 break-words [color:var(--rad-field-description-color,var(--rad-color-muted-foreground,oklch(0.45_0.01_286)))] [
|
|
36
|
+
'min-w-0 break-words [color:var(--rad-field-description-color,var(--rad-color-muted-foreground,oklch(0.45_0.01_286)))] text-[length:var(--rad-field-description-size,var(--rad-typography-roles-ui-supporting-size,0.8125rem))] forced-colors:text-[CanvasText] font-[family-name:var(--rad-typography-roles-ui-supporting-family,system-ui,sans-serif)] leading-[var(--rad-typography-roles-ui-supporting-line-height,1.5)] tracking-[var(--rad-typography-roles-ui-supporting-letter-spacing,0em)] font-[number:var(--rad-typography-roles-ui-supporting-weight,400)]'
|
|
37
37
|
|
|
38
38
|
const errorClass =
|
|
39
|
-
'min-w-0 break-words [color:var(--rad-field-error-color,var(--rad-color-invalid,oklch(0.56_0.19_25)))] [
|
|
39
|
+
'min-w-0 break-words [color:var(--rad-field-error-color,var(--rad-color-invalid,oklch(0.56_0.19_25)))] text-[length:var(--rad-field-error-size,var(--rad-typography-roles-ui-supporting-size,0.8125rem))] forced-colors:text-[CanvasText] font-[family-name:var(--rad-typography-roles-ui-supporting-family,system-ui,sans-serif)] leading-[var(--rad-typography-roles-ui-supporting-line-height,1.5)] tracking-[var(--rad-typography-roles-ui-supporting-letter-spacing,0em)] font-[number:var(--rad-typography-roles-ui-supporting-weight,400)]'
|
|
40
40
|
|
|
41
41
|
const requiredClass =
|
|
42
42
|
'ms-[0.25em] [color:var(--rad-field-required-color,var(--rad-color-invalid,oklch(0.56_0.19_25)))] forced-colors:text-[CanvasText]'
|
package/src/Input.tsx
CHANGED
|
@@ -14,9 +14,10 @@ const inputVariants = cva([
|
|
|
14
14
|
'box-border w-full min-w-0',
|
|
15
15
|
'h-[var(--rad-input-height,var(--_rad-control-height))]',
|
|
16
16
|
'px-[var(--rad-input-padding,var(--_rad-control-padding))]',
|
|
17
|
-
'
|
|
18
|
-
'[
|
|
19
|
-
'[
|
|
17
|
+
'font-[family-name:var(--rad-input-font-family,var(--rad-typography-roles-ui-body-family,system-ui,sans-serif))] tracking-[var(--rad-typography-roles-ui-body-letter-spacing,-0.011em)]',
|
|
18
|
+
'text-[length:var(--rad-input-font-size,var(--_rad-control-font-size))]',
|
|
19
|
+
'leading-[var(--rad-typography-roles-ui-body-line-height,1.5)]',
|
|
20
|
+
'font-[number:var(--rad-input-font-weight,var(--rad-typography-roles-ui-body-weight,400))]',
|
|
20
21
|
'[color:var(--rad-input-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))]',
|
|
21
22
|
'bg-[var(--rad-input-background,var(--rad-color-surface,oklch(1_0_0)))]',
|
|
22
23
|
'[border-width:var(--rad-input-border-width,var(--rad-control-border-width,1px))]',
|
package/src/Link.tsx
CHANGED
|
@@ -7,7 +7,6 @@ import type { ThemeStyle } from './themes/defineTheme.js'
|
|
|
7
7
|
|
|
8
8
|
const linkVariants = cva(
|
|
9
9
|
[
|
|
10
|
-
'[font-family:var(--rad-typography-family,system-ui,sans-serif)] [letter-spacing:var(--rad-typography-letter-spacing,-0.011em)]',
|
|
11
10
|
'[color:var(--_link-color)] [text-underline-offset:var(--rad-link-underline-offset,0.1875rem)]',
|
|
12
11
|
'transition-colors duration-[var(--rad-link-color-duration,var(--rad-motion-color-duration,150ms))]',
|
|
13
12
|
'hover:[color:var(--_link-hover)]',
|
package/src/RadioGroup.tsx
CHANGED
|
@@ -44,10 +44,10 @@ const dotClass =
|
|
|
44
44
|
'pointer-events-none absolute inset-[30%] rounded-[var(--rad-radio-radius,999px)] bg-[var(--rad-radio-mark,var(--rad-color-accent-foreground,oklch(0.985_0_0)))] peer-disabled:bg-[var(--rad-radio-mark,var(--rad-color-muted-foreground,oklch(0.45_0.01_286)))] opacity-0 peer-checked:opacity-100 forced-colors:bg-[HighlightText] forced-colors:peer-disabled:bg-[GrayText]'
|
|
45
45
|
|
|
46
46
|
const rowClass =
|
|
47
|
-
'
|
|
47
|
+
'inline-flex min-h-6 cursor-pointer items-center gap-[var(--rad-radio-label-gap,var(--rad-spacing-label-gap,0.5rem))] select-none has-disabled:cursor-not-allowed'
|
|
48
48
|
|
|
49
49
|
const labelClass =
|
|
50
|
-
'
|
|
50
|
+
'font-[family-name:var(--rad-typography-roles-ui-label-family,system-ui,sans-serif)] tracking-[var(--rad-typography-roles-ui-label-letter-spacing,-0.011em)] font-[number:var(--rad-typography-roles-ui-label-weight,400)] [color:var(--rad-radio-label-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))] text-[length:var(--rad-radio-label-size,var(--_rad-control-font-size))] leading-[var(--rad-typography-roles-ui-label-line-height,1.4)]'
|
|
51
51
|
|
|
52
52
|
const optionsClass =
|
|
53
53
|
'grid justify-items-start gap-[var(--rad-radio-group-gap,var(--rad-spacing-group-gap,0.75rem))]'
|
package/src/ThemeScope.tsx
CHANGED
|
@@ -11,7 +11,7 @@ type ScopeState = { theme: Theme; overrides: ThemeStyle }
|
|
|
11
11
|
const ThemeContext = createContext<ScopeState | null>(null)
|
|
12
12
|
const variables = new Set(Object.keys(defaultTheme.modes.light))
|
|
13
13
|
const scopeClass =
|
|
14
|
-
'[background:var(--rad-surface-canvas)] [color:var(--rad-color-foreground)]
|
|
14
|
+
'[background:var(--rad-surface-canvas)] [color:var(--rad-color-foreground)] font-[family-name:var(--rad-typography-roles-ui-body-family)] text-[length:var(--rad-typography-roles-ui-body-size)] font-[number:var(--rad-typography-roles-ui-body-weight)] tracking-[var(--rad-typography-roles-ui-body-letter-spacing)] leading-[var(--rad-typography-roles-ui-body-line-height)]'
|
|
15
15
|
|
|
16
16
|
export type ThemeScopeProps = Omit<ComponentProps<'div'>, 'style'> & {
|
|
17
17
|
theme?: Theme
|
package/src/actionStyles.ts
CHANGED
|
@@ -21,8 +21,8 @@ export const actionTone = cva('', {
|
|
|
21
21
|
|
|
22
22
|
export const actionVariants = cva(
|
|
23
23
|
[
|
|
24
|
-
'relative box-border inline-flex shrink-0 select-none items-center justify-center [border-style:var(--rad-button-border-style,var(--rad-control-border-style,solid))] [border-width:var(--rad-button-border-width,var(--rad-control-border-width,1px))] [border-color:var(--rad-button-border-color,var(--_btn-edge))] text-center
|
|
25
|
-
'
|
|
24
|
+
'relative box-border inline-flex shrink-0 select-none items-center justify-center [border-style:var(--rad-button-border-style,var(--rad-control-border-style,solid))] [border-width:var(--rad-button-border-width,var(--rad-control-border-width,1px))] [border-color:var(--rad-button-border-color,var(--_btn-edge))] text-center font-[family-name:var(--rad-button-font-family,var(--rad-typography-roles-ui-label-family,system-ui,sans-serif))] [text-transform:var(--rad-button-text-transform,none)] antialiased',
|
|
25
|
+
'font-[number:var(--rad-button-font-weight,var(--rad-typography-roles-ui-label-weight,550))] tracking-[var(--rad-button-letter-spacing,var(--rad-typography-roles-ui-label-letter-spacing,-0.011em))] text-[length:var(--_btn-fs)] leading-[var(--rad-typography-roles-ui-label-line-height,1.4)]',
|
|
26
26
|
'min-h-(--_btn-h) px-(--_btn-px) bg-(--_btn-bg) text-(--_btn-fg) no-underline',
|
|
27
27
|
'bg-[linear-gradient(to_bottom,rgb(255_255_255/var(--_btn-sheen)),rgb(255_255_255/0))]',
|
|
28
28
|
'[--_btn-corner:var(--rad-button-corner-shape,var(--rad-control-corner-shape,round))] rounded-(--_btn-radius) [corner-shape:var(--_btn-corner)]',
|
package/src/cn.ts
CHANGED
|
@@ -1 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import { createCn } from 'cn/config'
|
|
2
|
+
import type { CnFunction } from 'cn'
|
|
3
|
+
import { typographyRoles } from './themes/tokens.js'
|
|
4
|
+
|
|
5
|
+
// Semantic hooks live in the components layer. For callers using token shorthand
|
|
6
|
+
// utilities, register non-color variables explicitly rather than guessing from names.
|
|
7
|
+
const roleClasses = (prefix: string, leaf: string) =>
|
|
8
|
+
typographyRoles.map(role => `${prefix}-(--rad-typography-roles-${role}-${leaf})`)
|
|
9
|
+
export const cn: CnFunction = createCn({
|
|
10
|
+
extend: {
|
|
11
|
+
classGroups: {
|
|
12
|
+
'font-family': roleClasses('font', 'family'),
|
|
13
|
+
'font-weight': roleClasses('font', 'weight'),
|
|
14
|
+
'font-size': [...roleClasses('text', 'size'), ...roleClasses('text', 'fluid-size')],
|
|
15
|
+
leading: roleClasses('leading', 'line-height'),
|
|
16
|
+
tracking: roleClasses('tracking', 'letter-spacing'),
|
|
17
|
+
'max-inline-size': roleClasses('max-inline', 'measure'),
|
|
18
|
+
mbs: [
|
|
19
|
+
'mbs-(--rad-typography-flow-paragraph)',
|
|
20
|
+
'mbs-(--rad-typography-flow-heading-before)',
|
|
21
|
+
'mbs-(--rad-typography-flow-heading-after)'
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
})
|
package/src/index.ts
CHANGED
|
@@ -94,6 +94,8 @@ export type {
|
|
|
94
94
|
export { ThemeScope } from './ThemeScope.js'
|
|
95
95
|
export type { ThemeScopeProps } from './ThemeScope.js'
|
|
96
96
|
export type { ButtonProps, ButtonRenderProps, ButtonVariant } from './Button.js'
|
|
97
|
+
export { generateTypography, typographyPresets, typographyRoles } from './typography/index.js'
|
|
98
|
+
export type * from './typography/types.js'
|
|
97
99
|
export type { ControlSize, Tone } from './presentation.js'
|
|
98
100
|
|
|
99
101
|
export {
|
|
@@ -115,6 +117,7 @@ export type {
|
|
|
115
117
|
ThemeBrandSource,
|
|
116
118
|
ThemePalette,
|
|
117
119
|
ThemeTypographySection,
|
|
120
|
+
ThemeFontAxis,
|
|
118
121
|
ThemeFontMetadata
|
|
119
122
|
} from './themes/index.js'
|
|
120
123
|
|
package/src/styles.css
CHANGED
package/src/themes/baseline.css
CHANGED
|
@@ -32,6 +32,137 @@
|
|
|
32
32
|
--rad-color-danger: var(--_rad-light, oklch(0.56 0.19 25)) var(--_rad-dark, oklch(0.72 0.17 25));
|
|
33
33
|
--rad-color-danger-foreground: var(--_rad-light, oklch(0.99 0 0))
|
|
34
34
|
var(--_rad-dark, oklch(0.2 0.04 25));
|
|
35
|
+
--rad-typography-roles-prose-title-family: var(--rad-typography-family);
|
|
36
|
+
--rad-typography-roles-prose-title-size: 2.44140625rem;
|
|
37
|
+
--rad-typography-roles-prose-title-fluid-size: clamp(
|
|
38
|
+
2.44140625rem,
|
|
39
|
+
calc(1.41143799rem + 4.29153442cqi),
|
|
40
|
+
3.81469727rem
|
|
41
|
+
);
|
|
42
|
+
--rad-typography-roles-prose-title-weight: 600;
|
|
43
|
+
--rad-typography-roles-prose-title-line-height: 1.12;
|
|
44
|
+
--rad-typography-roles-prose-title-letter-spacing: -0.025em;
|
|
45
|
+
--rad-typography-roles-prose-title-measure: 22ch;
|
|
46
|
+
--rad-typography-roles-prose-heading-family: var(--rad-typography-family);
|
|
47
|
+
--rad-typography-roles-prose-heading-size: 1.5625rem;
|
|
48
|
+
--rad-typography-roles-prose-heading-fluid-size: clamp(
|
|
49
|
+
1.5625rem,
|
|
50
|
+
calc(1.26953125rem + 1.22070313cqi),
|
|
51
|
+
1.953125rem
|
|
52
|
+
);
|
|
53
|
+
--rad-typography-roles-prose-heading-weight: 600;
|
|
54
|
+
--rad-typography-roles-prose-heading-line-height: 1.25;
|
|
55
|
+
--rad-typography-roles-prose-heading-letter-spacing: -0.015em;
|
|
56
|
+
--rad-typography-roles-prose-heading-measure: 30ch;
|
|
57
|
+
--rad-typography-roles-prose-subheading-family: var(--rad-typography-family);
|
|
58
|
+
--rad-typography-roles-prose-subheading-size: 1.375rem;
|
|
59
|
+
--rad-typography-roles-prose-subheading-fluid-size: clamp(
|
|
60
|
+
1.375rem,
|
|
61
|
+
calc(1.234375rem + 0.5859375cqi),
|
|
62
|
+
1.5625rem
|
|
63
|
+
);
|
|
64
|
+
--rad-typography-roles-prose-subheading-weight: 600;
|
|
65
|
+
--rad-typography-roles-prose-subheading-line-height: 1.3;
|
|
66
|
+
--rad-typography-roles-prose-subheading-letter-spacing: -0.01em;
|
|
67
|
+
--rad-typography-roles-prose-subheading-measure: 36ch;
|
|
68
|
+
--rad-typography-roles-prose-body-family: var(--rad-typography-family);
|
|
69
|
+
--rad-typography-roles-prose-body-size: 1.25rem;
|
|
70
|
+
--rad-typography-roles-prose-body-fluid-size: 1.25rem;
|
|
71
|
+
--rad-typography-roles-prose-body-weight: 400;
|
|
72
|
+
--rad-typography-roles-prose-body-line-height: 1.6;
|
|
73
|
+
--rad-typography-roles-prose-body-letter-spacing: 0em;
|
|
74
|
+
--rad-typography-roles-prose-body-measure: 64ch;
|
|
75
|
+
--rad-typography-roles-prose-lead-family: var(--rad-typography-family);
|
|
76
|
+
--rad-typography-roles-prose-lead-size: 1.40625rem;
|
|
77
|
+
--rad-typography-roles-prose-lead-fluid-size: 1.40625rem;
|
|
78
|
+
--rad-typography-roles-prose-lead-weight: 400;
|
|
79
|
+
--rad-typography-roles-prose-lead-line-height: 1.5;
|
|
80
|
+
--rad-typography-roles-prose-lead-letter-spacing: 0em;
|
|
81
|
+
--rad-typography-roles-prose-lead-measure: 55ch;
|
|
82
|
+
--rad-typography-roles-prose-small-family: var(--rad-typography-family);
|
|
83
|
+
--rad-typography-roles-prose-small-size: 1rem;
|
|
84
|
+
--rad-typography-roles-prose-small-fluid-size: 1rem;
|
|
85
|
+
--rad-typography-roles-prose-small-weight: 400;
|
|
86
|
+
--rad-typography-roles-prose-small-line-height: 1.5;
|
|
87
|
+
--rad-typography-roles-prose-small-letter-spacing: 0em;
|
|
88
|
+
--rad-typography-roles-prose-small-measure: 64ch;
|
|
89
|
+
--rad-typography-roles-prose-quote-family: var(--rad-typography-family);
|
|
90
|
+
--rad-typography-roles-prose-quote-size: 1.5625rem;
|
|
91
|
+
--rad-typography-roles-prose-quote-fluid-size: 1.5625rem;
|
|
92
|
+
--rad-typography-roles-prose-quote-weight: 400;
|
|
93
|
+
--rad-typography-roles-prose-quote-line-height: 1.4;
|
|
94
|
+
--rad-typography-roles-prose-quote-letter-spacing: -0.01em;
|
|
95
|
+
--rad-typography-roles-prose-quote-measure: 64ch;
|
|
96
|
+
--rad-typography-roles-ui-title-family: var(--rad-typography-family);
|
|
97
|
+
--rad-typography-roles-ui-title-size: var(--rad-typography-heading-size);
|
|
98
|
+
--rad-typography-roles-ui-title-fluid-size: var(--rad-typography-heading-size);
|
|
99
|
+
--rad-typography-roles-ui-title-weight: var(--rad-typography-heading-weight);
|
|
100
|
+
--rad-typography-roles-ui-title-line-height: 1.3;
|
|
101
|
+
--rad-typography-roles-ui-title-letter-spacing: var(--rad-typography-letter-spacing);
|
|
102
|
+
--rad-typography-roles-ui-title-measure: none;
|
|
103
|
+
--rad-typography-roles-ui-body-family: var(--rad-typography-family);
|
|
104
|
+
--rad-typography-roles-ui-body-size: var(--rad-typography-body-size);
|
|
105
|
+
--rad-typography-roles-ui-body-fluid-size: var(--rad-typography-body-size);
|
|
106
|
+
--rad-typography-roles-ui-body-weight: var(--rad-typography-body-weight);
|
|
107
|
+
--rad-typography-roles-ui-body-line-height: 1.5;
|
|
108
|
+
--rad-typography-roles-ui-body-letter-spacing: var(--rad-typography-letter-spacing);
|
|
109
|
+
--rad-typography-roles-ui-body-measure: none;
|
|
110
|
+
--rad-typography-roles-ui-label-family: var(--rad-typography-family);
|
|
111
|
+
--rad-typography-roles-ui-label-size: var(--rad-typography-body-size);
|
|
112
|
+
--rad-typography-roles-ui-label-fluid-size: var(--rad-typography-body-size);
|
|
113
|
+
--rad-typography-roles-ui-label-weight: var(--rad-typography-label-weight);
|
|
114
|
+
--rad-typography-roles-ui-label-line-height: 1.4;
|
|
115
|
+
--rad-typography-roles-ui-label-letter-spacing: var(--rad-typography-letter-spacing);
|
|
116
|
+
--rad-typography-roles-ui-label-measure: none;
|
|
117
|
+
--rad-typography-roles-ui-supporting-family: var(--rad-typography-family);
|
|
118
|
+
--rad-typography-roles-ui-supporting-size: var(--rad-typography-small-size);
|
|
119
|
+
--rad-typography-roles-ui-supporting-fluid-size: var(--rad-typography-small-size);
|
|
120
|
+
--rad-typography-roles-ui-supporting-weight: var(--rad-typography-body-weight);
|
|
121
|
+
--rad-typography-roles-ui-supporting-line-height: 1.5;
|
|
122
|
+
--rad-typography-roles-ui-supporting-letter-spacing: var(--rad-typography-letter-spacing);
|
|
123
|
+
--rad-typography-roles-ui-supporting-measure: none;
|
|
124
|
+
--rad-typography-roles-ui-caption-family: var(--rad-typography-family);
|
|
125
|
+
--rad-typography-roles-ui-caption-size: 0.875rem;
|
|
126
|
+
--rad-typography-roles-ui-caption-fluid-size: 0.875rem;
|
|
127
|
+
--rad-typography-roles-ui-caption-weight: 400;
|
|
128
|
+
--rad-typography-roles-ui-caption-line-height: 1.5;
|
|
129
|
+
--rad-typography-roles-ui-caption-letter-spacing: 0em;
|
|
130
|
+
--rad-typography-roles-ui-caption-measure: none;
|
|
131
|
+
--rad-typography-roles-ui-metric-family: var(--rad-typography-family);
|
|
132
|
+
--rad-typography-roles-ui-metric-size: 2rem;
|
|
133
|
+
--rad-typography-roles-ui-metric-fluid-size: 2rem;
|
|
134
|
+
--rad-typography-roles-ui-metric-weight: 600;
|
|
135
|
+
--rad-typography-roles-ui-metric-line-height: 1.15;
|
|
136
|
+
--rad-typography-roles-ui-metric-letter-spacing: -0.03em;
|
|
137
|
+
--rad-typography-roles-ui-metric-measure: none;
|
|
138
|
+
--rad-typography-roles-ui-eyebrow-family: var(--rad-typography-family);
|
|
139
|
+
--rad-typography-roles-ui-eyebrow-size: 0.75rem;
|
|
140
|
+
--rad-typography-roles-ui-eyebrow-fluid-size: 0.75rem;
|
|
141
|
+
--rad-typography-roles-ui-eyebrow-weight: 600;
|
|
142
|
+
--rad-typography-roles-ui-eyebrow-line-height: 1.4;
|
|
143
|
+
--rad-typography-roles-ui-eyebrow-letter-spacing: 0.1em;
|
|
144
|
+
--rad-typography-roles-ui-eyebrow-measure: none;
|
|
145
|
+
--rad-typography-roles-display-family: var(--rad-typography-family);
|
|
146
|
+
--rad-typography-roles-display-size: 2.44140625rem;
|
|
147
|
+
--rad-typography-roles-display-fluid-size: clamp(
|
|
148
|
+
2.44140625rem,
|
|
149
|
+
calc(0.69618225rem + 7.27176666cqi),
|
|
150
|
+
4.76837158rem
|
|
151
|
+
);
|
|
152
|
+
--rad-typography-roles-display-weight: 600;
|
|
153
|
+
--rad-typography-roles-display-line-height: 1.06;
|
|
154
|
+
--rad-typography-roles-display-letter-spacing: -0.035em;
|
|
155
|
+
--rad-typography-roles-display-measure: 18ch;
|
|
156
|
+
--rad-typography-roles-code-family: ui-monospace, monospace;
|
|
157
|
+
--rad-typography-roles-code-size: 0.875rem;
|
|
158
|
+
--rad-typography-roles-code-fluid-size: 0.875rem;
|
|
159
|
+
--rad-typography-roles-code-weight: 400;
|
|
160
|
+
--rad-typography-roles-code-line-height: 1.65;
|
|
161
|
+
--rad-typography-roles-code-letter-spacing: 0em;
|
|
162
|
+
--rad-typography-roles-code-measure: 80ch;
|
|
163
|
+
--rad-typography-flow-paragraph: 1.25em;
|
|
164
|
+
--rad-typography-flow-heading-before: 2em;
|
|
165
|
+
--rad-typography-flow-heading-after: 0.625em;
|
|
35
166
|
--rad-typography-family: system-ui, sans-serif;
|
|
36
167
|
--rad-typography-body-size: 0.875rem;
|
|
37
168
|
--rad-typography-small-size: 0.8125rem;
|
|
@@ -75,7 +75,11 @@ function validateTokens(value: unknown, baseline: object, path: string) {
|
|
|
75
75
|
} else {
|
|
76
76
|
validateScalar(
|
|
77
77
|
item,
|
|
78
|
-
key === 'disabledOpacity'
|
|
78
|
+
key === 'disabledOpacity'
|
|
79
|
+
? 'opacity'
|
|
80
|
+
: key.endsWith('Weight') || key === 'weight'
|
|
81
|
+
? 'weight'
|
|
82
|
+
: 'css',
|
|
79
83
|
`${path}.${key}`
|
|
80
84
|
)
|
|
81
85
|
}
|
package/src/themes/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineTheme, type Theme, type ThemeDefinition, type ThemeLayer } from './defineTheme.js'
|
|
2
2
|
import { freezeTree, tokenDefaults } from './tokens.js'
|
|
3
|
+
import { generateTypography } from '../typography/index.js'
|
|
3
4
|
import type {
|
|
4
5
|
ThemeColorSection,
|
|
5
6
|
ThemeDocument,
|
|
@@ -157,11 +158,37 @@ function validateFonts(value: unknown, path: string) {
|
|
|
157
158
|
for (const [i, font] of value.entries()) {
|
|
158
159
|
const p = `${path}.${i}`
|
|
159
160
|
record(font, p)
|
|
160
|
-
keys(font, ['id', 'family', 'source', 'weights', 'styles'], p)
|
|
161
|
+
keys(font, ['id', 'family', 'source', 'weights', 'styles', 'axes'], p)
|
|
161
162
|
textValue(font.id, `${p}.id`)
|
|
162
163
|
textValue(font.family, `${p}.family`)
|
|
163
164
|
unique(font.id, ids, `${p}.id`)
|
|
164
165
|
choice(font.source, ['system', 'catalog', 'local'], `${p}.source`)
|
|
166
|
+
if (font.axes !== undefined) {
|
|
167
|
+
list(font.axes, `${p}.axes`)
|
|
168
|
+
if (font.axes.length > 32) throw new TypeError(`${p}.axes supports at most 32 axes.`)
|
|
169
|
+
const tags = new Set<unknown>()
|
|
170
|
+
for (const [j, axis] of font.axes.entries()) {
|
|
171
|
+
const at = `${p}.axes.${j}`
|
|
172
|
+
record(axis, at)
|
|
173
|
+
keys(axis, ['tag', 'min', 'default', 'max'], at)
|
|
174
|
+
if (typeof axis.tag !== 'string' || !/^[A-Za-z][A-Za-z0-9]{3}$/.test(axis.tag))
|
|
175
|
+
throw new TypeError(
|
|
176
|
+
`${at}.tag must contain four ASCII letters/digits, starting with a letter.`
|
|
177
|
+
)
|
|
178
|
+
unique(axis.tag, tags, `${at}.tag`)
|
|
179
|
+
for (const key of ['min', 'default', 'max'])
|
|
180
|
+
if (
|
|
181
|
+
typeof axis[key] !== 'number' ||
|
|
182
|
+
!Number.isFinite(axis[key]) ||
|
|
183
|
+
Math.abs(axis[key]) > 1000000
|
|
184
|
+
)
|
|
185
|
+
throw new TypeError(
|
|
186
|
+
`${at}.${key} must be a finite number between -1000000 and 1000000.`
|
|
187
|
+
)
|
|
188
|
+
if (Number(axis.min) > Number(axis.default) || Number(axis.default) > Number(axis.max))
|
|
189
|
+
throw new TypeError(`${at} must satisfy min <= default <= max.`)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
165
192
|
for (const key of ['weights', 'styles']) {
|
|
166
193
|
if (font[key] === undefined) continue
|
|
167
194
|
list(font[key], `${p}.${key}`)
|
|
@@ -169,7 +196,7 @@ function validateFonts(value: unknown, path: string) {
|
|
|
169
196
|
for (const [j, item] of font[key].entries()) {
|
|
170
197
|
const at = `${p}.${key}.${j}`
|
|
171
198
|
if (key === 'styles') choice(item, ['normal', 'italic'], at)
|
|
172
|
-
else if (typeof item !== 'number' || item < 1 || item > 1000)
|
|
199
|
+
else if (typeof item !== 'number' || !Number.isFinite(item) || item < 1 || item > 1000)
|
|
173
200
|
throw new TypeError(`${at} must be a weight from 1 to 1000.`)
|
|
174
201
|
unique(item, seen, at)
|
|
175
202
|
}
|
|
@@ -183,12 +210,15 @@ function toDefinition(sections: ThemeSections, id: string, name: string): ThemeD
|
|
|
183
210
|
for (const sectionName of sectionNames) {
|
|
184
211
|
const section = sections[sectionName]
|
|
185
212
|
if (!section) continue
|
|
213
|
+
if (sectionName === 'typography' && sections.typography?.typesetting !== undefined) {
|
|
214
|
+
common.tokens.typography = generateTypography(sections.typography.typesetting).tokens
|
|
215
|
+
}
|
|
186
216
|
for (const mode of ['common', 'light', 'dark'] as const) {
|
|
187
217
|
const values = mode === 'common' ? section.values : section.modes?.[mode]
|
|
188
218
|
if (values === undefined) continue
|
|
189
219
|
const layer = mode === 'common' ? common : modes[mode]
|
|
190
220
|
if (sectionName === 'components') layer.components = values as ThemeLayer['components']
|
|
191
|
-
else layer.tokens[sectionName] = values
|
|
221
|
+
else layer.tokens[sectionName] = merge(layer.tokens[sectionName], values)
|
|
192
222
|
}
|
|
193
223
|
}
|
|
194
224
|
return { id, name, ...common, modes }
|
|
@@ -222,7 +252,7 @@ export function parseThemeDocument(input: unknown): ThemeDocument | ThemeSection
|
|
|
222
252
|
...(name === 'color'
|
|
223
253
|
? ['brand', 'fidelity', 'palettes', 'anchor']
|
|
224
254
|
: name === 'typography'
|
|
225
|
-
? ['fonts']
|
|
255
|
+
? ['fonts', 'typesetting']
|
|
226
256
|
: [])
|
|
227
257
|
],
|
|
228
258
|
path
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ThemeComponentOverrides } from './components.js'
|
|
2
2
|
import type { ThemeTokens } from './tokens.js'
|
|
3
|
+
import type { TypographyInput } from '../typography/types.js'
|
|
3
4
|
|
|
4
5
|
/** One existing token group, with independently authored mode layers. */
|
|
5
6
|
export interface ThemeSection<T> {
|
|
@@ -35,6 +36,14 @@ export interface ThemeColorSection extends ThemeSection<ThemeTokens['color']> {
|
|
|
35
36
|
readonly anchor?: { readonly paletteId: string; readonly stop: ThemeColorStop }
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
/** Available OpenType axis range, never a font file or a trial-only setting. */
|
|
40
|
+
export interface ThemeFontAxis {
|
|
41
|
+
readonly tag: string
|
|
42
|
+
readonly min: number
|
|
43
|
+
readonly default: number
|
|
44
|
+
readonly max: number
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
/** Portable descriptors only. The consuming application owns loading and local availability. */
|
|
39
48
|
export interface ThemeFontMetadata {
|
|
40
49
|
readonly id: string
|
|
@@ -42,10 +51,13 @@ export interface ThemeFontMetadata {
|
|
|
42
51
|
readonly source: 'system' | 'catalog' | 'local'
|
|
43
52
|
readonly weights?: readonly number[]
|
|
44
53
|
readonly styles?: readonly ('normal' | 'italic')[]
|
|
54
|
+
readonly axes?: readonly ThemeFontAxis[]
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
export interface ThemeTypographySection extends ThemeSection<ThemeTokens['typography']> {
|
|
48
58
|
readonly fonts?: readonly ThemeFontMetadata[]
|
|
59
|
+
/** Generated defaults; explicit values and mode values override these leaves. */
|
|
60
|
+
readonly typesetting?: TypographyInput
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
/** Token groups are the extension seams for richer typesetting and spring authoring. */
|
package/src/themes/tokens.ts
CHANGED
|
@@ -1,3 +1,105 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
TypographyProseRhythm,
|
|
3
|
+
TypographyUIRhythm,
|
|
4
|
+
TypographyStyle,
|
|
5
|
+
TypographyRole,
|
|
6
|
+
TypographyTokens,
|
|
7
|
+
TypographyAssignment
|
|
8
|
+
} from '../typography/types.js'
|
|
9
|
+
|
|
10
|
+
/** Canonical calculations live beside the defaults so source CSS generation stays self-contained. */
|
|
11
|
+
export function typographyStyles(
|
|
12
|
+
prose: TypographyProseRhythm,
|
|
13
|
+
ui: TypographyUIRhythm
|
|
14
|
+
): Record<TypographyRole, TypographyStyle> {
|
|
15
|
+
const { size: r, lineHeight, measure, headingScale: q } = prose
|
|
16
|
+
const u = ui.size
|
|
17
|
+
const style = (
|
|
18
|
+
assignment: TypographyAssignment,
|
|
19
|
+
narrow: number,
|
|
20
|
+
wide: number,
|
|
21
|
+
weight: number,
|
|
22
|
+
leading: number,
|
|
23
|
+
tracking = 0,
|
|
24
|
+
width = 0
|
|
25
|
+
): TypographyStyle => ({
|
|
26
|
+
assignment,
|
|
27
|
+
narrow,
|
|
28
|
+
wide,
|
|
29
|
+
weight,
|
|
30
|
+
lineHeight: leading,
|
|
31
|
+
tracking,
|
|
32
|
+
measure: width
|
|
33
|
+
})
|
|
34
|
+
return {
|
|
35
|
+
'prose-title': style('headings', r * q ** 3, r * q ** 5, 600, 1.12, -0.025, 22),
|
|
36
|
+
'prose-heading': style('headings', r * q, r * q ** 2, 600, 1.25, -0.015, 30),
|
|
37
|
+
'prose-subheading': style('headings', r * 1.1, r * q, 600, 1.3, -0.01, 36),
|
|
38
|
+
'prose-body': style('body', r, r, 400, lineHeight, 0, measure),
|
|
39
|
+
'prose-lead': style('body', r * 1.125, r * 1.125, 400, 1.5, 0, 55),
|
|
40
|
+
'prose-small': style('body', r * 0.8, r * 0.8, 400, 1.5, 0, measure),
|
|
41
|
+
'prose-quote': style('body', r * 1.25, r * 1.25, 400, 1.4, -0.01, measure),
|
|
42
|
+
'ui-title': style('ui', u * 1.25, u * 1.25, 600, 1.3, -0.015),
|
|
43
|
+
'ui-body': style('ui', u, u, 400, ui.lineHeight),
|
|
44
|
+
'ui-label': style('ui', u, u, 500, 1.4),
|
|
45
|
+
'ui-supporting': style('ui', u * 0.9375, u * 0.9375, 400, 1.5),
|
|
46
|
+
'ui-caption': style('ui', u * 0.875, u * 0.875, 400, 1.5),
|
|
47
|
+
'ui-metric': style('ui', u * 2, u * 2, 600, 1.15, -0.03),
|
|
48
|
+
'ui-eyebrow': style('ui', u * 0.75, u * 0.75, 600, 1.4, 0.1),
|
|
49
|
+
display: style('headings', r * q ** 3, r * q ** 6, 600, 1.06, -0.035, 18),
|
|
50
|
+
code: style('code', 14, 14, 400, 1.65, 0, 80)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const baselineProse: TypographyProseRhythm = {
|
|
55
|
+
size: 20,
|
|
56
|
+
lineHeight: 1.6,
|
|
57
|
+
paragraphSpacing: 1.25,
|
|
58
|
+
measure: 64,
|
|
59
|
+
headingScale: 1.25
|
|
60
|
+
}
|
|
61
|
+
export const typographyRoles = Object.freeze(
|
|
62
|
+
Object.keys(typographyStyles(baselineProse, { size: 16, lineHeight: 1.5 })) as TypographyRole[]
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
function decimal(value: number): string {
|
|
66
|
+
return String(Number(value.toFixed(8)))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function typographyTokens(
|
|
70
|
+
styles: Readonly<Record<TypographyRole, TypographyStyle>>,
|
|
71
|
+
families: Readonly<Record<TypographyAssignment, string>>,
|
|
72
|
+
flow: number
|
|
73
|
+
): TypographyTokens {
|
|
74
|
+
const roles = {} as Record<TypographyRole, TypographyTokens['roles'][TypographyRole]>
|
|
75
|
+
for (const role of typographyRoles) {
|
|
76
|
+
const s = styles[role]
|
|
77
|
+
const slope = (s.wide - s.narrow) / 512
|
|
78
|
+
const intercept = s.narrow / 16 - slope * 24
|
|
79
|
+
const size = `${decimal(s.narrow / 16)}rem`
|
|
80
|
+
roles[role] = {
|
|
81
|
+
family: families[s.assignment],
|
|
82
|
+
size,
|
|
83
|
+
fluidSize:
|
|
84
|
+
s.narrow === s.wide
|
|
85
|
+
? size
|
|
86
|
+
: `clamp(${size}, calc(${decimal(intercept)}rem + ${decimal(slope * 100)}cqi), ${decimal(s.wide / 16)}rem)`,
|
|
87
|
+
weight: s.weight,
|
|
88
|
+
lineHeight: decimal(s.lineHeight),
|
|
89
|
+
letterSpacing: `${decimal(s.tracking)}em`,
|
|
90
|
+
measure: s.measure ? `${decimal(s.measure)}ch` : 'none'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
roles,
|
|
95
|
+
flow: {
|
|
96
|
+
paragraph: `${decimal(flow)}em`,
|
|
97
|
+
headingBefore: `${decimal(flow * 1.6)}em`,
|
|
98
|
+
headingAfter: `${decimal(flow * 0.5)}em`
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
1
103
|
/** The complete shared-token registry. CSS names are derived from these paths. */
|
|
2
104
|
export interface SharedTokens {
|
|
3
105
|
color: {
|
|
@@ -28,6 +130,8 @@ export interface SharedTokens {
|
|
|
28
130
|
labelWeight: string | number
|
|
29
131
|
headingWeight: string | number
|
|
30
132
|
letterSpacing: string
|
|
133
|
+
roles: TypographyTokens['roles']
|
|
134
|
+
flow: TypographyTokens['flow']
|
|
31
135
|
}
|
|
32
136
|
control: {
|
|
33
137
|
small: ControlMetrics
|
|
@@ -103,6 +207,7 @@ const light: SharedTokens = {
|
|
|
103
207
|
dangerForeground: 'oklch(0.99 0 0)'
|
|
104
208
|
},
|
|
105
209
|
typography: {
|
|
210
|
+
...baselineTypographyTokens(),
|
|
106
211
|
family: 'system-ui, sans-serif',
|
|
107
212
|
bodySize: '0.875rem',
|
|
108
213
|
smallSize: '0.8125rem',
|
|
@@ -205,6 +310,38 @@ export function freezeTree<T extends object>(value: T): Readonly<T> {
|
|
|
205
310
|
return Object.freeze(value)
|
|
206
311
|
}
|
|
207
312
|
|
|
313
|
+
// Legacy/preset leaves remain a bridge until a recipe or explicit role owns them.
|
|
314
|
+
// UI measures stay layout-owned; controls retain their independent size metrics.
|
|
315
|
+
function baselineTypographyTokens(): TypographyTokens {
|
|
316
|
+
const tokens = typographyTokens(
|
|
317
|
+
typographyStyles(baselineProse, { size: 16, lineHeight: 1.5 }),
|
|
318
|
+
{
|
|
319
|
+
body: 'var(--rad-typography-family)',
|
|
320
|
+
headings: 'var(--rad-typography-family)',
|
|
321
|
+
ui: 'var(--rad-typography-family)',
|
|
322
|
+
code: 'ui-monospace, monospace'
|
|
323
|
+
},
|
|
324
|
+
baselineProse.paragraphSpacing
|
|
325
|
+
)
|
|
326
|
+
const roles = { ...tokens.roles }
|
|
327
|
+
for (const [role, size, weight] of [
|
|
328
|
+
['ui-body', 'bodySize', 'bodyWeight'],
|
|
329
|
+
['ui-label', 'bodySize', 'labelWeight'],
|
|
330
|
+
['ui-title', 'headingSize', 'headingWeight'],
|
|
331
|
+
['ui-supporting', 'smallSize', 'bodyWeight']
|
|
332
|
+
] as const) {
|
|
333
|
+
const leaf = (name: string) => `var(--rad-typography-${kebabCase(name)})`
|
|
334
|
+
roles[role] = {
|
|
335
|
+
...tokens.roles[role],
|
|
336
|
+
size: leaf(size),
|
|
337
|
+
fluidSize: leaf(size),
|
|
338
|
+
weight: leaf(weight),
|
|
339
|
+
letterSpacing: leaf('letterSpacing')
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return { ...tokens, roles }
|
|
343
|
+
}
|
|
344
|
+
|
|
208
345
|
export const tokenDefaults = freezeTree({ light, dark })
|
|
209
346
|
|
|
210
347
|
export function kebabCase(value: string): string {
|