@poveste/plugin-tailwind 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,721 @@
1
+ import fs from 'node:fs';
2
+ import path from 'pathe';
3
+ import { getInjectedImport } from 'poveste';
4
+ /**
5
+ * The first of `fileNames` that exists and satisfies `accept`, searching `cwd`
6
+ * and then upwards.
7
+ *
8
+ * `accept` is not a convenience: every name below is an ordinary one, so a
9
+ * near-miss in the same directory would otherwise shadow the real entrypoint
10
+ * sitting behind it in the list.
11
+ */
12
+ function findUp(cwd, fileNames, accept) {
13
+ let { root } = path.parse(cwd);
14
+ let dir = cwd;
15
+ // On Windows this is `C:` and needs the trailing slash to terminate.
16
+ if (root[1] === ':' && root[2] === undefined) {
17
+ root += '/';
18
+ }
19
+ while (dir !== root) {
20
+ for (const fileName of fileNames) {
21
+ const searchPath = path.join(dir, fileName);
22
+ if (fs.existsSync(searchPath) && accept(searchPath)) {
23
+ return searchPath;
24
+ }
25
+ }
26
+ dir = path.dirname(dir);
27
+ }
28
+ return null;
29
+ }
30
+ const CSS_ENTRY_CANDIDATES = [
31
+ 'src/style.css',
32
+ 'src/styles.css',
33
+ 'src/main.css',
34
+ 'src/index.css',
35
+ 'src/app.css',
36
+ 'src/assets/main.css',
37
+ 'src/assets/style.css',
38
+ 'src/assets/css/main.css',
39
+ // Nuxt conventions
40
+ 'app/assets/css/main.css',
41
+ 'assets/css/main.css',
42
+ // Next.js conventions
43
+ 'styles/globals.css',
44
+ 'app/globals.css',
45
+ 'style.css',
46
+ 'styles.css',
47
+ ];
48
+ /**
49
+ * Whether a stylesheet is a Tailwind entrypoint, rather than merely a file with
50
+ * one of the names Tailwind entrypoints tend to have.
51
+ *
52
+ * Every name in `CSS_ENTRY_CANDIDATES` is an ordinary one — `src/app.css`,
53
+ * `styles.css` — so matching on the name alone hands the whole feature to
54
+ * projects that have never used Tailwind: a `Design System` group inserted into
55
+ * their tree, and a story rendering Tailwind's own defaults as if it were their
56
+ * design system.
57
+ *
58
+ * Both markers are Tailwind v4, which is what this plugin reads: the theme comes
59
+ * from CSS custom properties, so a v3 project using `@tailwind base` would be
60
+ * accepted here and then produce nothing.
61
+ */
62
+ export function isTailwindEntry(filePath) {
63
+ let source;
64
+ try {
65
+ source = fs.readFileSync(filePath, 'utf8');
66
+ }
67
+ catch {
68
+ return false;
69
+ }
70
+ // `@import 'tailwindcss'`, `"tailwindcss/theme"`, and the `layer(…)` and
71
+ // `source(…)` forms that follow the specifier. Deliberately not a bare
72
+ // `@import` test — the file that prompted this imports a font.
73
+ return /@import\s+["']tailwindcss(?:\/[^"']*)?["']/.test(source)
74
+ || /@theme\b/.test(source);
75
+ }
76
+ export function HstTailwind(options = {}) {
77
+ // An explicit `cssFile` is the caller saying so, and is taken at their word.
78
+ const tailwindCssFile = options.cssFile ?? findUp(process.cwd(), CSS_ENTRY_CANDIDATES, isTailwindEntry);
79
+ async function generate(api) {
80
+ try {
81
+ await api.fs.ensureDir(api.pluginTempDir);
82
+ await api.fs.emptyDir(api.pluginTempDir);
83
+ api.moduleLoader.clearCache();
84
+ await api.fs.writeFile(api.path.resolve(api.pluginTempDir, 'style.css'), css);
85
+ const theme = await loadTailwindTheme(api, tailwindCssFile);
86
+ const storyFile = api.path.resolve(api.pluginTempDir, 'Tailwind.story.js');
87
+ await api.fs.writeFile(storyFile, storyTemplate({ theme }));
88
+ api.addStoryFile(storyFile);
89
+ }
90
+ catch (e) {
91
+ api.error(e.stack ?? e.message);
92
+ }
93
+ }
94
+ return {
95
+ name: 'tailwind-tokens',
96
+ config(config) {
97
+ if (tailwindCssFile) {
98
+ // Add 'design-system' group
99
+ if (!config.tree) {
100
+ config.tree = {};
101
+ }
102
+ if (!config.tree.groups) {
103
+ config.tree.groups = [];
104
+ }
105
+ if (!config.tree.groups.some(g => g.id === 'design-system')) {
106
+ let index = 0;
107
+ // After 'top' group
108
+ const topIndex = config.tree.groups.findIndex(g => g.id === 'top');
109
+ if (topIndex > -1) {
110
+ index = topIndex + 1;
111
+ }
112
+ // Insert group
113
+ config.tree.groups.splice(index, 0, {
114
+ id: 'design-system',
115
+ title: 'Design System',
116
+ });
117
+ }
118
+ }
119
+ },
120
+ async onDev(api, onCleanup) {
121
+ if (tailwindCssFile) {
122
+ await generate(api);
123
+ const watcher = api.watcher.watch(tailwindCssFile)
124
+ .on('change', () => generate(api))
125
+ .on('add', () => generate(api));
126
+ onCleanup(() => {
127
+ watcher.close();
128
+ });
129
+ }
130
+ },
131
+ async onBuild(api) {
132
+ if (tailwindCssFile) {
133
+ await generate(api);
134
+ }
135
+ },
136
+ };
137
+ }
138
+ /**
139
+ * Tailwind v4 keeps its theme as flat CSS custom properties rather than a
140
+ * resolved JS config (`resolveConfig` is gone). Load the design system from the
141
+ * project's CSS entrypoint and reshape its variables into the grouped structure
142
+ * the story template renders.
143
+ */
144
+ /**
145
+ * Resolve a stylesheet referenced from CSS. A bare package specifier resolves
146
+ * to the JS entry, so its `style` field is used instead — that is how
147
+ * `@import 'tailwindcss'` reaches `tailwindcss/index.css`.
148
+ */
149
+ async function resolveStylesheet(api, id, importBase) {
150
+ const { createRequire } = await import('node:module');
151
+ const require = createRequire(`${importBase}/`);
152
+ if (id.startsWith('.')) {
153
+ return api.path.resolve(importBase, id);
154
+ }
155
+ if (id.endsWith('.css')) {
156
+ return require.resolve(id);
157
+ }
158
+ const packageJsonPath = require.resolve(`${id}/package.json`);
159
+ const packageJson = JSON.parse(await api.fs.readFile(packageJsonPath, 'utf8'));
160
+ return api.path.resolve(api.path.dirname(packageJsonPath), packageJson.style ?? 'index.css');
161
+ }
162
+ async function loadTailwindTheme(api, cssFile) {
163
+ const { __unstable__loadDesignSystem } = await import('tailwindcss');
164
+ const base = api.path.dirname(cssFile);
165
+ const designSystem = await __unstable__loadDesignSystem(await api.fs.readFile(cssFile, 'utf8'), {
166
+ base,
167
+ loadStylesheet: async (id, importBase) => {
168
+ const resolved = await resolveStylesheet(api, id, importBase);
169
+ return {
170
+ path: resolved,
171
+ base: api.path.dirname(resolved),
172
+ content: await api.fs.readFile(resolved, 'utf8'),
173
+ };
174
+ },
175
+ });
176
+ const vars = new Map([...designSystem.theme.entries()].map(([key, entry]) => [key, entry.value]));
177
+ /** All values in a `--namespace-*` group, keyed by their remainder. */
178
+ function group(namespace, exclude) {
179
+ const out = {};
180
+ const prefix = `${namespace}-`;
181
+ for (const [key, value] of vars) {
182
+ if (!key.startsWith(prefix))
183
+ continue;
184
+ if (exclude?.test(key))
185
+ continue;
186
+ out[key.slice(prefix.length)] = value;
187
+ }
188
+ return out;
189
+ }
190
+ /** Colours are rendered as shade sets: `red-500` -> `{ red: { 500: … } }`. */
191
+ function colors() {
192
+ const out = {};
193
+ for (const [key, value] of Object.entries(group('--color'))) {
194
+ const match = key.match(/^(.*)-(\d+)$/);
195
+ if (match) {
196
+ out[match[1]] ??= {};
197
+ out[match[1]][match[2]] = value;
198
+ }
199
+ else {
200
+ out[key] = value;
201
+ }
202
+ }
203
+ return out;
204
+ }
205
+ // v4 generates the spacing scale on demand from a single `--spacing` base,
206
+ // so the conventional steps are reconstructed here for display.
207
+ const SPACING_STEPS = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80, 96];
208
+ function spacing() {
209
+ const unit = vars.get('--spacing') ?? '0.25rem';
210
+ // Multiply out rather than emitting `calc(0.25rem * 4)`, so the story shows
211
+ // the resolved length the way the v3 resolved config did.
212
+ const [, rawAmount, cssUnit] = unit.trim().match(/^([\d.]+)([a-z%]*)$/i) ?? [];
213
+ const amount = Number(rawAmount);
214
+ const out = {};
215
+ for (const step of SPACING_STEPS) {
216
+ if (step === 0) {
217
+ out['0'] = '0px';
218
+ }
219
+ else {
220
+ out[String(step)] = Number.isFinite(amount)
221
+ ? `${Number((amount * step).toFixed(4))}${cssUnit}`
222
+ : `calc(${unit} * ${step})`;
223
+ }
224
+ }
225
+ return out;
226
+ }
227
+ // Fractions and keywords have no theme variables in v4 — they are static
228
+ // utilities — but they belong in the sizing scales the story lists.
229
+ const SIZING_EXTRAS = {
230
+ 'auto': 'auto',
231
+ 'full': '100%',
232
+ 'min': 'min-content',
233
+ 'max': 'max-content',
234
+ 'fit': 'fit-content',
235
+ 'px': '1px',
236
+ '1/2': '50%',
237
+ '1/3': '33.333333%',
238
+ '2/3': '66.666667%',
239
+ '1/4': '25%',
240
+ '3/4': '75%',
241
+ '1/5': '20%',
242
+ '2/5': '40%',
243
+ '3/5': '60%',
244
+ '4/5': '80%',
245
+ };
246
+ const palette = colors();
247
+ const scale = spacing();
248
+ return {
249
+ backgroundColor: palette,
250
+ textColor: palette,
251
+ borderColor: palette,
252
+ padding: scale,
253
+ margin: scale,
254
+ width: { ...scale, ...SIZING_EXTRAS, screen: '100vw' },
255
+ height: { ...scale, ...SIZING_EXTRAS, screen: '100vh' },
256
+ fontSize: group('--text', /--line-height$|--letter-spacing$|--font-weight$/),
257
+ fontWeight: group('--font-weight'),
258
+ fontFamily: group('--font', /^--font-weight-/),
259
+ letterSpacing: group('--tracking'),
260
+ lineHeight: group('--leading'),
261
+ dropShadow: group('--drop-shadow'),
262
+ borderRadius: group('--radius'),
263
+ // v4 has no border-width namespace; these are the built-in static utilities.
264
+ borderWidth: { DEFAULT: '1px', 0: '0px', 2: '2px', 4: '4px', 8: '8px' },
265
+ };
266
+ }
267
+ // No `import 'poveste-style'`: the story renders in a sandbox realm, where the
268
+ // app stylesheet is @scope'd away from story markup anyway — it only added
269
+ // ~100 KB of chrome CSS to every sandbox of every book using this plugin (#219).
270
+ // The swatches style themselves from the local stylesheet below.
271
+ function storyTemplate(tailwindConfig) {
272
+ return `
273
+ import './style.css'
274
+ import { createApp, h, markRaw, ref } from ${getInjectedImport('@poveste/vendors/vue')}
275
+ import {
276
+ HstColorShades,
277
+ HstTokenList,
278
+ HstTokenGrid,
279
+ HstText,
280
+ HstTextarea,
281
+ HstNumber,
282
+ } from ${getInjectedImport('@poveste/controls')}
283
+
284
+ const config = markRaw(${JSON.stringify(tailwindConfig, null, 2)})
285
+ const search = ref('')
286
+ const sampleText = ref('Cat sit like bread eat prawns daintily with a claw then lick paws clean wash down prawns with a lap of carnation milk then retire to the warmest spot on the couch to claw at the fabric before taking a catnap mrow cat cat moo moo lick ears lick paws')
287
+ const fontSize = ref(16)
288
+
289
+ function mountApp ({ el, state, onUnmount }, render) {
290
+ Object.assign(state, {
291
+ search,
292
+ sampleText,
293
+ fontSize,
294
+ })
295
+
296
+ const app = createApp({
297
+ render,
298
+ })
299
+ app.mount(el)
300
+
301
+ onUnmount(() => {
302
+ app.unmount()
303
+ })
304
+ }
305
+
306
+ export default {
307
+ id: 'tailwind',
308
+ title: 'Tailwind',
309
+ group: 'design-system',
310
+ icon: 'mdi:tailwind',
311
+ responsiveDisabled: true,
312
+ layout: { type: 'single', iframe: false },
313
+ variants: [
314
+ {
315
+ id: 'background-color',
316
+ title: 'Background Color',
317
+ icon: 'carbon:color-palette',
318
+ onMount: (api) => mountApp(api, () => Object.entries(config.theme.backgroundColor).map(([key, shades]) => h(HstColorShades, {
319
+ key,
320
+ shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
321
+ getName: shade => '' + (shade === 'DEFAULT' ? \`bg-\${key}\` : \`bg-\${key}-\${shade}\`),
322
+ search: search.value,
323
+ }, ({ color}) => h('div', {
324
+ class: '__pvt-shade',
325
+ style: {
326
+ backgroundColor: color.replace('<alpha-value>', 1),
327
+ },
328
+ })))),
329
+ onMountControls: (api) => mountApp(api, () => [
330
+ h(HstText, {
331
+ title: 'Filter...',
332
+ modelValue: search.value,
333
+ 'onUpdate:modelValue': value => { search.value = value },
334
+ }),
335
+ ]),
336
+ },
337
+ {
338
+ id: 'text-color',
339
+ title: 'Text Color',
340
+ icon: 'carbon:text-color',
341
+ onMount: (api) => mountApp(api, () => Object.entries(config.theme.textColor).map(([key, shades]) => h(HstColorShades, {
342
+ key,
343
+ shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
344
+ getName: shade => '' + (shade === 'DEFAULT' ? \`text-\${key}\` : \`text-\${key}-\${shade}\`),
345
+ search: search.value,
346
+ }, ({ color}) => h('div', {
347
+ class: '__pvt-shade __pvt-text',
348
+ style: {
349
+ color: color.replace('<alpha-value>', 1),
350
+ },
351
+ }, 'Aa')))),
352
+ onMountControls: (api) => mountApp(api, () => [
353
+ h(HstText, {
354
+ title: 'Filter...',
355
+ modelValue: search.value,
356
+ 'onUpdate:modelValue': value => { search.value = value },
357
+ }),
358
+ ]),
359
+ },
360
+ {
361
+ id: 'border-color',
362
+ title: 'Border Color',
363
+ icon: 'carbon:color-palette',
364
+ onMount: (api) => mountApp(api, () => Object.entries(config.theme.borderColor).map(([key, shades]) => h(HstColorShades, {
365
+ key,
366
+ shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
367
+ getName: shade => '' + (shade === 'DEFAULT' ? \`border-\${key}\` : \`border-\${key}-\${shade}\`),
368
+ search: search.value,
369
+ }, ({ color}) => h('div', {
370
+ class: '__pvt-shade __pvt-border',
371
+ style: {
372
+ borderColor: color.replace('<alpha-value>', 1),
373
+ },
374
+ })))),
375
+ onMountControls: (api) => mountApp(api, () => [
376
+ h(HstText, {
377
+ title: 'Filter...',
378
+ modelValue: search.value,
379
+ 'onUpdate:modelValue': value => { search.value = value },
380
+ }),
381
+ ]),
382
+ },
383
+ {
384
+ id: 'padding',
385
+ title: 'Padding',
386
+ icon: 'carbon:area',
387
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
388
+ tokens: config.theme.padding,
389
+ getName: key => \`p-\${key}\`,
390
+ }, ({ token }) => h('div', {
391
+ class: '__pvt-padding',
392
+ style: {
393
+ padding: token.value,
394
+ },
395
+ }, [
396
+ h('div', {
397
+ class: '__pvt-padding-box',
398
+ }),
399
+ ]))),
400
+ },
401
+ {
402
+ id: 'margin',
403
+ title: 'Margin',
404
+ icon: 'carbon:area',
405
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
406
+ tokens: config.theme.margin,
407
+ getName: key => \`m-\${key}\`,
408
+ }, ({ token }) => h('div', {
409
+ class: '__pvt-margin',
410
+ }, [
411
+ h('div', {
412
+ class: '__pvt-margin-box',
413
+ style: {
414
+ margin: token.value,
415
+ },
416
+ }),
417
+ ]))),
418
+ },
419
+ {
420
+ id: 'font-size',
421
+ title: 'Font Size',
422
+ icon: 'carbon:text-font',
423
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
424
+ tokens: config.theme.fontSize,
425
+ getName: key => \`text-\${key}\`,
426
+ }, ({ token }) => h('div', {
427
+ class: '__pvt-truncate',
428
+ style: {
429
+ fontSize: Array.isArray(token.value) ? token.value[0] : token.value,
430
+ ...(Array.isArray(token.value) && typeof token.value[1] === "object" ? token.value[1] : { lineHeight: token.value[1] })
431
+ },
432
+ }, sampleText.value))),
433
+ onMountControls: (api) => mountApp(api, () => [
434
+ h(HstTextarea, {
435
+ title: 'Sample text',
436
+ modelValue: sampleText.value,
437
+ 'onUpdate:modelValue': value => { sampleText.value = value },
438
+ rows: 5,
439
+ }),
440
+ ]),
441
+ },
442
+ {
443
+ id: 'font-weight',
444
+ title: 'Font Weight',
445
+ icon: 'carbon:text-font',
446
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
447
+ tokens: config.theme.fontWeight,
448
+ getName: key => \`font-\${key}\`,
449
+ }, ({ token }) => h('div', {
450
+ class: '__pvt-truncate',
451
+ style: {
452
+ fontWeight: token.value,
453
+ fontSize: \`\${fontSize.value}px\`,
454
+ },
455
+ }, sampleText.value))),
456
+ onMountControls: (api) => mountApp(api, () => [
457
+ h(HstTextarea, {
458
+ title: 'Sample text',
459
+ modelValue: sampleText.value,
460
+ 'onUpdate:modelValue': value => { sampleText.value = value },
461
+ rows: 5,
462
+ }),
463
+ h(HstNumber, {
464
+ title: 'Font size',
465
+ modelValue: fontSize.value,
466
+ 'onUpdate:modelValue': value => { fontSize.value = value },
467
+ min: 1,
468
+ }),
469
+ ]),
470
+ },
471
+ {
472
+ id: 'font-family',
473
+ title: 'Font Family',
474
+ icon: 'carbon:text-font',
475
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
476
+ tokens: config.theme.fontFamily,
477
+ getName: key => \`font-\${key}\`,
478
+ }, ({ token }) => h('div', {
479
+ class: '__pvt-truncate',
480
+ style: {
481
+ fontFamily: token.value,
482
+ fontSize: \`\${fontSize.value}px\`,
483
+ },
484
+ }, sampleText.value))),
485
+ onMountControls: (api) => mountApp(api, () => [
486
+ h(HstTextarea, {
487
+ title: 'Sample text',
488
+ modelValue: sampleText.value,
489
+ 'onUpdate:modelValue': value => { sampleText.value = value },
490
+ rows: 5,
491
+ }),
492
+ h(HstNumber, {
493
+ title: 'Font size',
494
+ modelValue: fontSize.value,
495
+ 'onUpdate:modelValue': value => { fontSize.value = value },
496
+ min: 1,
497
+ }),
498
+ ]),
499
+ },
500
+ {
501
+ id: 'letter-spacing',
502
+ title: 'Letter Spacing',
503
+ icon: 'carbon:text-font',
504
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
505
+ tokens: config.theme.letterSpacing,
506
+ getName: key => \`tracking-\${key}\`,
507
+ }, ({ token }) => h('div', {
508
+ class: '__pvt-truncate',
509
+ style: {
510
+ letterSpacing: token.value,
511
+ fontSize: \`\${fontSize.value}px\`,
512
+ },
513
+ }, sampleText.value))),
514
+ onMountControls: (api) => mountApp(api, () => [
515
+ h(HstTextarea, {
516
+ title: 'Sample text',
517
+ modelValue: sampleText.value,
518
+ 'onUpdate:modelValue': value => { sampleText.value = value },
519
+ rows: 5,
520
+ }),
521
+ h(HstNumber, {
522
+ title: 'Font size',
523
+ modelValue: fontSize.value,
524
+ 'onUpdate:modelValue': value => { fontSize.value = value },
525
+ min: 1,
526
+ }),
527
+ ]),
528
+ },
529
+ {
530
+ id: 'line-height',
531
+ title: 'Line Height',
532
+ icon: 'carbon:text-font',
533
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
534
+ tokens: config.theme.lineHeight,
535
+ getName: key => \`leading-\${key}\`,
536
+ }, ({ token }) => h('div', {
537
+ style: {
538
+ lineHeight: token.value,
539
+ },
540
+ }, sampleText.value))),
541
+ onMountControls: (api) => mountApp(api, () => [
542
+ h(HstTextarea, {
543
+ title: 'Sample text',
544
+ modelValue: sampleText.value,
545
+ 'onUpdate:modelValue': value => { sampleText.value = value },
546
+ rows: 5,
547
+ }),
548
+ // @TODO select font size
549
+ ]),
550
+ },
551
+ {
552
+ id: 'drop-shadow',
553
+ title: 'Drop Shadow',
554
+ icon: 'carbon:shape-except',
555
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
556
+ tokens: config.theme.dropShadow,
557
+ getName: key => '' + (key === 'DEFAULT' ? 'drop-shadow' : \`drop-shadow-\${key}\`),
558
+ colSize: 180,
559
+ }, ({ token }) => h('div', {
560
+ class: '__pvt-drop-shadow',
561
+ style: {
562
+ filter: \`\${(Array.isArray(token.value) ? token.value : [token.value]).map(v => \`drop-shadow(\${v})\`).join(' ')}\`,
563
+ },
564
+ }))),
565
+ },
566
+ {
567
+ id: 'border-radius',
568
+ title: 'Border Radius',
569
+ icon: 'carbon:condition-wait-point',
570
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
571
+ tokens: config.theme.borderRadius,
572
+ getName: key => '' + (key === 'DEFAULT' ? 'rounded' : \`rounded-\${key}\`),
573
+ colSize: 180,
574
+ }, ({ token }) => h('div', {
575
+ class: '__pvt-border-radius',
576
+ style: {
577
+ borderRadius: token.value,
578
+ },
579
+ }))),
580
+ },
581
+ {
582
+ id: 'border-width',
583
+ title: 'Border Width',
584
+ icon: 'carbon:checkbox',
585
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
586
+ tokens: config.theme.borderWidth,
587
+ getName: key => '' + (key === 'DEFAULT' ? 'border' : \`border-\${key}\`),
588
+ colSize: 180,
589
+ }, ({ token }) => h('div', {
590
+ class: '__pvt-border-width',
591
+ style: {
592
+ borderWidth: token.value,
593
+ },
594
+ }))),
595
+ },
596
+ {
597
+ id: 'width',
598
+ title: 'Width',
599
+ icon: 'carbon:pan-horizontal',
600
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
601
+ tokens: config.theme.width,
602
+ getName: key => '' + (key === 'DEFAULT' ? 'w' : \`w-\${key}\`),
603
+ }, ({ token }) => h('div', {
604
+ class: '__pvt-width',
605
+ }, [
606
+ h('div', {
607
+ class: '__pvt-width-box',
608
+ style: {
609
+ width: token.value,
610
+ },
611
+ }),
612
+ ]))),
613
+ },
614
+ {
615
+ id: 'height',
616
+ title: 'Height',
617
+ icon: 'carbon:pan-vertical',
618
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
619
+ tokens: config.theme.height,
620
+ getName: key => '' + (key === 'DEFAULT' ? 'h' : \`h-\${key}\`),
621
+ }, ({ token }) => h('div', {
622
+ class: '__pvt-height',
623
+ style: {
624
+ height: token.value,
625
+ },
626
+ }))),
627
+ },
628
+ {
629
+ id: 'full-config',
630
+ title: 'Full Config',
631
+ icon: 'carbon:code',
632
+ onMount: (api) => mountApp(api, () => h('pre', JSON.stringify(config, null, 2))),
633
+ },
634
+ ],
635
+ }`;
636
+ }
637
+ const css = `.__pvt-shade {
638
+ height: 80px;
639
+ border-radius: 4px;
640
+ }
641
+
642
+ .__pvt-text {
643
+ font-size: 4rem;
644
+ display: flex;
645
+ align-items: flex-end;
646
+ }
647
+
648
+ .__pvt-border {
649
+ border-style: solid;
650
+ border-width: 2px;
651
+ }
652
+
653
+ .__pvt-padding {
654
+ background-color: rgb(113 113 122 / 0.1);
655
+ width: min-content;
656
+ }
657
+
658
+ .__pvt-margin {
659
+ border: dashed 1px rgb(113 113 122 / 0.5);
660
+ width: min-content;
661
+ }
662
+
663
+ .__pvt-padding-box,
664
+ .__pvt-margin-box {
665
+ width: 5rem;
666
+ height: 5rem;
667
+ background-color: rgb(113 113 122 / 0.5);
668
+ }
669
+
670
+ .__pvt-padding,
671
+ .__pvt-padding-box,
672
+ .__pvt-margin,
673
+ .__pvt-margin-box,
674
+ .__pvt-drop-shadow {
675
+ border-radius: 4px;
676
+ }
677
+
678
+ .__pvt-truncate {
679
+ overflow: hidden;
680
+ text-overflow: ellipsis;
681
+ white-space: nowrap;
682
+ }
683
+
684
+ .__pvt-drop-shadow {
685
+ width: 8rem;
686
+ height: 8rem;
687
+ background: white;
688
+ margin-bottom: 0.5rem;
689
+ }
690
+
691
+ .__pvt-drop-shadow {
692
+ background: #4e4e57;
693
+ }
694
+
695
+ .__pvt-border-radius {
696
+ width: 8rem;
697
+ height: 8rem;
698
+ background-color: rgb(113 113 122 / 0.5);
699
+ }
700
+
701
+ .__pvt-border-width {
702
+ width: 8rem;
703
+ height: 8rem;
704
+ border-color: rgb(113 113 122 / 0.5);
705
+ background-color: rgb(113 113 122 / 0.1);
706
+ }
707
+
708
+ .__pvt-width {
709
+ background-color: rgb(113 113 122 / 0.1);
710
+ }
711
+
712
+ .__pvt-width-box,
713
+ .__pvt-height {
714
+ background-color: rgb(113 113 122 / 0.5);
715
+ }
716
+
717
+ .__pvt-width-box {
718
+ height: 5rem;
719
+ }`;
720
+ /** @deprecated Use `HstTailwind`. Kept for books that named the old builtin. */
721
+ export const tailwindTokens = HstTailwind;