histoire 0.9.0 → 0.9.3

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