@classic-homes/theme-tailwind-preset 0.9.0 → 0.12.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.
Files changed (3) hide show
  1. package/index.js +17 -446
  2. package/package.json +3 -2
  3. package/theme.js +515 -0
package/index.js CHANGED
@@ -18,108 +18,33 @@
18
18
  * ```
19
19
  */
20
20
 
21
- const tokens = require('@classic-homes/theme-tokens');
22
-
23
- /**
24
- * Base heading typography, emitted through `addBase`.
25
- *
26
- * theme-styles/base.css sets the same scale inside `@layer classic-theme.base`,
27
- * but any consumer that runs `@tailwind base` also gets Tailwind preflight's
28
- * `h1..h6 { font-size: inherit; font-weight: inherit }`. Preflight is
29
- * unlayered, so it outranks the theme's layered rule by cascade semantics -
30
- * and @csstools/postcss-cascade-layers (postcss-config) keeps that ordering
31
- * with specificity boosts. Bare headings therefore rendered at body size with
32
- * the inherited weight in every Tailwind app, including our own example apps.
33
- *
34
- * `addBase` output lands inside Tailwind's base output *after* preflight, so
35
- * it wins on source order. Sizes and weights come from the `fontSize.h1..h6`
36
- * scale below, so the utilities (`text-h1`) and the bare elements agree.
37
- * Color and margins are left to base.css/preflight on purpose: this only
38
- * restores what preflight resets.
39
- */
40
- // Heading sizes for the typography scale (mirrors theme-styles base.css).
41
- // h1 pairs with `font-serif italic` (Spectral 500); h2-h6 are Figtree 600.
42
- // Exposed as `text-h1`..`text-h6` and emitted on the bare elements by
43
- // `headingBase` below, so the two never drift.
44
- const headingScale = {
45
- // 2.75rem leading: a 2rem line on 40px type made wrapped titles overlap
46
- h1: ['2.5rem', { lineHeight: '2.75rem', fontWeight: '500' }], // 40px
47
- h2: ['1.75rem', { lineHeight: '2.25rem', fontWeight: '600' }], // 28px
48
- h3: ['1.5rem', { lineHeight: '2rem', fontWeight: '600' }], // 24px
49
- h4: ['1.25rem', { lineHeight: '1.75rem', fontWeight: '600' }], // 20px
50
- h5: ['1.125rem', { lineHeight: '1.5rem', fontWeight: '600' }], // 18px
51
- h6: ['1rem', { lineHeight: '1.5rem', fontWeight: '600' }], // 16px
52
- };
53
-
54
- function headingBase({ addBase, theme }) {
55
- // Not theme('fontSize.h1'): Tailwind 3 resolves that to the size string alone
56
- const heading = (level) => {
57
- const [fontSize, { lineHeight, fontWeight }] = headingScale[level];
58
- return { fontSize, lineHeight, fontWeight };
59
- };
60
- // theme() hands fontFamily back as a joined string in Tailwind 3, an array in 4
61
- const stack = (key) => [].concat(theme(key)).join(', ');
62
- const serif = stack('fontFamily.serif');
63
- const sans = stack('fontFamily.sans');
64
- addBase({
65
- h1: {
66
- fontFamily: `var(--font-serif, ${serif})`,
67
- fontStyle: 'italic',
68
- ...heading('h1'),
69
- },
70
- h2: { fontFamily: `var(--font-sans, ${sans})`, ...heading('h2') },
71
- h3: { fontFamily: `var(--font-sans, ${sans})`, ...heading('h3') },
72
- h4: { fontFamily: `var(--font-sans, ${sans})`, ...heading('h4') },
73
- h5: { fontFamily: `var(--font-sans, ${sans})`, ...heading('h5') },
74
- h6: { fontFamily: `var(--font-sans, ${sans})`, ...heading('h6') },
75
- });
21
+ const {
22
+ darkMode,
23
+ headingStyles,
24
+ responsiveBaseStyles,
25
+ tapTargetUtilities,
26
+ theme,
27
+ } = require('./theme.js');
28
+
29
+ // The theme and the styles below are plain data in ./theme.js, shared with
30
+ // the Tailwind 4 stylesheet in @classic-homes/theme-styles. Edit them there.
31
+
32
+ function headingBase({ addBase }) {
33
+ addBase(headingStyles);
76
34
  }
77
35
 
78
- /**
79
- * `tap-target`: grows an element's hit area to at least 44×44px on coarse pointers
80
- * (touch) with a centred, invisible ::after — layout and visuals don't change.
81
- * For small icon buttons, chip removers, inline text buttons and sort headers.
82
- *
83
- * - Sets `position: relative` unless the element is already `absolute`/`fixed`/`sticky`.
84
- * - Uses `::after`: don't combine with other `after:` utilities on the same element.
85
- * - Neighbouring targets closer than 44px will overlap; the later one in the DOM wins.
86
- */
87
- /**
88
- * Base resets preflight leaves out that break narrow layouts and touch:
89
- * - fieldset defaults to `min-inline-size: min-content`, so a fieldset holding a wide row
90
- * (columns editor, radio grid) refuses to shrink and pushes the page sideways on phones.
91
- * - <summary> toggles get vertical padding on coarse pointers.
92
- */
93
36
  function responsiveBase({ addBase }) {
94
- addBase({
95
- fieldset: { minWidth: '0' },
96
- // <details> toggles are usually one text line (16–20px); on touch give them a
97
- // 36px+ row. Padding utilities on the summary still win (utilities layer).
98
- '@media (pointer: coarse)': { summary: { paddingTop: '0.5rem', paddingBottom: '0.5rem' } },
99
- });
37
+ addBase(responsiveBaseStyles);
100
38
  }
101
39
 
102
40
  function tapTarget({ addUtilities }) {
103
- addUtilities({
104
- '.tap-target:not(.absolute):not(.fixed):not(.sticky)': { position: 'relative' },
105
- '@media (pointer: coarse)': {
106
- '.tap-target::after': {
107
- content: "''",
108
- position: 'absolute',
109
- top: '50%',
110
- left: '50%',
111
- width: 'max(100%, 44px)',
112
- height: 'max(100%, 44px)',
113
- transform: 'translate(-50%, -50%)',
114
- },
115
- },
116
- });
41
+ addUtilities(tapTargetUtilities);
117
42
  }
118
43
 
119
44
  /** @type {import('tailwindcss').Config} */
120
45
  module.exports = {
121
46
  // Enable dark mode via class on <html> element
122
- darkMode: ['class'],
47
+ darkMode,
123
48
 
124
49
  future: {
125
50
  // Gate hover:/group-hover: styles behind @media (hover: hover) and (pointer: fine)
@@ -127,360 +52,6 @@ module.exports = {
127
52
  hoverOnlyWhenSupported: true,
128
53
  },
129
54
 
130
- theme: {
131
- // Container with brand max-widths
132
- container: {
133
- center: true,
134
- padding: {
135
- DEFAULT: '1rem',
136
- sm: '2rem',
137
- lg: '4rem',
138
- xl: '5rem',
139
- '2xl': '6rem',
140
- },
141
- screens: {
142
- sm: '640px',
143
- md: '768px',
144
- lg: '1024px',
145
- xl: '1280px',
146
- '2xl': '1400px', // Intentionally narrower than the 2xl breakpoint (1536px) for better readability
147
- },
148
- },
149
-
150
- extend: {
151
- // Brand color palettes from tokens
152
- // Each color includes shades (50-950) and a foreground color for text on colored backgrounds
153
- colors: {
154
- // Neutrals
155
- gray: tokens.colors.gray,
156
-
157
- // Core brand colors (foreground property included from tokens)
158
- red: tokens.colors.red,
159
- teal: tokens.colors.teal,
160
- navy: tokens.colors.navy,
161
- plum: tokens.colors.plum,
162
- sage: tokens.colors.sage, // Note: sage does not include foreground (muted color)
163
-
164
- // Collection colors (foreground property included from tokens)
165
- stone: tokens.colors.stone,
166
- forest: tokens.colors.forest,
167
- lavender: tokens.colors.lavender,
168
- sky: tokens.colors.sky,
169
- deepTeal: tokens.colors.deepTeal,
170
- charcoal: tokens.colors.charcoal,
171
-
172
- // Semantic color utilities (using CSS variables for theming)
173
- border: 'hsl(var(--border))',
174
- input: 'hsl(var(--input))',
175
- ring: 'hsl(var(--ring))',
176
- outline: {
177
- DEFAULT: 'hsl(var(--outline))',
178
- hover: 'hsl(var(--outline-hover))',
179
- },
180
- toolbar: {
181
- DEFAULT: 'hsl(var(--toolbar))',
182
- foreground: 'hsl(var(--toolbar-foreground))',
183
- muted: 'hsl(var(--toolbar-muted))',
184
- border: 'hsl(var(--toolbar-border))',
185
- },
186
- background: {
187
- DEFAULT: 'hsl(var(--background))',
188
- hover: 'hsl(var(--background-hover))',
189
- },
190
- foreground: 'hsl(var(--foreground))',
191
-
192
- primary: {
193
- DEFAULT: 'hsl(var(--primary))',
194
- foreground: 'hsl(var(--primary-foreground))',
195
- hover: 'hsl(var(--primary-hover))',
196
- },
197
- secondary: {
198
- DEFAULT: 'hsl(var(--secondary))',
199
- foreground: 'hsl(var(--secondary-foreground))',
200
- hover: 'hsl(var(--secondary-hover))',
201
- border: 'hsl(var(--secondary-border))',
202
- soft: 'hsl(var(--secondary-soft))',
203
- },
204
- destructive: {
205
- DEFAULT: 'hsl(var(--destructive))',
206
- foreground: 'hsl(var(--destructive-foreground))',
207
- hover: 'hsl(var(--destructive-hover))',
208
- },
209
- muted: {
210
- DEFAULT: 'hsl(var(--muted))',
211
- foreground: 'hsl(var(--muted-foreground))',
212
- hover: 'hsl(var(--muted-hover))',
213
- },
214
- accent: {
215
- DEFAULT: 'hsl(var(--accent))',
216
- foreground: 'hsl(var(--accent-foreground))',
217
- hover: 'hsl(var(--accent-hover))',
218
- },
219
- popover: {
220
- DEFAULT: 'hsl(var(--popover))',
221
- foreground: 'hsl(var(--popover-foreground))',
222
- },
223
- card: {
224
- DEFAULT: 'hsl(var(--card))',
225
- foreground: 'hsl(var(--card-foreground))',
226
- },
227
-
228
- // Status colors (for alerts, notifications, feedback)
229
- success: {
230
- DEFAULT: 'hsl(var(--success))',
231
- foreground: 'hsl(var(--success-foreground))',
232
- },
233
- warning: {
234
- DEFAULT: 'hsl(var(--warning))',
235
- foreground: 'hsl(var(--warning-foreground))',
236
- },
237
- info: {
238
- DEFAULT: 'hsl(var(--info))',
239
- foreground: 'hsl(var(--info-foreground))',
240
- },
241
-
242
- // Layout colors
243
- 'content-bg': 'hsl(var(--content-bg))',
244
- 'surface-border': 'hsl(var(--surface-border))',
245
-
246
- // Sidebar colors
247
- sidebar: {
248
- DEFAULT: 'hsl(var(--sidebar-background))',
249
- foreground: 'hsl(var(--sidebar-foreground))',
250
- primary: 'hsl(var(--sidebar-primary))',
251
- 'primary-foreground': 'hsl(var(--sidebar-primary-foreground))',
252
- accent: 'hsl(var(--sidebar-accent))',
253
- 'accent-foreground': 'hsl(var(--sidebar-accent-foreground))',
254
- 'accent-hover': 'hsl(var(--sidebar-accent-hover))',
255
- border: 'hsl(var(--sidebar-border))',
256
- ring: 'hsl(var(--sidebar-ring))',
257
- },
258
-
259
- // Chart colors
260
- chart: {
261
- 1: 'hsl(var(--chart-1))',
262
- 2: 'hsl(var(--chart-2))',
263
- 3: 'hsl(var(--chart-3))',
264
- 4: 'hsl(var(--chart-4))',
265
- 5: 'hsl(var(--chart-5))',
266
- },
267
-
268
- // Brand colors (direct hex for exact matching)
269
- brand: {
270
- 'red-logo': 'var(--color-red-logo)',
271
- 'red-primary': 'var(--color-red-primary)',
272
- 'grey-1': 'var(--color-grey-1)',
273
- 'grey-2': 'var(--color-grey-2)',
274
- 'core-1': 'var(--color-core-1)',
275
- 'core-2': 'var(--color-core-2)',
276
- 'core-3': 'var(--color-core-3)',
277
- 'core-4': 'var(--color-core-4)',
278
- 'core-4-tint': 'var(--color-core-4-tint)',
279
- 'collection-1': 'var(--color-collection-1)',
280
- 'collection-2': 'var(--color-collection-2)',
281
- 'collection-3': 'var(--color-collection-3)',
282
- 'collection-4': 'var(--color-collection-4)',
283
- 'collection-5': 'var(--color-collection-5)',
284
- 'collection-6': 'var(--color-collection-6)',
285
- },
286
- },
287
-
288
- spacing: tokens.spacing,
289
-
290
- fontFamily: tokens.fontFamily,
291
-
292
- fontSize: {
293
- ...tokens.fontSize,
294
- ...headingScale,
295
- },
296
-
297
- fontWeight: tokens.fontWeight,
298
-
299
- // Border radius uses token values directly for consistency
300
- // The --radius CSS variable (0.5rem) is available for components that need dynamic theming
301
- borderRadius: tokens.borderRadius,
302
-
303
- boxShadow: tokens.boxShadow,
304
-
305
- zIndex: tokens.zIndex,
306
-
307
- aspectRatio: tokens.aspectRatio,
308
-
309
- screens: tokens.breakpoints,
310
-
311
- transitionDuration: tokens.transition.duration,
312
-
313
- transitionTimingFunction: tokens.transition.timing,
314
-
315
- keyframes: {
316
- // Accordion animations (Radix/Bits UI)
317
- 'accordion-down': {
318
- from: { height: '0' },
319
- to: { height: 'var(--radix-accordion-content-height)' },
320
- },
321
- 'accordion-up': {
322
- from: { height: 'var(--radix-accordion-content-height)' },
323
- to: { height: '0' },
324
- },
325
- // Collapsible animations
326
- 'collapsible-down': {
327
- from: { height: '0' },
328
- to: { height: 'var(--bits-collapsible-content-height)' },
329
- },
330
- 'collapsible-up': {
331
- from: { height: 'var(--bits-collapsible-content-height)' },
332
- to: { height: '0' },
333
- },
334
- // Fade animations
335
- 'fade-in': {
336
- from: { opacity: '0' },
337
- to: { opacity: '1' },
338
- },
339
- 'fade-out': {
340
- from: { opacity: '1' },
341
- to: { opacity: '0' },
342
- },
343
- // Slide animations
344
- 'slide-up': {
345
- from: { opacity: '0', transform: 'translateY(10px)' },
346
- to: { opacity: '1', transform: 'translateY(0)' },
347
- },
348
- 'slide-down': {
349
- from: { opacity: '0', transform: 'translateY(-10px)' },
350
- to: { opacity: '1', transform: 'translateY(0)' },
351
- },
352
- 'slide-left': {
353
- from: { opacity: '0', transform: 'translateX(10px)' },
354
- to: { opacity: '1', transform: 'translateX(0)' },
355
- },
356
- 'slide-right': {
357
- from: { opacity: '0', transform: 'translateX(-10px)' },
358
- to: { opacity: '1', transform: 'translateX(0)' },
359
- },
360
- // Scale animations
361
- 'scale-in': {
362
- from: { opacity: '0', transform: 'scale(0.95)' },
363
- to: { opacity: '1', transform: 'scale(1)' },
364
- },
365
- 'scale-out': {
366
- from: { opacity: '1', transform: 'scale(1)' },
367
- to: { opacity: '0', transform: 'scale(0.95)' },
368
- },
369
- // Spinner
370
- 'spin-slow': {
371
- from: { transform: 'rotate(0deg)' },
372
- to: { transform: 'rotate(360deg)' },
373
- },
374
- // Pulse
375
- 'pulse-subtle': {
376
- '0%, 100%': { opacity: '1' },
377
- '50%': { opacity: '0.7' },
378
- },
379
- // Progress bar indeterminate
380
- 'progress-indeterminate': {
381
- '0%': { transform: 'translateX(-100%)' },
382
- '100%': { transform: 'translateX(400%)' },
383
- },
384
- // Skeleton shimmer
385
- shimmer: {
386
- '0%': { backgroundPosition: '-200% 0' },
387
- '100%': { backgroundPosition: '200% 0' },
388
- },
389
- // Logo trace animation
390
- trace: {
391
- to: { 'stroke-dashoffset': '-14' },
392
- },
393
-
394
- // DataPanel slide animations (from edges)
395
- 'panel-slide-in-left': {
396
- from: { opacity: '0', transform: 'translateX(-100%)' },
397
- to: { opacity: '1', transform: 'translateX(0)' },
398
- },
399
- 'panel-slide-out-left': {
400
- from: { opacity: '1', transform: 'translateX(0)' },
401
- to: { opacity: '0', transform: 'translateX(-100%)' },
402
- },
403
- 'panel-slide-in-right': {
404
- from: { opacity: '0', transform: 'translateX(100%)' },
405
- to: { opacity: '1', transform: 'translateX(0)' },
406
- },
407
- 'panel-slide-out-right': {
408
- from: { opacity: '1', transform: 'translateX(0)' },
409
- to: { opacity: '0', transform: 'translateX(100%)' },
410
- },
411
- 'panel-slide-in-top': {
412
- from: { opacity: '0', transform: 'translateY(-100%)' },
413
- to: { opacity: '1', transform: 'translateY(0)' },
414
- },
415
- 'panel-slide-out-top': {
416
- from: { opacity: '1', transform: 'translateY(0)' },
417
- to: { opacity: '0', transform: 'translateY(-100%)' },
418
- },
419
- 'panel-slide-in-bottom': {
420
- from: { opacity: '0', transform: 'translateY(100%)' },
421
- to: { opacity: '1', transform: 'translateY(0)' },
422
- },
423
- 'panel-slide-out-bottom': {
424
- from: { opacity: '1', transform: 'translateY(0)' },
425
- to: { opacity: '0', transform: 'translateY(100%)' },
426
- },
427
- // DataPanel detach/attach animations
428
- 'panel-detach': {
429
- from: { opacity: '0', transform: 'scale(0.95)' },
430
- to: { opacity: '1', transform: 'scale(1)' },
431
- },
432
- 'panel-attach': {
433
- from: { opacity: '1', transform: 'scale(1)' },
434
- to: { opacity: '0', transform: 'scale(0.95)' },
435
- },
436
- // DataPanel collapse/expand (for content area)
437
- 'panel-collapse': {
438
- from: { height: 'var(--panel-content-height)', opacity: '1' },
439
- to: { height: '0', opacity: '0' },
440
- },
441
- 'panel-expand': {
442
- from: { height: '0', opacity: '0' },
443
- to: { height: 'var(--panel-content-height)', opacity: '1' },
444
- },
445
- },
446
-
447
- animation: {
448
- // Use token durations for single source of truth
449
- 'accordion-down': `accordion-down ${tokens.animation.duration.base} ease-out`,
450
- 'accordion-up': `accordion-up ${tokens.animation.duration.base} ease-out`,
451
- 'collapsible-down': `collapsible-down ${tokens.animation.duration.base} ease-out`,
452
- 'collapsible-up': `collapsible-up ${tokens.animation.duration.base} ease-out`,
453
- 'fade-in': `fade-in ${tokens.animation.duration.base} ease-out`,
454
- 'fade-out': `fade-out ${tokens.animation.duration.base} ease-out`,
455
- 'slide-up': `slide-up ${tokens.animation.duration.base} ease-out`,
456
- 'slide-down': `slide-down ${tokens.animation.duration.base} ease-out`,
457
- 'slide-left': `slide-left ${tokens.animation.duration.base} ease-out`,
458
- 'slide-right': `slide-right ${tokens.animation.duration.base} ease-out`,
459
- 'scale-in': `scale-in ${tokens.animation.duration.base} ease-out`,
460
- 'scale-out': `scale-out ${tokens.animation.duration.base} ease-out`,
461
- // Looping animations take literal durations: the 500ms `slower` token made
462
- // spin-slow twice as fast as Tailwind's 1s `spin` and the shimmer 4x too fast.
463
- 'spin-slow': 'spin-slow 2s linear infinite',
464
- 'pulse-subtle': `pulse-subtle ${tokens.transition.duration.slower} cubic-bezier(0.4, 0, 0.6, 1) infinite`,
465
- 'progress-indeterminate': 'progress-indeterminate 1.5s ease-in-out infinite',
466
- shimmer: 'shimmer 2s linear infinite',
467
- trace: `trace ${tokens.transition.duration.slower} linear infinite`,
468
-
469
- // DataPanel animations
470
- 'panel-slide-in-left': `panel-slide-in-left ${tokens.animation.duration.base} ease-out`,
471
- 'panel-slide-out-left': `panel-slide-out-left ${tokens.animation.duration.base} ease-out`,
472
- 'panel-slide-in-right': `panel-slide-in-right ${tokens.animation.duration.base} ease-out`,
473
- 'panel-slide-out-right': `panel-slide-out-right ${tokens.animation.duration.base} ease-out`,
474
- 'panel-slide-in-top': `panel-slide-in-top ${tokens.animation.duration.base} ease-out`,
475
- 'panel-slide-out-top': `panel-slide-out-top ${tokens.animation.duration.base} ease-out`,
476
- 'panel-slide-in-bottom': `panel-slide-in-bottom ${tokens.animation.duration.base} ease-out`,
477
- 'panel-slide-out-bottom': `panel-slide-out-bottom ${tokens.animation.duration.base} ease-out`,
478
- 'panel-detach': `panel-detach ${tokens.animation.duration.base} ease-out`,
479
- 'panel-attach': `panel-attach ${tokens.animation.duration.base} ease-out`,
480
- 'panel-collapse': `panel-collapse ${tokens.animation.duration.base} ease-out`,
481
- 'panel-expand': `panel-expand ${tokens.animation.duration.base} ease-out`,
482
- },
483
- },
484
- },
55
+ theme,
485
56
  plugins: [headingBase, responsiveBase, tapTarget],
486
57
  };
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@classic-homes/theme-tailwind-preset",
3
- "version": "0.9.0",
3
+ "version": "0.12.0",
4
4
  "description": "Tailwind CSS preset for the Classic theme system",
5
5
  "main": "index.js",
6
6
  "sideEffects": false,
7
7
  "files": [
8
- "index.js"
8
+ "index.js",
9
+ "theme.js"
9
10
  ],
10
11
  "scripts": {
11
12
  "build": "echo 'No build needed for tailwind-preset'",
package/theme.js ADDED
@@ -0,0 +1,515 @@
1
+ /**
2
+ * The preset as plain data: theme, dark-mode strategy, base styles and
3
+ * utilities, with no Tailwind plugin API.
4
+ *
5
+ * Read by the Tailwind 3 preset (`index.js`) and by the generator of the
6
+ * Tailwind 4 stylesheet in `@classic-homes/theme-styles`
7
+ * (`packages/styles/scripts/build-tailwind-v4.mjs`), so the two cannot drift.
8
+ * Change the theme here, never in either output.
9
+ */
10
+
11
+ const tokens = require('@classic-homes/theme-tokens');
12
+
13
+ /** Dark mode: a `.dark` class on an ancestor (usually <html>). */
14
+ const darkMode = ['class'];
15
+
16
+ // Heading sizes for the typography scale (mirrors theme-styles base.css).
17
+ // h1 pairs with `font-serif italic` (Spectral 500); h2-h6 are Figtree 600.
18
+ // Exposed as `text-h1`..`text-h6` and emitted on the bare elements by
19
+ // `headingBase` below, so the two never drift.
20
+ const headingScale = {
21
+ // 2.75rem leading: a 2rem line on 40px type made wrapped titles overlap
22
+ h1: ['2.5rem', { lineHeight: '2.75rem', fontWeight: '500' }], // 40px
23
+ h2: ['1.75rem', { lineHeight: '2.25rem', fontWeight: '600' }], // 28px
24
+ h3: ['1.5rem', { lineHeight: '2rem', fontWeight: '600' }], // 24px
25
+ h4: ['1.25rem', { lineHeight: '1.75rem', fontWeight: '600' }], // 20px
26
+ h5: ['1.125rem', { lineHeight: '1.5rem', fontWeight: '600' }], // 18px
27
+ h6: ['1rem', { lineHeight: '1.5rem', fontWeight: '600' }], // 16px
28
+ };
29
+
30
+ /**
31
+ * Base heading typography, emitted through `addBase`.
32
+ *
33
+ * theme-styles/base.css sets the same scale inside `@layer classic-theme.base`,
34
+ * but any consumer that runs `@tailwind base` also gets Tailwind preflight's
35
+ * `h1..h6 { font-size: inherit; font-weight: inherit }`. Preflight is
36
+ * unlayered, so it outranks the theme's layered rule by cascade semantics -
37
+ * and @csstools/postcss-cascade-layers (postcss-config) keeps that ordering
38
+ * with specificity boosts. Bare headings therefore rendered at body size with
39
+ * the inherited weight in every Tailwind app, including our own example apps.
40
+ *
41
+ * `addBase` output lands inside Tailwind's base output *after* preflight, so
42
+ * it wins on source order. Sizes and weights come from the `fontSize.h1..h6`
43
+ * scale below, so the utilities (`text-h1`) and the bare elements agree.
44
+ * Color and margins are left to base.css/preflight on purpose: this only
45
+ * restores what preflight resets.
46
+ */
47
+ const stack = (fonts) => fonts.join(', ');
48
+ const headingStyles = Object.fromEntries(
49
+ Object.entries(headingScale).map(([level, [fontSize, { lineHeight, fontWeight }]]) => [
50
+ level,
51
+ level === 'h1'
52
+ ? {
53
+ fontFamily: `var(--font-serif, ${stack(tokens.fontFamily.serif)})`,
54
+ fontStyle: 'italic',
55
+ fontSize,
56
+ lineHeight,
57
+ fontWeight,
58
+ }
59
+ : {
60
+ fontFamily: `var(--font-sans, ${stack(tokens.fontFamily.sans)})`,
61
+ fontSize,
62
+ lineHeight,
63
+ fontWeight,
64
+ },
65
+ ])
66
+ );
67
+
68
+ /**
69
+ * Base resets preflight leaves out that break narrow layouts and touch:
70
+ * - fieldset defaults to `min-inline-size: min-content`, so a fieldset holding a wide row
71
+ * (columns editor, radio grid) refuses to shrink and pushes the page sideways on phones.
72
+ * - <summary> toggles get vertical padding on coarse pointers.
73
+ */
74
+ const responsiveBaseStyles = {
75
+ fieldset: { minWidth: '0' },
76
+ // <details> toggles are usually one text line (16–20px); on touch give them a
77
+ // 36px+ row. Padding utilities on the summary still win (utilities layer).
78
+ '@media (pointer: coarse)': { summary: { paddingTop: '0.5rem', paddingBottom: '0.5rem' } },
79
+ };
80
+
81
+ /**
82
+ * `tap-target`: grows an element's hit area to at least 44×44px on coarse pointers
83
+ * (touch) with a centred, invisible ::after — layout and visuals don't change.
84
+ * For small icon buttons, chip removers, inline text buttons and sort headers.
85
+ *
86
+ * - Sets `position: relative` unless the element is already `absolute`/`fixed`/`sticky`.
87
+ * - Uses `::after`: don't combine with other `after:` utilities on the same element.
88
+ * - Neighbouring targets closer than 44px will overlap; the later one in the DOM wins.
89
+ */
90
+ const tapTargetUtilities = {
91
+ '.tap-target:not(.absolute):not(.fixed):not(.sticky)': { position: 'relative' },
92
+ '@media (pointer: coarse)': {
93
+ '.tap-target::after': {
94
+ content: "''",
95
+ position: 'absolute',
96
+ top: '50%',
97
+ left: '50%',
98
+ width: 'max(100%, 44px)',
99
+ height: 'max(100%, 44px)',
100
+ transform: 'translate(-50%, -50%)',
101
+ },
102
+ },
103
+ };
104
+
105
+ const theme = {
106
+ // Container with brand max-widths
107
+ container: {
108
+ center: true,
109
+ padding: {
110
+ DEFAULT: '1rem',
111
+ sm: '2rem',
112
+ lg: '4rem',
113
+ xl: '5rem',
114
+ '2xl': '6rem',
115
+ },
116
+ screens: {
117
+ sm: '640px',
118
+ md: '768px',
119
+ lg: '1024px',
120
+ xl: '1280px',
121
+ '2xl': '1400px', // Intentionally narrower than the 2xl breakpoint (1536px) for better readability
122
+ },
123
+ },
124
+
125
+ extend: {
126
+ // Brand color palettes from tokens
127
+ // Each color includes shades (50-950) and a foreground color for text on colored backgrounds
128
+ colors: {
129
+ // Neutrals
130
+ gray: tokens.colors.gray,
131
+
132
+ // Core brand colors (foreground property included from tokens)
133
+ red: tokens.colors.red,
134
+ teal: tokens.colors.teal,
135
+ navy: tokens.colors.navy,
136
+ plum: tokens.colors.plum,
137
+ sage: tokens.colors.sage, // Note: sage does not include foreground (muted color)
138
+
139
+ // Collection colors (foreground property included from tokens)
140
+ stone: tokens.colors.stone,
141
+ forest: tokens.colors.forest,
142
+ lavender: tokens.colors.lavender,
143
+ sky: tokens.colors.sky,
144
+ deepTeal: tokens.colors.deepTeal,
145
+ charcoal: tokens.colors.charcoal,
146
+
147
+ // Semantic color utilities (using CSS variables for theming)
148
+ border: 'hsl(var(--border))',
149
+ input: 'hsl(var(--input))',
150
+ ring: 'hsl(var(--ring))',
151
+ outline: {
152
+ DEFAULT: 'hsl(var(--outline))',
153
+ hover: 'hsl(var(--outline-hover))',
154
+ },
155
+ toolbar: {
156
+ DEFAULT: 'hsl(var(--toolbar))',
157
+ foreground: 'hsl(var(--toolbar-foreground))',
158
+ muted: 'hsl(var(--toolbar-muted))',
159
+ border: 'hsl(var(--toolbar-border))',
160
+ },
161
+ background: {
162
+ DEFAULT: 'hsl(var(--background))',
163
+ hover: 'hsl(var(--background-hover))',
164
+ },
165
+ foreground: 'hsl(var(--foreground))',
166
+
167
+ primary: {
168
+ DEFAULT: 'hsl(var(--primary))',
169
+ foreground: 'hsl(var(--primary-foreground))',
170
+ hover: 'hsl(var(--primary-hover))',
171
+ active: 'hsl(var(--primary-active))',
172
+ },
173
+ promo: {
174
+ DEFAULT: 'hsl(var(--promo))',
175
+ foreground: 'hsl(var(--promo-foreground))',
176
+ hover: 'hsl(var(--promo-hover))',
177
+ },
178
+ live: {
179
+ DEFAULT: 'hsl(var(--live))',
180
+ foreground: 'hsl(var(--live-foreground))',
181
+ },
182
+ nav: {
183
+ active: 'hsl(var(--nav-active))',
184
+ 'active-foreground': 'hsl(var(--nav-active-foreground))',
185
+ hover: 'hsl(var(--nav-hover))',
186
+ },
187
+ row: {
188
+ zebra: 'hsl(var(--row-zebra))',
189
+ hover: 'hsl(var(--row-hover))',
190
+ 'hover-zebra': 'hsl(var(--row-hover-zebra))',
191
+ selected: 'hsl(var(--row-selected))',
192
+ },
193
+ link: 'hsl(var(--link))',
194
+ secondary: {
195
+ DEFAULT: 'hsl(var(--secondary))',
196
+ foreground: 'hsl(var(--secondary-foreground))',
197
+ hover: 'hsl(var(--secondary-hover))',
198
+ border: 'hsl(var(--secondary-border))',
199
+ soft: 'hsl(var(--secondary-soft))',
200
+ },
201
+ destructive: {
202
+ DEFAULT: 'hsl(var(--destructive))',
203
+ foreground: 'hsl(var(--destructive-foreground))',
204
+ hover: 'hsl(var(--destructive-hover))',
205
+ },
206
+ muted: {
207
+ DEFAULT: 'hsl(var(--muted))',
208
+ foreground: 'hsl(var(--muted-foreground))',
209
+ hover: 'hsl(var(--muted-hover))',
210
+ },
211
+ accent: {
212
+ DEFAULT: 'hsl(var(--accent))',
213
+ foreground: 'hsl(var(--accent-foreground))',
214
+ hover: 'hsl(var(--accent-hover))',
215
+ },
216
+ popover: {
217
+ DEFAULT: 'hsl(var(--popover))',
218
+ foreground: 'hsl(var(--popover-foreground))',
219
+ },
220
+ card: {
221
+ DEFAULT: 'hsl(var(--card))',
222
+ foreground: 'hsl(var(--card-foreground))',
223
+ },
224
+
225
+ // Status colors (for alerts, notifications, feedback)
226
+ success: {
227
+ DEFAULT: 'hsl(var(--success))',
228
+ foreground: 'hsl(var(--success-foreground))',
229
+ },
230
+ warning: {
231
+ DEFAULT: 'hsl(var(--warning))',
232
+ foreground: 'hsl(var(--warning-foreground))',
233
+ },
234
+ info: {
235
+ DEFAULT: 'hsl(var(--info))',
236
+ foreground: 'hsl(var(--info-foreground))',
237
+ },
238
+
239
+ // Layout colors
240
+ 'content-bg': 'hsl(var(--content-bg))',
241
+ 'surface-border': 'hsl(var(--surface-border))',
242
+
243
+ // Sidebar colors
244
+ sidebar: {
245
+ DEFAULT: 'hsl(var(--sidebar-background))',
246
+ foreground: 'hsl(var(--sidebar-foreground))',
247
+ primary: 'hsl(var(--sidebar-primary))',
248
+ 'primary-foreground': 'hsl(var(--sidebar-primary-foreground))',
249
+ accent: 'hsl(var(--sidebar-accent))',
250
+ 'accent-foreground': 'hsl(var(--sidebar-accent-foreground))',
251
+ 'accent-hover': 'hsl(var(--sidebar-accent-hover))',
252
+ border: 'hsl(var(--sidebar-border))',
253
+ ring: 'hsl(var(--sidebar-ring))',
254
+ },
255
+
256
+ // Chart colors
257
+ chart: {
258
+ 1: 'hsl(var(--chart-1))',
259
+ 2: 'hsl(var(--chart-2))',
260
+ 3: 'hsl(var(--chart-3))',
261
+ 4: 'hsl(var(--chart-4))',
262
+ 5: 'hsl(var(--chart-5))',
263
+ },
264
+
265
+ // Digital Color Reference v2.5 palette (hex, by name): bg-ch-paper,
266
+ // border-ch-linen, bg-ch-collection-preamble …
267
+ ch: {
268
+ ...Object.fromEntries(
269
+ Object.entries(tokens.ch)
270
+ .filter(([, value]) => typeof value === 'string')
271
+ .map(([key, value]) => [
272
+ key
273
+ .replace(/([a-z])([A-Z0-9])/g, '$1-$2')
274
+ .replace(/([0-9])([A-Za-z])/g, '$1-$2')
275
+ .toLowerCase(),
276
+ value,
277
+ ])
278
+ ),
279
+ collection: {
280
+ preamble: tokens.ch.collection.preamble,
281
+ cadence: tokens.ch.collection.cadence,
282
+ portrait: tokens.ch.collection.portrait,
283
+ midtown: tokens.ch.collection.midtown,
284
+ 'four-square': tokens.ch.collection.fourSquare,
285
+ classic: tokens.ch.collection.classic,
286
+ },
287
+ reserved: tokens.ch.reserved,
288
+ },
289
+
290
+ // Brand colors (direct hex for exact matching)
291
+ brand: {
292
+ 'red-logo': 'var(--color-red-logo)',
293
+ 'red-primary': 'var(--color-red-primary)',
294
+ 'grey-1': 'var(--color-grey-1)',
295
+ 'grey-2': 'var(--color-grey-2)',
296
+ 'core-1': 'var(--color-core-1)',
297
+ 'core-2': 'var(--color-core-2)',
298
+ 'core-3': 'var(--color-core-3)',
299
+ 'core-4': 'var(--color-core-4)',
300
+ 'core-4-tint': 'var(--color-core-4-tint)',
301
+ 'collection-1': 'var(--color-collection-1)',
302
+ 'collection-2': 'var(--color-collection-2)',
303
+ 'collection-3': 'var(--color-collection-3)',
304
+ 'collection-4': 'var(--color-collection-4)',
305
+ 'collection-5': 'var(--color-collection-5)',
306
+ 'collection-6': 'var(--color-collection-6)',
307
+ },
308
+ },
309
+
310
+ spacing: tokens.spacing,
311
+
312
+ fontFamily: tokens.fontFamily,
313
+
314
+ fontSize: {
315
+ ...tokens.fontSize,
316
+ ...headingScale,
317
+ },
318
+
319
+ fontWeight: tokens.fontWeight,
320
+
321
+ // Border radius uses token values directly for consistency
322
+ // The --radius CSS variable (0.5rem) is available for components that need dynamic theming
323
+ borderRadius: tokens.borderRadius,
324
+
325
+ boxShadow: tokens.boxShadow,
326
+
327
+ zIndex: tokens.zIndex,
328
+
329
+ aspectRatio: tokens.aspectRatio,
330
+
331
+ screens: tokens.breakpoints,
332
+
333
+ transitionDuration: tokens.transition.duration,
334
+
335
+ transitionTimingFunction: tokens.transition.timing,
336
+
337
+ keyframes: {
338
+ // Accordion animations (Radix/Bits UI)
339
+ 'accordion-down': {
340
+ from: { height: '0' },
341
+ to: { height: 'var(--radix-accordion-content-height)' },
342
+ },
343
+ 'accordion-up': {
344
+ from: { height: 'var(--radix-accordion-content-height)' },
345
+ to: { height: '0' },
346
+ },
347
+ // Collapsible animations
348
+ 'collapsible-down': {
349
+ from: { height: '0' },
350
+ to: { height: 'var(--bits-collapsible-content-height)' },
351
+ },
352
+ 'collapsible-up': {
353
+ from: { height: 'var(--bits-collapsible-content-height)' },
354
+ to: { height: '0' },
355
+ },
356
+ // Fade animations
357
+ 'fade-in': {
358
+ from: { opacity: '0' },
359
+ to: { opacity: '1' },
360
+ },
361
+ 'fade-out': {
362
+ from: { opacity: '1' },
363
+ to: { opacity: '0' },
364
+ },
365
+ // Slide animations
366
+ 'slide-up': {
367
+ from: { opacity: '0', transform: 'translateY(10px)' },
368
+ to: { opacity: '1', transform: 'translateY(0)' },
369
+ },
370
+ 'slide-down': {
371
+ from: { opacity: '0', transform: 'translateY(-10px)' },
372
+ to: { opacity: '1', transform: 'translateY(0)' },
373
+ },
374
+ 'slide-left': {
375
+ from: { opacity: '0', transform: 'translateX(10px)' },
376
+ to: { opacity: '1', transform: 'translateX(0)' },
377
+ },
378
+ 'slide-right': {
379
+ from: { opacity: '0', transform: 'translateX(-10px)' },
380
+ to: { opacity: '1', transform: 'translateX(0)' },
381
+ },
382
+ // Scale animations
383
+ 'scale-in': {
384
+ from: { opacity: '0', transform: 'scale(0.95)' },
385
+ to: { opacity: '1', transform: 'scale(1)' },
386
+ },
387
+ 'scale-out': {
388
+ from: { opacity: '1', transform: 'scale(1)' },
389
+ to: { opacity: '0', transform: 'scale(0.95)' },
390
+ },
391
+ // Spinner
392
+ 'spin-slow': {
393
+ from: { transform: 'rotate(0deg)' },
394
+ to: { transform: 'rotate(360deg)' },
395
+ },
396
+ // Pulse
397
+ 'pulse-subtle': {
398
+ '0%, 100%': { opacity: '1' },
399
+ '50%': { opacity: '0.7' },
400
+ },
401
+ // Progress bar indeterminate
402
+ 'progress-indeterminate': {
403
+ '0%': { transform: 'translateX(-100%)' },
404
+ '100%': { transform: 'translateX(400%)' },
405
+ },
406
+ // Skeleton shimmer
407
+ shimmer: {
408
+ '0%': { backgroundPosition: '-200% 0' },
409
+ '100%': { backgroundPosition: '200% 0' },
410
+ },
411
+ // Logo trace animation
412
+ trace: {
413
+ to: { 'stroke-dashoffset': '-14' },
414
+ },
415
+
416
+ // DataPanel slide animations (from edges)
417
+ 'panel-slide-in-left': {
418
+ from: { opacity: '0', transform: 'translateX(-100%)' },
419
+ to: { opacity: '1', transform: 'translateX(0)' },
420
+ },
421
+ 'panel-slide-out-left': {
422
+ from: { opacity: '1', transform: 'translateX(0)' },
423
+ to: { opacity: '0', transform: 'translateX(-100%)' },
424
+ },
425
+ 'panel-slide-in-right': {
426
+ from: { opacity: '0', transform: 'translateX(100%)' },
427
+ to: { opacity: '1', transform: 'translateX(0)' },
428
+ },
429
+ 'panel-slide-out-right': {
430
+ from: { opacity: '1', transform: 'translateX(0)' },
431
+ to: { opacity: '0', transform: 'translateX(100%)' },
432
+ },
433
+ 'panel-slide-in-top': {
434
+ from: { opacity: '0', transform: 'translateY(-100%)' },
435
+ to: { opacity: '1', transform: 'translateY(0)' },
436
+ },
437
+ 'panel-slide-out-top': {
438
+ from: { opacity: '1', transform: 'translateY(0)' },
439
+ to: { opacity: '0', transform: 'translateY(-100%)' },
440
+ },
441
+ 'panel-slide-in-bottom': {
442
+ from: { opacity: '0', transform: 'translateY(100%)' },
443
+ to: { opacity: '1', transform: 'translateY(0)' },
444
+ },
445
+ 'panel-slide-out-bottom': {
446
+ from: { opacity: '1', transform: 'translateY(0)' },
447
+ to: { opacity: '0', transform: 'translateY(100%)' },
448
+ },
449
+ // DataPanel detach/attach animations
450
+ 'panel-detach': {
451
+ from: { opacity: '0', transform: 'scale(0.95)' },
452
+ to: { opacity: '1', transform: 'scale(1)' },
453
+ },
454
+ 'panel-attach': {
455
+ from: { opacity: '1', transform: 'scale(1)' },
456
+ to: { opacity: '0', transform: 'scale(0.95)' },
457
+ },
458
+ // DataPanel collapse/expand (for content area)
459
+ 'panel-collapse': {
460
+ from: { height: 'var(--panel-content-height)', opacity: '1' },
461
+ to: { height: '0', opacity: '0' },
462
+ },
463
+ 'panel-expand': {
464
+ from: { height: '0', opacity: '0' },
465
+ to: { height: 'var(--panel-content-height)', opacity: '1' },
466
+ },
467
+ },
468
+
469
+ animation: {
470
+ // Use token durations for single source of truth
471
+ 'accordion-down': `accordion-down ${tokens.animation.duration.base} ease-out`,
472
+ 'accordion-up': `accordion-up ${tokens.animation.duration.base} ease-out`,
473
+ 'collapsible-down': `collapsible-down ${tokens.animation.duration.base} ease-out`,
474
+ 'collapsible-up': `collapsible-up ${tokens.animation.duration.base} ease-out`,
475
+ 'fade-in': `fade-in ${tokens.animation.duration.base} ease-out`,
476
+ 'fade-out': `fade-out ${tokens.animation.duration.base} ease-out`,
477
+ 'slide-up': `slide-up ${tokens.animation.duration.base} ease-out`,
478
+ 'slide-down': `slide-down ${tokens.animation.duration.base} ease-out`,
479
+ 'slide-left': `slide-left ${tokens.animation.duration.base} ease-out`,
480
+ 'slide-right': `slide-right ${tokens.animation.duration.base} ease-out`,
481
+ 'scale-in': `scale-in ${tokens.animation.duration.base} ease-out`,
482
+ 'scale-out': `scale-out ${tokens.animation.duration.base} ease-out`,
483
+ // Looping animations take literal durations: the 500ms `slower` token made
484
+ // spin-slow twice as fast as Tailwind's 1s `spin` and the shimmer 4x too fast.
485
+ 'spin-slow': 'spin-slow 2s linear infinite',
486
+ 'pulse-subtle': `pulse-subtle ${tokens.transition.duration.slower} cubic-bezier(0.4, 0, 0.6, 1) infinite`,
487
+ 'progress-indeterminate': 'progress-indeterminate 1.5s ease-in-out infinite',
488
+ shimmer: 'shimmer 2s linear infinite',
489
+ trace: `trace ${tokens.transition.duration.slower} linear infinite`,
490
+
491
+ // DataPanel animations
492
+ 'panel-slide-in-left': `panel-slide-in-left ${tokens.animation.duration.base} ease-out`,
493
+ 'panel-slide-out-left': `panel-slide-out-left ${tokens.animation.duration.base} ease-out`,
494
+ 'panel-slide-in-right': `panel-slide-in-right ${tokens.animation.duration.base} ease-out`,
495
+ 'panel-slide-out-right': `panel-slide-out-right ${tokens.animation.duration.base} ease-out`,
496
+ 'panel-slide-in-top': `panel-slide-in-top ${tokens.animation.duration.base} ease-out`,
497
+ 'panel-slide-out-top': `panel-slide-out-top ${tokens.animation.duration.base} ease-out`,
498
+ 'panel-slide-in-bottom': `panel-slide-in-bottom ${tokens.animation.duration.base} ease-out`,
499
+ 'panel-slide-out-bottom': `panel-slide-out-bottom ${tokens.animation.duration.base} ease-out`,
500
+ 'panel-detach': `panel-detach ${tokens.animation.duration.base} ease-out`,
501
+ 'panel-attach': `panel-attach ${tokens.animation.duration.base} ease-out`,
502
+ 'panel-collapse': `panel-collapse ${tokens.animation.duration.base} ease-out`,
503
+ 'panel-expand': `panel-expand ${tokens.animation.duration.base} ease-out`,
504
+ },
505
+ },
506
+ };
507
+
508
+ module.exports = {
509
+ darkMode,
510
+ headingScale,
511
+ headingStyles,
512
+ responsiveBaseStyles,
513
+ tapTargetUtilities,
514
+ theme,
515
+ };