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.
- package/dist/node/builtin-plugins/tailwind-tokens.js +390 -383
- package/dist/node/builtin-plugins/vanilla-support/MountStory.d.ts +14 -0
- package/dist/node/builtin-plugins/vanilla-support/MountStory.js +39 -0
- package/dist/node/builtin-plugins/vanilla-support/RenderStory.d.ts +38 -0
- package/dist/node/builtin-plugins/vanilla-support/RenderStory.js +131 -0
- package/dist/node/builtin-plugins/vanilla-support/client.d.ts +3 -0
- package/dist/node/builtin-plugins/vanilla-support/client.js +5 -0
- package/dist/node/builtin-plugins/vanilla-support/collect.d.ts +2 -0
- package/dist/node/builtin-plugins/vanilla-support/collect.js +33 -0
- package/dist/node/builtin-plugins/vanilla-support/plugin.d.ts +2 -0
- package/dist/node/builtin-plugins/vanilla-support/plugin.js +29 -0
- package/dist/node/builtin-plugins/vanilla-support/types.d.ts +35 -0
- package/dist/node/builtin-plugins/vanilla-support/types.js +3 -0
- package/dist/node/builtin-plugins/vanilla-support/vanilla.story.d.ts +3 -0
- package/dist/node/builtin-plugins/vanilla-support/vanilla.story.js +55 -0
- package/dist/node/config.js +2 -0
- package/dist/node/server.js +1 -1
- package/dist/node/vite.js +7 -11
- package/package.json +5 -5
- package/src/node/builtin-plugins/tailwind-tokens.ts +393 -383
- package/src/node/builtin-plugins/vanilla-support/MountStory.ts +50 -0
- package/src/node/builtin-plugins/vanilla-support/RenderStory.ts +166 -0
- package/src/node/builtin-plugins/vanilla-support/client.ts +6 -0
- package/src/node/builtin-plugins/vanilla-support/collect.ts +42 -0
- package/src/node/builtin-plugins/vanilla-support/plugin.ts +35 -0
- package/src/node/builtin-plugins/vanilla-support/types.ts +40 -0
- package/src/node/builtin-plugins/vanilla-support/vanilla.story.ts +63 -0
- package/src/node/config.ts +2 -0
- package/src/node/server.ts +2 -2
- package/src/node/vite.ts +7 -11
|
@@ -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.
|
|
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) =>
|
|
84
|
-
import '
|
|
85
|
-
import {
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
title
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
:
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
title
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
:
|
|
303
|
-
:
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
:
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
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
|
-
.
|
|
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
|
+
}`
|