histoire 0.2.3 → 0.3.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/client/app/App.vue +9 -4
- package/dist/client/app/codegen/const.d.ts +1 -0
- package/dist/client/app/codegen/const.js +3 -0
- package/dist/client/app/codegen/vue3.js +82 -21
- package/dist/client/app/components/app/AppHeader.vue +2 -2
- package/dist/client/app/components/app/Breadcrumb.vue +1 -1
- package/dist/client/app/components/base/BaseEmpty.vue +17 -1
- package/dist/client/app/components/base/BaseListItemLink.vue +1 -1
- package/dist/client/app/components/base/BaseTab.vue +1 -1
- package/dist/client/app/components/exposed/Story.vue +22 -1
- package/dist/client/app/components/exposed/Variant.vue +13 -1
- package/dist/client/app/components/sandbox/SandboxVue3.vue +6 -4
- package/dist/client/app/components/sandbox/lib.js +2 -1
- package/dist/client/app/components/search/SearchItem.vue +1 -0
- package/dist/client/app/components/search/SearchLoading.vue +16 -0
- package/dist/client/app/components/search/SearchModal.vue +12 -148
- package/dist/client/app/components/search/SearchPane.vue +210 -0
- package/dist/client/app/components/search/search-data.d.ts +2 -0
- package/dist/client/app/components/search/search-data.js +7 -0
- package/dist/client/app/components/story/StoryControls.vue +5 -0
- package/dist/client/app/components/story/StoryDocs.vue +18 -11
- package/dist/client/app/components/story/StoryEvent.vue +53 -0
- package/dist/client/app/components/story/StoryEvents.vue +45 -0
- package/dist/client/app/components/story/StoryResponsivePreview.vue +41 -8
- package/dist/client/app/components/story/StorySidePanel.vue +28 -3
- package/dist/client/app/components/story/StorySourceCode.vue +24 -14
- package/dist/client/app/components/story/StoryView.vue +16 -2
- package/dist/client/app/components/story/toolbar/StoryVariantNewTab.vue +1 -1
- package/dist/client/app/components/tree/StoryGroup.vue +75 -0
- package/dist/client/app/components/{story → tree}/StoryList.vue +8 -2
- package/{src/client/app/components/story → dist/client/app/components/tree}/StoryListFolder.vue +10 -8
- package/{src/client/app/components/story → dist/client/app/components/tree}/StoryListItem.vue +7 -4
- package/dist/client/app/router.d.ts +1 -0
- package/dist/client/app/router.js +3 -1
- package/dist/client/app/sandbox.js +11 -1
- package/dist/client/app/stores/events.d.ts +29 -0
- package/dist/client/app/stores/events.js +25 -0
- package/dist/client/app/stores/folder.d.ts +10 -0
- package/dist/client/app/stores/folder.js +47 -0
- package/dist/client/app/stores/story.d.ts +20 -8
- package/dist/client/app/stores/story.js +20 -28
- package/dist/client/app/style/floating-vue.pcss +3 -1
- package/dist/client/app/style/main.pcss +5 -0
- package/dist/client/app/style/sandbox.css +2 -0
- package/dist/client/app/types.d.ts +9 -1
- package/dist/client/app/util/const.d.ts +1 -0
- package/dist/client/app/util/const.js +1 -0
- package/dist/client/app/util/events.d.ts +1 -0
- package/dist/client/app/util/events.js +31 -0
- package/dist/client/app/util/mapping.js +2 -2
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.js +2 -1
- package/dist/client/server/Story.server.vue +21 -4
- package/dist/node/alias.d.ts +2 -1
- package/dist/node/alias.js +3 -2
- package/dist/node/build.js +74 -21
- package/dist/node/builtin-plugins/tailwind-tokens.d.ts +5 -0
- package/dist/node/builtin-plugins/tailwind-tokens.js +510 -0
- package/dist/node/collect/index.js +5 -3
- package/dist/node/commands/preview.js +4 -25
- package/dist/node/config.d.ts +111 -5
- package/dist/node/config.js +40 -23
- package/dist/node/context.d.ts +3 -3
- package/dist/node/context.js +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/load.d.ts +12 -0
- package/dist/node/load.js +42 -0
- package/dist/node/plugin.d.ts +67 -11
- package/dist/node/plugin.js +42 -245
- package/dist/node/preview.d.ts +8 -0
- package/dist/node/preview.js +41 -0
- package/dist/node/search.d.ts +2 -0
- package/dist/node/search.js +68 -0
- package/dist/node/server.js +43 -21
- package/dist/node/stories.d.ts +2 -0
- package/dist/node/stories.js +9 -4
- package/dist/node/tree.d.ts +16 -12
- package/dist/node/tree.js +45 -5
- package/dist/node/types.d.ts +11 -0
- package/dist/node/util/find-up.d.ts +1 -0
- package/dist/node/util/find-up.js +20 -0
- package/dist/node/vite.d.ts +13 -0
- package/dist/node/vite.js +278 -0
- package/dist/style.css +179 -36
- package/package.json +5 -3
- package/scripts/copy.mjs +2 -1
- package/src/client/app/App.vue +9 -4
- package/src/client/app/codegen/const.ts +3 -0
- package/src/client/app/codegen/vue3.ts +80 -22
- package/src/client/app/components/app/AppHeader.vue +2 -2
- package/src/client/app/components/app/Breadcrumb.vue +1 -1
- package/src/client/app/components/base/BaseEmpty.vue +17 -1
- package/src/client/app/components/base/BaseListItemLink.vue +1 -1
- package/src/client/app/components/base/BaseTab.vue +1 -1
- package/src/client/app/components/exposed/Story.vue +22 -1
- package/src/client/app/components/exposed/Variant.vue +13 -1
- package/src/client/app/components/sandbox/SandboxVue3.vue +6 -4
- package/src/client/app/components/sandbox/lib.ts +3 -1
- package/src/client/app/components/search/SearchItem.vue +1 -0
- package/src/client/app/components/search/SearchLoading.vue +16 -0
- package/src/client/app/components/search/SearchModal.vue +12 -148
- package/src/client/app/components/search/SearchPane.vue +210 -0
- package/src/client/app/components/search/search-data.ts +9 -0
- package/src/client/app/components/story/StoryControls.vue +5 -0
- package/src/client/app/components/story/StoryDocs.vue +18 -11
- package/src/client/app/components/story/StoryEvent.vue +53 -0
- package/src/client/app/components/story/StoryEvents.vue +45 -0
- package/src/client/app/components/story/StoryResponsivePreview.vue +41 -8
- package/src/client/app/components/story/StorySidePanel.vue +28 -3
- package/src/client/app/components/story/StorySourceCode.vue +24 -14
- package/src/client/app/components/story/StoryView.vue +16 -2
- package/src/client/app/components/story/toolbar/StoryVariantNewTab.vue +1 -1
- package/src/client/app/components/tree/StoryGroup.vue +75 -0
- package/src/client/app/components/{story → tree}/StoryList.vue +8 -2
- package/{dist/client/app/components/story → src/client/app/components/tree}/StoryListFolder.vue +10 -8
- package/{dist/client/app/components/story → src/client/app/components/tree}/StoryListItem.vue +7 -4
- package/src/client/app/router.ts +4 -1
- package/src/client/app/sandbox.ts +12 -2
- package/src/client/app/stores/events.ts +36 -0
- package/src/client/app/stores/folder.ts +59 -0
- package/src/client/app/stores/story.ts +20 -35
- package/src/client/app/style/floating-vue.pcss +3 -1
- package/src/client/app/style/main.pcss +5 -0
- package/src/client/app/style/sandbox.css +2 -0
- package/src/client/app/types.ts +10 -1
- package/src/client/app/util/const.ts +1 -0
- package/src/client/app/util/events.ts +30 -0
- package/src/client/app/util/mapping.ts +2 -2
- package/src/client/index.ts +2 -1
- package/src/client/server/Story.server.vue +21 -4
- package/src/node/alias.ts +4 -2
- package/src/node/build.ts +86 -21
- package/src/node/builtin-plugins/tailwind-tokens.ts +521 -0
- package/src/node/collect/index.ts +6 -4
- package/src/node/commands/preview.ts +4 -33
- package/src/node/config.ts +62 -29
- package/src/node/context.ts +3 -3
- package/src/node/index.ts +1 -0
- package/src/node/load.ts +63 -0
- package/src/node/plugin.ts +75 -252
- package/src/node/preview.ts +56 -0
- package/src/node/search.ts +75 -0
- package/src/node/server.ts +49 -23
- package/src/node/stories.ts +9 -4
- package/src/node/tree.spec.ts +35 -17
- package/src/node/tree.ts +64 -10
- package/src/node/types.ts +12 -0
- package/src/node/util/find-up.ts +24 -0
- package/src/node/vite.ts +296 -0
- package/tailwind.config.cjs +1 -0
- package/tsconfig.json +2 -0
- package/dist/client/app/codegen/serialize-js.ts +0 -119
- package/dist/client/app/codegen/util.ts +0 -79
- package/dist/client/app/codegen/vue3.ts +0 -276
- package/dist/client/app/components/sandbox/lib.ts +0 -8
- package/dist/client/app/global-components.ts +0 -13
- package/dist/client/app/index.ts +0 -28
- package/dist/client/app/router.ts +0 -17
- package/dist/client/app/sandbox.ts +0 -94
- package/dist/client/app/stores/preview-settings.ts +0 -17
- package/dist/client/app/stores/story.ts +0 -62
- package/dist/client/app/types.ts +0 -70
- package/dist/client/app/util/config.ts +0 -6
- package/dist/client/app/util/const.ts +0 -3
- package/dist/client/app/util/dark.ts +0 -4
- package/dist/client/app/util/env.ts +0 -1
- package/dist/client/app/util/keyboard.ts +0 -99
- package/dist/client/app/util/mapping.ts +0 -48
- package/dist/client/app/util/preview-settings.ts +0 -8
- package/dist/client/app/util/reactivity.ts +0 -22
- package/dist/client/app/util/responsive.ts +0 -3
- package/dist/client/app/util/scroll.ts +0 -31
- package/dist/client/app/util/tooltip.ts +0 -13
- package/dist/client/app/util/variant.ts +0 -20
- package/dist/client/index.ts +0 -12
- package/dist/client/server/index.ts +0 -32
- package/dist/client/shim.d.ts +0 -5
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
import { BasePluginApi, Plugin } from '../plugin.js'
|
|
2
|
+
import { findUp } from '../util/find-up.js'
|
|
3
|
+
|
|
4
|
+
export interface TailwindTokensOptions {
|
|
5
|
+
configFile?: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function tailwindTokens (options: TailwindTokensOptions = {}): Plugin {
|
|
9
|
+
const tailwindConfigFile = options.configFile ?? findUp(process.cwd(), [
|
|
10
|
+
'tailwind.config.js',
|
|
11
|
+
'tailwind.config.cjs',
|
|
12
|
+
'tailwind.config.mjs',
|
|
13
|
+
'tailwind.config.ts',
|
|
14
|
+
'tailwind-config.js',
|
|
15
|
+
'tailwind-config.cjs',
|
|
16
|
+
'tailwind-config.mjs',
|
|
17
|
+
'tailwind-config.ts',
|
|
18
|
+
])
|
|
19
|
+
|
|
20
|
+
async function generate (api: BasePluginApi) {
|
|
21
|
+
try {
|
|
22
|
+
await api.fs.ensureDir(api.pluginTempDir)
|
|
23
|
+
await api.fs.emptyDir(api.pluginTempDir)
|
|
24
|
+
api.moduleLoader.clearCache()
|
|
25
|
+
const tailwindConfig = await api.moduleLoader.loadModule(tailwindConfigFile)
|
|
26
|
+
const { default: resolveConfig } = await import('tailwindcss/resolveConfig.js')
|
|
27
|
+
const resolvedTailwindConfig = resolveConfig(tailwindConfig)
|
|
28
|
+
const storyFile = api.path.resolve(api.pluginTempDir, 'Tailwind.story.vue')
|
|
29
|
+
await api.fs.writeFile(storyFile, storyTemplate(resolvedTailwindConfig))
|
|
30
|
+
api.addStoryFile(storyFile)
|
|
31
|
+
} catch (e) {
|
|
32
|
+
api.error(e.stack ?? e.message)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
name: 'tailwind-tokens',
|
|
38
|
+
|
|
39
|
+
config (config) {
|
|
40
|
+
if (tailwindConfigFile) {
|
|
41
|
+
// Add 'design-system' group
|
|
42
|
+
if (!config.tree) {
|
|
43
|
+
config.tree = {}
|
|
44
|
+
}
|
|
45
|
+
if (!config.tree.groups) {
|
|
46
|
+
config.tree.groups = []
|
|
47
|
+
}
|
|
48
|
+
if (!config.tree.groups.some(g => g.id === 'design-system')) {
|
|
49
|
+
let index = 0
|
|
50
|
+
// After 'top' group
|
|
51
|
+
const topIndex = config.tree.groups.findIndex(g => g.id === 'top')
|
|
52
|
+
if (topIndex > -1) {
|
|
53
|
+
index = topIndex + 1
|
|
54
|
+
}
|
|
55
|
+
// Insert group
|
|
56
|
+
config.tree.groups.splice(index, 0, {
|
|
57
|
+
id: 'design-system',
|
|
58
|
+
title: 'Design System',
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
onDev (api, onCleanup) {
|
|
65
|
+
if (tailwindConfigFile) {
|
|
66
|
+
const watcher = api.watcher.watch(tailwindConfigFile)
|
|
67
|
+
.on('change', () => generate(api))
|
|
68
|
+
.on('add', () => generate(api))
|
|
69
|
+
onCleanup(() => {
|
|
70
|
+
watcher.close()
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
async onBuild (api) {
|
|
76
|
+
if (tailwindConfigFile) {
|
|
77
|
+
await generate(api)
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const storyTemplate = (tailwindConfig: any) => `<script setup>
|
|
84
|
+
import 'histoire/dist/style.css'
|
|
85
|
+
import { ref } from 'vue'
|
|
86
|
+
const config = ${JSON.stringify(tailwindConfig, 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
|
+
defineExpose({
|
|
91
|
+
search,
|
|
92
|
+
sampleText,
|
|
93
|
+
fontSize,
|
|
94
|
+
})
|
|
95
|
+
</script>
|
|
96
|
+
<template>
|
|
97
|
+
<Story id="tailwind" title="Tailwind" group="design-system" icon="mdi:tailwind" responsiveDisabled>
|
|
98
|
+
<Variant id="background-color" title="Background Color" icon="carbon:color-palette">
|
|
99
|
+
<HstColorShades
|
|
100
|
+
v-for="(shades, key) of config.theme.backgroundColor"
|
|
101
|
+
:key="key"
|
|
102
|
+
:shades="typeof shades === 'object' ? shades : { DEFAULT: shades }"
|
|
103
|
+
:get-name="shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`bg-\${key}\` : \`bg-\${key}-\${shade}\`)"
|
|
104
|
+
:search="search"
|
|
105
|
+
>
|
|
106
|
+
<template #default="{ color }">
|
|
107
|
+
<div
|
|
108
|
+
class="shade"
|
|
109
|
+
:style="{
|
|
110
|
+
backgroundColor: color,
|
|
111
|
+
}"
|
|
112
|
+
/>
|
|
113
|
+
</template>
|
|
114
|
+
</HstColorShades>
|
|
115
|
+
<template #controls>
|
|
116
|
+
<HstText
|
|
117
|
+
v-model="search"
|
|
118
|
+
title="Filter..."
|
|
119
|
+
/>
|
|
120
|
+
</template>
|
|
121
|
+
</Variant>
|
|
122
|
+
<Variant id="text-color" title="Text Color" icon="carbon:text-color">
|
|
123
|
+
<HstColorShades
|
|
124
|
+
v-for="(shades, key) of config.theme.textColor"
|
|
125
|
+
:key="key"
|
|
126
|
+
:shades="typeof shades === 'object' ? shades : { DEFAULT: shades }"
|
|
127
|
+
:get-name="shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`text-\${key}\` : \`text-\${key}-\${shade}\`)"
|
|
128
|
+
:search="search"
|
|
129
|
+
>
|
|
130
|
+
<template #default="{ color }">
|
|
131
|
+
<div
|
|
132
|
+
class="shade text"
|
|
133
|
+
:style="{
|
|
134
|
+
color: color,
|
|
135
|
+
}"
|
|
136
|
+
>
|
|
137
|
+
Aa
|
|
138
|
+
</div>
|
|
139
|
+
</template>
|
|
140
|
+
</HstColorShades>
|
|
141
|
+
<template #controls>
|
|
142
|
+
<HstText
|
|
143
|
+
v-model="search"
|
|
144
|
+
title="Filter..."
|
|
145
|
+
/>
|
|
146
|
+
</template>
|
|
147
|
+
</Variant>
|
|
148
|
+
<Variant id="border-color" title="Border Color" icon="carbon:color-palette">
|
|
149
|
+
<HstColorShades
|
|
150
|
+
v-for="(shades, key) of config.theme.borderColor"
|
|
151
|
+
:key="key"
|
|
152
|
+
:shades="typeof shades === 'object' ? shades : { DEFAULT: shades }"
|
|
153
|
+
:get-name="shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`border-\${key}\` : \`border-\${key}-\${shade}\`)"
|
|
154
|
+
:search="search"
|
|
155
|
+
>
|
|
156
|
+
<template #default="{ color }">
|
|
157
|
+
<div
|
|
158
|
+
class="shade border"
|
|
159
|
+
:style="{
|
|
160
|
+
borderColor: color,
|
|
161
|
+
}"
|
|
162
|
+
/>
|
|
163
|
+
</template>
|
|
164
|
+
</HstColorShades>
|
|
165
|
+
<template #controls>
|
|
166
|
+
<HstText
|
|
167
|
+
v-model="search"
|
|
168
|
+
title="Filter..."
|
|
169
|
+
/>
|
|
170
|
+
</template>
|
|
171
|
+
</Variant>
|
|
172
|
+
<Variant id="padding" title="Padding" icon="carbon:area">
|
|
173
|
+
<HstTokenList
|
|
174
|
+
:tokens="config.theme.padding"
|
|
175
|
+
:get-name="key => \`\${config.prefix ?? ''}p-\${key}\`"
|
|
176
|
+
>
|
|
177
|
+
<template #default="{ token }">
|
|
178
|
+
<div class="padding"
|
|
179
|
+
:style="{
|
|
180
|
+
padding: token.value,
|
|
181
|
+
}"
|
|
182
|
+
>
|
|
183
|
+
<div
|
|
184
|
+
class="padding-box"
|
|
185
|
+
/>
|
|
186
|
+
</div>
|
|
187
|
+
</template>
|
|
188
|
+
</HstTokenList>
|
|
189
|
+
</Variant>
|
|
190
|
+
<Variant id="margin" title="Margin" icon="carbon:area">
|
|
191
|
+
<HstTokenList
|
|
192
|
+
:tokens="config.theme.margin"
|
|
193
|
+
:get-name="key => \`\${config.prefix ?? ''}m-\${key}\`"
|
|
194
|
+
>
|
|
195
|
+
<template #default="{ token }">
|
|
196
|
+
<div class="margin"
|
|
197
|
+
:style="{
|
|
198
|
+
padding: token.value,
|
|
199
|
+
}"
|
|
200
|
+
>
|
|
201
|
+
<div
|
|
202
|
+
class="margin-box"
|
|
203
|
+
/>
|
|
204
|
+
</div>
|
|
205
|
+
</template>
|
|
206
|
+
</HstTokenList>
|
|
207
|
+
</Variant>
|
|
208
|
+
<Variant id="font-size" title="Font Size" icon="carbon:text-font">
|
|
209
|
+
<HstTokenList
|
|
210
|
+
:tokens="config.theme.fontSize"
|
|
211
|
+
:get-name="key => \`\${config.prefix ?? ''}text-\${key}\`"
|
|
212
|
+
>
|
|
213
|
+
<template #default="{ token }">
|
|
214
|
+
<div
|
|
215
|
+
class="truncate"
|
|
216
|
+
:style="{
|
|
217
|
+
fontSize: token.value[0],
|
|
218
|
+
...token.value[1],
|
|
219
|
+
}"
|
|
220
|
+
>
|
|
221
|
+
{{ sampleText }}
|
|
222
|
+
</div>
|
|
223
|
+
</template>
|
|
224
|
+
</HstTokenList>
|
|
225
|
+
<template #controls>
|
|
226
|
+
<HstTextarea
|
|
227
|
+
v-model="sampleText"
|
|
228
|
+
title="Sample text"
|
|
229
|
+
rows="5"
|
|
230
|
+
/>
|
|
231
|
+
</template>
|
|
232
|
+
</Variant>
|
|
233
|
+
<Variant id="font-weight" title="Font Weight" icon="carbon:text-font">
|
|
234
|
+
<HstTokenList
|
|
235
|
+
:tokens="config.theme.fontWeight"
|
|
236
|
+
:get-name="key => \`\${config.prefix ?? ''}font-\${key}\`"
|
|
237
|
+
>
|
|
238
|
+
<template #default="{ token }">
|
|
239
|
+
<div
|
|
240
|
+
class="truncate"
|
|
241
|
+
:style="{
|
|
242
|
+
fontWeight: token.value,
|
|
243
|
+
fontSize: \`\${fontSize}px\`,
|
|
244
|
+
}"
|
|
245
|
+
>
|
|
246
|
+
{{ sampleText }}
|
|
247
|
+
</div>
|
|
248
|
+
</template>
|
|
249
|
+
</HstTokenList>
|
|
250
|
+
<template #controls>
|
|
251
|
+
<HstTextarea
|
|
252
|
+
v-model="sampleText"
|
|
253
|
+
title="Sample text"
|
|
254
|
+
rows="5"
|
|
255
|
+
/>
|
|
256
|
+
<HstNumber
|
|
257
|
+
v-model="fontSize"
|
|
258
|
+
title="Font size"
|
|
259
|
+
min="1"
|
|
260
|
+
/>
|
|
261
|
+
</template>
|
|
262
|
+
</Variant>
|
|
263
|
+
<Variant id="font-family" title="Font Family" icon="carbon:text-font">
|
|
264
|
+
<HstTokenList
|
|
265
|
+
:tokens="config.theme.fontFamily"
|
|
266
|
+
:get-name="key => \`\${config.prefix ?? ''}font-\${key}\`"
|
|
267
|
+
>
|
|
268
|
+
<template #default="{ token }">
|
|
269
|
+
<div
|
|
270
|
+
class="truncate"
|
|
271
|
+
:style="{
|
|
272
|
+
fontFamily: token.value,
|
|
273
|
+
fontSize: \`\${fontSize}px\`,
|
|
274
|
+
}"
|
|
275
|
+
>
|
|
276
|
+
{{ sampleText }}
|
|
277
|
+
</div>
|
|
278
|
+
</template>
|
|
279
|
+
</HstTokenList>
|
|
280
|
+
<template #controls>
|
|
281
|
+
<HstTextarea
|
|
282
|
+
v-model="sampleText"
|
|
283
|
+
title="Sample text"
|
|
284
|
+
rows="5"
|
|
285
|
+
/>
|
|
286
|
+
<HstNumber
|
|
287
|
+
v-model="fontSize"
|
|
288
|
+
title="Font size"
|
|
289
|
+
min="1"
|
|
290
|
+
/>
|
|
291
|
+
</template>
|
|
292
|
+
</Variant>
|
|
293
|
+
<Variant id="letter-spacing" title="Letter Spacing" icon="carbon:text-font">
|
|
294
|
+
<HstTokenList
|
|
295
|
+
:tokens="config.theme.letterSpacing"
|
|
296
|
+
:get-name="key => \`\${config.prefix ?? ''}tracking-\${key}\`"
|
|
297
|
+
>
|
|
298
|
+
<template #default="{ token }">
|
|
299
|
+
<div
|
|
300
|
+
class="truncate"
|
|
301
|
+
:style="{
|
|
302
|
+
letterSpacing: token.value,
|
|
303
|
+
fontSize: \`\${fontSize}px\`,
|
|
304
|
+
}"
|
|
305
|
+
>
|
|
306
|
+
{{ sampleText }}
|
|
307
|
+
</div>
|
|
308
|
+
</template>
|
|
309
|
+
</HstTokenList>
|
|
310
|
+
<template #controls>
|
|
311
|
+
<HstTextarea
|
|
312
|
+
v-model="sampleText"
|
|
313
|
+
title="Sample text"
|
|
314
|
+
rows="5"
|
|
315
|
+
/>
|
|
316
|
+
<HstNumber
|
|
317
|
+
v-model="fontSize"
|
|
318
|
+
title="Font size"
|
|
319
|
+
min="1"
|
|
320
|
+
/>
|
|
321
|
+
</template>
|
|
322
|
+
</Variant>
|
|
323
|
+
<Variant id="line-height" title="Line Height" icon="carbon:text-font">
|
|
324
|
+
<HstTokenList
|
|
325
|
+
:tokens="config.theme.lineHeight"
|
|
326
|
+
:get-name="key => \`\${config.prefix ?? ''}leading-\${key}\`"
|
|
327
|
+
>
|
|
328
|
+
<template #default="{ token }">
|
|
329
|
+
<div
|
|
330
|
+
:style="{
|
|
331
|
+
lineHeight: token.value,
|
|
332
|
+
fontSize: \`\${fontSize}px\`,
|
|
333
|
+
}"
|
|
334
|
+
>
|
|
335
|
+
{{ sampleText }}
|
|
336
|
+
</div>
|
|
337
|
+
</template>
|
|
338
|
+
</HstTokenList>
|
|
339
|
+
<template #controls>
|
|
340
|
+
<HstTextarea
|
|
341
|
+
v-model="sampleText"
|
|
342
|
+
title="Sample text"
|
|
343
|
+
rows="5"
|
|
344
|
+
/>
|
|
345
|
+
<HstNumber
|
|
346
|
+
v-model="fontSize"
|
|
347
|
+
title="Font size"
|
|
348
|
+
min="1"
|
|
349
|
+
/>
|
|
350
|
+
</template>
|
|
351
|
+
</Variant>
|
|
352
|
+
<Variant id="drop-shadow" title="Drop Shadow" icon="carbon:shape-except">
|
|
353
|
+
<HstTokenGrid
|
|
354
|
+
:tokens="config.theme.dropShadow"
|
|
355
|
+
:get-name="key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'drop-shadow' : \`drop-shadow-\${key}\`)"
|
|
356
|
+
:col-size="180"
|
|
357
|
+
>
|
|
358
|
+
<template #default="{ token }">
|
|
359
|
+
<div
|
|
360
|
+
class="drop-shadow"
|
|
361
|
+
:style="{
|
|
362
|
+
filter: \`\${(Array.isArray(token.value) ? token.value : [token.value]).map(v => \`drop-shadow(\${v})\`).join(' ')}\`,
|
|
363
|
+
}"
|
|
364
|
+
/>
|
|
365
|
+
</template>
|
|
366
|
+
</HstTokenGrid>
|
|
367
|
+
</Variant>
|
|
368
|
+
<Variant id="border-radius" title="Border Radius" icon="carbon:condition-wait-point">
|
|
369
|
+
<HstTokenGrid
|
|
370
|
+
:tokens="config.theme.borderRadius"
|
|
371
|
+
:get-name="key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'rounded' : \`rounded-\${key}\`)"
|
|
372
|
+
:col-size="180"
|
|
373
|
+
>
|
|
374
|
+
<template #default="{ token }">
|
|
375
|
+
<div
|
|
376
|
+
class="border-radius"
|
|
377
|
+
:style="{
|
|
378
|
+
borderRadius: token.value,
|
|
379
|
+
}"
|
|
380
|
+
/>
|
|
381
|
+
</template>
|
|
382
|
+
</HstTokenGrid>
|
|
383
|
+
</Variant>
|
|
384
|
+
<Variant id="border-width" title="Border Width" icon="carbon:checkbox">
|
|
385
|
+
<HstTokenGrid
|
|
386
|
+
:tokens="config.theme.borderWidth"
|
|
387
|
+
:get-name="key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'border' : \`border-\${key}\`)"
|
|
388
|
+
:col-size="180"
|
|
389
|
+
>
|
|
390
|
+
<template #default="{ token }">
|
|
391
|
+
<div
|
|
392
|
+
class="border-width"
|
|
393
|
+
:style="{
|
|
394
|
+
borderWidth: token.value,
|
|
395
|
+
}"
|
|
396
|
+
/>
|
|
397
|
+
</template>
|
|
398
|
+
</HstTokenGrid>
|
|
399
|
+
</Variant>
|
|
400
|
+
<Variant id="width" title="Width" icon="carbon:pan-horizontal">
|
|
401
|
+
<HstTokenList
|
|
402
|
+
:tokens="config.theme.width"
|
|
403
|
+
:get-name="key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'w' : \`w-\${key}\`)"
|
|
404
|
+
>
|
|
405
|
+
<template #default="{ token }">
|
|
406
|
+
<div class="width">
|
|
407
|
+
<div
|
|
408
|
+
class="width-box"
|
|
409
|
+
:style="{
|
|
410
|
+
width: token.value,
|
|
411
|
+
}"
|
|
412
|
+
/>
|
|
413
|
+
</div>
|
|
414
|
+
</template>
|
|
415
|
+
</HstTokenList>
|
|
416
|
+
</Variant>
|
|
417
|
+
<Variant id="height" title="Height" icon="carbon:pan-vertical">
|
|
418
|
+
<HstTokenList
|
|
419
|
+
:tokens="config.theme.height"
|
|
420
|
+
:get-name="key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'h' : \`h-\${key}\`)"
|
|
421
|
+
>
|
|
422
|
+
<template #default="{ token }">
|
|
423
|
+
<div
|
|
424
|
+
class="height"
|
|
425
|
+
:style="{
|
|
426
|
+
height: token.value,
|
|
427
|
+
}"
|
|
428
|
+
/>
|
|
429
|
+
</template>
|
|
430
|
+
</HstTokenList>
|
|
431
|
+
</Variant>
|
|
432
|
+
<Variant id="full-config" title="Full Config" icon="carbon:code">
|
|
433
|
+
<pre>{{ config }}</pre>
|
|
434
|
+
</Variant>
|
|
435
|
+
</Story>
|
|
436
|
+
</template>
|
|
437
|
+
<style scoped>
|
|
438
|
+
.shade {
|
|
439
|
+
height: 80px;
|
|
440
|
+
border-radius: 4px;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.text {
|
|
444
|
+
font-size: 4rem;
|
|
445
|
+
display: flex;
|
|
446
|
+
align-items: flex-end;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.border {
|
|
450
|
+
border-style: solid;
|
|
451
|
+
border-width: 2px;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
.padding {
|
|
455
|
+
background-color: rgb(113 113 122 / 0.1);
|
|
456
|
+
width: min-content;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
.margin {
|
|
460
|
+
border: dashed 1px rgb(113 113 122 / 0.5);
|
|
461
|
+
width: min-content;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
.padding-box,
|
|
465
|
+
.margin-box {
|
|
466
|
+
width: 5rem;
|
|
467
|
+
height: 5rem;
|
|
468
|
+
background-color: rgb(113 113 122 / 0.5);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
.padding,
|
|
472
|
+
.padding-box,
|
|
473
|
+
.margin,
|
|
474
|
+
.margin-box,
|
|
475
|
+
.drop-shadow {
|
|
476
|
+
border-radius: 4px;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
.truncate {
|
|
480
|
+
overflow: hidden;
|
|
481
|
+
text-overflow: ellipsis;
|
|
482
|
+
white-space: nowrap;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
.drop-shadow {
|
|
486
|
+
width: 8rem;
|
|
487
|
+
height: 8rem;
|
|
488
|
+
background: white;
|
|
489
|
+
margin-bottom: 0.5rem;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.dark .drop-shadow {
|
|
493
|
+
background: #4e4e57;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
.border-radius {
|
|
497
|
+
width: 8rem;
|
|
498
|
+
height: 8rem;
|
|
499
|
+
background-color: rgb(113 113 122 / 0.5);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.border-width {
|
|
503
|
+
width: 8rem;
|
|
504
|
+
height: 8rem;
|
|
505
|
+
border-color: rgb(113 113 122 / 0.5);
|
|
506
|
+
background-color: rgb(113 113 122 / 0.1);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
.width {
|
|
510
|
+
background-color: rgb(113 113 122 / 0.1);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
.width-box,
|
|
514
|
+
.height {
|
|
515
|
+
background-color: rgb(113 113 122 / 0.5);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
.width-box {
|
|
519
|
+
height: 5rem;
|
|
520
|
+
}
|
|
521
|
+
</style>`
|
|
@@ -7,7 +7,7 @@ import pc from 'picocolors'
|
|
|
7
7
|
import Tinypool from 'tinypool'
|
|
8
8
|
import { createBirpc } from 'birpc'
|
|
9
9
|
import type { StoryFile } from '../types.js'
|
|
10
|
-
import { createPath
|
|
10
|
+
import { createPath } from '../tree.js'
|
|
11
11
|
import type { Context } from '../context.js'
|
|
12
12
|
import type { Payload, ReturnData } from './worker.js'
|
|
13
13
|
|
|
@@ -30,10 +30,11 @@ export function useCollectStories (options: UseCollectStoriesOptions, ctx: Conte
|
|
|
30
30
|
const threadPool = new Tinypool({
|
|
31
31
|
filename: new URL('./worker.js', import.meta.url).href,
|
|
32
32
|
// WebContainer compatibility (Stackblitz)
|
|
33
|
-
useAtomics:
|
|
33
|
+
useAtomics: typeof process.versions.webcontainer !== 'string',
|
|
34
34
|
})
|
|
35
35
|
|
|
36
36
|
function clearCache () {
|
|
37
|
+
server.moduleGraph.invalidateAll()
|
|
37
38
|
node.fetchCache.clear()
|
|
38
39
|
}
|
|
39
40
|
|
|
@@ -78,12 +79,13 @@ export function useCollectStories (options: UseCollectStoriesOptions, ctx: Conte
|
|
|
78
79
|
} else if (storyData.length > 1) {
|
|
79
80
|
console.warn(pc.yellow(`⚠️ Multiple stories not supported: ${storyFile.path}`))
|
|
80
81
|
}
|
|
82
|
+
storyFile.id = storyData[0].id
|
|
81
83
|
storyFile.story = storyData[0]
|
|
82
|
-
|
|
84
|
+
storyFile.treeFile = {
|
|
83
85
|
title: storyData[0].title,
|
|
84
86
|
path: relative(server.config.root, storyFile.path),
|
|
85
87
|
}
|
|
86
|
-
storyFile.treePath = createPath(ctx.config,
|
|
88
|
+
storyFile.treePath = createPath(ctx.config, storyFile.treeFile)
|
|
87
89
|
storyFile.story.title = storyFile.treePath[storyFile.treePath.length - 1]
|
|
88
90
|
} catch (e) {
|
|
89
91
|
console.error(pc.red(`Error while collecting story ${storyFile.path}:\n${e.frame ? `${pc.bold(e.message)}\n${e.frame}` : e.stack}`))
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import http from 'http'
|
|
2
1
|
import { resolveConfig as resolveViteConfig } from 'vite'
|
|
3
|
-
import connect from 'connect'
|
|
4
|
-
import sirv from 'sirv'
|
|
5
2
|
import pc from 'picocolors'
|
|
6
3
|
import { createContext } from '../context.js'
|
|
7
|
-
import { createVitePlugins } from '../
|
|
4
|
+
import { createVitePlugins } from '../vite.js'
|
|
5
|
+
import { startPreview } from '../preview.js'
|
|
8
6
|
|
|
9
7
|
export interface PreviewOptions {
|
|
10
8
|
port?: number
|
|
@@ -18,33 +16,6 @@ export async function previewCommand (options: PreviewOptions) {
|
|
|
18
16
|
plugins: await createVitePlugins(ctx),
|
|
19
17
|
}, 'build')
|
|
20
18
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
app.use(
|
|
24
|
-
viteConfig.base,
|
|
25
|
-
sirv(ctx.config.outDir, {
|
|
26
|
-
dev: true,
|
|
27
|
-
etag: true,
|
|
28
|
-
single: true,
|
|
29
|
-
}),
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
let port = options.port ?? 3000
|
|
33
|
-
|
|
34
|
-
const httpServer = http.createServer(app)
|
|
35
|
-
|
|
36
|
-
function onError (e: Error & { code?: string }) {
|
|
37
|
-
if (e.code === 'EADDRINUSE') {
|
|
38
|
-
httpServer.listen(++port)
|
|
39
|
-
} else {
|
|
40
|
-
throw e
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
httpServer.on('error', onError)
|
|
45
|
-
|
|
46
|
-
httpServer.listen(port, () => {
|
|
47
|
-
httpServer.off('error', onError)
|
|
48
|
-
console.log(`Preview server listening on ${pc.cyan(`http://localhost:${port}`)}`)
|
|
49
|
-
})
|
|
19
|
+
const { baseUrl } = await startPreview(viteConfig, options.port, ctx)
|
|
20
|
+
console.log(`Preview server listening on ${pc.cyan(baseUrl)}`)
|
|
50
21
|
}
|