histoire 0.9.1 → 0.9.2

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 (30) hide show
  1. package/dist/node/builtin-plugins/tailwind-tokens.js +390 -383
  2. package/dist/node/builtin-plugins/vanilla-support/MountStory.d.ts +14 -0
  3. package/dist/node/builtin-plugins/vanilla-support/MountStory.js +39 -0
  4. package/dist/node/builtin-plugins/vanilla-support/RenderStory.d.ts +38 -0
  5. package/dist/node/builtin-plugins/vanilla-support/RenderStory.js +131 -0
  6. package/dist/node/builtin-plugins/vanilla-support/client.d.ts +3 -0
  7. package/dist/node/builtin-plugins/vanilla-support/client.js +5 -0
  8. package/dist/node/builtin-plugins/vanilla-support/collect.d.ts +2 -0
  9. package/dist/node/builtin-plugins/vanilla-support/collect.js +33 -0
  10. package/dist/node/builtin-plugins/vanilla-support/plugin.d.ts +2 -0
  11. package/dist/node/builtin-plugins/vanilla-support/plugin.js +29 -0
  12. package/dist/node/builtin-plugins/vanilla-support/types.d.ts +35 -0
  13. package/dist/node/builtin-plugins/vanilla-support/types.js +3 -0
  14. package/dist/node/builtin-plugins/vanilla-support/vanilla.story.d.ts +3 -0
  15. package/dist/node/builtin-plugins/vanilla-support/vanilla.story.js +55 -0
  16. package/dist/node/config.js +2 -0
  17. package/dist/node/server.js +1 -1
  18. package/dist/node/vite.js +7 -11
  19. package/package.json +5 -5
  20. package/src/node/builtin-plugins/tailwind-tokens.ts +393 -383
  21. package/src/node/builtin-plugins/vanilla-support/MountStory.ts +50 -0
  22. package/src/node/builtin-plugins/vanilla-support/RenderStory.ts +166 -0
  23. package/src/node/builtin-plugins/vanilla-support/client.ts +6 -0
  24. package/src/node/builtin-plugins/vanilla-support/collect.ts +42 -0
  25. package/src/node/builtin-plugins/vanilla-support/plugin.ts +35 -0
  26. package/src/node/builtin-plugins/vanilla-support/types.ts +40 -0
  27. package/src/node/builtin-plugins/vanilla-support/vanilla.story.ts +63 -0
  28. package/src/node/config.ts +2 -0
  29. package/src/node/server.ts +2 -2
  30. package/src/node/vite.ts +7 -11
@@ -1,4 +1,9 @@
1
+ import { createRequire } from 'module';
1
2
  import { findUp } from '../util/find-up.js';
3
+ const require = createRequire(import.meta.url);
4
+ function resolveImport(request) {
5
+ return JSON.stringify(require.resolve(request));
6
+ }
2
7
  export function tailwindTokens(options = {}) {
3
8
  const tailwindConfigFile = options.configFile ?? findUp(process.cwd(), [
4
9
  'tailwind.config.js',
@@ -15,10 +20,11 @@ export function tailwindTokens(options = {}) {
15
20
  await api.fs.ensureDir(api.pluginTempDir);
16
21
  await api.fs.emptyDir(api.pluginTempDir);
17
22
  api.moduleLoader.clearCache();
23
+ await api.fs.writeFile(api.path.resolve(api.pluginTempDir, 'style.css'), css);
18
24
  const tailwindConfig = await api.moduleLoader.loadModule(tailwindConfigFile);
19
25
  const { default: resolveConfig } = await import('tailwindcss/resolveConfig.js');
20
26
  const resolvedTailwindConfig = resolveConfig(tailwindConfig);
21
- const storyFile = api.path.resolve(api.pluginTempDir, 'Tailwind.story.vue');
27
+ const storyFile = api.path.resolve(api.pluginTempDir, 'Tailwind.story.js');
22
28
  await api.fs.writeFile(storyFile, storyTemplate(resolvedTailwindConfig));
23
29
  api.addStoryFile(storyFile);
24
30
  }
@@ -27,7 +33,7 @@ export function tailwindTokens(options = {}) {
27
33
  }
28
34
  }
29
35
  return {
30
- name: 'tailwind-tokens',
36
+ name: 'builtin:tailwind-tokens',
31
37
  config(config) {
32
38
  if (tailwindConfigFile) {
33
39
  // Add 'design-system' group
@@ -69,449 +75,450 @@ export function tailwindTokens(options = {}) {
69
75
  },
70
76
  };
71
77
  }
72
- const storyTemplate = (tailwindConfig) => `<script>
73
- import 'histoire-style'
74
- import { ref, markRaw } from 'vue'
78
+ const storyTemplate = (tailwindConfig) => `import 'histoire-style'
79
+ import './style.css'
80
+ import { createApp, h, markRaw, ref } from ${resolveImport('@histoire/vendors/vue')}
81
+ import {
82
+ HstColorShades,
83
+ HstTokenList,
84
+ HstTokenGrid,
85
+ HstText,
86
+ HstTextarea,
87
+ HstNumber,
88
+ } from ${resolveImport('@histoire/controls')}
75
89
 
76
90
  const config = markRaw(${JSON.stringify(tailwindConfig, null, 2)})
91
+ const search = ref('')
92
+ 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')
93
+ const fontSize = ref(16)
77
94
 
78
- export default {
79
- setup () {
80
- const search = ref('')
81
- 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')
82
- const fontSize = ref(16)
83
- return {
84
- config,
85
- search,
86
- sampleText,
87
- fontSize,
88
- }
89
- }
95
+ function mountApp ({ el, state, onUnmount }, render) {
96
+ Object.assign(state, {
97
+ search,
98
+ sampleText,
99
+ fontSize,
100
+ })
101
+
102
+ const app = createApp({
103
+ render,
104
+ })
105
+ app.mount(el)
106
+
107
+ onUnmount(() => {
108
+ app.unmount()
109
+ })
90
110
  }
91
- </script>
92
- <template>
93
- <Story id="tailwind" title="Tailwind" group="design-system" icon="mdi:tailwind" responsiveDisabled :layout="{ type: 'single', iframe: false }">
94
- <Variant id="background-color" title="Background Color" icon="carbon:color-palette">
95
- <HstColorShades
96
- v-for="(shades, key) of config.theme.backgroundColor"
97
- :key="key"
98
- :shades="typeof shades === 'object' ? shades : { DEFAULT: shades }"
99
- :get-name="shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`bg-\${key}\` : \`bg-\${key}-\${shade}\`)"
100
- :search="search"
101
- >
102
- <template #default="{ color }">
103
- <div
104
- class="shade"
105
- :style="{
106
- backgroundColor: color,
107
- }"
108
- />
109
- </template>
110
- </HstColorShades>
111
- <template #controls>
112
- <HstText
113
- v-model="search"
114
- title="Filter..."
115
- />
116
- </template>
117
- </Variant>
118
- <Variant id="text-color" title="Text Color" icon="carbon:text-color">
119
- <HstColorShades
120
- v-for="(shades, key) of config.theme.textColor"
121
- :key="key"
122
- :shades="typeof shades === 'object' ? shades : { DEFAULT: shades }"
123
- :get-name="shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`text-\${key}\` : \`text-\${key}-\${shade}\`)"
124
- :search="search"
125
- >
126
- <template #default="{ color }">
127
- <div
128
- class="shade text"
129
- :style="{
130
- color: color,
131
- }"
132
- >
133
- Aa
134
- </div>
135
- </template>
136
- </HstColorShades>
137
- <template #controls>
138
- <HstText
139
- v-model="search"
140
- title="Filter..."
141
- />
142
- </template>
143
- </Variant>
144
- <Variant id="border-color" title="Border Color" icon="carbon:color-palette">
145
- <HstColorShades
146
- v-for="(shades, key) of config.theme.borderColor"
147
- :key="key"
148
- :shades="typeof shades === 'object' ? shades : { DEFAULT: shades }"
149
- :get-name="shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`border-\${key}\` : \`border-\${key}-\${shade}\`)"
150
- :search="search"
151
- >
152
- <template #default="{ color }">
153
- <div
154
- class="shade border"
155
- :style="{
156
- borderColor: color,
157
- }"
158
- />
159
- </template>
160
- </HstColorShades>
161
- <template #controls>
162
- <HstText
163
- v-model="search"
164
- title="Filter..."
165
- />
166
- </template>
167
- </Variant>
168
- <Variant id="padding" title="Padding" icon="carbon:area">
169
- <HstTokenList
170
- :tokens="config.theme.padding"
171
- :get-name="key => \`\${config.prefix ?? ''}p-\${key}\`"
172
- >
173
- <template #default="{ token }">
174
- <div class="padding"
175
- :style="{
176
- padding: token.value,
177
- }"
178
- >
179
- <div
180
- class="padding-box"
181
- />
182
- </div>
183
- </template>
184
- </HstTokenList>
185
- </Variant>
186
- <Variant id="margin" title="Margin" icon="carbon:area">
187
- <HstTokenList
188
- :tokens="config.theme.margin"
189
- :get-name="key => \`\${config.prefix ?? ''}m-\${key}\`"
190
- >
191
- <template #default="{ token }">
192
- <div class="margin"
193
- :style="{
194
- padding: token.value,
195
- }"
196
- >
197
- <div
198
- class="margin-box"
199
- />
200
- </div>
201
- </template>
202
- </HstTokenList>
203
- </Variant>
204
- <Variant id="font-size" title="Font Size" icon="carbon:text-font">
205
- <HstTokenList
206
- :tokens="config.theme.fontSize"
207
- :get-name="key => \`\${config.prefix ?? ''}text-\${key}\`"
208
- >
209
- <template #default="{ token }">
210
- <div
211
- class="truncate"
212
- :style="{
213
- fontSize: token.value[0],
214
- ...token.value[1],
215
- }"
216
- >
217
- {{ sampleText }}
218
- </div>
219
- </template>
220
- </HstTokenList>
221
- <template #controls>
222
- <HstTextarea
223
- v-model="sampleText"
224
- title="Sample text"
225
- rows="5"
226
- />
227
- </template>
228
- </Variant>
229
- <Variant id="font-weight" title="Font Weight" icon="carbon:text-font">
230
- <HstTokenList
231
- :tokens="config.theme.fontWeight"
232
- :get-name="key => \`\${config.prefix ?? ''}font-\${key}\`"
233
- >
234
- <template #default="{ token }">
235
- <div
236
- class="truncate"
237
- :style="{
238
- fontWeight: token.value,
239
- fontSize: \`\${fontSize}px\`,
240
- }"
241
- >
242
- {{ sampleText }}
243
- </div>
244
- </template>
245
- </HstTokenList>
246
- <template #controls>
247
- <HstTextarea
248
- v-model="sampleText"
249
- title="Sample text"
250
- rows="5"
251
- />
252
- <HstNumber
253
- v-model="fontSize"
254
- title="Font size"
255
- min="1"
256
- />
257
- </template>
258
- </Variant>
259
- <Variant id="font-family" title="Font Family" icon="carbon:text-font">
260
- <HstTokenList
261
- :tokens="config.theme.fontFamily"
262
- :get-name="key => \`\${config.prefix ?? ''}font-\${key}\`"
263
- >
264
- <template #default="{ token }">
265
- <div
266
- class="truncate"
267
- :style="{
268
- fontFamily: token.value,
269
- fontSize: \`\${fontSize}px\`,
270
- }"
271
- >
272
- {{ sampleText }}
273
- </div>
274
- </template>
275
- </HstTokenList>
276
- <template #controls>
277
- <HstTextarea
278
- v-model="sampleText"
279
- title="Sample text"
280
- rows="5"
281
- />
282
- <HstNumber
283
- v-model="fontSize"
284
- title="Font size"
285
- min="1"
286
- />
287
- </template>
288
- </Variant>
289
- <Variant id="letter-spacing" title="Letter Spacing" icon="carbon:text-font">
290
- <HstTokenList
291
- :tokens="config.theme.letterSpacing"
292
- :get-name="key => \`\${config.prefix ?? ''}tracking-\${key}\`"
293
- >
294
- <template #default="{ token }">
295
- <div
296
- class="truncate"
297
- :style="{
298
- letterSpacing: token.value,
299
- fontSize: \`\${fontSize}px\`,
300
- }"
301
- >
302
- {{ sampleText }}
303
- </div>
304
- </template>
305
- </HstTokenList>
306
- <template #controls>
307
- <HstTextarea
308
- v-model="sampleText"
309
- title="Sample text"
310
- rows="5"
311
- />
312
- <HstNumber
313
- v-model="fontSize"
314
- title="Font size"
315
- min="1"
316
- />
317
- </template>
318
- </Variant>
319
- <Variant id="line-height" title="Line Height" icon="carbon:text-font">
320
- <HstTokenList
321
- :tokens="config.theme.lineHeight"
322
- :get-name="key => \`\${config.prefix ?? ''}leading-\${key}\`"
323
- >
324
- <template #default="{ token }">
325
- <div
326
- :style="{
327
- lineHeight: token.value,
328
- fontSize: \`\${fontSize}px\`,
329
- }"
330
- >
331
- {{ sampleText }}
332
- </div>
333
- </template>
334
- </HstTokenList>
335
- <template #controls>
336
- <HstTextarea
337
- v-model="sampleText"
338
- title="Sample text"
339
- rows="5"
340
- />
341
- <HstNumber
342
- v-model="fontSize"
343
- title="Font size"
344
- min="1"
345
- />
346
- </template>
347
- </Variant>
348
- <Variant id="drop-shadow" title="Drop Shadow" icon="carbon:shape-except">
349
- <HstTokenGrid
350
- :tokens="config.theme.dropShadow"
351
- :get-name="key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'drop-shadow' : \`drop-shadow-\${key}\`)"
352
- :col-size="180"
353
- >
354
- <template #default="{ token }">
355
- <div
356
- class="drop-shadow"
357
- :style="{
358
- filter: \`\${(Array.isArray(token.value) ? token.value : [token.value]).map(v => \`drop-shadow(\${v})\`).join(' ')}\`,
359
- }"
360
- />
361
- </template>
362
- </HstTokenGrid>
363
- </Variant>
364
- <Variant id="border-radius" title="Border Radius" icon="carbon:condition-wait-point">
365
- <HstTokenGrid
366
- :tokens="config.theme.borderRadius"
367
- :get-name="key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'rounded' : \`rounded-\${key}\`)"
368
- :col-size="180"
369
- >
370
- <template #default="{ token }">
371
- <div
372
- class="border-radius"
373
- :style="{
374
- borderRadius: token.value,
375
- }"
376
- />
377
- </template>
378
- </HstTokenGrid>
379
- </Variant>
380
- <Variant id="border-width" title="Border Width" icon="carbon:checkbox">
381
- <HstTokenGrid
382
- :tokens="config.theme.borderWidth"
383
- :get-name="key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'border' : \`border-\${key}\`)"
384
- :col-size="180"
385
- >
386
- <template #default="{ token }">
387
- <div
388
- class="border-width"
389
- :style="{
390
- borderWidth: token.value,
391
- }"
392
- />
393
- </template>
394
- </HstTokenGrid>
395
- </Variant>
396
- <Variant id="width" title="Width" icon="carbon:pan-horizontal">
397
- <HstTokenList
398
- :tokens="config.theme.width"
399
- :get-name="key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'w' : \`w-\${key}\`)"
400
- >
401
- <template #default="{ token }">
402
- <div class="width">
403
- <div
404
- class="width-box"
405
- :style="{
406
- width: token.value,
407
- }"
408
- />
409
- </div>
410
- </template>
411
- </HstTokenList>
412
- </Variant>
413
- <Variant id="height" title="Height" icon="carbon:pan-vertical">
414
- <HstTokenList
415
- :tokens="config.theme.height"
416
- :get-name="key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'h' : \`h-\${key}\`)"
417
- >
418
- <template #default="{ token }">
419
- <div
420
- class="height"
421
- :style="{
422
- height: token.value,
423
- }"
424
- />
425
- </template>
426
- </HstTokenList>
427
- </Variant>
428
- <Variant id="full-config" title="Full Config" icon="carbon:code">
429
- <pre>{{ config }}</pre>
430
- </Variant>
431
- </Story>
432
- </template>
433
- <style scoped>
434
- .shade {
111
+
112
+ export default {
113
+ id: 'tailwind',
114
+ title: 'Tailwind',
115
+ group: 'design-system',
116
+ icon: 'mdi:tailwind',
117
+ responsiveDisabled: true,
118
+ layout: { type: 'single', iframe: false },
119
+ variants: [
120
+ {
121
+ id: 'background-color',
122
+ title: 'Background Color',
123
+ icon: 'carbon:color-palette',
124
+ onMount: (api) => mountApp(api, () => Object.entries(config.theme.backgroundColor).map(([key, shades]) => h(HstColorShades, {
125
+ key,
126
+ shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
127
+ getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`bg-\${key}\` : \`bg-\${key}-\${shade}\`),
128
+ search: search.value,
129
+ }, ({ color}) => h('div', {
130
+ class: '__hst-shade',
131
+ style: {
132
+ backgroundColor: color,
133
+ },
134
+ })))),
135
+ onMountControls: (api) => mountApp(api, () => [
136
+ h(HstText, {
137
+ title: 'Filter...',
138
+ modelValue: search.value,
139
+ 'onUpdate:modelValue': value => { search.value = value },
140
+ }),
141
+ ]),
142
+ },
143
+ {
144
+ id: 'text-color',
145
+ title: 'Text Color',
146
+ icon: 'carbon:text-color',
147
+ onMount: (api) => mountApp(api, () => Object.entries(config.theme.textColor).map(([key, shades]) => h(HstColorShades, {
148
+ key,
149
+ shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
150
+ getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`text-\${key}\` : \`text-\${key}-\${shade}\`),
151
+ search: search.value,
152
+ }, ({ color}) => h('div', {
153
+ class: '__hst-shade __hst-text',
154
+ style: {
155
+ color,
156
+ },
157
+ }, 'Aa')))),
158
+ onMountControls: (api) => mountApp(api, () => [
159
+ h(HstText, {
160
+ title: 'Filter...',
161
+ modelValue: search.value,
162
+ 'onUpdate:modelValue': value => { search.value = value },
163
+ }),
164
+ ]),
165
+ },
166
+ {
167
+ id: 'border-color',
168
+ title: 'Border Color',
169
+ icon: 'carbon:color-palette',
170
+ onMount: (api) => mountApp(api, () => Object.entries(config.theme.borderColor).map(([key, shades]) => h(HstColorShades, {
171
+ key,
172
+ shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
173
+ getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`border-\${key}\` : \`border-\${key}-\${shade}\`),
174
+ search: search.value,
175
+ }, ({ color}) => h('div', {
176
+ class: '__hst-shade __hst-border',
177
+ style: {
178
+ borderColor: color,
179
+ },
180
+ })))),
181
+ onMountControls: (api) => mountApp(api, () => [
182
+ h(HstText, {
183
+ title: 'Filter...',
184
+ modelValue: search.value,
185
+ 'onUpdate:modelValue': value => { search.value = value },
186
+ }),
187
+ ]),
188
+ },
189
+ {
190
+ id: 'padding',
191
+ title: 'Padding',
192
+ icon: 'carbon:area',
193
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
194
+ tokens: config.theme.padding,
195
+ getName: key => \`\${config.prefix ?? ''}p-\${key}\`,
196
+ }, ({ token }) => h('div', {
197
+ class: '__hst-padding',
198
+ style: {
199
+ padding: token.value,
200
+ },
201
+ }, [
202
+ h('div', {
203
+ class: '__hst-padding-box',
204
+ }),
205
+ ]))),
206
+ },
207
+ {
208
+ id: 'margin',
209
+ title: 'Margin',
210
+ icon: 'carbon:area',
211
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
212
+ tokens: config.theme.margin,
213
+ getName: key => \`\${config.prefix ?? ''}m-\${key}\`,
214
+ }, ({ token }) => h('div', {
215
+ class: '__hst-margin',
216
+ }, [
217
+ h('div', {
218
+ class: '__hst-margin-box',
219
+ style: {
220
+ margin: token.value,
221
+ },
222
+ }),
223
+ ]))),
224
+ },
225
+ {
226
+ id: 'font-size',
227
+ title: 'Font Size',
228
+ icon: 'carbon:text-font',
229
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
230
+ tokens: config.theme.fontSize,
231
+ getName: key => \`\${config.prefix ?? ''}text-\${key}\`,
232
+ }, ({ token }) => h('div', {
233
+ class: '__hst-truncate',
234
+ style: {
235
+ fontSize: token.value[0],
236
+ ...token.value[1],
237
+ },
238
+ }, sampleText.value))),
239
+ onMountControls: (api) => mountApp(api, () => [
240
+ h(HstTextarea, {
241
+ title: 'Sample text',
242
+ modelValue: sampleText.value,
243
+ 'onUpdate:modelValue': value => { sampleText.value = value },
244
+ rows: 5,
245
+ }),
246
+ ]),
247
+ },
248
+ {
249
+ id: 'font-weight',
250
+ title: 'Font Weight',
251
+ icon: 'carbon:text-font',
252
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
253
+ tokens: config.theme.fontWeight,
254
+ getName: key => \`\${config.prefix ?? ''}font-\${key}\`,
255
+ }, ({ token }) => h('div', {
256
+ class: '__hst-truncate',
257
+ style: {
258
+ fontWeight: token.value,
259
+ fontSize: \`\${fontSize.value}px\`,
260
+ },
261
+ }, sampleText.value))),
262
+ onMountControls: (api) => mountApp(api, () => [
263
+ h(HstTextarea, {
264
+ title: 'Sample text',
265
+ modelValue: sampleText.value,
266
+ 'onUpdate:modelValue': value => { sampleText.value = value },
267
+ rows: 5,
268
+ }),
269
+ h(HstNumber, {
270
+ title: 'Font size',
271
+ modelValue: fontSize.value,
272
+ 'onUpdate:modelValue': value => { fontSize.value = value },
273
+ min: 1,
274
+ }),
275
+ ]),
276
+ },
277
+ {
278
+ id: 'font-family',
279
+ title: 'Font Family',
280
+ icon: 'carbon:text-font',
281
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
282
+ tokens: config.theme.fontFamily,
283
+ getName: key => \`\${config.prefix ?? ''}font-\${key}\`,
284
+ }, ({ token }) => h('div', {
285
+ class: '__hst-truncate',
286
+ style: {
287
+ fontFamily: token.value,
288
+ fontSize: \`\${fontSize.value}px\`,
289
+ },
290
+ }, sampleText.value))),
291
+ onMountControls: (api) => mountApp(api, () => [
292
+ h(HstTextarea, {
293
+ title: 'Sample text',
294
+ modelValue: sampleText.value,
295
+ 'onUpdate:modelValue': value => { sampleText.value = value },
296
+ rows: 5,
297
+ }),
298
+ h(HstNumber, {
299
+ title: 'Font size',
300
+ modelValue: fontSize.value,
301
+ 'onUpdate:modelValue': value => { fontSize.value = value },
302
+ min: 1,
303
+ }),
304
+ ]),
305
+ },
306
+ {
307
+ id: 'letter-spacing',
308
+ title: 'Letter Spacing',
309
+ icon: 'carbon:text-font',
310
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
311
+ tokens: config.theme.letterSpacing,
312
+ getName: key => \`\${config.prefix ?? ''}tracking-\${key}\`,
313
+ }, ({ token }) => h('div', {
314
+ class: '__hst-truncate',
315
+ style: {
316
+ letterSpacing: token.value,
317
+ fontSize: \`\${fontSize.value}px\`,
318
+ },
319
+ }, sampleText.value))),
320
+ onMountControls: (api) => mountApp(api, () => [
321
+ h(HstTextarea, {
322
+ title: 'Sample text',
323
+ modelValue: sampleText.value,
324
+ 'onUpdate:modelValue': value => { sampleText.value = value },
325
+ rows: 5,
326
+ }),
327
+ h(HstNumber, {
328
+ title: 'Font size',
329
+ modelValue: fontSize.value,
330
+ 'onUpdate:modelValue': value => { fontSize.value = value },
331
+ min: 1,
332
+ }),
333
+ ]),
334
+ },
335
+ {
336
+ id: 'line-height',
337
+ title: 'Line Height',
338
+ icon: 'carbon:text-font',
339
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
340
+ tokens: config.theme.lineHeight,
341
+ getName: key => \`\${config.prefix ?? ''}leading-\${key}\`,
342
+ }, ({ token }) => h('div', {
343
+ style: {
344
+ lineHeight: token.value,
345
+ },
346
+ }, sampleText.value))),
347
+ onMountControls: (api) => mountApp(api, () => [
348
+ h(HstTextarea, {
349
+ title: 'Sample text',
350
+ modelValue: sampleText.value,
351
+ 'onUpdate:modelValue': value => { sampleText.value = value },
352
+ rows: 5,
353
+ }),
354
+ // @TODO select font size
355
+ ]),
356
+ },
357
+ {
358
+ id: 'drop-shadow',
359
+ title: 'Drop Shadow',
360
+ icon: 'carbon:shape-except',
361
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
362
+ tokens: config.theme.dropShadow,
363
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'drop-shadow' : \`drop-shadow-\${key}\`),
364
+ colSize: 180,
365
+ }, ({ token }) => h('div', {
366
+ class: '__hst-drop-shadow',
367
+ style: {
368
+ filter: \`\${(Array.isArray(token.value) ? token.value : [token.value]).map(v => \`drop-shadow(\${v})\`).join(' ')}\`,
369
+ },
370
+ }))),
371
+ },
372
+ {
373
+ id: 'border-radius',
374
+ title: 'Border Radius',
375
+ icon: 'carbon:condition-wait-point',
376
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
377
+ tokens: config.theme.borderRadius,
378
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'rounded' : \`rounded-\${key}\`),
379
+ colSize: 180,
380
+ }, ({ token }) => h('div', {
381
+ class: '__hst-border-radius',
382
+ style: {
383
+ borderRadius: token.value,
384
+ },
385
+ }))),
386
+ },
387
+ {
388
+ id: 'border-width',
389
+ title: 'Border Width',
390
+ icon: 'carbon:checkbox',
391
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
392
+ tokens: config.theme.borderWidth,
393
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'border' : \`border-\${key}\`),
394
+ colSize: 180,
395
+ }, ({ token }) => h('div', {
396
+ class: '__hst-border-width',
397
+ style: {
398
+ borderWidth: token.value,
399
+ },
400
+ }))),
401
+ },
402
+ {
403
+ id: 'width',
404
+ title: 'Width',
405
+ icon: 'carbon:pan-horizontal',
406
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
407
+ tokens: config.theme.width,
408
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'w' : \`w-\${key}\`),
409
+ }, ({ token }) => h('div', {
410
+ class: '__hst-width',
411
+ }, [
412
+ h('div', {
413
+ class: '__hst-width-box',
414
+ style: {
415
+ width: token.value,
416
+ },
417
+ }),
418
+ ]))),
419
+ },
420
+ {
421
+ id: 'height',
422
+ title: 'Height',
423
+ icon: 'carbon:pan-vertical',
424
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
425
+ tokens: config.theme.height,
426
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'h' : \`h-\${key}\`),
427
+ }, ({ token }) => h('div', {
428
+ class: '__hst-height',
429
+ style: {
430
+ height: token.value,
431
+ },
432
+ }))),
433
+ },
434
+ {
435
+ id: 'full-config',
436
+ title: 'Full Config',
437
+ icon: 'carbon:code',
438
+ onMount: (api) => mountApp(api, () => h('pre', JSON.stringify(config, null, 2))),
439
+ },
440
+ ],
441
+ }`;
442
+ const css = `.__hst-shade {
435
443
  height: 80px;
436
444
  border-radius: 4px;
437
445
  }
438
446
 
439
- .text {
447
+ .__hst-text {
440
448
  font-size: 4rem;
441
449
  display: flex;
442
450
  align-items: flex-end;
443
451
  }
444
452
 
445
- .border {
453
+ .__hst-border {
446
454
  border-style: solid;
447
455
  border-width: 2px;
448
456
  }
449
457
 
450
- .padding {
458
+ .__hst-padding {
451
459
  background-color: rgb(113 113 122 / 0.1);
452
460
  width: min-content;
453
461
  }
454
462
 
455
- .margin {
463
+ .__hst-margin {
456
464
  border: dashed 1px rgb(113 113 122 / 0.5);
457
465
  width: min-content;
458
466
  }
459
467
 
460
- .padding-box,
461
- .margin-box {
468
+ .__hst-padding-box,
469
+ .__hst-margin-box {
462
470
  width: 5rem;
463
471
  height: 5rem;
464
472
  background-color: rgb(113 113 122 / 0.5);
465
473
  }
466
474
 
467
- .padding,
468
- .padding-box,
469
- .margin,
470
- .margin-box,
471
- .drop-shadow {
475
+ .__hst-padding,
476
+ .__hst-padding-box,
477
+ .__hst-margin,
478
+ .__hst-margin-box,
479
+ .__hst-drop-shadow {
472
480
  border-radius: 4px;
473
481
  }
474
482
 
475
- .truncate {
483
+ .__hst-truncate {
476
484
  overflow: hidden;
477
485
  text-overflow: ellipsis;
478
486
  white-space: nowrap;
479
487
  }
480
488
 
481
- .drop-shadow {
489
+ .__hst-drop-shadow {
482
490
  width: 8rem;
483
491
  height: 8rem;
484
492
  background: white;
485
493
  margin-bottom: 0.5rem;
486
494
  }
487
495
 
488
- .dark .drop-shadow {
496
+ .__hst-drop-shadow {
489
497
  background: #4e4e57;
490
498
  }
491
499
 
492
- .border-radius {
500
+ .__hst-border-radius {
493
501
  width: 8rem;
494
502
  height: 8rem;
495
503
  background-color: rgb(113 113 122 / 0.5);
496
504
  }
497
505
 
498
- .border-width {
506
+ .__hst-border-width {
499
507
  width: 8rem;
500
508
  height: 8rem;
501
509
  border-color: rgb(113 113 122 / 0.5);
502
510
  background-color: rgb(113 113 122 / 0.1);
503
511
  }
504
512
 
505
- .width {
513
+ .__hst-width {
506
514
  background-color: rgb(113 113 122 / 0.1);
507
515
  }
508
516
 
509
- .width-box,
510
- .height {
517
+ .__hst-width-box,
518
+ .__hst-height {
511
519
  background-color: rgb(113 113 122 / 0.5);
512
520
  }
513
521
 
514
- .width-box {
522
+ .__hst-width-box {
515
523
  height: 5rem;
516
- }
517
- </style>`;
524
+ }`;