histoire 0.12.4 → 0.13.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/node/builtin-plugins/pinceau-tokens.d.ts +6 -0
- package/dist/node/builtin-plugins/pinceau-tokens.js +505 -0
- package/dist/node/collect/index.js +1 -0
- package/dist/node/index.d.ts +7 -0
- package/dist/node/util/vendors.d.ts +1 -0
- package/dist/node/util/vendors.js +7 -2
- package/dist/node/vite.js +20 -2
- package/package.json +8 -8
- package/src/node/builtin-plugins/pinceau-tokens.ts +521 -0
- package/src/node/collect/index.ts +1 -0
- package/src/node/index.ts +8 -0
- package/src/node/util/vendors.ts +9 -2
- package/src/node/vite.ts +22 -2
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import { getInjectedImport } from '../util/vendors.js';
|
|
2
|
+
import { join } from 'pathe';
|
|
3
|
+
export function pinceauTokens(options = {}) {
|
|
4
|
+
const themePath = join(process.cwd(), 'node_modules/.vite/pinceau/index.js');
|
|
5
|
+
async function generate(api) {
|
|
6
|
+
try {
|
|
7
|
+
await api.fs.ensureDir(api.pluginTempDir);
|
|
8
|
+
await api.fs.emptyDir(api.pluginTempDir);
|
|
9
|
+
api.moduleLoader.clearCache();
|
|
10
|
+
await api.fs.writeFile(api.path.resolve(api.pluginTempDir, 'style.css'), css);
|
|
11
|
+
const theme = await api.moduleLoader.loadModule(themePath);
|
|
12
|
+
const storyFile = api.path.resolve(api.pluginTempDir, 'Pinceau.story.js');
|
|
13
|
+
await api.fs.writeFile(storyFile, storyTemplate(theme));
|
|
14
|
+
api.addStoryFile(storyFile);
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
api.error(e.stack ?? e.message);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
name: 'builtin:pinceau-tokens',
|
|
22
|
+
config(config) {
|
|
23
|
+
// Add 'design-system' group
|
|
24
|
+
if (!config.tree) {
|
|
25
|
+
config.tree = {};
|
|
26
|
+
}
|
|
27
|
+
if (!config.tree.groups) {
|
|
28
|
+
config.tree.groups = [];
|
|
29
|
+
}
|
|
30
|
+
if (!config.tree.groups.some(g => g.id === 'design-system')) {
|
|
31
|
+
let index = 0;
|
|
32
|
+
// After 'top' group
|
|
33
|
+
const topIndex = config.tree.groups.findIndex(g => g.id === 'top');
|
|
34
|
+
if (topIndex > -1) {
|
|
35
|
+
index = topIndex + 1;
|
|
36
|
+
}
|
|
37
|
+
// Insert group
|
|
38
|
+
config.tree.groups.splice(index, 0, {
|
|
39
|
+
id: 'design-system',
|
|
40
|
+
title: 'Design System',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
onDev(api, onCleanup) {
|
|
45
|
+
const watcher = api.watcher.watch(themePath)
|
|
46
|
+
.on('change', () => generate(api))
|
|
47
|
+
.on('add', () => generate(api));
|
|
48
|
+
onCleanup(() => {
|
|
49
|
+
watcher.close();
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
async onBuild(api) {
|
|
53
|
+
await generate(api);
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const storyTemplate = (pinceauConfig) => {
|
|
58
|
+
pinceauConfig = pinceauConfig?.theme || pinceauConfig?.default?.theme || {};
|
|
59
|
+
return `import 'histoire-style'
|
|
60
|
+
import './style.css'
|
|
61
|
+
import { createApp, h, markRaw, ref } from ${getInjectedImport('@histoire/vendors/vue')}
|
|
62
|
+
import {
|
|
63
|
+
HstColorShades,
|
|
64
|
+
HstTokenList,
|
|
65
|
+
HstTokenGrid,
|
|
66
|
+
HstText,
|
|
67
|
+
HstTextarea,
|
|
68
|
+
HstNumber,
|
|
69
|
+
} from ${getInjectedImport('@histoire/controls')}
|
|
70
|
+
|
|
71
|
+
const config = markRaw(${JSON.stringify(pinceauConfig, null, 2)})
|
|
72
|
+
const search = ref('')
|
|
73
|
+
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')
|
|
74
|
+
const fontSize = ref(16)
|
|
75
|
+
const flattenTokens = (data, transformValue = (value) => (value?.value || value)) => {
|
|
76
|
+
const output = {}
|
|
77
|
+
function step(obj, prev) {
|
|
78
|
+
Object.keys(obj).forEach((key) => {
|
|
79
|
+
const value = obj[key]
|
|
80
|
+
const isarray = Array.isArray(value)
|
|
81
|
+
const type = Object.prototype.toString.call(value)
|
|
82
|
+
const isobject
|
|
83
|
+
= type === '[object Object]'
|
|
84
|
+
|| type === '[object Array]'
|
|
85
|
+
|
|
86
|
+
const newKey = prev ? prev + '.' + key : key
|
|
87
|
+
|
|
88
|
+
if (value.value && !output[newKey]) {
|
|
89
|
+
output[newKey] = transformValue(value)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!isarray && isobject && Object.keys(value).length) { return step(value, newKey) }
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
step(data)
|
|
96
|
+
return output
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function mountApp ({ el, state, onUnmount }, render) {
|
|
100
|
+
Object.assign(state, {
|
|
101
|
+
search,
|
|
102
|
+
sampleText,
|
|
103
|
+
fontSize,
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
const app = createApp({
|
|
107
|
+
render,
|
|
108
|
+
})
|
|
109
|
+
app.mount(el)
|
|
110
|
+
|
|
111
|
+
onUnmount(() => {
|
|
112
|
+
app.unmount()
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/*
|
|
117
|
+
media?: PinceauTokens
|
|
118
|
+
colors?: ScaleTokens
|
|
119
|
+
fonts?: PinceauTokens
|
|
120
|
+
fontWeights?: FontWeightTokens
|
|
121
|
+
fontSizes?: BreakpointsTokens
|
|
122
|
+
size?: BreakpointsTokens
|
|
123
|
+
space?: BreakpointsTokens
|
|
124
|
+
radii?: BreakpointsTokens
|
|
125
|
+
borders?: BreakpointsTokens
|
|
126
|
+
borderWidths?: BreakpointsTokens
|
|
127
|
+
borderStyles?: BreakpointsTokens
|
|
128
|
+
shadows?: BreakpointsTokens
|
|
129
|
+
opacity?: BreakpointsTokens
|
|
130
|
+
leads?: BreakpointsTokens
|
|
131
|
+
letterSpacings?: BreakpointsTokens
|
|
132
|
+
transitions?: PinceauTokens
|
|
133
|
+
zIndices?: PinceauTokens
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
export default {
|
|
137
|
+
id: 'pinceau',
|
|
138
|
+
title: 'Pinceau',
|
|
139
|
+
group: 'design-system',
|
|
140
|
+
icon: 'noto:paintbrush',
|
|
141
|
+
responsiveDisabled: true,
|
|
142
|
+
layout: { type: 'single', iframe: false },
|
|
143
|
+
variants: [
|
|
144
|
+
{
|
|
145
|
+
id: 'media-queries',
|
|
146
|
+
title: 'Media Queries',
|
|
147
|
+
icon: 'carbon:screen',
|
|
148
|
+
onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
|
|
149
|
+
tokens: flattenTokens(config.media),
|
|
150
|
+
getName: key => '@mq.' + key,
|
|
151
|
+
colSize: 180,
|
|
152
|
+
}, ({ token }) => h('div', {
|
|
153
|
+
class: '__hst-drop-shadow',
|
|
154
|
+
}))),
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: 'colors',
|
|
158
|
+
title: 'Colors',
|
|
159
|
+
icon: 'carbon:color-palette',
|
|
160
|
+
onMount: (api) => mountApp(api, () => Object.entries(config.colors).map(([key, shades]) => h(HstColorShades, {
|
|
161
|
+
key,
|
|
162
|
+
shades: shades.value ? { DEFAULT: shades.value } : flattenTokens(shades),
|
|
163
|
+
getName: shade => '{colors.' + key + '.' + shade + '}',
|
|
164
|
+
search: search.value,
|
|
165
|
+
}, ({ color}) => h('div', {
|
|
166
|
+
class: '__hst-shade',
|
|
167
|
+
style: {
|
|
168
|
+
backgroundColor: color,
|
|
169
|
+
},
|
|
170
|
+
})))),
|
|
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
|
+
// SPACES
|
|
180
|
+
{
|
|
181
|
+
id: 'Spaces',
|
|
182
|
+
title: 'Spaces',
|
|
183
|
+
icon: 'carbon:area',
|
|
184
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
185
|
+
tokens: flattenTokens(config.space),
|
|
186
|
+
getName: key => '{space.' + key + '}',
|
|
187
|
+
}, ({ token }) => h('div', {
|
|
188
|
+
class: '__hst-spaces',
|
|
189
|
+
style: {
|
|
190
|
+
padding: token.value,
|
|
191
|
+
},
|
|
192
|
+
}, [
|
|
193
|
+
h('div', {
|
|
194
|
+
class: '__hst-spaces-box',
|
|
195
|
+
}),
|
|
196
|
+
]))),
|
|
197
|
+
},
|
|
198
|
+
// SIZES
|
|
199
|
+
{
|
|
200
|
+
id: 'sizes',
|
|
201
|
+
title: 'Sizes',
|
|
202
|
+
icon: 'carbon:pan-horizontal',
|
|
203
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
204
|
+
tokens: flattenTokens(config.size),
|
|
205
|
+
getName: key => '{size.' + key + '}',
|
|
206
|
+
}, ({ token }) => h('div', {
|
|
207
|
+
class: '__hst-width',
|
|
208
|
+
}, [
|
|
209
|
+
h('div', {
|
|
210
|
+
class: '__hst-width-box',
|
|
211
|
+
style: {
|
|
212
|
+
width: token.value,
|
|
213
|
+
},
|
|
214
|
+
}),
|
|
215
|
+
]))),
|
|
216
|
+
},
|
|
217
|
+
// FONTSIZES
|
|
218
|
+
{
|
|
219
|
+
id: 'font-size',
|
|
220
|
+
title: 'Font Size',
|
|
221
|
+
icon: 'carbon:text-font',
|
|
222
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
223
|
+
tokens: flattenTokens(config.fontSizes),
|
|
224
|
+
getName: key => '{fontSizes.' + key + '}',
|
|
225
|
+
}, ({ token }) => h('div', {
|
|
226
|
+
class: '__hst-truncate',
|
|
227
|
+
style: {
|
|
228
|
+
fontSize: token.value,
|
|
229
|
+
},
|
|
230
|
+
}, sampleText.value))),
|
|
231
|
+
onMountControls: (api) => mountApp(api, () => [
|
|
232
|
+
h(HstTextarea, {
|
|
233
|
+
title: 'Sample text',
|
|
234
|
+
modelValue: sampleText.value,
|
|
235
|
+
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
236
|
+
rows: 5,
|
|
237
|
+
}),
|
|
238
|
+
]),
|
|
239
|
+
},
|
|
240
|
+
// FONTWEIGHTS
|
|
241
|
+
{
|
|
242
|
+
id: 'font-weight',
|
|
243
|
+
title: 'Font Weight',
|
|
244
|
+
icon: 'carbon:text-font',
|
|
245
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
246
|
+
tokens: flattenTokens(config.fontWeights),
|
|
247
|
+
getName: key => '{fontWeights.' + key + '}',
|
|
248
|
+
}, ({ token }) => h('div', {
|
|
249
|
+
class: '__hst-truncate',
|
|
250
|
+
style: {
|
|
251
|
+
fontWeight: token.value,
|
|
252
|
+
fontSize: \`\${fontSize.value}px\`,
|
|
253
|
+
},
|
|
254
|
+
}, sampleText.value))),
|
|
255
|
+
onMountControls: (api) => mountApp(api, () => [
|
|
256
|
+
h(HstTextarea, {
|
|
257
|
+
title: 'Sample text',
|
|
258
|
+
modelValue: sampleText.value,
|
|
259
|
+
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
260
|
+
rows: 5,
|
|
261
|
+
}),
|
|
262
|
+
h(HstNumber, {
|
|
263
|
+
title: 'Font size',
|
|
264
|
+
modelValue: fontSize.value,
|
|
265
|
+
'onUpdate:modelValue': value => { fontSize.value = value },
|
|
266
|
+
min: 1,
|
|
267
|
+
}),
|
|
268
|
+
]),
|
|
269
|
+
},
|
|
270
|
+
// FONTS
|
|
271
|
+
{
|
|
272
|
+
id: 'fonts',
|
|
273
|
+
title: 'Fonts',
|
|
274
|
+
icon: 'carbon:text-font',
|
|
275
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
276
|
+
tokens: flattenTokens(config.fonts),
|
|
277
|
+
getName: key => '{fonts.' + key + '}',
|
|
278
|
+
}, ({ token }) => h('div', {
|
|
279
|
+
class: '__hst-truncate',
|
|
280
|
+
style: {
|
|
281
|
+
fontFamily: token.value,
|
|
282
|
+
fontSize: \`\${fontSize.value}px\`,
|
|
283
|
+
},
|
|
284
|
+
}, sampleText.value))),
|
|
285
|
+
onMountControls: (api) => mountApp(api, () => [
|
|
286
|
+
h(HstTextarea, {
|
|
287
|
+
title: 'Sample text',
|
|
288
|
+
modelValue: sampleText.value,
|
|
289
|
+
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
290
|
+
rows: 5,
|
|
291
|
+
}),
|
|
292
|
+
h(HstNumber, {
|
|
293
|
+
title: 'Font size',
|
|
294
|
+
modelValue: fontSize.value,
|
|
295
|
+
'onUpdate:modelValue': value => { fontSize.value = value },
|
|
296
|
+
min: 1,
|
|
297
|
+
}),
|
|
298
|
+
]),
|
|
299
|
+
},
|
|
300
|
+
// LETTERSPACINGS
|
|
301
|
+
{
|
|
302
|
+
id: 'letter-spacing',
|
|
303
|
+
title: 'Letter Spacing',
|
|
304
|
+
icon: 'carbon:text-font',
|
|
305
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
306
|
+
tokens: flattenTokens(config.letterSpacings),
|
|
307
|
+
getName: key => '{letterSpacings.' + key + '}',
|
|
308
|
+
}, ({ token }) => h('div', {
|
|
309
|
+
class: '__hst-truncate',
|
|
310
|
+
style: {
|
|
311
|
+
letterSpacing: token.value,
|
|
312
|
+
fontSize: \`\${fontSize.value}px\`,
|
|
313
|
+
},
|
|
314
|
+
}, sampleText.value))),
|
|
315
|
+
onMountControls: (api) => mountApp(api, () => [
|
|
316
|
+
h(HstTextarea, {
|
|
317
|
+
title: 'Sample text',
|
|
318
|
+
modelValue: sampleText.value,
|
|
319
|
+
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
320
|
+
rows: 5,
|
|
321
|
+
}),
|
|
322
|
+
h(HstNumber, {
|
|
323
|
+
title: 'Font size',
|
|
324
|
+
modelValue: fontSize.value,
|
|
325
|
+
'onUpdate:modelValue': value => { fontSize.value = value },
|
|
326
|
+
min: 1,
|
|
327
|
+
}),
|
|
328
|
+
]),
|
|
329
|
+
},
|
|
330
|
+
// LEADS
|
|
331
|
+
{
|
|
332
|
+
id: 'leads',
|
|
333
|
+
title: 'Leads',
|
|
334
|
+
icon: 'carbon:text-font',
|
|
335
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
336
|
+
tokens: flattenTokens(config.leads),
|
|
337
|
+
getName: key => '{leads.' + key + '}',
|
|
338
|
+
}, ({ token }) => h('div', {
|
|
339
|
+
style: {
|
|
340
|
+
lineHeight: token.value,
|
|
341
|
+
},
|
|
342
|
+
}, sampleText.value))),
|
|
343
|
+
onMountControls: (api) => mountApp(api, () => [
|
|
344
|
+
h(HstTextarea, {
|
|
345
|
+
title: 'Sample text',
|
|
346
|
+
modelValue: sampleText.value,
|
|
347
|
+
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
348
|
+
rows: 5,
|
|
349
|
+
}),
|
|
350
|
+
// @TODO select font size
|
|
351
|
+
]),
|
|
352
|
+
},
|
|
353
|
+
// SHADOWS
|
|
354
|
+
{
|
|
355
|
+
id: 'shadows',
|
|
356
|
+
title: 'Shadows',
|
|
357
|
+
icon: 'carbon:shape-except',
|
|
358
|
+
onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
|
|
359
|
+
tokens: flattenTokens(config.shadows),
|
|
360
|
+
getName: key => '{shadows.' + key + '}',
|
|
361
|
+
colSize: 180,
|
|
362
|
+
}, ({ token }) => h('div', {
|
|
363
|
+
class: '__hst-drop-shadow',
|
|
364
|
+
style: 'box-shadow:' + token.value,
|
|
365
|
+
}))),
|
|
366
|
+
},
|
|
367
|
+
// OPACITIES
|
|
368
|
+
{
|
|
369
|
+
id: 'opacities',
|
|
370
|
+
title: 'Opacities',
|
|
371
|
+
icon: 'carbon:bring-forward',
|
|
372
|
+
onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
|
|
373
|
+
tokens: flattenTokens(config.opacity),
|
|
374
|
+
getName: key => '{opacity.' + key + '}',
|
|
375
|
+
colSize: 180,
|
|
376
|
+
}, ({ token }) => h('div', {
|
|
377
|
+
class: '__hst-drop-shadow',
|
|
378
|
+
style: 'opacity:' + token.value,
|
|
379
|
+
}))),
|
|
380
|
+
},
|
|
381
|
+
// RADII
|
|
382
|
+
{
|
|
383
|
+
id: 'border-radius',
|
|
384
|
+
title: 'Border Radius',
|
|
385
|
+
icon: 'carbon:condition-wait-point',
|
|
386
|
+
onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
|
|
387
|
+
tokens: flattenTokens(config.radii),
|
|
388
|
+
getName: key => '{radii.' + key + '}',
|
|
389
|
+
colSize: 180,
|
|
390
|
+
}, ({ token }) => h('div', {
|
|
391
|
+
class: '__hst-border-radius',
|
|
392
|
+
style: {
|
|
393
|
+
borderRadius: token.value,
|
|
394
|
+
},
|
|
395
|
+
}))),
|
|
396
|
+
},
|
|
397
|
+
// BORDERWIDTHS
|
|
398
|
+
{
|
|
399
|
+
id: 'border-width',
|
|
400
|
+
title: 'Border Width',
|
|
401
|
+
icon: 'carbon:checkbox',
|
|
402
|
+
onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
|
|
403
|
+
tokens: flattenTokens(config.borderWidths),
|
|
404
|
+
getName: key => '{borderWidths.' + key + '}',
|
|
405
|
+
colSize: 180,
|
|
406
|
+
}, ({ token }) => h('div', {
|
|
407
|
+
class: '__hst-border-width',
|
|
408
|
+
style: {
|
|
409
|
+
borderWidth: token.value,
|
|
410
|
+
},
|
|
411
|
+
}))),
|
|
412
|
+
},
|
|
413
|
+
// FULL CONFIG
|
|
414
|
+
{
|
|
415
|
+
id: 'full-config',
|
|
416
|
+
title: 'Full Config',
|
|
417
|
+
icon: 'carbon:code',
|
|
418
|
+
onMount: (api) => mountApp(api, () => h('pre', JSON.stringify(config, null, 2))),
|
|
419
|
+
},
|
|
420
|
+
],
|
|
421
|
+
}`;
|
|
422
|
+
};
|
|
423
|
+
const css = `.__hst-shade {
|
|
424
|
+
height: 80px;
|
|
425
|
+
border-radius: 4px;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.__hst-text {
|
|
429
|
+
font-size: 4rem;
|
|
430
|
+
display: flex;
|
|
431
|
+
align-items: flex-end;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
.__hst-border {
|
|
435
|
+
border-style: solid;
|
|
436
|
+
border-width: 2px;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
.__hst-spaces {
|
|
440
|
+
background-color: rgb(113 113 122 / 0.1);
|
|
441
|
+
width: min-content;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.__hst-margin {
|
|
445
|
+
border: dashed 1px rgb(113 113 122 / 0.5);
|
|
446
|
+
width: min-content;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.__hst-spaces-box,
|
|
450
|
+
.__hst-margin-box {
|
|
451
|
+
width: 5rem;
|
|
452
|
+
height: 5rem;
|
|
453
|
+
background-color: rgb(113 113 122 / 0.5);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.__hst-spaces,
|
|
457
|
+
.__hst-spaces-box,
|
|
458
|
+
.__hst-margin,
|
|
459
|
+
.__hst-margin-box,
|
|
460
|
+
.__hst-drop-shadow {
|
|
461
|
+
border-radius: 4px;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
.__hst-truncate {
|
|
465
|
+
overflow: hidden;
|
|
466
|
+
text-overflow: ellipsis;
|
|
467
|
+
white-space: nowrap;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
.__hst-drop-shadow {
|
|
471
|
+
width: 8rem;
|
|
472
|
+
height: 8rem;
|
|
473
|
+
background: white;
|
|
474
|
+
margin-bottom: 0.5rem;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
.__hst-drop-shadow {
|
|
478
|
+
background: #4e4e57;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
.__hst-border-radius {
|
|
482
|
+
width: 8rem;
|
|
483
|
+
height: 8rem;
|
|
484
|
+
background-color: rgb(113 113 122 / 0.5);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.__hst-border-width {
|
|
488
|
+
width: 8rem;
|
|
489
|
+
height: 8rem;
|
|
490
|
+
border-color: rgb(113 113 122 / 0.5);
|
|
491
|
+
background-color: rgb(113 113 122 / 0.1);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.__hst-width {
|
|
495
|
+
background-color: rgb(113 113 122 / 0.1);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.__hst-width-box,
|
|
499
|
+
.__hst-height {
|
|
500
|
+
background-color: rgb(113 113 122 / 0.5);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
.__hst-width-box {
|
|
504
|
+
height: 5rem;
|
|
505
|
+
}`;
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
// Resolve an absolute path to e.g. node_modules/.pnpm/histoire@0.11.7_vite@3.2.4/node_modules/histoire/dist/node/vendors/controls.js
|
|
4
|
+
// https://github.com/histoire-dev/histoire/issues/282
|
|
5
|
+
export const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
1
6
|
// https://github.com/vitejs/vite/issues/9661
|
|
2
7
|
const alias = {
|
|
3
|
-
'@histoire/vendors/vue': '
|
|
4
|
-
'@histoire/controls': '
|
|
8
|
+
'@histoire/vendors/vue': path.resolve(__dirname, '../vendors/vue.js'),
|
|
9
|
+
'@histoire/controls': path.resolve(__dirname, '../vendors/controls.js'),
|
|
5
10
|
};
|
|
6
11
|
export function getInjectedImport(request) {
|
|
7
12
|
let id = request;
|
package/dist/node/vite.js
CHANGED
|
@@ -110,6 +110,15 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
110
110
|
alias: {
|
|
111
111
|
'histoire-style': join(APP_PATH, process.env.HISTOIRE_DEV ? 'app/style/main.pcss' : 'style.css'),
|
|
112
112
|
},
|
|
113
|
+
...(isServer
|
|
114
|
+
? {
|
|
115
|
+
// Force resolving deps like Node.JS resolution algorithm (in case some modules are not loaded with ssr: true e.g. .vue files)
|
|
116
|
+
conditions: ['node'],
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
118
|
+
// @ts-ignore we support Vite ^3.0, but browserField is available in Vite ^3.2
|
|
119
|
+
browserField: false,
|
|
120
|
+
}
|
|
121
|
+
: {}),
|
|
113
122
|
},
|
|
114
123
|
optimizeDeps: {
|
|
115
124
|
entries: [
|
|
@@ -151,12 +160,21 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
|
|
|
151
160
|
__VUE_PROD_DEVTOOLS__: 'true',
|
|
152
161
|
// Disable warnings
|
|
153
162
|
'process.env.NODE_ENV': JSON.stringify(isServer ? 'production' : process.env.NODE_ENV ?? 'development'),
|
|
154
|
-
|
|
155
|
-
|
|
163
|
+
...!isServer
|
|
164
|
+
? {
|
|
165
|
+
// Collect flag
|
|
166
|
+
'process.env.HST_COLLECT': 'false',
|
|
167
|
+
}
|
|
168
|
+
: {},
|
|
156
169
|
},
|
|
157
170
|
cacheDir: isServer ? 'node_modules/.hst-vite-server' : 'node_modules/.hst-vite',
|
|
158
171
|
};
|
|
159
172
|
},
|
|
173
|
+
options() {
|
|
174
|
+
this.meta.histoire = {
|
|
175
|
+
isCollecting: isServer,
|
|
176
|
+
};
|
|
177
|
+
},
|
|
160
178
|
async resolveId(id, importer) {
|
|
161
179
|
if (id.startsWith(STORIES_ID)) {
|
|
162
180
|
return RESOLVED_STORIES_ID;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "histoire",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "A fast story book powered by Vite",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"histoire": "./bin.mjs"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@histoire/app": "^0.
|
|
37
|
-
"@histoire/controls": "^0.
|
|
38
|
-
"@histoire/shared": "^0.
|
|
39
|
-
"@histoire/vendors": "^0.
|
|
36
|
+
"@histoire/app": "^0.13.0",
|
|
37
|
+
"@histoire/controls": "^0.13.0",
|
|
38
|
+
"@histoire/shared": "^0.13.0",
|
|
39
|
+
"@histoire/vendors": "^0.13.0",
|
|
40
40
|
"@types/flexsearch": "^0.7.3",
|
|
41
41
|
"@types/markdown-it": "^12.2.3",
|
|
42
42
|
"birpc": "^0.1.1",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"shiki-es": "^0.1.2",
|
|
64
64
|
"sirv": "^2.0.2",
|
|
65
65
|
"tinypool": "^0.1.2",
|
|
66
|
-
"vite-node": "0.
|
|
66
|
+
"vite-node": "0.28.4"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"vite": "^2.9.0 || ^3.0.0 || ^4.0.0"
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"@types/micromatch": "^4.0.2",
|
|
77
77
|
"@types/node": "^17.0.32",
|
|
78
78
|
"rollup": "^3.5.1",
|
|
79
|
-
"typescript": "^4.
|
|
80
|
-
"vite": "^4.
|
|
79
|
+
"typescript": "^4.9.5",
|
|
80
|
+
"vite": "^4.1.0"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"build": "rimraf dist && tsc -d",
|
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
import type { Plugin, PluginApiBase } from '@histoire/shared'
|
|
2
|
+
import { getInjectedImport } from '../util/vendors.js'
|
|
3
|
+
import { findUp } from '../util/find-up.js'
|
|
4
|
+
import { join } from 'pathe'
|
|
5
|
+
|
|
6
|
+
export interface PinceauTokensOptions {
|
|
7
|
+
configOrPaths?: string | string[]
|
|
8
|
+
configFileName?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function pinceauTokens (options: PinceauTokensOptions = {}): Plugin {
|
|
12
|
+
const themePath = join(process.cwd(), 'node_modules/.vite/pinceau/index.js')
|
|
13
|
+
|
|
14
|
+
async function generate (api: PluginApiBase) {
|
|
15
|
+
try {
|
|
16
|
+
await api.fs.ensureDir(api.pluginTempDir)
|
|
17
|
+
await api.fs.emptyDir(api.pluginTempDir)
|
|
18
|
+
api.moduleLoader.clearCache()
|
|
19
|
+
await api.fs.writeFile(api.path.resolve(api.pluginTempDir, 'style.css'), css)
|
|
20
|
+
const theme = await api.moduleLoader.loadModule(themePath)
|
|
21
|
+
const storyFile = api.path.resolve(api.pluginTempDir, 'Pinceau.story.js')
|
|
22
|
+
await api.fs.writeFile(storyFile, storyTemplate(theme))
|
|
23
|
+
api.addStoryFile(storyFile)
|
|
24
|
+
} catch (e) {
|
|
25
|
+
api.error(e.stack ?? e.message)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
name: 'builtin:pinceau-tokens',
|
|
31
|
+
|
|
32
|
+
config (config) {
|
|
33
|
+
// Add 'design-system' group
|
|
34
|
+
if (!config.tree) {
|
|
35
|
+
config.tree = {}
|
|
36
|
+
}
|
|
37
|
+
if (!config.tree.groups) {
|
|
38
|
+
config.tree.groups = []
|
|
39
|
+
}
|
|
40
|
+
if (!config.tree.groups.some(g => g.id === 'design-system')) {
|
|
41
|
+
let index = 0
|
|
42
|
+
// After 'top' group
|
|
43
|
+
const topIndex = config.tree.groups.findIndex(g => g.id === 'top')
|
|
44
|
+
if (topIndex > -1) {
|
|
45
|
+
index = topIndex + 1
|
|
46
|
+
}
|
|
47
|
+
// Insert group
|
|
48
|
+
config.tree.groups.splice(index, 0, {
|
|
49
|
+
id: 'design-system',
|
|
50
|
+
title: 'Design System',
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
onDev (api, onCleanup) {
|
|
56
|
+
const watcher = api.watcher.watch(themePath)
|
|
57
|
+
.on('change', () => generate(api))
|
|
58
|
+
.on('add', () => generate(api))
|
|
59
|
+
|
|
60
|
+
onCleanup(() => {
|
|
61
|
+
watcher.close()
|
|
62
|
+
})
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
async onBuild (api) {
|
|
66
|
+
await generate(api)
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const storyTemplate = (pinceauConfig: any) => {
|
|
72
|
+
pinceauConfig = pinceauConfig?.theme || pinceauConfig?.default?.theme || {}
|
|
73
|
+
|
|
74
|
+
return `import 'histoire-style'
|
|
75
|
+
import './style.css'
|
|
76
|
+
import { createApp, h, markRaw, ref } from ${getInjectedImport('@histoire/vendors/vue')}
|
|
77
|
+
import {
|
|
78
|
+
HstColorShades,
|
|
79
|
+
HstTokenList,
|
|
80
|
+
HstTokenGrid,
|
|
81
|
+
HstText,
|
|
82
|
+
HstTextarea,
|
|
83
|
+
HstNumber,
|
|
84
|
+
} from ${getInjectedImport('@histoire/controls')}
|
|
85
|
+
|
|
86
|
+
const config = markRaw(${JSON.stringify(pinceauConfig, null, 2)})
|
|
87
|
+
const search = ref('')
|
|
88
|
+
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')
|
|
89
|
+
const fontSize = ref(16)
|
|
90
|
+
const flattenTokens = (data, transformValue = (value) => (value?.value || value)) => {
|
|
91
|
+
const output = {}
|
|
92
|
+
function step(obj, prev) {
|
|
93
|
+
Object.keys(obj).forEach((key) => {
|
|
94
|
+
const value = obj[key]
|
|
95
|
+
const isarray = Array.isArray(value)
|
|
96
|
+
const type = Object.prototype.toString.call(value)
|
|
97
|
+
const isobject
|
|
98
|
+
= type === '[object Object]'
|
|
99
|
+
|| type === '[object Array]'
|
|
100
|
+
|
|
101
|
+
const newKey = prev ? prev + '.' + key : key
|
|
102
|
+
|
|
103
|
+
if (value.value && !output[newKey]) {
|
|
104
|
+
output[newKey] = transformValue(value)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!isarray && isobject && Object.keys(value).length) { return step(value, newKey) }
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
step(data)
|
|
111
|
+
return output
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function mountApp ({ el, state, onUnmount }, render) {
|
|
115
|
+
Object.assign(state, {
|
|
116
|
+
search,
|
|
117
|
+
sampleText,
|
|
118
|
+
fontSize,
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
const app = createApp({
|
|
122
|
+
render,
|
|
123
|
+
})
|
|
124
|
+
app.mount(el)
|
|
125
|
+
|
|
126
|
+
onUnmount(() => {
|
|
127
|
+
app.unmount()
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/*
|
|
132
|
+
media?: PinceauTokens
|
|
133
|
+
colors?: ScaleTokens
|
|
134
|
+
fonts?: PinceauTokens
|
|
135
|
+
fontWeights?: FontWeightTokens
|
|
136
|
+
fontSizes?: BreakpointsTokens
|
|
137
|
+
size?: BreakpointsTokens
|
|
138
|
+
space?: BreakpointsTokens
|
|
139
|
+
radii?: BreakpointsTokens
|
|
140
|
+
borders?: BreakpointsTokens
|
|
141
|
+
borderWidths?: BreakpointsTokens
|
|
142
|
+
borderStyles?: BreakpointsTokens
|
|
143
|
+
shadows?: BreakpointsTokens
|
|
144
|
+
opacity?: BreakpointsTokens
|
|
145
|
+
leads?: BreakpointsTokens
|
|
146
|
+
letterSpacings?: BreakpointsTokens
|
|
147
|
+
transitions?: PinceauTokens
|
|
148
|
+
zIndices?: PinceauTokens
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
export default {
|
|
152
|
+
id: 'pinceau',
|
|
153
|
+
title: 'Pinceau',
|
|
154
|
+
group: 'design-system',
|
|
155
|
+
icon: 'noto:paintbrush',
|
|
156
|
+
responsiveDisabled: true,
|
|
157
|
+
layout: { type: 'single', iframe: false },
|
|
158
|
+
variants: [
|
|
159
|
+
{
|
|
160
|
+
id: 'media-queries',
|
|
161
|
+
title: 'Media Queries',
|
|
162
|
+
icon: 'carbon:screen',
|
|
163
|
+
onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
|
|
164
|
+
tokens: flattenTokens(config.media),
|
|
165
|
+
getName: key => '@mq.' + key,
|
|
166
|
+
colSize: 180,
|
|
167
|
+
}, ({ token }) => h('div', {
|
|
168
|
+
class: '__hst-drop-shadow',
|
|
169
|
+
}))),
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
id: 'colors',
|
|
173
|
+
title: 'Colors',
|
|
174
|
+
icon: 'carbon:color-palette',
|
|
175
|
+
onMount: (api) => mountApp(api, () => Object.entries(config.colors).map(([key, shades]) => h(HstColorShades, {
|
|
176
|
+
key,
|
|
177
|
+
shades: shades.value ? { DEFAULT: shades.value } : flattenTokens(shades),
|
|
178
|
+
getName: shade => '{colors.' + key + '.' + shade + '}',
|
|
179
|
+
search: search.value,
|
|
180
|
+
}, ({ color}) => h('div', {
|
|
181
|
+
class: '__hst-shade',
|
|
182
|
+
style: {
|
|
183
|
+
backgroundColor: color,
|
|
184
|
+
},
|
|
185
|
+
})))),
|
|
186
|
+
onMountControls: (api) => mountApp(api, () => [
|
|
187
|
+
h(HstText, {
|
|
188
|
+
title: 'Filter...',
|
|
189
|
+
modelValue: search.value,
|
|
190
|
+
'onUpdate:modelValue': value => { search.value = value },
|
|
191
|
+
}),
|
|
192
|
+
]),
|
|
193
|
+
},
|
|
194
|
+
// SPACES
|
|
195
|
+
{
|
|
196
|
+
id: 'Spaces',
|
|
197
|
+
title: 'Spaces',
|
|
198
|
+
icon: 'carbon:area',
|
|
199
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
200
|
+
tokens: flattenTokens(config.space),
|
|
201
|
+
getName: key => '{space.' + key + '}',
|
|
202
|
+
}, ({ token }) => h('div', {
|
|
203
|
+
class: '__hst-spaces',
|
|
204
|
+
style: {
|
|
205
|
+
padding: token.value,
|
|
206
|
+
},
|
|
207
|
+
}, [
|
|
208
|
+
h('div', {
|
|
209
|
+
class: '__hst-spaces-box',
|
|
210
|
+
}),
|
|
211
|
+
]))),
|
|
212
|
+
},
|
|
213
|
+
// SIZES
|
|
214
|
+
{
|
|
215
|
+
id: 'sizes',
|
|
216
|
+
title: 'Sizes',
|
|
217
|
+
icon: 'carbon:pan-horizontal',
|
|
218
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
219
|
+
tokens: flattenTokens(config.size),
|
|
220
|
+
getName: key => '{size.' + key + '}',
|
|
221
|
+
}, ({ token }) => h('div', {
|
|
222
|
+
class: '__hst-width',
|
|
223
|
+
}, [
|
|
224
|
+
h('div', {
|
|
225
|
+
class: '__hst-width-box',
|
|
226
|
+
style: {
|
|
227
|
+
width: token.value,
|
|
228
|
+
},
|
|
229
|
+
}),
|
|
230
|
+
]))),
|
|
231
|
+
},
|
|
232
|
+
// FONTSIZES
|
|
233
|
+
{
|
|
234
|
+
id: 'font-size',
|
|
235
|
+
title: 'Font Size',
|
|
236
|
+
icon: 'carbon:text-font',
|
|
237
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
238
|
+
tokens: flattenTokens(config.fontSizes),
|
|
239
|
+
getName: key => '{fontSizes.' + key + '}',
|
|
240
|
+
}, ({ token }) => h('div', {
|
|
241
|
+
class: '__hst-truncate',
|
|
242
|
+
style: {
|
|
243
|
+
fontSize: token.value,
|
|
244
|
+
},
|
|
245
|
+
}, sampleText.value))),
|
|
246
|
+
onMountControls: (api) => mountApp(api, () => [
|
|
247
|
+
h(HstTextarea, {
|
|
248
|
+
title: 'Sample text',
|
|
249
|
+
modelValue: sampleText.value,
|
|
250
|
+
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
251
|
+
rows: 5,
|
|
252
|
+
}),
|
|
253
|
+
]),
|
|
254
|
+
},
|
|
255
|
+
// FONTWEIGHTS
|
|
256
|
+
{
|
|
257
|
+
id: 'font-weight',
|
|
258
|
+
title: 'Font Weight',
|
|
259
|
+
icon: 'carbon:text-font',
|
|
260
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
261
|
+
tokens: flattenTokens(config.fontWeights),
|
|
262
|
+
getName: key => '{fontWeights.' + key + '}',
|
|
263
|
+
}, ({ token }) => h('div', {
|
|
264
|
+
class: '__hst-truncate',
|
|
265
|
+
style: {
|
|
266
|
+
fontWeight: token.value,
|
|
267
|
+
fontSize: \`\${fontSize.value}px\`,
|
|
268
|
+
},
|
|
269
|
+
}, sampleText.value))),
|
|
270
|
+
onMountControls: (api) => mountApp(api, () => [
|
|
271
|
+
h(HstTextarea, {
|
|
272
|
+
title: 'Sample text',
|
|
273
|
+
modelValue: sampleText.value,
|
|
274
|
+
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
275
|
+
rows: 5,
|
|
276
|
+
}),
|
|
277
|
+
h(HstNumber, {
|
|
278
|
+
title: 'Font size',
|
|
279
|
+
modelValue: fontSize.value,
|
|
280
|
+
'onUpdate:modelValue': value => { fontSize.value = value },
|
|
281
|
+
min: 1,
|
|
282
|
+
}),
|
|
283
|
+
]),
|
|
284
|
+
},
|
|
285
|
+
// FONTS
|
|
286
|
+
{
|
|
287
|
+
id: 'fonts',
|
|
288
|
+
title: 'Fonts',
|
|
289
|
+
icon: 'carbon:text-font',
|
|
290
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
291
|
+
tokens: flattenTokens(config.fonts),
|
|
292
|
+
getName: key => '{fonts.' + key + '}',
|
|
293
|
+
}, ({ token }) => h('div', {
|
|
294
|
+
class: '__hst-truncate',
|
|
295
|
+
style: {
|
|
296
|
+
fontFamily: token.value,
|
|
297
|
+
fontSize: \`\${fontSize.value}px\`,
|
|
298
|
+
},
|
|
299
|
+
}, sampleText.value))),
|
|
300
|
+
onMountControls: (api) => mountApp(api, () => [
|
|
301
|
+
h(HstTextarea, {
|
|
302
|
+
title: 'Sample text',
|
|
303
|
+
modelValue: sampleText.value,
|
|
304
|
+
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
305
|
+
rows: 5,
|
|
306
|
+
}),
|
|
307
|
+
h(HstNumber, {
|
|
308
|
+
title: 'Font size',
|
|
309
|
+
modelValue: fontSize.value,
|
|
310
|
+
'onUpdate:modelValue': value => { fontSize.value = value },
|
|
311
|
+
min: 1,
|
|
312
|
+
}),
|
|
313
|
+
]),
|
|
314
|
+
},
|
|
315
|
+
// LETTERSPACINGS
|
|
316
|
+
{
|
|
317
|
+
id: 'letter-spacing',
|
|
318
|
+
title: 'Letter Spacing',
|
|
319
|
+
icon: 'carbon:text-font',
|
|
320
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
321
|
+
tokens: flattenTokens(config.letterSpacings),
|
|
322
|
+
getName: key => '{letterSpacings.' + key + '}',
|
|
323
|
+
}, ({ token }) => h('div', {
|
|
324
|
+
class: '__hst-truncate',
|
|
325
|
+
style: {
|
|
326
|
+
letterSpacing: token.value,
|
|
327
|
+
fontSize: \`\${fontSize.value}px\`,
|
|
328
|
+
},
|
|
329
|
+
}, sampleText.value))),
|
|
330
|
+
onMountControls: (api) => mountApp(api, () => [
|
|
331
|
+
h(HstTextarea, {
|
|
332
|
+
title: 'Sample text',
|
|
333
|
+
modelValue: sampleText.value,
|
|
334
|
+
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
335
|
+
rows: 5,
|
|
336
|
+
}),
|
|
337
|
+
h(HstNumber, {
|
|
338
|
+
title: 'Font size',
|
|
339
|
+
modelValue: fontSize.value,
|
|
340
|
+
'onUpdate:modelValue': value => { fontSize.value = value },
|
|
341
|
+
min: 1,
|
|
342
|
+
}),
|
|
343
|
+
]),
|
|
344
|
+
},
|
|
345
|
+
// LEADS
|
|
346
|
+
{
|
|
347
|
+
id: 'leads',
|
|
348
|
+
title: 'Leads',
|
|
349
|
+
icon: 'carbon:text-font',
|
|
350
|
+
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
351
|
+
tokens: flattenTokens(config.leads),
|
|
352
|
+
getName: key => '{leads.' + key + '}',
|
|
353
|
+
}, ({ token }) => h('div', {
|
|
354
|
+
style: {
|
|
355
|
+
lineHeight: token.value,
|
|
356
|
+
},
|
|
357
|
+
}, sampleText.value))),
|
|
358
|
+
onMountControls: (api) => mountApp(api, () => [
|
|
359
|
+
h(HstTextarea, {
|
|
360
|
+
title: 'Sample text',
|
|
361
|
+
modelValue: sampleText.value,
|
|
362
|
+
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
363
|
+
rows: 5,
|
|
364
|
+
}),
|
|
365
|
+
// @TODO select font size
|
|
366
|
+
]),
|
|
367
|
+
},
|
|
368
|
+
// SHADOWS
|
|
369
|
+
{
|
|
370
|
+
id: 'shadows',
|
|
371
|
+
title: 'Shadows',
|
|
372
|
+
icon: 'carbon:shape-except',
|
|
373
|
+
onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
|
|
374
|
+
tokens: flattenTokens(config.shadows),
|
|
375
|
+
getName: key => '{shadows.' + key + '}',
|
|
376
|
+
colSize: 180,
|
|
377
|
+
}, ({ token }) => h('div', {
|
|
378
|
+
class: '__hst-drop-shadow',
|
|
379
|
+
style: 'box-shadow:' + token.value,
|
|
380
|
+
}))),
|
|
381
|
+
},
|
|
382
|
+
// OPACITIES
|
|
383
|
+
{
|
|
384
|
+
id: 'opacities',
|
|
385
|
+
title: 'Opacities',
|
|
386
|
+
icon: 'carbon:bring-forward',
|
|
387
|
+
onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
|
|
388
|
+
tokens: flattenTokens(config.opacity),
|
|
389
|
+
getName: key => '{opacity.' + key + '}',
|
|
390
|
+
colSize: 180,
|
|
391
|
+
}, ({ token }) => h('div', {
|
|
392
|
+
class: '__hst-drop-shadow',
|
|
393
|
+
style: 'opacity:' + token.value,
|
|
394
|
+
}))),
|
|
395
|
+
},
|
|
396
|
+
// RADII
|
|
397
|
+
{
|
|
398
|
+
id: 'border-radius',
|
|
399
|
+
title: 'Border Radius',
|
|
400
|
+
icon: 'carbon:condition-wait-point',
|
|
401
|
+
onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
|
|
402
|
+
tokens: flattenTokens(config.radii),
|
|
403
|
+
getName: key => '{radii.' + key + '}',
|
|
404
|
+
colSize: 180,
|
|
405
|
+
}, ({ token }) => h('div', {
|
|
406
|
+
class: '__hst-border-radius',
|
|
407
|
+
style: {
|
|
408
|
+
borderRadius: token.value,
|
|
409
|
+
},
|
|
410
|
+
}))),
|
|
411
|
+
},
|
|
412
|
+
// BORDERWIDTHS
|
|
413
|
+
{
|
|
414
|
+
id: 'border-width',
|
|
415
|
+
title: 'Border Width',
|
|
416
|
+
icon: 'carbon:checkbox',
|
|
417
|
+
onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
|
|
418
|
+
tokens: flattenTokens(config.borderWidths),
|
|
419
|
+
getName: key => '{borderWidths.' + key + '}',
|
|
420
|
+
colSize: 180,
|
|
421
|
+
}, ({ token }) => h('div', {
|
|
422
|
+
class: '__hst-border-width',
|
|
423
|
+
style: {
|
|
424
|
+
borderWidth: token.value,
|
|
425
|
+
},
|
|
426
|
+
}))),
|
|
427
|
+
},
|
|
428
|
+
// FULL CONFIG
|
|
429
|
+
{
|
|
430
|
+
id: 'full-config',
|
|
431
|
+
title: 'Full Config',
|
|
432
|
+
icon: 'carbon:code',
|
|
433
|
+
onMount: (api) => mountApp(api, () => h('pre', JSON.stringify(config, null, 2))),
|
|
434
|
+
},
|
|
435
|
+
],
|
|
436
|
+
}`
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const css = `.__hst-shade {
|
|
440
|
+
height: 80px;
|
|
441
|
+
border-radius: 4px;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.__hst-text {
|
|
445
|
+
font-size: 4rem;
|
|
446
|
+
display: flex;
|
|
447
|
+
align-items: flex-end;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
.__hst-border {
|
|
451
|
+
border-style: solid;
|
|
452
|
+
border-width: 2px;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.__hst-spaces {
|
|
456
|
+
background-color: rgb(113 113 122 / 0.1);
|
|
457
|
+
width: min-content;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.__hst-margin {
|
|
461
|
+
border: dashed 1px rgb(113 113 122 / 0.5);
|
|
462
|
+
width: min-content;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
.__hst-spaces-box,
|
|
466
|
+
.__hst-margin-box {
|
|
467
|
+
width: 5rem;
|
|
468
|
+
height: 5rem;
|
|
469
|
+
background-color: rgb(113 113 122 / 0.5);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.__hst-spaces,
|
|
473
|
+
.__hst-spaces-box,
|
|
474
|
+
.__hst-margin,
|
|
475
|
+
.__hst-margin-box,
|
|
476
|
+
.__hst-drop-shadow {
|
|
477
|
+
border-radius: 4px;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
.__hst-truncate {
|
|
481
|
+
overflow: hidden;
|
|
482
|
+
text-overflow: ellipsis;
|
|
483
|
+
white-space: nowrap;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
.__hst-drop-shadow {
|
|
487
|
+
width: 8rem;
|
|
488
|
+
height: 8rem;
|
|
489
|
+
background: white;
|
|
490
|
+
margin-bottom: 0.5rem;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.__hst-drop-shadow {
|
|
494
|
+
background: #4e4e57;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
.__hst-border-radius {
|
|
498
|
+
width: 8rem;
|
|
499
|
+
height: 8rem;
|
|
500
|
+
background-color: rgb(113 113 122 / 0.5);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
.__hst-border-width {
|
|
504
|
+
width: 8rem;
|
|
505
|
+
height: 8rem;
|
|
506
|
+
border-color: rgb(113 113 122 / 0.5);
|
|
507
|
+
background-color: rgb(113 113 122 / 0.1);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
.__hst-width {
|
|
511
|
+
background-color: rgb(113 113 122 / 0.1);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
.__hst-width-box,
|
|
515
|
+
.__hst-height {
|
|
516
|
+
background-color: rgb(113 113 122 / 0.5);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
.__hst-width-box {
|
|
520
|
+
height: 5rem;
|
|
521
|
+
}`
|
package/src/node/index.ts
CHANGED
package/src/node/util/vendors.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
|
|
4
|
+
// Resolve an absolute path to e.g. node_modules/.pnpm/histoire@0.11.7_vite@3.2.4/node_modules/histoire/dist/node/vendors/controls.js
|
|
5
|
+
// https://github.com/histoire-dev/histoire/issues/282
|
|
6
|
+
export const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
7
|
+
|
|
1
8
|
// https://github.com/vitejs/vite/issues/9661
|
|
2
9
|
const alias = {
|
|
3
|
-
'@histoire/vendors/vue': '
|
|
4
|
-
'@histoire/controls': '
|
|
10
|
+
'@histoire/vendors/vue': path.resolve(__dirname, '../vendors/vue.js'),
|
|
11
|
+
'@histoire/controls': path.resolve(__dirname, '../vendors/controls.js'),
|
|
5
12
|
}
|
|
6
13
|
|
|
7
14
|
export function getInjectedImport (request: string) {
|
package/src/node/vite.ts
CHANGED
|
@@ -134,6 +134,16 @@ export async function getViteConfigWithPlugins (isServer: boolean, ctx: Context)
|
|
|
134
134
|
alias: {
|
|
135
135
|
'histoire-style': join(APP_PATH, process.env.HISTOIRE_DEV ? 'app/style/main.pcss' : 'style.css'),
|
|
136
136
|
},
|
|
137
|
+
|
|
138
|
+
...(isServer
|
|
139
|
+
? {
|
|
140
|
+
// Force resolving deps like Node.JS resolution algorithm (in case some modules are not loaded with ssr: true e.g. .vue files)
|
|
141
|
+
conditions: ['node'],
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
143
|
+
// @ts-ignore we support Vite ^3.0, but browserField is available in Vite ^3.2
|
|
144
|
+
browserField: false,
|
|
145
|
+
}
|
|
146
|
+
: {}),
|
|
137
147
|
},
|
|
138
148
|
optimizeDeps: {
|
|
139
149
|
entries: [
|
|
@@ -175,13 +185,23 @@ export async function getViteConfigWithPlugins (isServer: boolean, ctx: Context)
|
|
|
175
185
|
__VUE_PROD_DEVTOOLS__: 'true',
|
|
176
186
|
// Disable warnings
|
|
177
187
|
'process.env.NODE_ENV': JSON.stringify(isServer ? 'production' : process.env.NODE_ENV ?? 'development'),
|
|
178
|
-
|
|
179
|
-
|
|
188
|
+
...!isServer
|
|
189
|
+
? {
|
|
190
|
+
// Collect flag
|
|
191
|
+
'process.env.HST_COLLECT': 'false',
|
|
192
|
+
}
|
|
193
|
+
: {},
|
|
180
194
|
},
|
|
181
195
|
cacheDir: isServer ? 'node_modules/.hst-vite-server' : 'node_modules/.hst-vite',
|
|
182
196
|
}
|
|
183
197
|
},
|
|
184
198
|
|
|
199
|
+
options () {
|
|
200
|
+
this.meta.histoire = {
|
|
201
|
+
isCollecting: isServer,
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
|
|
185
205
|
async resolveId (id, importer) {
|
|
186
206
|
if (id.startsWith(STORIES_ID)) {
|
|
187
207
|
return RESOLVED_STORIES_ID
|