@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.
Files changed (85) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +9 -0
  3. package/dist/library/Card.d.ts.map +1 -1
  4. package/dist/library/Card.js +8 -6
  5. package/dist/library/Card.js.map +1 -1
  6. package/dist/library/Checkbox.js +2 -2
  7. package/dist/library/Checkbox.js.map +1 -1
  8. package/dist/library/Collapsible.d.ts.map +1 -1
  9. package/dist/library/Collapsible.js +5 -4
  10. package/dist/library/Collapsible.js.map +1 -1
  11. package/dist/library/Dialog.d.ts.map +1 -1
  12. package/dist/library/Dialog.js +8 -6
  13. package/dist/library/Dialog.js.map +1 -1
  14. package/dist/library/Field.js +4 -4
  15. package/dist/library/Field.js.map +1 -1
  16. package/dist/library/Input.d.ts.map +1 -1
  17. package/dist/library/Input.js +4 -3
  18. package/dist/library/Input.js.map +1 -1
  19. package/dist/library/Link.d.ts.map +1 -1
  20. package/dist/library/Link.js +0 -1
  21. package/dist/library/Link.js.map +1 -1
  22. package/dist/library/RadioGroup.js +2 -2
  23. package/dist/library/RadioGroup.js.map +1 -1
  24. package/dist/library/ThemeScope.js +1 -1
  25. package/dist/library/ThemeScope.js.map +1 -1
  26. package/dist/library/actionStyles.js +2 -2
  27. package/dist/library/actionStyles.js.map +1 -1
  28. package/dist/library/cn.d.ts +2 -1
  29. package/dist/library/cn.d.ts.map +1 -1
  30. package/dist/library/cn.js +22 -1
  31. package/dist/library/cn.js.map +1 -1
  32. package/dist/library/index.d.ts +3 -1
  33. package/dist/library/index.d.ts.map +1 -1
  34. package/dist/library/index.js +1 -0
  35. package/dist/library/index.js.map +1 -1
  36. package/dist/library/styles.css +1 -1
  37. package/dist/library/themes/defineTheme.d.ts.map +1 -1
  38. package/dist/library/themes/defineTheme.js +5 -1
  39. package/dist/library/themes/defineTheme.js.map +1 -1
  40. package/dist/library/themes/index.d.ts +1 -1
  41. package/dist/library/themes/index.d.ts.map +1 -1
  42. package/dist/library/themes/index.js.map +1 -1
  43. package/dist/library/themes/themeDocument.d.ts.map +1 -1
  44. package/dist/library/themes/themeDocument.js +29 -4
  45. package/dist/library/themes/themeDocument.js.map +1 -1
  46. package/dist/library/themes/themeDocumentTypes.d.ts +11 -0
  47. package/dist/library/themes/themeDocumentTypes.d.ts.map +1 -1
  48. package/dist/library/themes/themeDocumentTypes.js.map +1 -1
  49. package/dist/library/themes/tokens.d.ts +7 -0
  50. package/dist/library/themes/tokens.d.ts.map +1 -1
  51. package/dist/library/themes/tokens.js +99 -0
  52. package/dist/library/themes/tokens.js.map +1 -1
  53. package/dist/library/typography/index.d.ts +72 -0
  54. package/dist/library/typography/index.d.ts.map +1 -0
  55. package/dist/library/typography/index.js +160 -0
  56. package/dist/library/typography/index.js.map +1 -0
  57. package/dist/library/typography/types.d.ts +78 -0
  58. package/dist/library/typography/types.d.ts.map +1 -0
  59. package/dist/library/typography/types.js +2 -0
  60. package/dist/library/typography/types.js.map +1 -0
  61. package/docs/system.md +7 -0
  62. package/docs/theming.md +204 -0
  63. package/package.json +7 -2
  64. package/src/Card.tsx +8 -6
  65. package/src/Checkbox.tsx +2 -2
  66. package/src/Collapsible.tsx +5 -4
  67. package/src/Dialog.tsx +8 -6
  68. package/src/Field.tsx +4 -4
  69. package/src/Input.tsx +4 -3
  70. package/src/Link.tsx +0 -1
  71. package/src/RadioGroup.tsx +2 -2
  72. package/src/ThemeScope.tsx +1 -1
  73. package/src/actionStyles.ts +2 -2
  74. package/src/cn.ts +25 -1
  75. package/src/index.ts +3 -0
  76. package/src/styles.css +1 -0
  77. package/src/themes/baseline.css +131 -0
  78. package/src/themes/defineTheme.ts +5 -1
  79. package/src/themes/index.ts +1 -0
  80. package/src/themes/themeDocument.ts +34 -4
  81. package/src/themes/themeDocumentTypes.ts +12 -0
  82. package/src/themes/tokens.ts +137 -0
  83. package/src/typography/index.ts +199 -0
  84. package/src/typography/types.ts +92 -0
  85. package/src/typography.css +336 -0
@@ -0,0 +1,160 @@
1
+ import { freezeTree, typographyRoles, typographyStyles, typographyTokens } from '../themes/tokens.js';
2
+ export { typographyRoles };
3
+ const inter = { family: 'Inter, system-ui, sans-serif', profile: 'inter' };
4
+ const serif = { family: '"Source Serif 4", Georgia, serif', profile: 'source-serif-4' };
5
+ const plex = { family: '"IBM Plex Sans", system-ui, sans-serif', profile: 'plex-sans' };
6
+ const mono = { family: '"IBM Plex Mono", ui-monospace, monospace', profile: 'plex-mono' };
7
+ export const typographyPresets = freezeTree({
8
+ inter: { name: 'Inter', fonts: { body: inter, headings: inter, ui: inter, code: mono } },
9
+ 'source-serif': {
10
+ name: 'Source Serif 4 + Inter',
11
+ fonts: { body: serif, headings: serif, ui: inter, code: mono }
12
+ },
13
+ plex: {
14
+ name: 'Plex Sans + Plex Mono',
15
+ fonts: { body: plex, headings: plex, ui: plex, code: mono }
16
+ }
17
+ });
18
+ const assignments = ['body', 'headings', 'ui', 'code'];
19
+ const profiles = [
20
+ 'inter',
21
+ 'source-serif-4',
22
+ 'plex-sans',
23
+ 'plex-mono',
24
+ 'manual'
25
+ ];
26
+ const bodyProfiles = {
27
+ inter: [20, 1.6, 64],
28
+ 'source-serif-4': [21, 1.65, 62],
29
+ 'plex-sans': [20, 1.6, 62]
30
+ };
31
+ const weights = {
32
+ inter: [100, 900],
33
+ 'source-serif-4': [200, 900],
34
+ 'plex-sans': [100, 700],
35
+ 'plex-mono': [100, 700]
36
+ };
37
+ function record(value, path) {
38
+ if (!value ||
39
+ typeof value !== 'object' ||
40
+ Array.isArray(value) ||
41
+ ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
42
+ throw new TypeError(`${path} must be a plain object.`);
43
+ }
44
+ function keys(value, allowed, path) {
45
+ for (const key of Object.keys(value))
46
+ if (!allowed.includes(key))
47
+ throw new TypeError(`Unknown key: ${path}.${key}.`);
48
+ }
49
+ function number(value, min, max, path) {
50
+ if (typeof value !== 'number' || !Number.isFinite(value) || value < min || value > max)
51
+ throw new TypeError(`${path} must be a finite number from ${min} to ${max}.`);
52
+ }
53
+ function metrics(value, bounds, path) {
54
+ record(value, path);
55
+ keys(value, Object.keys(bounds), path);
56
+ for (const [key, item] of Object.entries(value))
57
+ if (item !== undefined)
58
+ number(item, ...bounds[key], `${path}.${key}`);
59
+ }
60
+ /** Pure, server-safe calculations. Input omits automatic metrics; output never loads a font. */
61
+ export function generateTypography(input = {}) {
62
+ record(input, 'typography');
63
+ keys(input, ['preset', 'fonts', 'prose', 'ui', 'styles'], 'typography');
64
+ const preset = input.preset === undefined ? 'inter' : input.preset;
65
+ if (typeof preset !== 'string' || !Object.hasOwn(typographyPresets, preset))
66
+ throw new TypeError('Unknown typography.preset.');
67
+ const fonts = { ...typographyPresets[preset].fonts };
68
+ if (input.fonts !== undefined) {
69
+ record(input.fonts, 'typography.fonts');
70
+ keys(input.fonts, assignments, 'typography.fonts');
71
+ for (const key of assignments) {
72
+ const font = input.fonts[key];
73
+ if (font === undefined)
74
+ continue;
75
+ record(font, `typography.fonts.${key}`);
76
+ keys(font, ['family', 'profile'], `typography.fonts.${key}`);
77
+ if (typeof font.family !== 'string' ||
78
+ !font.family.trim() ||
79
+ /[;{}@]|url\s*\(/i.test(font.family) ||
80
+ [...font.family].some(character => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127))
81
+ throw new TypeError(`typography.fonts.${key}.family must be a CSS font-family list.`);
82
+ if (font.profile !== undefined && !profiles.includes(font.profile))
83
+ throw new TypeError(`Unknown typography.fonts.${key}.profile.`);
84
+ fonts[key] = { family: font.family, profile: font.profile ?? 'manual' };
85
+ }
86
+ }
87
+ const manualProse = input.prose === undefined ? {} : input.prose, manualUI = input.ui === undefined ? {} : input.ui;
88
+ metrics(manualProse, {
89
+ size: [12, 40],
90
+ lineHeight: [1, 3],
91
+ paragraphSpacing: [0, 4],
92
+ measure: [20, 120],
93
+ headingScale: [1.1, 1.5]
94
+ }, 'typography.prose');
95
+ metrics(manualUI, { size: [12, 32], lineHeight: [1, 3] }, 'typography.ui');
96
+ const profile = bodyProfiles[fonts.body.profile ?? 'manual'];
97
+ const prose = {
98
+ size: profile?.[0] ?? 20,
99
+ lineHeight: profile?.[1] ?? 1.65,
100
+ measure: profile?.[2] ?? 64,
101
+ paragraphSpacing: 1.25,
102
+ headingScale: 1.25,
103
+ ...defined(manualProse)
104
+ };
105
+ const ui = { size: 16, lineHeight: 1.5, ...defined(manualUI) };
106
+ const styles = typographyStyles(prose, ui);
107
+ const overrides = input.styles === undefined ? {} : input.styles;
108
+ record(overrides, 'typography.styles');
109
+ keys(overrides, typographyRoles, 'typography.styles');
110
+ for (const role of typographyRoles) {
111
+ const override = overrides[role];
112
+ if (override === undefined)
113
+ continue;
114
+ record(override, `typography.styles.${role}`);
115
+ const { assignment, ...numeric } = override;
116
+ if (assignment !== undefined && !assignments.includes(assignment))
117
+ throw new TypeError(`Unknown typography.styles.${role}.assignment.`);
118
+ metrics(numeric, {
119
+ narrow: [8, 256],
120
+ wide: [8, 512],
121
+ weight: [1, 1000],
122
+ lineHeight: [0.8, 3],
123
+ tracking: [-0.2, 0.5],
124
+ measure: [0, 120]
125
+ }, `typography.styles.${role}`);
126
+ styles[role] = { ...styles[role], ...defined(override) };
127
+ if (styles[role].wide < styles[role].narrow)
128
+ throw new TypeError(`typography.styles.${role}.wide must be at least narrow.`);
129
+ }
130
+ const warnings = [];
131
+ for (const role of typographyRoles) {
132
+ const s = styles[role], range = weights[fonts[s.assignment].profile ?? 'manual'];
133
+ if (range && (s.weight < range[0] || s.weight > range[1]))
134
+ warnings.push({ role, requestedWeight: s.weight, supportedWeights: range });
135
+ }
136
+ return freezeTree({
137
+ input: {
138
+ preset,
139
+ fonts,
140
+ prose: defined(manualProse),
141
+ ui: defined(manualUI),
142
+ styles: Object.fromEntries(Object.entries(overrides)
143
+ .filter(([, v]) => v !== undefined)
144
+ .map(([k, v]) => [k, defined(v)]))
145
+ },
146
+ prose,
147
+ ui,
148
+ styles,
149
+ tokens: typographyTokens(styles, Object.fromEntries(assignments.map(key => [key, fonts[key].family])), prose.paragraphSpacing),
150
+ recommendations: {
151
+ body: !!profile,
152
+ ui: fonts.ui.profile === 'inter' || fonts.ui.profile === 'plex-sans'
153
+ },
154
+ warnings
155
+ });
156
+ }
157
+ function defined(value) {
158
+ return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined));
159
+ }
160
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/typography/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,qBAAqB,CAAA;AAU5B,OAAO,EAAE,eAAe,EAAE,CAAA;AAE1B,MAAM,KAAK,GAAG,EAAE,MAAM,EAAE,8BAA8B,EAAE,OAAO,EAAE,OAAO,EAAW,CAAA;AACnF,MAAM,KAAK,GAAG,EAAE,MAAM,EAAE,kCAAkC,EAAE,OAAO,EAAE,gBAAgB,EAAW,CAAA;AAChG,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,wCAAwC,EAAE,OAAO,EAAE,WAAW,EAAW,CAAA;AAChG,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,0CAA0C,EAAE,OAAO,EAAE,WAAW,EAAW,CAAA;AAClG,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;IAC1C,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IACxF,cAAc,EAAE;QACd,IAAI,EAAE,wBAAwB;QAC9B,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE;K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,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;iBAClC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAE,CAAC,CAAC,CAAC,CACrC;SACF;QACD,KAAK;QACL,EAAE;QACF,MAAM;QACN,MAAM,EAAE,gBAAgB,CACtB,MAAM,EACN,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAGlE,EACD,KAAK,CAAC,gBAAgB,CACvB;QACD,eAAe,EAAE;YACf,IAAI,EAAE,CAAC,CAAC,OAAO;YACf,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,KAAK,OAAO,IAAI,KAAK,CAAC,EAAE,CAAC,OAAO,KAAK,WAAW;SACrE;QACD,QAAQ;KACT,CAAC,CAAA;AACJ,CAAC;AACD,SAAS,OAAO,CAAmB,KAAQ;IACzC,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAM,CAAA;AAC1F,CAAC","sourcesContent":["import {\n freezeTree,\n typographyRoles,\n typographyStyles,\n typographyTokens\n} from '../themes/tokens.js'\nimport type {\n TypographyAssignment,\n TypographyFont,\n TypographyInput,\n TypographyProfile,\n TypographyProseRhythm,\n TypographyResult\n} from './types.js'\nexport type * from './types.js'\nexport { typographyRoles }\n\nconst inter = { family: 'Inter, system-ui, sans-serif', profile: 'inter' } as const\nconst serif = { family: '\"Source Serif 4\", Georgia, serif', profile: 'source-serif-4' } as const\nconst plex = { family: '\"IBM Plex Sans\", system-ui, sans-serif', profile: 'plex-sans' } as const\nconst mono = { family: '\"IBM Plex Mono\", ui-monospace, monospace', profile: 'plex-mono' } as const\nexport const typographyPresets = freezeTree({\n inter: { name: 'Inter', fonts: { body: inter, headings: inter, ui: inter, code: mono } },\n 'source-serif': {\n name: 'Source Serif 4 + Inter',\n fonts: { body: serif, headings: serif, ui: inter, code: mono }\n },\n plex: {\n name: 'Plex Sans + Plex Mono',\n fonts: { body: plex, headings: plex, ui: plex, code: mono }\n }\n} as const)\nconst assignments: readonly TypographyAssignment[] = ['body', 'headings', 'ui', 'code']\nconst profiles: readonly TypographyProfile[] = [\n 'inter',\n 'source-serif-4',\n 'plex-sans',\n 'plex-mono',\n 'manual'\n]\nconst bodyProfiles: Partial<Record<TypographyProfile, readonly [number, number, number]>> = {\n inter: [20, 1.6, 64],\n 'source-serif-4': [21, 1.65, 62],\n 'plex-sans': [20, 1.6, 62]\n}\nconst weights: Partial<Record<TypographyProfile, readonly [number, number]>> = {\n inter: [100, 900],\n 'source-serif-4': [200, 900],\n 'plex-sans': [100, 700],\n 'plex-mono': [100, 700]\n}\nfunction record(value: unknown, path: string): void {\n if (\n !value ||\n typeof value !== 'object' ||\n Array.isArray(value) ||\n ![Object.prototype, null].includes(Object.getPrototypeOf(value))\n )\n throw new TypeError(`${path} must be a plain object.`)\n}\nfunction keys(value: object, allowed: readonly string[], path: string) {\n for (const key of Object.keys(value))\n if (!allowed.includes(key)) throw new TypeError(`Unknown key: ${path}.${key}.`)\n}\nfunction number(value: unknown, min: number, max: number, path: string) {\n if (typeof value !== 'number' || !Number.isFinite(value) || value < min || value > max)\n throw new TypeError(`${path} must be a finite number from ${min} to ${max}.`)\n}\nfunction metrics(value: object, bounds: Record<string, readonly [number, number]>, path: string) {\n record(value, path)\n keys(value, Object.keys(bounds), path)\n for (const [key, item] of Object.entries(value))\n if (item !== undefined) number(item, ...bounds[key], `${path}.${key}`)\n}\n\n/** Pure, server-safe calculations. Input omits automatic metrics; output never loads a font. */\nexport function generateTypography(input: TypographyInput = {}): TypographyResult {\n record(input, 'typography')\n keys(input, ['preset', 'fonts', 'prose', 'ui', 'styles'], 'typography')\n const preset = input.preset === undefined ? 'inter' : input.preset\n if (typeof preset !== 'string' || !Object.hasOwn(typographyPresets, preset))\n throw new TypeError('Unknown typography.preset.')\n const fonts = { ...typographyPresets[preset].fonts } as Record<\n TypographyAssignment,\n TypographyFont\n >\n if (input.fonts !== undefined) {\n record(input.fonts, 'typography.fonts')\n keys(input.fonts, assignments, 'typography.fonts')\n for (const key of assignments) {\n const font = input.fonts[key]\n if (font === undefined) continue\n record(font, `typography.fonts.${key}`)\n keys(font, ['family', 'profile'], `typography.fonts.${key}`)\n if (\n typeof font.family !== 'string' ||\n !font.family.trim() ||\n /[;{}@]|url\\s*\\(/i.test(font.family) ||\n [...font.family].some(\n character => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127\n )\n )\n throw new TypeError(`typography.fonts.${key}.family must be a CSS font-family list.`)\n if (font.profile !== undefined && !profiles.includes(font.profile))\n throw new TypeError(`Unknown typography.fonts.${key}.profile.`)\n fonts[key] = { family: font.family, profile: font.profile ?? 'manual' }\n }\n }\n const manualProse = input.prose === undefined ? {} : input.prose,\n manualUI = input.ui === undefined ? {} : input.ui\n metrics(\n manualProse,\n {\n size: [12, 40],\n lineHeight: [1, 3],\n paragraphSpacing: [0, 4],\n measure: [20, 120],\n headingScale: [1.1, 1.5]\n },\n 'typography.prose'\n )\n metrics(manualUI, { size: [12, 32], lineHeight: [1, 3] }, 'typography.ui')\n const profile = bodyProfiles[fonts.body.profile ?? 'manual']\n const prose: TypographyProseRhythm = {\n size: profile?.[0] ?? 20,\n lineHeight: profile?.[1] ?? 1.65,\n measure: profile?.[2] ?? 64,\n paragraphSpacing: 1.25,\n headingScale: 1.25,\n ...defined(manualProse)\n }\n const ui = { size: 16, lineHeight: 1.5, ...defined(manualUI) }\n const styles = typographyStyles(prose, ui)\n const overrides = input.styles === undefined ? {} : input.styles\n record(overrides, 'typography.styles')\n keys(overrides, typographyRoles, 'typography.styles')\n for (const role of typographyRoles) {\n const override = overrides[role]\n if (override === undefined) continue\n record(override, `typography.styles.${role}`)\n const { assignment, ...numeric } = override\n if (assignment !== undefined && !assignments.includes(assignment))\n throw new TypeError(`Unknown typography.styles.${role}.assignment.`)\n metrics(\n numeric,\n {\n narrow: [8, 256],\n wide: [8, 512],\n weight: [1, 1000],\n lineHeight: [0.8, 3],\n tracking: [-0.2, 0.5],\n measure: [0, 120]\n },\n `typography.styles.${role}`\n )\n styles[role] = { ...styles[role], ...defined(override) }\n if (styles[role].wide < styles[role].narrow)\n throw new TypeError(`typography.styles.${role}.wide must be at least narrow.`)\n }\n const warnings: TypographyResult['warnings'][number][] = []\n for (const role of typographyRoles) {\n const s = styles[role],\n range = weights[fonts[s.assignment].profile ?? 'manual']\n if (range && (s.weight < range[0] || s.weight > range[1]))\n warnings.push({ role, requestedWeight: s.weight, supportedWeights: range })\n }\n return freezeTree({\n input: {\n preset,\n fonts,\n prose: defined(manualProse),\n ui: defined(manualUI),\n styles: Object.fromEntries(\n Object.entries(overrides)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => [k, defined(v!)])\n )\n },\n prose,\n ui,\n styles,\n tokens: typographyTokens(\n styles,\n Object.fromEntries(assignments.map(key => [key, fonts[key].family])) as Record<\n TypographyAssignment,\n string\n >,\n prose.paragraphSpacing\n ),\n recommendations: {\n body: !!profile,\n ui: fonts.ui.profile === 'inter' || fonts.ui.profile === 'plex-sans'\n },\n warnings\n })\n}\nfunction defined<T extends object>(value: T): T {\n return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined)) as T\n}\n"]}
@@ -0,0 +1,78 @@
1
+ /** Stable text styles; presentation is independent of the element's HTML semantics. */
2
+ export type TypographyRole = 'prose-title' | 'prose-heading' | 'prose-subheading' | 'prose-body' | 'prose-lead' | 'prose-small' | 'prose-quote' | 'ui-title' | 'ui-body' | 'ui-label' | 'ui-supporting' | 'ui-caption' | 'ui-metric' | 'ui-eyebrow' | 'display' | 'code';
3
+ export type TypographyAssignment = 'body' | 'headings' | 'ui' | 'code';
4
+ export type TypographyProfile = 'inter' | 'source-serif-4' | 'plex-sans' | 'plex-mono' | 'manual';
5
+ export type TypographyPreset = 'inter' | 'source-serif' | 'plex';
6
+ export interface TypographyFont {
7
+ /** CSS font-family list; choosing it never loads a font. */
8
+ readonly family: string;
9
+ /** Explicit provenance of a studied font. Omitted for an unfamiliar/manual font. */
10
+ readonly profile?: TypographyProfile;
11
+ }
12
+ export interface TypographyProseRhythm {
13
+ /** Reference pixels at a 16px root, emitted as rem. */
14
+ readonly size: number;
15
+ readonly lineHeight: number;
16
+ readonly paragraphSpacing: number;
17
+ readonly measure: number;
18
+ readonly headingScale: number;
19
+ }
20
+ export interface TypographyUIRhythm {
21
+ readonly size: number;
22
+ readonly lineHeight: number;
23
+ }
24
+ export interface TypographyStyle {
25
+ readonly assignment: TypographyAssignment;
26
+ /** Reference pixels at a 16px root. */
27
+ readonly narrow: number;
28
+ readonly wide: number;
29
+ readonly weight: number;
30
+ readonly lineHeight: number;
31
+ /** em; zero is deliberately not the old global negative tracking. */
32
+ readonly tracking: number;
33
+ /** ch; zero means the layout owns measure. */
34
+ readonly measure: number;
35
+ }
36
+ export interface TypographyInput {
37
+ readonly preset?: TypographyPreset;
38
+ readonly fonts?: Readonly<Partial<Record<TypographyAssignment, TypographyFont>>>;
39
+ /** Only manual settings belong here; omission keeps a profile-derived default live. */
40
+ readonly prose?: Partial<TypographyProseRhythm>;
41
+ readonly ui?: Partial<TypographyUIRhythm>;
42
+ readonly styles?: Readonly<Partial<Record<TypographyRole, Partial<TypographyStyle>>>>;
43
+ }
44
+ export interface TypographyRoleTokens {
45
+ readonly family: string;
46
+ readonly size: string;
47
+ readonly fluidSize: string;
48
+ readonly weight: number | string;
49
+ readonly lineHeight: string;
50
+ readonly letterSpacing: string;
51
+ readonly measure: string;
52
+ }
53
+ export interface TypographyTokens {
54
+ readonly roles: Readonly<Record<TypographyRole, TypographyRoleTokens>>;
55
+ readonly flow: {
56
+ readonly paragraph: string;
57
+ readonly headingBefore: string;
58
+ readonly headingAfter: string;
59
+ };
60
+ }
61
+ export interface TypographyResult {
62
+ /** Replayable input retains manual/automatic ownership rather than pinning computed defaults. */
63
+ readonly input: TypographyInput;
64
+ readonly prose: TypographyProseRhythm;
65
+ readonly ui: TypographyUIRhythm;
66
+ readonly styles: Readonly<Record<TypographyRole, TypographyStyle>>;
67
+ readonly tokens: TypographyTokens;
68
+ readonly recommendations: {
69
+ readonly body: boolean;
70
+ readonly ui: boolean;
71
+ };
72
+ readonly warnings: readonly {
73
+ readonly role: TypographyRole;
74
+ readonly requestedWeight: number;
75
+ readonly supportedWeights: readonly [number, number];
76
+ }[];
77
+ }
78
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/typography/types.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,MAAM,cAAc,GACtB,aAAa,GACb,eAAe,GACf,kBAAkB,GAClB,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,aAAa,GACb,UAAU,GACV,SAAS,GACT,UAAU,GACV,eAAe,GACf,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,SAAS,GACT,MAAM,CAAA;AAEV,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,GAAG,MAAM,CAAA;AACtE,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,gBAAgB,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAA;AACjG,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,cAAc,GAAG,MAAM,CAAA;AAEhE,MAAM,WAAW,cAAc;IAC7B,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,oFAAoF;IACpF,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAA;CACrC;AACD,MAAM,WAAW,qBAAqB;IACpC,uDAAuD;IACvD,QAAQ,CAAC,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AS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KACrD,EAAE,CAAA;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/typography/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Stable text styles; presentation is independent of the element's HTML semantics. */\nexport type TypographyRole =\n | 'prose-title'\n | 'prose-heading'\n | 'prose-subheading'\n | 'prose-body'\n | 'prose-lead'\n | 'prose-small'\n | 'prose-quote'\n | 'ui-title'\n | 'ui-body'\n | 'ui-label'\n | 'ui-supporting'\n | 'ui-caption'\n | 'ui-metric'\n | 'ui-eyebrow'\n | 'display'\n | 'code'\n\nexport type TypographyAssignment = 'body' | 'headings' | 'ui' | 'code'\nexport type TypographyProfile = 'inter' | 'source-serif-4' | 'plex-sans' | 'plex-mono' | 'manual'\nexport type TypographyPreset = 'inter' | 'source-serif' | 'plex'\n\nexport interface TypographyFont {\n /** CSS font-family list; choosing it never loads a font. */\n readonly family: string\n /** Explicit provenance of a studied font. Omitted for an unfamiliar/manual font. */\n readonly profile?: TypographyProfile\n}\nexport interface TypographyProseRhythm {\n /** Reference pixels at a 16px root, emitted as rem. */\n readonly size: number\n readonly lineHeight: number\n readonly paragraphSpacing: number\n readonly measure: number\n readonly headingScale: number\n}\nexport interface TypographyUIRhythm {\n readonly size: number\n readonly lineHeight: number\n}\nexport interface TypographyStyle {\n readonly assignment: TypographyAssignment\n /** Reference pixels at a 16px root. */\n readonly narrow: number\n readonly wide: number\n readonly weight: number\n readonly lineHeight: number\n /** em; zero is deliberately not the old global negative tracking. */\n readonly tracking: number\n /** ch; zero means the layout owns measure. */\n readonly measure: number\n}\nexport interface TypographyInput {\n readonly preset?: TypographyPreset\n readonly fonts?: Readonly<Partial<Record<TypographyAssignment, TypographyFont>>>\n /** Only manual settings belong here; omission keeps a profile-derived default live. */\n readonly prose?: Partial<TypographyProseRhythm>\n readonly ui?: Partial<TypographyUIRhythm>\n readonly styles?: Readonly<Partial<Record<TypographyRole, Partial<TypographyStyle>>>>\n}\nexport interface TypographyRoleTokens {\n readonly family: string\n readonly size: string\n readonly fluidSize: string\n readonly weight: number | string\n readonly lineHeight: string\n readonly letterSpacing: string\n readonly measure: string\n}\nexport interface TypographyTokens {\n readonly roles: Readonly<Record<TypographyRole, TypographyRoleTokens>>\n readonly flow: {\n readonly paragraph: string\n readonly headingBefore: string\n readonly headingAfter: string\n }\n}\nexport interface TypographyResult {\n /** Replayable input retains manual/automatic ownership rather than pinning computed defaults. */\n readonly input: TypographyInput\n readonly prose: TypographyProseRhythm\n readonly ui: TypographyUIRhythm\n readonly styles: Readonly<Record<TypographyRole, TypographyStyle>>\n readonly tokens: TypographyTokens\n readonly recommendations: { readonly body: boolean; readonly ui: boolean }\n readonly warnings: readonly {\n readonly role: TypographyRole\n readonly requestedWeight: number\n readonly supportedWeights: readonly [number, number]\n }[]\n}\n"]}
package/docs/system.md CHANGED
@@ -54,6 +54,13 @@ For public workshop editing, use the versioned `ThemeDocument` authoring API.
54
54
  Its token sections compile through `defineTheme` into the same `ThemeScope`
55
55
  contract. Section imports preserve unrelated settings and deliberate component
56
56
  exceptions. See [portable documents and import semantics](theming.md#portable-workshop-documents). The pure
57
+ `generateTypography` interface and `typography.typesetting` recipe supply opt-in
58
+ font assignments, 16 text styles and independent prose/UI rhythms through the
59
+ same compiler. Use the semantic HTML hooks and local container documented under
60
+ [responsive typography](theming.md#responsive-typography); production component text consumes the shared UI roles. Control sizes retain
61
+ their font-size/geometry metrics, and inline links inherit their surrounding text.
62
+ The baseline UI roles bridge the legacy typography leaves; recipes and explicit
63
+ role values take ownership when supplied. The pure
57
64
  `generateColorWall` interface supplies calibrated sRGB palette metadata through
58
65
  `@cognitap/radiant/color`; see [color-wall inputs and output](theming.md#generate-a-color-wall). Use
59
66
  `colorCalibrationPresets` for independent wall/ramp treatments (Classic, Balanced,
package/docs/theming.md CHANGED
@@ -209,6 +209,14 @@ or regenerated palette; the compiler never silently adjusts the source.
209
209
  fonts and determines availability. Local font bytes, file paths/handles, URLs,
210
210
  DOM objects and runtime functions have no fields in the schema. A local family
211
211
  name can travel with the configuration, but the local font itself does not.
212
+ Optional `axes` records available OpenType ranges as `{ tag, min, default, max }`.
213
+ Axis tags are unique four-character ASCII identifiers; at most 32 finite, ordered
214
+ ranges are accepted per font. These are capabilities for setup and inspection,
215
+ not selected variations. Trial-only axis adjustments remain in the typeface lab.
216
+ Full/selective documents retain these descriptors; compiling them does not change
217
+ paint or load font files. Compressed custom files without inspected axes remain
218
+ unverified rather than receiving invented capabilities.
219
+
212
220
  Font metadata does not set `typography.values.family` automatically.
213
221
 
214
222
  Full and selective authoring JSON preserve those descriptors; only selecting
@@ -218,6 +226,202 @@ arrays, strings, booleans, null and finite numbers, restricted further by their
218
226
  field schema. Functions, class/binary instances, cycles, accessors and unsupported
219
227
  keys fail before import can silently discard data.
220
228
 
229
+ ## Responsive typography
230
+
231
+ Typesetting is opt-in and uses the existing theme compiler. The accepted
232
+ [role model](research/dev-162-typography-model.md) separates Body/Headings/UI/Code
233
+ font assignments, 16 text styles and independent prose/UI rhythms.
234
+
235
+ ```tsx
236
+ import { ThemeScope, compileThemeDocument, defineThemeDocument,
237
+ generateTypography, updateThemeDocument } from '@cognitap/radiant'
238
+
239
+ const document = defineThemeDocument({
240
+ kind: 'radiant-theme', version: 1, id: 'publication', name: 'Publication',
241
+ sections: { typography: { typesetting: {
242
+ preset: 'source-serif',
243
+ prose: { paragraphSpacing: 1.4 },
244
+ styles: { 'prose-title': { weight: 650 } },
245
+ } } },
246
+ })
247
+ const theme = compileThemeDocument(document)
248
+
249
+ // Inside your application, with either documented CSS route:
250
+ <ThemeScope theme={theme}>
251
+ <article data-rad-prose="" data-rad-type-container="">
252
+ <h1>A shared language for careful work</h1>
253
+ <p data-rad-text="prose-lead">A lead can use its own reusable style.</p>
254
+ <p>Body copy with <em>emphasis</em> and <code>inline.code</code>.</p>
255
+ <h2>A new section</h2>
256
+ <p>Paragraph and heading spacing follow the prose rhythm.</p>
257
+ </article>
258
+ </ThemeScope>
259
+
260
+ const next = updateThemeDocument(document, {
261
+ typography: { typesetting: { ui: { size: 18 } } },
262
+ })
263
+ const result = generateTypography(next.sections.typography!.typesetting)
264
+ ```
265
+
266
+ `generateTypography`, `typographyPresets`, `typographyRoles` and their types also
267
+ export from the pure `@cognitap/radiant/typography` entry. It imports no React,
268
+ reads no browser globals and loads no fonts. For plain definitions, pass
269
+ `result.tokens` as `tokens.typography` to `defineTheme`. `prose`, `ui`, and
270
+ `styles` expose calculated settings. Immutable `result.input` is JSON-replayable
271
+ and preserves manual/automatic ownership instead of pinning calculated metrics.
272
+
273
+ ### Authoring and precedence
274
+
275
+ `typography.typesetting` generates common defaults. Explicit `typography.values`
276
+ leaves override them, followed by `typography.modes.light/dark` leaves. Existing
277
+ component exceptions retain their precedence. Typography-only section exports
278
+ carry recipes, explicit values and font descriptors through the existing
279
+ merge/replace import rules; no second compiler or loading path is introduced.
280
+
281
+ `preset` is `inter` (default), `source-serif`, or `plex`. Each `fonts.body`,
282
+ `headings`, `ui` and `code` accepts a CSS `family` list and optional `profile`:
283
+ `inter`, `source-serif-4`, `plex-sans`, `plex-mono`, or `manual`. A new family
284
+ without a profile selects manual defaults. A profile is an explicit claim about
285
+ the supplied font, not detection of an installed file. Consumers own that setup.
286
+
287
+ | Manual setting | Bounds | Default |
288
+ | -------------------------- | ----------------------- | ------------------------------------- |
289
+ | `prose.size` | 12–40 reference px | Inter/Plex: 20, Serif: 21, manual: 20 |
290
+ | `prose.lineHeight` | 1–3 | Inter/Plex: 1.6, Serif/manual: 1.65 |
291
+ | `prose.paragraphSpacing` | 0–4em | 1.25em |
292
+ | `prose.measure` | 20–120ch | Inter/manual: 64, Serif/Plex: 62 |
293
+ | `prose.headingScale` | 1.1–1.5 | 1.25 |
294
+ | `ui.size`, `ui.lineHeight` | 12–32 reference px, 1–3 | 16px / 1.5 |
295
+
296
+ Each `styles[role]` accepts `assignment`, `narrow`, `wide`, `weight`, `lineHeight`,
297
+ `tracking` and `measure`. Endpoint sizes are reference pixels at a 16px root,
298
+ emitted as rem. Narrow is 8–256px; wide 8–512px and at least narrow. Weight is
299
+ 1–1000, leading .8–3, tracking -.2–.5em and measure 0–120ch; zero measure means
300
+ layout-owned. These are predictable bounds, not a guarantee every combination
301
+ will look good.
302
+
303
+ `recommendations.body/ui` flags known contextual starting points. Other fonts
304
+ remain manually tunable. `warnings` identifies style weights outside a claimed
305
+ profile's range, retaining the authored value rather than silently clamping it.
306
+ Inspect warnings before accepting a theme. There is no universal readability
307
+ score or implicit normalization.
308
+
309
+ Context updates preserve explicit `styles` overrides. To reset a style or return
310
+ a metric to automatic behavior, omit that key from the next recipe and **replace**
311
+ the typography section, retaining other metadata/explicit values. Merge semantics
312
+ cannot delete a stored leaf by omission. To select a fresh starting point,
313
+ replace its recipe; merging only a preset ID intentionally retains old overrides.
314
+ When merging a saved font assignment, change its family and profile together
315
+ (use `manual` for an unfamiliar font), or replace the recipe. Merging only a
316
+ family retains a previously stored profile.
317
+
318
+ ### Semantic HTML and local width
319
+
320
+ - `data-rad-text="prose-title"` selects presentation on any semantic element; it
321
+ does not set heading levels or ARIA roles. `typographyRoles` lists all 16 values:
322
+ prose title/heading/subheading/body/lead/small/quote; UI title/body/label/
323
+ supporting/caption/metric/eyebrow; display; code.
324
+ - `data-rad-prose` opts a container into Body typography, maximum measure and
325
+ flow. Its **direct** headings, paragraphs/lists, captions, quotes and `pre`
326
+ blocks receive their corresponding styles. Nested section wrappers can opt
327
+ into prose explicitly.
328
+ - Explicit `data-rad-text` wins over automatic element mapping. A direct block
329
+ with `data-rad-not-prose` or a Radiant `data-slot` host skips mapping/flow;
330
+ ordinary inherited font properties still inherit. Opt-out is not a reset.
331
+ - `data-rad-type-container` establishes the named `radiant-type` inline-size
332
+ container. Put it on the content column, including nested columns. Heading/
333
+ display sizing interpolates over 24–56rem of local width. Body/UI sizes stay
334
+ fixed rem values. Without an opt-in ancestor, roles use their compact endpoint.
335
+
336
+ Hooks are low-specificity rules in the components layer. Utilities, ordinary
337
+ application CSS and inline styles override them. Token shorthand utilities are
338
+ registered by property in the existing class merger, for example
339
+ `text-(--rad-typography-roles-prose-title-size)` and
340
+ `font-(--rad-typography-roles-prose-title-family)`. An application Tailwind build
341
+ must generate new utilities; importing precompiled library CSS does not do that.
342
+
343
+ Measure is a maximum, not minimum width or exact character count. Prose wraps
344
+ long words; preformatted code scrolls within its box. Give scrollable code
345
+ keyboard access and an appropriate name where needed. UI styles leave measure
346
+ to the layout. Inline code uses .9em and inherited weight/leading, not block-code
347
+ line boxes. Actual italic/weight assets are required; text-style hosts disable
348
+ synthetic font styles.
349
+
350
+ Direct token authoring uses `roles[role].size` for the compact endpoint and
351
+ `fluidSize` for the responsive expression. Set both to fix a style at all widths,
352
+ or set equal `narrow`/`wide` inputs. Other role leaves are `family`, `weight`,
353
+ `lineHeight`, `letterSpacing` and `measure`; prose flow leaves are
354
+ `flow.paragraph`, `headingBefore` and `headingAfter`.
355
+
356
+ ### Fonts, migration and verification
357
+
358
+ Load chosen families/styles/weights with your application's font loader or
359
+ self-hosted `@font-face`. Presets contain family/fallback lists, not font URLs,
360
+ bytes or loaders. `typography.fonts` remains portable metadata; it does not load
361
+ fonts or automatically select assignments. The role baseline follows the legacy
362
+ shared family, with system monospace for code. Generated presets explicitly
363
+ select their named families.
364
+
365
+ ### Component roles and earlier themes
366
+
367
+ Production families now consume the same UI roles as the workshop specimens:
368
+
369
+ | Text host | Shared role | Deliberate size owner |
370
+ | -------------------------------------------------------------------------- | ------------------------- | ---------------------------------------------------- |
371
+ | ThemeScope, Card, DialogContent, Field, Collapsible and disclosure content | `ui-body` | Role; `collapsible.contentSize` remains an exception |
372
+ | CardTitle, DialogTitle | `ui-title` | Role; component title size/weight overrides win |
373
+ | Field label/legend, CollapsibleTrigger, AccordionTrigger | `ui-label` | Role; Field label overrides win |
374
+ | Button, action-shaped Link | `ui-label` | Existing `controlSize` and Button font-size slots |
375
+ | Input | `ui-body` | Existing `controlSize` and Input font-size slot |
376
+ | Checkbox/Radio label | `ui-label` | Existing `controlSize` and label-size slots |
377
+ | Field help/error, CardDescription, DialogDescription | `ui-supporting` | Role; existing component size slots win |
378
+ | Inline/subtle Link | Inherits surrounding text | Parent text, including prose and code assignments |
379
+
380
+ Roles supply family, weight, line height and tracking. Component UI text uses
381
+ `size` (the compact endpoint), without prose measure limits or prose margins.
382
+ Control sizes deliberately keep their 13/14/15px font metrics and 32/40/48px
383
+ height/min-height defaults. Changing UI rhythm/style size therefore changes
384
+ ordinary interface copy and labels, while size-constrained controls retain their
385
+ metrics. To change those metrics, author `control.small/medium/large.fontSize`
386
+ (and height/padding as needed), or a supported component font-size exception.
387
+ Button and action-shaped Link share the Button-only typography exceptions.
388
+ Accordion and Dialog actions reuse disclosure/Button styling respectively.
389
+
390
+ The baseline `ui-body`, `ui-label`, `ui-title` and `ui-supporting` roles alias
391
+ legacy family, size, weight and tracking leaves. Earlier themes and every built-in
392
+ preset therefore retain their authored families/sizes/weights and deliberate
393
+ Button exceptions. Baseline UI leading is now explicit: Body/Supporting 1.5,
394
+ Label 1.4 and Title 1.3. Checkbox/Radio labels and disclosure triggers now use the
395
+ shared label weight rather than inheriting body weight. These wrapping/rhythm
396
+ changes require matching package JavaScript/CSS and layout review.
397
+
398
+ To migrate a theme, replace `family/bodySize/bodyWeight` with `roles['ui-body']`,
399
+ `smallSize` with `roles['ui-supporting'].size`, `headingSize/headingWeight` with
400
+ `roles['ui-title']`, and `labelWeight` with `roles['ui-label'].weight`. The earlier
401
+ shared family/tracking fields affect all four baseline roles; specify those
402
+ leaves on each role to retain that breadth. Prefer a `typesetting` recipe when
403
+ you want independently assigned Body/Headings/UI/Code families and repeatable
404
+ rhythms. A recipe materializes these roles and then explicit `values`/mode role
405
+ leaves override it; legacy leaves no longer control recipe-owned roles. There
406
+ is no implicit recipe adoption or destructive migration of stored documents.
407
+ Local component variables, caller utilities and ordinary CSS retain precedence.
408
+ When migrating a legacy CSS variable applied directly to a text host, set the
409
+ corresponding role variable on that host; inherited role aliases may already
410
+ have resolved on the enclosing theme scope.
411
+
412
+ New `roles` and `flow` are ordinary shared token leaves with partial/mode
413
+ overrides. Older 0.0.4 parsers reject the new authoring keys; consume matching
414
+ package JavaScript/CSS and defer the public docs pin to chapter promotion.
415
+
416
+ Canonical examples: **System → Typography → Roles / Prose / Components / Serif Interface / Mono Interface**. The installed
417
+ artifact gate verifies all 16 roles at 320/390/640/800px, both modes, nested
418
+ containers and named/mode-only scopes, caller overrides, flow, inline code and
419
+ root-enlargement/text-spacing probes through compiled CSS and Tailwind, each
420
+ with/without reset. These fixtures use system fallbacks; actual-font quality
421
+ remains bounded by DEV-162's recorded study. Browser zoom, manual AT, more scripts/
422
+ browsers, production component adoption and final public review remain chapter
423
+ acceptance work.
424
+
221
425
  ## Generate a color wall
222
426
 
223
427
  ```ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognitap/radiant",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "React interaction components and presentation primitives",
5
5
  "homepage": "https://github.com/cognitap/radiant#readme",
6
6
  "bugs": {
@@ -24,7 +24,8 @@
24
24
  "src/styles.css",
25
25
  "src/themes/baseline.css",
26
26
  "!src/**/*.stories.*",
27
- "!src/**/*.test.*"
27
+ "!src/**/*.test.*",
28
+ "src/typography.css"
28
29
  ],
29
30
  "type": "module",
30
31
  "sideEffects": [
@@ -41,6 +42,10 @@
41
42
  "./color": {
42
43
  "types": "./dist/library/color/index.d.ts",
43
44
  "default": "./dist/library/color/index.js"
45
+ },
46
+ "./typography": {
47
+ "types": "./dist/library/typography/index.d.ts",
48
+ "default": "./dist/library/typography/index.js"
44
49
  }
45
50
  },
46
51
  "publishConfig": {
package/src/Card.tsx CHANGED
@@ -9,7 +9,7 @@ const colorMotionClass =
9
9
 
10
10
  const cardVariants = cva([
11
11
  colorMotionClass,
12
- '[font-family:var(--rad-typography-family,system-ui,sans-serif)] [letter-spacing:var(--rad-typography-letter-spacing,-0.011em)] [font-size:var(--rad-typography-body-size,0.875rem)] [font-weight:var(--rad-typography-body-weight,400)]',
12
+ '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)]',
13
13
  'box-border grid w-full gap-[var(--rad-card-gap,var(--rad-surface-gap,1rem))] text-start antialiased',
14
14
  'rounded-[var(--rad-card-radius,var(--rad-surface-radius,0.75rem))]',
15
15
  '[corner-shape:var(--rad-card-corner-shape,var(--rad-surface-corner-shape,round))]',
@@ -29,17 +29,19 @@ const cardHeaderVariants = cva([
29
29
 
30
30
  const cardTitleVariants = cva([
31
31
  colorMotionClass,
32
- 'm-0 min-w-0 break-words leading-snug',
33
- '[font-size:var(--rad-card-title-size,var(--rad-typography-heading-size,1.125rem))]',
34
- '[font-weight:var(--rad-card-title-weight,var(--rad-typography-heading-weight,600))]',
32
+ 'm-0 min-w-0 break-words',
33
+ '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)]',
34
+ 'text-[length:var(--rad-card-title-size,var(--rad-typography-roles-ui-title-size,1.125rem))] leading-[var(--rad-typography-roles-ui-title-line-height,1.3)]',
35
+ 'font-[number:var(--rad-card-title-weight,var(--rad-typography-roles-ui-title-weight,600))]',
35
36
  'forced-colors:text-[CanvasText]'
36
37
  ])
37
38
 
38
39
  const cardDescriptionVariants = cva([
39
40
  colorMotionClass,
40
- 'm-0 min-w-0 break-words leading-snug',
41
+ 'm-0 min-w-0 break-words',
41
42
  '[color:var(--rad-card-description-color,var(--rad-color-muted-foreground,oklch(0.45_0.01_286)))]',
42
- '[font-size:var(--rad-card-description-size,var(--rad-typography-small-size,0.8125rem))]',
43
+ '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)]',
44
+ 'text-[length:var(--rad-card-description-size,var(--rad-typography-roles-ui-supporting-size,0.8125rem))] leading-[var(--rad-typography-roles-ui-supporting-line-height,1.5)]',
43
45
  'forced-colors:text-[CanvasText]'
44
46
  ])
45
47
 
package/src/Checkbox.tsx CHANGED
@@ -43,10 +43,10 @@ const markClass =
43
43
  'pointer-events-none absolute inset-0 size-full scale-65 [color:var(--rad-checkbox-mark,var(--rad-color-accent-foreground,oklch(0.985_0_0)))] peer-disabled:[color:var(--rad-checkbox-mark,var(--rad-color-muted-foreground,oklch(0.45_0.01_286)))] forced-colors:text-[HighlightText] forced-colors:peer-disabled:text-[GrayText]'
44
44
 
45
45
  const rowClass =
46
- '[font-family:var(--rad-typography-family,system-ui,sans-serif)] [letter-spacing:var(--rad-typography-letter-spacing,-0.011em)] [font-weight:var(--rad-typography-body-weight,400)] inline-flex min-h-6 cursor-pointer items-center gap-[var(--rad-checkbox-gap,var(--rad-spacing-label-gap,0.5rem))] select-none has-disabled:cursor-not-allowed'
46
+ 'inline-flex min-h-6 cursor-pointer items-center gap-[var(--rad-checkbox-gap,var(--rad-spacing-label-gap,0.5rem))] select-none has-disabled:cursor-not-allowed'
47
47
 
48
48
  const labelClass =
49
- 'leading-snug [color:var(--rad-checkbox-label-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))] [font-size:var(--rad-checkbox-label-size,var(--_rad-control-font-size))]'
49
+ '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-checkbox-label-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))] text-[length:var(--rad-checkbox-label-size,var(--_rad-control-font-size))] leading-[var(--rad-typography-roles-ui-label-line-height,1.4)]'
50
50
 
51
51
  export type CheckboxProps = Omit<
52
52
  ComponentProps<'input'>,
@@ -13,8 +13,8 @@ const colorMotionClass =
13
13
 
14
14
  const collapsibleVariants = cva([
15
15
  colorMotionClass,
16
- '[font-family:var(--rad-typography-family,system-ui,sans-serif)] [letter-spacing:var(--rad-typography-letter-spacing,-0.011em)] [font-size:var(--rad-typography-body-size,0.875rem)] [font-weight:var(--rad-typography-body-weight,400)]',
17
- 'group box-border grid w-full gap-[var(--rad-collapsible-gap,var(--rad-surface-gap,1rem))] text-start antialiased',
16
+ '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)]',
17
+ 'group box-border grid w-full min-w-0 gap-[var(--rad-collapsible-gap,var(--rad-surface-gap,1rem))] text-start antialiased',
18
18
  'rounded-[var(--rad-collapsible-radius,var(--rad-surface-radius,0.75rem))]',
19
19
  '[corner-shape:var(--rad-collapsible-corner-shape,var(--rad-surface-corner-shape,round))]',
20
20
  '[border-width:var(--rad-collapsible-border-width,var(--rad-surface-border-width,1px))]',
@@ -35,7 +35,8 @@ const collapsibleVariants = cva([
35
35
 
36
36
  const collapsibleTriggerVariants = cva([
37
37
  colorMotionClass,
38
- 'flex w-full cursor-pointer items-center gap-[var(--rad-collapsible-gap,var(--rad-surface-gap,1rem))]',
38
+ 'font-[family-name:var(--rad-typography-roles-ui-label-family,system-ui,sans-serif)] text-[length:var(--rad-typography-roles-ui-label-size,0.875rem)] font-[number:var(--rad-typography-roles-ui-label-weight,550)] leading-[var(--rad-typography-roles-ui-label-line-height,1.4)] tracking-[var(--rad-typography-roles-ui-label-letter-spacing,0em)]',
39
+ 'box-border flex w-full min-w-0 cursor-pointer break-words items-center gap-[var(--rad-collapsible-gap,var(--rad-surface-gap,1rem))]',
39
40
  'list-none p-[var(--rad-collapsible-padding,var(--rad-surface-padding,1.5rem))]',
40
41
  '[&::-webkit-details-marker]:hidden [&::marker]:content-none',
41
42
  'focus-visible:rounded-[var(--rad-collapsible-radius,var(--rad-surface-radius,0.75rem))]',
@@ -59,7 +60,7 @@ const collapsibleContentVariants = cva([
59
60
  colorMotionClass,
60
61
  'min-w-0 px-[var(--rad-collapsible-padding,var(--rad-surface-padding,1.5rem))] pb-[var(--rad-collapsible-padding,var(--rad-surface-padding,1.5rem))]',
61
62
  '[color:var(--rad-collapsible-content-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))]',
62
- '[font-size:var(--rad-collapsible-content-size,var(--rad-typography-body-size,0.875rem))]',
63
+ 'text-[length:var(--rad-collapsible-content-size,var(--rad-typography-roles-ui-body-size,0.875rem))]',
63
64
  'forced-colors:text-[CanvasText]'
64
65
  ])
65
66