poveste 0.5.2 → 0.6.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/bin.js +2 -1
- package/dist/node/build.d.ts.map +1 -1
- package/dist/node/build.js +31 -0
- package/dist/node/builtin-plugins/pinceau-tokens.d.ts.map +1 -1
- package/dist/node/builtin-plugins/pinceau-tokens.js +4 -3
- package/dist/node/commands/dev.d.ts +1 -1
- package/dist/node/commands/dev.d.ts.map +1 -1
- package/dist/node/commands/dev.js +3 -1
- package/dist/node/commands/port.d.ts +18 -0
- package/dist/node/commands/port.d.ts.map +1 -0
- package/dist/node/commands/port.js +35 -0
- package/dist/node/commands/preview.d.ts +1 -1
- package/dist/node/commands/preview.d.ts.map +1 -1
- package/dist/node/commands/preview.js +3 -1
- package/dist/node/config.d.ts.map +1 -1
- package/dist/node/config.js +9 -3
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +3 -0
- package/dist/node/markdown.d.ts.map +1 -1
- package/dist/node/markdown.js +2 -10
- package/dist/node/preview.d.ts.map +1 -1
- package/dist/node/preview.js +6 -1
- package/dist/node/server.d.ts.map +1 -1
- package/dist/node/server.js +22 -1
- package/dist/node/stories.d.ts.map +1 -1
- package/dist/node/stories.js +2 -10
- package/dist/node/util/watch-ignore.d.ts +3 -0
- package/dist/node/util/watch-ignore.d.ts.map +1 -0
- package/dist/node/util/watch-ignore.js +12 -0
- package/dist/node/virtual/resolved-generated-global-setup.d.ts.map +1 -1
- package/dist/node/virtual/resolved-generated-global-setup.js +13 -5
- package/dist/node/virtual/util.d.ts +11 -0
- package/dist/node/virtual/util.d.ts.map +1 -1
- package/dist/node/virtual/util.js +13 -0
- package/dist/node/vite.d.ts.map +1 -1
- package/dist/node/vite.js +12 -2
- package/package.json +5 -5
- package/src/node/__tests__/config.spec.ts +25 -0
- package/src/node/__tests__/port.spec.ts +65 -0
- package/src/node/__tests__/virtual-setup.spec.ts +13 -3
- package/src/node/__tests__/watch-ignore.spec.ts +33 -0
- package/src/node/bin.ts +2 -1
- package/src/node/build.ts +34 -0
- package/src/node/builtin-plugins/pinceau-tokens.ts +5 -3
- package/src/node/commands/dev.ts +5 -2
- package/src/node/commands/port.ts +41 -0
- package/src/node/commands/preview.ts +5 -2
- package/src/node/config.ts +10 -3
- package/src/node/index.ts +3 -0
- package/src/node/markdown.ts +2 -11
- package/src/node/preview.ts +6 -1
- package/src/node/server.ts +24 -1
- package/src/node/stories.ts +2 -11
- package/src/node/util/watch-ignore.ts +13 -0
- package/src/node/virtual/resolved-generated-global-setup.ts +13 -5
- package/src/node/virtual/util.ts +14 -0
- package/src/node/vite.ts +12 -1
- package/dist/node/builtin-plugins/tailwind-tokens.d.ts +0 -11
- package/dist/node/builtin-plugins/tailwind-tokens.d.ts.map +0 -1
- package/dist/node/builtin-plugins/tailwind-tokens.js +0 -659
- package/src/node/builtin-plugins/tailwind-tokens.ts +0 -692
|
@@ -1,692 +0,0 @@
|
|
|
1
|
-
import type { Plugin, PluginApiBase } from '@poveste/shared'
|
|
2
|
-
import { findUp } from '../util/find-up.js'
|
|
3
|
-
import { getInjectedImport } from '../util/vendors.js'
|
|
4
|
-
|
|
5
|
-
export interface TailwindTokensOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Path to the CSS entrypoint that imports Tailwind and declares `@theme`.
|
|
8
|
-
* Tailwind v4 is CSS-first, so the design tokens are read from CSS rather
|
|
9
|
-
* than from a JS config. Auto-detected when omitted.
|
|
10
|
-
*/
|
|
11
|
-
cssFile?: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const CSS_ENTRY_CANDIDATES = [
|
|
15
|
-
'src/style.css',
|
|
16
|
-
'src/styles.css',
|
|
17
|
-
'src/main.css',
|
|
18
|
-
'src/index.css',
|
|
19
|
-
'src/app.css',
|
|
20
|
-
'src/assets/main.css',
|
|
21
|
-
'src/assets/style.css',
|
|
22
|
-
'src/assets/css/main.css',
|
|
23
|
-
// Nuxt conventions
|
|
24
|
-
'app/assets/css/main.css',
|
|
25
|
-
'assets/css/main.css',
|
|
26
|
-
// Next.js conventions
|
|
27
|
-
'styles/globals.css',
|
|
28
|
-
'app/globals.css',
|
|
29
|
-
'style.css',
|
|
30
|
-
'styles.css',
|
|
31
|
-
]
|
|
32
|
-
|
|
33
|
-
export function tailwindTokens(options: TailwindTokensOptions = {}): Plugin {
|
|
34
|
-
const tailwindCssFile = options.cssFile ?? findUp(process.cwd(), CSS_ENTRY_CANDIDATES)
|
|
35
|
-
|
|
36
|
-
async function generate(api: PluginApiBase) {
|
|
37
|
-
try {
|
|
38
|
-
await api.fs.ensureDir(api.pluginTempDir)
|
|
39
|
-
await api.fs.emptyDir(api.pluginTempDir)
|
|
40
|
-
api.moduleLoader.clearCache()
|
|
41
|
-
await api.fs.writeFile(api.path.resolve(api.pluginTempDir, 'style.css'), css)
|
|
42
|
-
const theme = await loadTailwindTheme(api, tailwindCssFile)
|
|
43
|
-
const storyFile = api.path.resolve(api.pluginTempDir, 'Tailwind.story.js')
|
|
44
|
-
await api.fs.writeFile(storyFile, storyTemplate({ theme }))
|
|
45
|
-
api.addStoryFile(storyFile)
|
|
46
|
-
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
api.error(e.stack ?? e.message)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
name: 'builtin:tailwind-tokens',
|
|
54
|
-
|
|
55
|
-
config(config) {
|
|
56
|
-
if (tailwindCssFile) {
|
|
57
|
-
// Add 'design-system' group
|
|
58
|
-
if (!config.tree) {
|
|
59
|
-
config.tree = {}
|
|
60
|
-
}
|
|
61
|
-
if (!config.tree.groups) {
|
|
62
|
-
config.tree.groups = []
|
|
63
|
-
}
|
|
64
|
-
if (!config.tree.groups.some(g => g.id === 'design-system')) {
|
|
65
|
-
let index = 0
|
|
66
|
-
// After 'top' group
|
|
67
|
-
const topIndex = config.tree.groups.findIndex(g => g.id === 'top')
|
|
68
|
-
if (topIndex > -1) {
|
|
69
|
-
index = topIndex + 1
|
|
70
|
-
}
|
|
71
|
-
// Insert group
|
|
72
|
-
config.tree.groups.splice(index, 0, {
|
|
73
|
-
id: 'design-system',
|
|
74
|
-
title: 'Design System',
|
|
75
|
-
})
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
onDev(api, onCleanup) {
|
|
81
|
-
if (tailwindCssFile) {
|
|
82
|
-
const watcher = api.watcher.watch(tailwindCssFile)
|
|
83
|
-
.on('change', () => generate(api))
|
|
84
|
-
.on('add', () => generate(api))
|
|
85
|
-
onCleanup(() => {
|
|
86
|
-
watcher.close()
|
|
87
|
-
})
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
async onBuild(api) {
|
|
92
|
-
if (tailwindCssFile) {
|
|
93
|
-
await generate(api)
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Tailwind v4 keeps its theme as flat CSS custom properties rather than a
|
|
101
|
-
* resolved JS config (`resolveConfig` is gone). Load the design system from the
|
|
102
|
-
* project's CSS entrypoint and reshape its variables into the grouped structure
|
|
103
|
-
* the story template renders.
|
|
104
|
-
*/
|
|
105
|
-
/**
|
|
106
|
-
* Resolve a stylesheet referenced from CSS. A bare package specifier resolves
|
|
107
|
-
* to the JS entry, so its `style` field is used instead — that is how
|
|
108
|
-
* `@import 'tailwindcss'` reaches `tailwindcss/index.css`.
|
|
109
|
-
*/
|
|
110
|
-
async function resolveStylesheet(api: PluginApiBase, id: string, importBase: string) {
|
|
111
|
-
const { createRequire } = await import('node:module')
|
|
112
|
-
const require = createRequire(`${importBase}/`)
|
|
113
|
-
|
|
114
|
-
if (id.startsWith('.')) {
|
|
115
|
-
return api.path.resolve(importBase, id)
|
|
116
|
-
}
|
|
117
|
-
if (id.endsWith('.css')) {
|
|
118
|
-
return require.resolve(id)
|
|
119
|
-
}
|
|
120
|
-
const packageJsonPath = require.resolve(`${id}/package.json`)
|
|
121
|
-
const packageJson = JSON.parse(await api.fs.readFile(packageJsonPath, 'utf8'))
|
|
122
|
-
return api.path.resolve(api.path.dirname(packageJsonPath), packageJson.style ?? 'index.css')
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async function loadTailwindTheme(api: PluginApiBase, cssFile: string) {
|
|
126
|
-
const { __unstable__loadDesignSystem } = await import('tailwindcss')
|
|
127
|
-
|
|
128
|
-
const base = api.path.dirname(cssFile)
|
|
129
|
-
const designSystem = await __unstable__loadDesignSystem(
|
|
130
|
-
await api.fs.readFile(cssFile, 'utf8'),
|
|
131
|
-
{
|
|
132
|
-
base,
|
|
133
|
-
loadStylesheet: async (id: string, importBase: string) => {
|
|
134
|
-
const resolved = await resolveStylesheet(api, id, importBase)
|
|
135
|
-
return {
|
|
136
|
-
path: resolved,
|
|
137
|
-
base: api.path.dirname(resolved),
|
|
138
|
-
content: await api.fs.readFile(resolved, 'utf8'),
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
const vars = new Map<string, string>(
|
|
145
|
-
[...designSystem.theme.entries()].map(([key, entry]: [string, any]) => [key, entry.value]),
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
/** All values in a `--namespace-*` group, keyed by their remainder. */
|
|
149
|
-
function group(namespace: string, exclude?: RegExp) {
|
|
150
|
-
const out: Record<string, string> = {}
|
|
151
|
-
const prefix = `${namespace}-`
|
|
152
|
-
for (const [key, value] of vars) {
|
|
153
|
-
if (!key.startsWith(prefix)) continue
|
|
154
|
-
if (exclude?.test(key)) continue
|
|
155
|
-
out[key.slice(prefix.length)] = value
|
|
156
|
-
}
|
|
157
|
-
return out
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/** Colours are rendered as shade sets: `red-500` -> `{ red: { 500: … } }`. */
|
|
161
|
-
function colors() {
|
|
162
|
-
const out: Record<string, any> = {}
|
|
163
|
-
for (const [key, value] of Object.entries(group('--color'))) {
|
|
164
|
-
const match = key.match(/^(.*)-(\d+)$/)
|
|
165
|
-
if (match) {
|
|
166
|
-
out[match[1]] ??= {}
|
|
167
|
-
out[match[1]][match[2]] = value
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
out[key] = value
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return out
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// v4 generates the spacing scale on demand from a single `--spacing` base,
|
|
177
|
-
// so the conventional steps are reconstructed here for display.
|
|
178
|
-
const SPACING_STEPS = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80, 96]
|
|
179
|
-
function spacing() {
|
|
180
|
-
const unit = vars.get('--spacing') ?? '0.25rem'
|
|
181
|
-
// Multiply out rather than emitting `calc(0.25rem * 4)`, so the story shows
|
|
182
|
-
// the resolved length the way the v3 resolved config did.
|
|
183
|
-
const [, rawAmount, cssUnit] = unit.trim().match(/^([\d.]+)([a-z%]*)$/i) ?? []
|
|
184
|
-
const amount = Number(rawAmount)
|
|
185
|
-
const out: Record<string, string> = {}
|
|
186
|
-
for (const step of SPACING_STEPS) {
|
|
187
|
-
if (step === 0) {
|
|
188
|
-
out['0'] = '0px'
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
out[String(step)] = Number.isFinite(amount)
|
|
192
|
-
? `${Number((amount * step).toFixed(4))}${cssUnit}`
|
|
193
|
-
: `calc(${unit} * ${step})`
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return out
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// Fractions and keywords have no theme variables in v4 — they are static
|
|
200
|
-
// utilities — but they belong in the sizing scales the story lists.
|
|
201
|
-
const SIZING_EXTRAS: Record<string, string> = {
|
|
202
|
-
'auto': 'auto',
|
|
203
|
-
'full': '100%',
|
|
204
|
-
'min': 'min-content',
|
|
205
|
-
'max': 'max-content',
|
|
206
|
-
'fit': 'fit-content',
|
|
207
|
-
'px': '1px',
|
|
208
|
-
'1/2': '50%',
|
|
209
|
-
'1/3': '33.333333%',
|
|
210
|
-
'2/3': '66.666667%',
|
|
211
|
-
'1/4': '25%',
|
|
212
|
-
'3/4': '75%',
|
|
213
|
-
'1/5': '20%',
|
|
214
|
-
'2/5': '40%',
|
|
215
|
-
'3/5': '60%',
|
|
216
|
-
'4/5': '80%',
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const palette = colors()
|
|
220
|
-
const scale = spacing()
|
|
221
|
-
|
|
222
|
-
return {
|
|
223
|
-
backgroundColor: palette,
|
|
224
|
-
textColor: palette,
|
|
225
|
-
borderColor: palette,
|
|
226
|
-
padding: scale,
|
|
227
|
-
margin: scale,
|
|
228
|
-
width: { ...scale, ...SIZING_EXTRAS, screen: '100vw' },
|
|
229
|
-
height: { ...scale, ...SIZING_EXTRAS, screen: '100vh' },
|
|
230
|
-
fontSize: group('--text', /--line-height$|--letter-spacing$|--font-weight$/),
|
|
231
|
-
fontWeight: group('--font-weight'),
|
|
232
|
-
fontFamily: group('--font', /^--font-weight-/),
|
|
233
|
-
letterSpacing: group('--tracking'),
|
|
234
|
-
lineHeight: group('--leading'),
|
|
235
|
-
dropShadow: group('--drop-shadow'),
|
|
236
|
-
borderRadius: group('--radius'),
|
|
237
|
-
// v4 has no border-width namespace; these are the built-in static utilities.
|
|
238
|
-
borderWidth: { DEFAULT: '1px', 0: '0px', 2: '2px', 4: '4px', 8: '8px' },
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function storyTemplate(tailwindConfig: any) {
|
|
243
|
-
return `
|
|
244
|
-
import 'poveste-style'
|
|
245
|
-
import './style.css'
|
|
246
|
-
import { createApp, h, markRaw, ref } from ${getInjectedImport('@poveste/vendors/vue')}
|
|
247
|
-
import {
|
|
248
|
-
HstColorShades,
|
|
249
|
-
HstTokenList,
|
|
250
|
-
HstTokenGrid,
|
|
251
|
-
HstText,
|
|
252
|
-
HstTextarea,
|
|
253
|
-
HstNumber,
|
|
254
|
-
} from ${getInjectedImport('@poveste/controls')}
|
|
255
|
-
|
|
256
|
-
const config = markRaw(${JSON.stringify(tailwindConfig, null, 2)})
|
|
257
|
-
const search = ref('')
|
|
258
|
-
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')
|
|
259
|
-
const fontSize = ref(16)
|
|
260
|
-
|
|
261
|
-
function mountApp ({ el, state, onUnmount }, render) {
|
|
262
|
-
Object.assign(state, {
|
|
263
|
-
search,
|
|
264
|
-
sampleText,
|
|
265
|
-
fontSize,
|
|
266
|
-
})
|
|
267
|
-
|
|
268
|
-
const app = createApp({
|
|
269
|
-
render,
|
|
270
|
-
})
|
|
271
|
-
app.mount(el)
|
|
272
|
-
|
|
273
|
-
onUnmount(() => {
|
|
274
|
-
app.unmount()
|
|
275
|
-
})
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export default {
|
|
279
|
-
id: 'tailwind',
|
|
280
|
-
title: 'Tailwind',
|
|
281
|
-
group: 'design-system',
|
|
282
|
-
icon: 'mdi:tailwind',
|
|
283
|
-
responsiveDisabled: true,
|
|
284
|
-
layout: { type: 'single', iframe: false },
|
|
285
|
-
variants: [
|
|
286
|
-
{
|
|
287
|
-
id: 'background-color',
|
|
288
|
-
title: 'Background Color',
|
|
289
|
-
icon: 'carbon:color-palette',
|
|
290
|
-
onMount: (api) => mountApp(api, () => Object.entries(config.theme.backgroundColor).map(([key, shades]) => h(HstColorShades, {
|
|
291
|
-
key,
|
|
292
|
-
shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
|
|
293
|
-
getName: shade => '' + (shade === 'DEFAULT' ? \`bg-\${key}\` : \`bg-\${key}-\${shade}\`),
|
|
294
|
-
search: search.value,
|
|
295
|
-
}, ({ color}) => h('div', {
|
|
296
|
-
class: '__pvt-shade',
|
|
297
|
-
style: {
|
|
298
|
-
backgroundColor: color.replace('<alpha-value>', 1),
|
|
299
|
-
},
|
|
300
|
-
})))),
|
|
301
|
-
onMountControls: (api) => mountApp(api, () => [
|
|
302
|
-
h(HstText, {
|
|
303
|
-
title: 'Filter...',
|
|
304
|
-
modelValue: search.value,
|
|
305
|
-
'onUpdate:modelValue': value => { search.value = value },
|
|
306
|
-
}),
|
|
307
|
-
]),
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
id: 'text-color',
|
|
311
|
-
title: 'Text Color',
|
|
312
|
-
icon: 'carbon:text-color',
|
|
313
|
-
onMount: (api) => mountApp(api, () => Object.entries(config.theme.textColor).map(([key, shades]) => h(HstColorShades, {
|
|
314
|
-
key,
|
|
315
|
-
shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
|
|
316
|
-
getName: shade => '' + (shade === 'DEFAULT' ? \`text-\${key}\` : \`text-\${key}-\${shade}\`),
|
|
317
|
-
search: search.value,
|
|
318
|
-
}, ({ color}) => h('div', {
|
|
319
|
-
class: '__pvt-shade __pvt-text',
|
|
320
|
-
style: {
|
|
321
|
-
color: color.replace('<alpha-value>', 1),
|
|
322
|
-
},
|
|
323
|
-
}, 'Aa')))),
|
|
324
|
-
onMountControls: (api) => mountApp(api, () => [
|
|
325
|
-
h(HstText, {
|
|
326
|
-
title: 'Filter...',
|
|
327
|
-
modelValue: search.value,
|
|
328
|
-
'onUpdate:modelValue': value => { search.value = value },
|
|
329
|
-
}),
|
|
330
|
-
]),
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
id: 'border-color',
|
|
334
|
-
title: 'Border Color',
|
|
335
|
-
icon: 'carbon:color-palette',
|
|
336
|
-
onMount: (api) => mountApp(api, () => Object.entries(config.theme.borderColor).map(([key, shades]) => h(HstColorShades, {
|
|
337
|
-
key,
|
|
338
|
-
shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
|
|
339
|
-
getName: shade => '' + (shade === 'DEFAULT' ? \`border-\${key}\` : \`border-\${key}-\${shade}\`),
|
|
340
|
-
search: search.value,
|
|
341
|
-
}, ({ color}) => h('div', {
|
|
342
|
-
class: '__pvt-shade __pvt-border',
|
|
343
|
-
style: {
|
|
344
|
-
borderColor: color.replace('<alpha-value>', 1),
|
|
345
|
-
},
|
|
346
|
-
})))),
|
|
347
|
-
onMountControls: (api) => mountApp(api, () => [
|
|
348
|
-
h(HstText, {
|
|
349
|
-
title: 'Filter...',
|
|
350
|
-
modelValue: search.value,
|
|
351
|
-
'onUpdate:modelValue': value => { search.value = value },
|
|
352
|
-
}),
|
|
353
|
-
]),
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
id: 'padding',
|
|
357
|
-
title: 'Padding',
|
|
358
|
-
icon: 'carbon:area',
|
|
359
|
-
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
360
|
-
tokens: config.theme.padding,
|
|
361
|
-
getName: key => \`p-\${key}\`,
|
|
362
|
-
}, ({ token }) => h('div', {
|
|
363
|
-
class: '__pvt-padding',
|
|
364
|
-
style: {
|
|
365
|
-
padding: token.value,
|
|
366
|
-
},
|
|
367
|
-
}, [
|
|
368
|
-
h('div', {
|
|
369
|
-
class: '__pvt-padding-box',
|
|
370
|
-
}),
|
|
371
|
-
]))),
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
id: 'margin',
|
|
375
|
-
title: 'Margin',
|
|
376
|
-
icon: 'carbon:area',
|
|
377
|
-
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
378
|
-
tokens: config.theme.margin,
|
|
379
|
-
getName: key => \`m-\${key}\`,
|
|
380
|
-
}, ({ token }) => h('div', {
|
|
381
|
-
class: '__pvt-margin',
|
|
382
|
-
}, [
|
|
383
|
-
h('div', {
|
|
384
|
-
class: '__pvt-margin-box',
|
|
385
|
-
style: {
|
|
386
|
-
margin: token.value,
|
|
387
|
-
},
|
|
388
|
-
}),
|
|
389
|
-
]))),
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
id: 'font-size',
|
|
393
|
-
title: 'Font Size',
|
|
394
|
-
icon: 'carbon:text-font',
|
|
395
|
-
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
396
|
-
tokens: config.theme.fontSize,
|
|
397
|
-
getName: key => \`text-\${key}\`,
|
|
398
|
-
}, ({ token }) => h('div', {
|
|
399
|
-
class: '__pvt-truncate',
|
|
400
|
-
style: {
|
|
401
|
-
fontSize: Array.isArray(token.value) ? token.value[0] : token.value,
|
|
402
|
-
...(Array.isArray(token.value) && typeof token.value[1] === "object" ? token.value[1] : { lineHeight: token.value[1] })
|
|
403
|
-
},
|
|
404
|
-
}, sampleText.value))),
|
|
405
|
-
onMountControls: (api) => mountApp(api, () => [
|
|
406
|
-
h(HstTextarea, {
|
|
407
|
-
title: 'Sample text',
|
|
408
|
-
modelValue: sampleText.value,
|
|
409
|
-
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
410
|
-
rows: 5,
|
|
411
|
-
}),
|
|
412
|
-
]),
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
id: 'font-weight',
|
|
416
|
-
title: 'Font Weight',
|
|
417
|
-
icon: 'carbon:text-font',
|
|
418
|
-
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
419
|
-
tokens: config.theme.fontWeight,
|
|
420
|
-
getName: key => \`font-\${key}\`,
|
|
421
|
-
}, ({ token }) => h('div', {
|
|
422
|
-
class: '__pvt-truncate',
|
|
423
|
-
style: {
|
|
424
|
-
fontWeight: token.value,
|
|
425
|
-
fontSize: \`\${fontSize.value}px\`,
|
|
426
|
-
},
|
|
427
|
-
}, sampleText.value))),
|
|
428
|
-
onMountControls: (api) => mountApp(api, () => [
|
|
429
|
-
h(HstTextarea, {
|
|
430
|
-
title: 'Sample text',
|
|
431
|
-
modelValue: sampleText.value,
|
|
432
|
-
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
433
|
-
rows: 5,
|
|
434
|
-
}),
|
|
435
|
-
h(HstNumber, {
|
|
436
|
-
title: 'Font size',
|
|
437
|
-
modelValue: fontSize.value,
|
|
438
|
-
'onUpdate:modelValue': value => { fontSize.value = value },
|
|
439
|
-
min: 1,
|
|
440
|
-
}),
|
|
441
|
-
]),
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
id: 'font-family',
|
|
445
|
-
title: 'Font Family',
|
|
446
|
-
icon: 'carbon:text-font',
|
|
447
|
-
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
448
|
-
tokens: config.theme.fontFamily,
|
|
449
|
-
getName: key => \`font-\${key}\`,
|
|
450
|
-
}, ({ token }) => h('div', {
|
|
451
|
-
class: '__pvt-truncate',
|
|
452
|
-
style: {
|
|
453
|
-
fontFamily: token.value,
|
|
454
|
-
fontSize: \`\${fontSize.value}px\`,
|
|
455
|
-
},
|
|
456
|
-
}, sampleText.value))),
|
|
457
|
-
onMountControls: (api) => mountApp(api, () => [
|
|
458
|
-
h(HstTextarea, {
|
|
459
|
-
title: 'Sample text',
|
|
460
|
-
modelValue: sampleText.value,
|
|
461
|
-
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
462
|
-
rows: 5,
|
|
463
|
-
}),
|
|
464
|
-
h(HstNumber, {
|
|
465
|
-
title: 'Font size',
|
|
466
|
-
modelValue: fontSize.value,
|
|
467
|
-
'onUpdate:modelValue': value => { fontSize.value = value },
|
|
468
|
-
min: 1,
|
|
469
|
-
}),
|
|
470
|
-
]),
|
|
471
|
-
},
|
|
472
|
-
{
|
|
473
|
-
id: 'letter-spacing',
|
|
474
|
-
title: 'Letter Spacing',
|
|
475
|
-
icon: 'carbon:text-font',
|
|
476
|
-
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
477
|
-
tokens: config.theme.letterSpacing,
|
|
478
|
-
getName: key => \`tracking-\${key}\`,
|
|
479
|
-
}, ({ token }) => h('div', {
|
|
480
|
-
class: '__pvt-truncate',
|
|
481
|
-
style: {
|
|
482
|
-
letterSpacing: token.value,
|
|
483
|
-
fontSize: \`\${fontSize.value}px\`,
|
|
484
|
-
},
|
|
485
|
-
}, sampleText.value))),
|
|
486
|
-
onMountControls: (api) => mountApp(api, () => [
|
|
487
|
-
h(HstTextarea, {
|
|
488
|
-
title: 'Sample text',
|
|
489
|
-
modelValue: sampleText.value,
|
|
490
|
-
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
491
|
-
rows: 5,
|
|
492
|
-
}),
|
|
493
|
-
h(HstNumber, {
|
|
494
|
-
title: 'Font size',
|
|
495
|
-
modelValue: fontSize.value,
|
|
496
|
-
'onUpdate:modelValue': value => { fontSize.value = value },
|
|
497
|
-
min: 1,
|
|
498
|
-
}),
|
|
499
|
-
]),
|
|
500
|
-
},
|
|
501
|
-
{
|
|
502
|
-
id: 'line-height',
|
|
503
|
-
title: 'Line Height',
|
|
504
|
-
icon: 'carbon:text-font',
|
|
505
|
-
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
506
|
-
tokens: config.theme.lineHeight,
|
|
507
|
-
getName: key => \`leading-\${key}\`,
|
|
508
|
-
}, ({ token }) => h('div', {
|
|
509
|
-
style: {
|
|
510
|
-
lineHeight: token.value,
|
|
511
|
-
},
|
|
512
|
-
}, sampleText.value))),
|
|
513
|
-
onMountControls: (api) => mountApp(api, () => [
|
|
514
|
-
h(HstTextarea, {
|
|
515
|
-
title: 'Sample text',
|
|
516
|
-
modelValue: sampleText.value,
|
|
517
|
-
'onUpdate:modelValue': value => { sampleText.value = value },
|
|
518
|
-
rows: 5,
|
|
519
|
-
}),
|
|
520
|
-
// @TODO select font size
|
|
521
|
-
]),
|
|
522
|
-
},
|
|
523
|
-
{
|
|
524
|
-
id: 'drop-shadow',
|
|
525
|
-
title: 'Drop Shadow',
|
|
526
|
-
icon: 'carbon:shape-except',
|
|
527
|
-
onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
|
|
528
|
-
tokens: config.theme.dropShadow,
|
|
529
|
-
getName: key => '' + (key === 'DEFAULT' ? 'drop-shadow' : \`drop-shadow-\${key}\`),
|
|
530
|
-
colSize: 180,
|
|
531
|
-
}, ({ token }) => h('div', {
|
|
532
|
-
class: '__pvt-drop-shadow',
|
|
533
|
-
style: {
|
|
534
|
-
filter: \`\${(Array.isArray(token.value) ? token.value : [token.value]).map(v => \`drop-shadow(\${v})\`).join(' ')}\`,
|
|
535
|
-
},
|
|
536
|
-
}))),
|
|
537
|
-
},
|
|
538
|
-
{
|
|
539
|
-
id: 'border-radius',
|
|
540
|
-
title: 'Border Radius',
|
|
541
|
-
icon: 'carbon:condition-wait-point',
|
|
542
|
-
onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
|
|
543
|
-
tokens: config.theme.borderRadius,
|
|
544
|
-
getName: key => '' + (key === 'DEFAULT' ? 'rounded' : \`rounded-\${key}\`),
|
|
545
|
-
colSize: 180,
|
|
546
|
-
}, ({ token }) => h('div', {
|
|
547
|
-
class: '__pvt-border-radius',
|
|
548
|
-
style: {
|
|
549
|
-
borderRadius: token.value,
|
|
550
|
-
},
|
|
551
|
-
}))),
|
|
552
|
-
},
|
|
553
|
-
{
|
|
554
|
-
id: 'border-width',
|
|
555
|
-
title: 'Border Width',
|
|
556
|
-
icon: 'carbon:checkbox',
|
|
557
|
-
onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
|
|
558
|
-
tokens: config.theme.borderWidth,
|
|
559
|
-
getName: key => '' + (key === 'DEFAULT' ? 'border' : \`border-\${key}\`),
|
|
560
|
-
colSize: 180,
|
|
561
|
-
}, ({ token }) => h('div', {
|
|
562
|
-
class: '__pvt-border-width',
|
|
563
|
-
style: {
|
|
564
|
-
borderWidth: token.value,
|
|
565
|
-
},
|
|
566
|
-
}))),
|
|
567
|
-
},
|
|
568
|
-
{
|
|
569
|
-
id: 'width',
|
|
570
|
-
title: 'Width',
|
|
571
|
-
icon: 'carbon:pan-horizontal',
|
|
572
|
-
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
573
|
-
tokens: config.theme.width,
|
|
574
|
-
getName: key => '' + (key === 'DEFAULT' ? 'w' : \`w-\${key}\`),
|
|
575
|
-
}, ({ token }) => h('div', {
|
|
576
|
-
class: '__pvt-width',
|
|
577
|
-
}, [
|
|
578
|
-
h('div', {
|
|
579
|
-
class: '__pvt-width-box',
|
|
580
|
-
style: {
|
|
581
|
-
width: token.value,
|
|
582
|
-
},
|
|
583
|
-
}),
|
|
584
|
-
]))),
|
|
585
|
-
},
|
|
586
|
-
{
|
|
587
|
-
id: 'height',
|
|
588
|
-
title: 'Height',
|
|
589
|
-
icon: 'carbon:pan-vertical',
|
|
590
|
-
onMount: (api) => mountApp(api, () => h(HstTokenList, {
|
|
591
|
-
tokens: config.theme.height,
|
|
592
|
-
getName: key => '' + (key === 'DEFAULT' ? 'h' : \`h-\${key}\`),
|
|
593
|
-
}, ({ token }) => h('div', {
|
|
594
|
-
class: '__pvt-height',
|
|
595
|
-
style: {
|
|
596
|
-
height: token.value,
|
|
597
|
-
},
|
|
598
|
-
}))),
|
|
599
|
-
},
|
|
600
|
-
{
|
|
601
|
-
id: 'full-config',
|
|
602
|
-
title: 'Full Config',
|
|
603
|
-
icon: 'carbon:code',
|
|
604
|
-
onMount: (api) => mountApp(api, () => h('pre', JSON.stringify(config, null, 2))),
|
|
605
|
-
},
|
|
606
|
-
],
|
|
607
|
-
}`
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
const css = `.__pvt-shade {
|
|
611
|
-
height: 80px;
|
|
612
|
-
border-radius: 4px;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
.__pvt-text {
|
|
616
|
-
font-size: 4rem;
|
|
617
|
-
display: flex;
|
|
618
|
-
align-items: flex-end;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
.__pvt-border {
|
|
622
|
-
border-style: solid;
|
|
623
|
-
border-width: 2px;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
.__pvt-padding {
|
|
627
|
-
background-color: rgb(113 113 122 / 0.1);
|
|
628
|
-
width: min-content;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
.__pvt-margin {
|
|
632
|
-
border: dashed 1px rgb(113 113 122 / 0.5);
|
|
633
|
-
width: min-content;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
.__pvt-padding-box,
|
|
637
|
-
.__pvt-margin-box {
|
|
638
|
-
width: 5rem;
|
|
639
|
-
height: 5rem;
|
|
640
|
-
background-color: rgb(113 113 122 / 0.5);
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
.__pvt-padding,
|
|
644
|
-
.__pvt-padding-box,
|
|
645
|
-
.__pvt-margin,
|
|
646
|
-
.__pvt-margin-box,
|
|
647
|
-
.__pvt-drop-shadow {
|
|
648
|
-
border-radius: 4px;
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
.__pvt-truncate {
|
|
652
|
-
overflow: hidden;
|
|
653
|
-
text-overflow: ellipsis;
|
|
654
|
-
white-space: nowrap;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
.__pvt-drop-shadow {
|
|
658
|
-
width: 8rem;
|
|
659
|
-
height: 8rem;
|
|
660
|
-
background: white;
|
|
661
|
-
margin-bottom: 0.5rem;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
.__pvt-drop-shadow {
|
|
665
|
-
background: #4e4e57;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
.__pvt-border-radius {
|
|
669
|
-
width: 8rem;
|
|
670
|
-
height: 8rem;
|
|
671
|
-
background-color: rgb(113 113 122 / 0.5);
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
.__pvt-border-width {
|
|
675
|
-
width: 8rem;
|
|
676
|
-
height: 8rem;
|
|
677
|
-
border-color: rgb(113 113 122 / 0.5);
|
|
678
|
-
background-color: rgb(113 113 122 / 0.1);
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
.__pvt-width {
|
|
682
|
-
background-color: rgb(113 113 122 / 0.1);
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
.__pvt-width-box,
|
|
686
|
-
.__pvt-height {
|
|
687
|
-
background-color: rgb(113 113 122 / 0.5);
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
.__pvt-width-box {
|
|
691
|
-
height: 5rem;
|
|
692
|
-
}`
|