@histoire/controls 0.2.2 → 0.2.5
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/components/HstCopyIcon.vue.d.ts +15 -0
- package/dist/components/design-tokens/HstColorShades.story.vue.d.ts +2 -0
- package/dist/components/design-tokens/HstColorShades.vue.d.ts +19 -0
- package/dist/components/design-tokens/HstTokenGrid.story.vue.d.ts +2 -0
- package/dist/components/design-tokens/HstTokenGrid.vue.d.ts +33 -0
- package/dist/components/design-tokens/HstTokenList.story.vue.d.ts +2 -0
- package/dist/components/design-tokens/HstTokenList.vue.d.ts +17 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.es.js +2323 -86
- package/dist/style.css +149 -0
- package/package.json +18 -13
- package/src/components/HstCopyIcon.vue +34 -0
- package/src/components/design-tokens/HstColorShades.story.vue +390 -0
- package/src/components/design-tokens/HstColorShades.vue +87 -0
- package/src/components/design-tokens/HstTokenGrid.story.vue +35 -0
- package/src/components/design-tokens/HstTokenGrid.vue +79 -0
- package/src/components/design-tokens/HstTokenList.story.vue +79 -0
- package/src/components/design-tokens/HstTokenList.vue +58 -0
- package/src/index.ts +4 -0
- package/tsconfig.json +2 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import HstColorShades from './HstColorShades.vue'
|
|
3
|
+
|
|
4
|
+
const colors = {
|
|
5
|
+
slate: {
|
|
6
|
+
50: '#f8fafc',
|
|
7
|
+
100: '#f1f5f9',
|
|
8
|
+
200: '#e2e8f0',
|
|
9
|
+
300: '#cbd5e1',
|
|
10
|
+
400: '#94a3b8',
|
|
11
|
+
500: '#64748b',
|
|
12
|
+
600: '#475569',
|
|
13
|
+
700: '#334155',
|
|
14
|
+
750: '#283548',
|
|
15
|
+
800: '#1e293b',
|
|
16
|
+
850: '#151f32',
|
|
17
|
+
900: '#0f172a',
|
|
18
|
+
950: '#09101f',
|
|
19
|
+
},
|
|
20
|
+
gray: {
|
|
21
|
+
50: '#f9fafb',
|
|
22
|
+
100: '#f3f4f6',
|
|
23
|
+
200: '#e5e7eb',
|
|
24
|
+
300: '#d1d5db',
|
|
25
|
+
400: '#9ca3af',
|
|
26
|
+
500: '#6b7280',
|
|
27
|
+
600: '#4b5563',
|
|
28
|
+
700: '#374151',
|
|
29
|
+
750: '#2b3546',
|
|
30
|
+
800: '#1f2937',
|
|
31
|
+
850: '#18212f',
|
|
32
|
+
900: '#111827',
|
|
33
|
+
950: '#0c101d',
|
|
34
|
+
},
|
|
35
|
+
zinc: {
|
|
36
|
+
50: '#fafafa',
|
|
37
|
+
100: '#f4f4f5',
|
|
38
|
+
200: '#e4e4e7',
|
|
39
|
+
300: '#d4d4d8',
|
|
40
|
+
400: '#a1a1aa',
|
|
41
|
+
500: '#71717a',
|
|
42
|
+
600: '#52525b',
|
|
43
|
+
700: '#3f3f46',
|
|
44
|
+
750: '#323238',
|
|
45
|
+
800: '#27272a',
|
|
46
|
+
850: '#1f1f21',
|
|
47
|
+
900: '#18181b',
|
|
48
|
+
950: '#101012',
|
|
49
|
+
},
|
|
50
|
+
neutral: {
|
|
51
|
+
50: '#fafafa',
|
|
52
|
+
100: '#f5f5f5',
|
|
53
|
+
200: '#e5e5e5',
|
|
54
|
+
300: '#d4d4d4',
|
|
55
|
+
400: '#a3a3a3',
|
|
56
|
+
500: '#737373',
|
|
57
|
+
600: '#525252',
|
|
58
|
+
700: '#404040',
|
|
59
|
+
750: '#333333',
|
|
60
|
+
800: '#262626',
|
|
61
|
+
850: '#1f1f1f',
|
|
62
|
+
900: '#171717',
|
|
63
|
+
950: '#0f0f0f',
|
|
64
|
+
},
|
|
65
|
+
stone: {
|
|
66
|
+
50: '#fafaf9',
|
|
67
|
+
100: '#f5f5f4',
|
|
68
|
+
200: '#e7e5e4',
|
|
69
|
+
300: '#d6d3d1',
|
|
70
|
+
400: '#a8a29e',
|
|
71
|
+
500: '#78716c',
|
|
72
|
+
600: '#57534e',
|
|
73
|
+
700: '#44403c',
|
|
74
|
+
750: '#363230',
|
|
75
|
+
800: '#292524',
|
|
76
|
+
850: '#211e1c',
|
|
77
|
+
900: '#1c1917',
|
|
78
|
+
950: '#171412',
|
|
79
|
+
},
|
|
80
|
+
red: {
|
|
81
|
+
50: '#fef2f2',
|
|
82
|
+
100: '#fee2e2',
|
|
83
|
+
200: '#fecaca',
|
|
84
|
+
300: '#fca5a5',
|
|
85
|
+
400: '#f87171',
|
|
86
|
+
500: '#ef4444',
|
|
87
|
+
600: '#dc2626',
|
|
88
|
+
700: '#b91c1c',
|
|
89
|
+
800: '#991b1b',
|
|
90
|
+
900: '#7f1d1d',
|
|
91
|
+
},
|
|
92
|
+
orange: {
|
|
93
|
+
50: '#fff7ed',
|
|
94
|
+
100: '#ffedd5',
|
|
95
|
+
200: '#fed7aa',
|
|
96
|
+
300: '#fdba74',
|
|
97
|
+
400: '#fb923c',
|
|
98
|
+
500: '#f97316',
|
|
99
|
+
600: '#ea580c',
|
|
100
|
+
700: '#c2410c',
|
|
101
|
+
800: '#9a3412',
|
|
102
|
+
900: '#7c2d12',
|
|
103
|
+
},
|
|
104
|
+
amber: {
|
|
105
|
+
50: '#fffbeb',
|
|
106
|
+
100: '#fef3c7',
|
|
107
|
+
200: '#fde68a',
|
|
108
|
+
300: '#fcd34d',
|
|
109
|
+
400: '#fbbf24',
|
|
110
|
+
500: '#f59e0b',
|
|
111
|
+
600: '#d97706',
|
|
112
|
+
700: '#b45309',
|
|
113
|
+
800: '#92400e',
|
|
114
|
+
900: '#78350f',
|
|
115
|
+
},
|
|
116
|
+
yellow: {
|
|
117
|
+
50: '#fefce8',
|
|
118
|
+
100: '#fef9c3',
|
|
119
|
+
200: '#fef08a',
|
|
120
|
+
300: '#fde047',
|
|
121
|
+
400: '#facc15',
|
|
122
|
+
500: '#eab308',
|
|
123
|
+
600: '#ca8a04',
|
|
124
|
+
700: '#a16207',
|
|
125
|
+
800: '#854d0e',
|
|
126
|
+
900: '#713f12',
|
|
127
|
+
},
|
|
128
|
+
lime: {
|
|
129
|
+
50: '#f7fee7',
|
|
130
|
+
100: '#ecfccb',
|
|
131
|
+
200: '#d9f99d',
|
|
132
|
+
300: '#bef264',
|
|
133
|
+
400: '#a3e635',
|
|
134
|
+
500: '#84cc16',
|
|
135
|
+
600: '#65a30d',
|
|
136
|
+
700: '#4d7c0f',
|
|
137
|
+
800: '#3f6212',
|
|
138
|
+
900: '#365314',
|
|
139
|
+
},
|
|
140
|
+
green: {
|
|
141
|
+
50: '#f0fdf4',
|
|
142
|
+
100: '#dcfce7',
|
|
143
|
+
200: '#bbf7d0',
|
|
144
|
+
300: '#86efac',
|
|
145
|
+
400: '#4ade80',
|
|
146
|
+
500: '#22c55e',
|
|
147
|
+
600: '#16a34a',
|
|
148
|
+
700: '#15803d',
|
|
149
|
+
800: '#166534',
|
|
150
|
+
900: '#14532d',
|
|
151
|
+
},
|
|
152
|
+
emerald: {
|
|
153
|
+
50: '#ecfdf5',
|
|
154
|
+
100: '#d1fae5',
|
|
155
|
+
200: '#a7f3d0',
|
|
156
|
+
300: '#6ee7b7',
|
|
157
|
+
400: '#34d399',
|
|
158
|
+
500: '#10b981',
|
|
159
|
+
600: '#059669',
|
|
160
|
+
700: '#047857',
|
|
161
|
+
800: '#065f46',
|
|
162
|
+
900: '#064e3b',
|
|
163
|
+
},
|
|
164
|
+
teal: {
|
|
165
|
+
50: '#f0fdfa',
|
|
166
|
+
100: '#ccfbf1',
|
|
167
|
+
200: '#99f6e4',
|
|
168
|
+
300: '#5eead4',
|
|
169
|
+
400: '#2dd4bf',
|
|
170
|
+
500: '#14b8a6',
|
|
171
|
+
600: '#0d9488',
|
|
172
|
+
700: '#0f766e',
|
|
173
|
+
800: '#115e59',
|
|
174
|
+
900: '#134e4a',
|
|
175
|
+
},
|
|
176
|
+
cyan: {
|
|
177
|
+
50: '#ecfeff',
|
|
178
|
+
100: '#cffafe',
|
|
179
|
+
200: '#a5f3fc',
|
|
180
|
+
300: '#67e8f9',
|
|
181
|
+
400: '#22d3ee',
|
|
182
|
+
500: '#06b6d4',
|
|
183
|
+
600: '#0891b2',
|
|
184
|
+
700: '#0e7490',
|
|
185
|
+
800: '#155e75',
|
|
186
|
+
900: '#164e63',
|
|
187
|
+
},
|
|
188
|
+
sky: {
|
|
189
|
+
50: '#f0f9ff',
|
|
190
|
+
100: '#e0f2fe',
|
|
191
|
+
200: '#bae6fd',
|
|
192
|
+
300: '#7dd3fc',
|
|
193
|
+
400: '#38bdf8',
|
|
194
|
+
500: '#0ea5e9',
|
|
195
|
+
600: '#0284c7',
|
|
196
|
+
700: '#0369a1',
|
|
197
|
+
800: '#075985',
|
|
198
|
+
900: '#0c4a6e',
|
|
199
|
+
},
|
|
200
|
+
blue: {
|
|
201
|
+
50: '#eff6ff',
|
|
202
|
+
100: '#dbeafe',
|
|
203
|
+
200: '#bfdbfe',
|
|
204
|
+
300: '#93c5fd',
|
|
205
|
+
400: '#60a5fa',
|
|
206
|
+
500: '#3b82f6',
|
|
207
|
+
600: '#2563eb',
|
|
208
|
+
700: '#1d4ed8',
|
|
209
|
+
800: '#1e40af',
|
|
210
|
+
900: '#1e3a8a',
|
|
211
|
+
},
|
|
212
|
+
indigo: {
|
|
213
|
+
50: '#eef2ff',
|
|
214
|
+
100: '#e0e7ff',
|
|
215
|
+
200: '#c7d2fe',
|
|
216
|
+
300: '#a5b4fc',
|
|
217
|
+
400: '#818cf8',
|
|
218
|
+
500: '#6366f1',
|
|
219
|
+
600: '#4f46e5',
|
|
220
|
+
700: '#4338ca',
|
|
221
|
+
800: '#3730a3',
|
|
222
|
+
900: '#312e81',
|
|
223
|
+
},
|
|
224
|
+
violet: {
|
|
225
|
+
50: '#f5f3ff',
|
|
226
|
+
100: '#ede9fe',
|
|
227
|
+
200: '#ddd6fe',
|
|
228
|
+
300: '#c4b5fd',
|
|
229
|
+
400: '#a78bfa',
|
|
230
|
+
500: '#8b5cf6',
|
|
231
|
+
600: '#7c3aed',
|
|
232
|
+
700: '#6d28d9',
|
|
233
|
+
800: '#5b21b6',
|
|
234
|
+
900: '#4c1d95',
|
|
235
|
+
},
|
|
236
|
+
purple: {
|
|
237
|
+
50: '#faf5ff',
|
|
238
|
+
100: '#f3e8ff',
|
|
239
|
+
200: '#e9d5ff',
|
|
240
|
+
300: '#d8b4fe',
|
|
241
|
+
400: '#c084fc',
|
|
242
|
+
500: '#a855f7',
|
|
243
|
+
600: '#9333ea',
|
|
244
|
+
700: '#7e22ce',
|
|
245
|
+
800: '#6b21a8',
|
|
246
|
+
900: '#581c87',
|
|
247
|
+
},
|
|
248
|
+
fuchsia: {
|
|
249
|
+
50: '#fdf4ff',
|
|
250
|
+
100: '#fae8ff',
|
|
251
|
+
200: '#f5d0fe',
|
|
252
|
+
300: '#f0abfc',
|
|
253
|
+
400: '#e879f9',
|
|
254
|
+
500: '#d946ef',
|
|
255
|
+
600: '#c026d3',
|
|
256
|
+
700: '#a21caf',
|
|
257
|
+
800: '#86198f',
|
|
258
|
+
900: '#701a75',
|
|
259
|
+
},
|
|
260
|
+
pink: {
|
|
261
|
+
50: '#fdf2f8',
|
|
262
|
+
100: '#fce7f3',
|
|
263
|
+
200: '#fbcfe8',
|
|
264
|
+
300: '#f9a8d4',
|
|
265
|
+
400: '#f472b6',
|
|
266
|
+
500: '#ec4899',
|
|
267
|
+
600: '#db2777',
|
|
268
|
+
700: '#be185d',
|
|
269
|
+
800: '#9d174d',
|
|
270
|
+
900: '#831843',
|
|
271
|
+
},
|
|
272
|
+
rose: {
|
|
273
|
+
50: '#fff1f2',
|
|
274
|
+
100: '#ffe4e6',
|
|
275
|
+
200: '#fecdd3',
|
|
276
|
+
300: '#fda4af',
|
|
277
|
+
400: '#fb7185',
|
|
278
|
+
500: '#f43f5e',
|
|
279
|
+
600: '#e11d48',
|
|
280
|
+
700: '#be123c',
|
|
281
|
+
800: '#9f1239',
|
|
282
|
+
900: '#881337',
|
|
283
|
+
},
|
|
284
|
+
}
|
|
285
|
+
</script>
|
|
286
|
+
|
|
287
|
+
<template>
|
|
288
|
+
<Story
|
|
289
|
+
title="design-tokens/HstColorShades"
|
|
290
|
+
responsive-disabled
|
|
291
|
+
>
|
|
292
|
+
<Variant title="default">
|
|
293
|
+
<HstColorShades
|
|
294
|
+
v-for="(shades, key) of colors"
|
|
295
|
+
:key="key"
|
|
296
|
+
:shades="shades"
|
|
297
|
+
:get-name="shade => `${key}-${shade}`"
|
|
298
|
+
/>
|
|
299
|
+
</Variant>
|
|
300
|
+
|
|
301
|
+
<Variant title="background">
|
|
302
|
+
<HstColorShades
|
|
303
|
+
v-for="(shades, key) of colors"
|
|
304
|
+
:key="key"
|
|
305
|
+
:shades="shades"
|
|
306
|
+
:get-name="shade => `${key}-${shade}`"
|
|
307
|
+
>
|
|
308
|
+
<template #default="{ color }">
|
|
309
|
+
<div
|
|
310
|
+
class="htw-rounded htw-h-[100px]"
|
|
311
|
+
:style="{
|
|
312
|
+
backgroundColor: color,
|
|
313
|
+
}"
|
|
314
|
+
/>
|
|
315
|
+
</template>
|
|
316
|
+
</HstColorShades>
|
|
317
|
+
</Variant>
|
|
318
|
+
|
|
319
|
+
<Variant title="text">
|
|
320
|
+
<HstColorShades
|
|
321
|
+
v-for="(shades, key) of colors"
|
|
322
|
+
:key="key"
|
|
323
|
+
:shades="shades"
|
|
324
|
+
:get-name="shade => `${key}-${shade}`"
|
|
325
|
+
>
|
|
326
|
+
<template #default="{ color }">
|
|
327
|
+
<div
|
|
328
|
+
class="htw-rounded htw-h-[100px] htw-text-5xl htw-flex htw-items-end"
|
|
329
|
+
:style="{
|
|
330
|
+
color: color,
|
|
331
|
+
}"
|
|
332
|
+
>
|
|
333
|
+
Aa
|
|
334
|
+
</div>
|
|
335
|
+
</template>
|
|
336
|
+
</HstColorShades>
|
|
337
|
+
</Variant>
|
|
338
|
+
|
|
339
|
+
<Variant title="border">
|
|
340
|
+
<HstColorShades
|
|
341
|
+
v-for="(shades, key) of colors"
|
|
342
|
+
:key="key"
|
|
343
|
+
:shades="shades"
|
|
344
|
+
:get-name="shade => `${key}-${shade}`"
|
|
345
|
+
>
|
|
346
|
+
<template #default="{ color }">
|
|
347
|
+
<div
|
|
348
|
+
class="htw-rounded htw-h-[100px] htw-border-solid htw-border-2"
|
|
349
|
+
:style="{
|
|
350
|
+
borderColor: color,
|
|
351
|
+
}"
|
|
352
|
+
/>
|
|
353
|
+
</template>
|
|
354
|
+
</HstColorShades>
|
|
355
|
+
</Variant>
|
|
356
|
+
|
|
357
|
+
<Variant
|
|
358
|
+
title="with search"
|
|
359
|
+
:init-state="() => ({
|
|
360
|
+
search: '',
|
|
361
|
+
})"
|
|
362
|
+
>
|
|
363
|
+
<template #default="{ state }">
|
|
364
|
+
<HstColorShades
|
|
365
|
+
v-for="(shades, key) of colors"
|
|
366
|
+
:key="key"
|
|
367
|
+
:shades="shades"
|
|
368
|
+
:get-name="shade => `${key}-${shade}`"
|
|
369
|
+
:search="state.search"
|
|
370
|
+
/>
|
|
371
|
+
</template>
|
|
372
|
+
|
|
373
|
+
<template #controls="{ state }">
|
|
374
|
+
<HstText
|
|
375
|
+
v-model="state.search"
|
|
376
|
+
title="Filter colors..."
|
|
377
|
+
/>
|
|
378
|
+
</template>
|
|
379
|
+
</Variant>
|
|
380
|
+
|
|
381
|
+
<Variant title="long names">
|
|
382
|
+
<HstColorShades
|
|
383
|
+
v-for="(shades, key) of colors"
|
|
384
|
+
:key="key"
|
|
385
|
+
:shades="shades"
|
|
386
|
+
:get-name="shade => `${'\'very-'.repeat(5)}long-${key}-${shade}`"
|
|
387
|
+
/>
|
|
388
|
+
</Variant>
|
|
389
|
+
</Story>
|
|
390
|
+
</template>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
export default {
|
|
3
|
+
name: 'HstColorShades',
|
|
4
|
+
}
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { computed } from 'vue'
|
|
9
|
+
import { VTooltip as vTooltip } from 'floating-vue'
|
|
10
|
+
import HstCopyIcon from '../HstCopyIcon.vue'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{
|
|
13
|
+
shades: Record<string, string>
|
|
14
|
+
// @TODO report eslint bug
|
|
15
|
+
// eslint-disable-next-line func-call-spacing
|
|
16
|
+
getName?: (key: string, color: string) => string
|
|
17
|
+
search?: string
|
|
18
|
+
}>()
|
|
19
|
+
|
|
20
|
+
const shadesWithName = computed(() => {
|
|
21
|
+
const shades = props.shades
|
|
22
|
+
const getName = props.getName
|
|
23
|
+
return Object.entries(shades).map(([key, color]) => {
|
|
24
|
+
const name = getName ? getName(key, color) : key
|
|
25
|
+
return {
|
|
26
|
+
key,
|
|
27
|
+
color,
|
|
28
|
+
name,
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const displayedShades = computed(() => {
|
|
34
|
+
let list = shadesWithName.value
|
|
35
|
+
if (props.search) {
|
|
36
|
+
const reg = new RegExp(props.search, 'i')
|
|
37
|
+
list = list.filter(({ name }) => reg.test(name))
|
|
38
|
+
}
|
|
39
|
+
return list
|
|
40
|
+
})
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<div
|
|
45
|
+
v-if="displayedShades.length"
|
|
46
|
+
class="htw-grid htw-gap-4 htw-grid-cols-[repeat(auto-fill,minmax(200px,1fr))] htw-m-4"
|
|
47
|
+
>
|
|
48
|
+
<div
|
|
49
|
+
v-for="shade of displayedShades"
|
|
50
|
+
:key="shade.key"
|
|
51
|
+
class="htw-flex htw-flex-col htw-gap-2 htw-group"
|
|
52
|
+
>
|
|
53
|
+
<slot
|
|
54
|
+
:color="shade.color"
|
|
55
|
+
>
|
|
56
|
+
<div
|
|
57
|
+
class="htw-rounded-full htw-w-16 htw-h-16"
|
|
58
|
+
:style="{
|
|
59
|
+
backgroundColor: shade.color,
|
|
60
|
+
}"
|
|
61
|
+
/>
|
|
62
|
+
</slot>
|
|
63
|
+
<div>
|
|
64
|
+
<div class="htw-flex htw-gap-1">
|
|
65
|
+
<pre
|
|
66
|
+
v-tooltip="shade.name.length > 23 ? shade.name : ''"
|
|
67
|
+
class="htw-my-0 htw-truncate htw-shrink"
|
|
68
|
+
>{{ shade.name }}</pre>
|
|
69
|
+
<HstCopyIcon
|
|
70
|
+
:content="shade.name"
|
|
71
|
+
class="htw-hidden group-hover:htw-block htw-flex-none"
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
<div class="htw-flex htw-gap-1">
|
|
75
|
+
<pre
|
|
76
|
+
v-tooltip="shade.color.length > 23 ? shade.color : ''"
|
|
77
|
+
class="htw-my-0 htw-opacity-50 htw-truncate htw-shrink"
|
|
78
|
+
>{{ shade.color }}</pre>
|
|
79
|
+
<HstCopyIcon
|
|
80
|
+
:content="shade.color"
|
|
81
|
+
class="htw-hidden group-hover:htw-block htw-flex-none"
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</template>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import HstTokenGrid from './HstTokenGrid.vue'
|
|
3
|
+
|
|
4
|
+
const tokens = {
|
|
5
|
+
sm: 'filter: drop-shadow(0 1px 1px rgb(0 0 0 / 0.05))',
|
|
6
|
+
DEFAULT: 'filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.1)) drop-shadow(0 1px 1px rgb(0 0 0 / 0.06))',
|
|
7
|
+
md: 'filter: drop-shadow(0 4px 3px rgb(0 0 0 / 0.07)) drop-shadow(0 2px 2px rgb(0 0 0 / 0.06))',
|
|
8
|
+
lg: 'filter: drop-shadow(0 10px 8px rgb(0 0 0 / 0.04)) drop-shadow(0 4px 3px rgb(0 0 0 / 0.1))',
|
|
9
|
+
xl: 'filter: drop-shadow(0 20px 13px rgb(0 0 0 / 0.03)) drop-shadow(0 8px 5px rgb(0 0 0 / 0.08))',
|
|
10
|
+
'2xl': 'filter: drop-shadow(0 25px 25px rgb(0 0 0 / 0.15))',
|
|
11
|
+
none: 'filter: drop-shadow(0 0 #0000)',
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<Story
|
|
17
|
+
title="design-tokens/HstTokenGrid"
|
|
18
|
+
responsive-disabled
|
|
19
|
+
>
|
|
20
|
+
<Variant title="default">
|
|
21
|
+
<HstTokenGrid
|
|
22
|
+
:tokens="tokens"
|
|
23
|
+
:get-name="key => key === 'DEFAULT' ? 'drop-shadow' : `drop-shadow-${key}`"
|
|
24
|
+
:col-size="160"
|
|
25
|
+
>
|
|
26
|
+
<template #default="{ token }">
|
|
27
|
+
<div
|
|
28
|
+
class="htw-w-32 htw-h-32 htw-bg-white dark:htw-bg-black htw-rounded htw-mb-2"
|
|
29
|
+
:style="token.value"
|
|
30
|
+
/>
|
|
31
|
+
</template>
|
|
32
|
+
</HstTokenGrid>
|
|
33
|
+
</Variant>
|
|
34
|
+
</Story>
|
|
35
|
+
</template>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
export default {
|
|
3
|
+
name: 'HstDesignTokens',
|
|
4
|
+
}
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { computed, withDefaults } from 'vue'
|
|
9
|
+
import { VTooltip as vTooltip } from 'floating-vue'
|
|
10
|
+
import HstCopyIcon from '../HstCopyIcon.vue'
|
|
11
|
+
|
|
12
|
+
const props = withDefaults(defineProps<{
|
|
13
|
+
tokens: Record<string, string | number>
|
|
14
|
+
colSize?: number
|
|
15
|
+
// @TODO report eslint bug
|
|
16
|
+
// eslint-disable-next-line func-call-spacing
|
|
17
|
+
getName?: (key: string, value: string | number) => string
|
|
18
|
+
}>(), {
|
|
19
|
+
colSize: 180,
|
|
20
|
+
getName: null,
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const processedTokens = computed(() => {
|
|
24
|
+
const list = props.tokens
|
|
25
|
+
const getName = props.getName
|
|
26
|
+
return Object.entries(list).map(([key, value]) => {
|
|
27
|
+
const name = getName ? getName(key, value) : key
|
|
28
|
+
return {
|
|
29
|
+
key,
|
|
30
|
+
name,
|
|
31
|
+
value: typeof value === 'string' ? value : value.toString(),
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const colSizePx = computed(() => `${props.colSize}px`)
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<template>
|
|
40
|
+
<div class="htw-bind-col-size htw-grid htw-gap-4 htw-m-4">
|
|
41
|
+
<div
|
|
42
|
+
v-for="token of processedTokens"
|
|
43
|
+
:key="token.key"
|
|
44
|
+
class="htw-flex htw-flex-col htw-gap-2 htw-group"
|
|
45
|
+
>
|
|
46
|
+
<slot
|
|
47
|
+
:token="token"
|
|
48
|
+
/>
|
|
49
|
+
<div>
|
|
50
|
+
<div class="htw-flex htw-gap-1">
|
|
51
|
+
<pre
|
|
52
|
+
v-tooltip="token.name.length > colSize / 8 ? token.name : ''"
|
|
53
|
+
class="htw-my-0 htw-truncate htw-shrink"
|
|
54
|
+
>{{ token.name }}</pre>
|
|
55
|
+
<HstCopyIcon
|
|
56
|
+
:content="token.name"
|
|
57
|
+
class="htw-hidden group-hover:htw-block htw-flex-none"
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="htw-flex htw-gap-1">
|
|
61
|
+
<pre
|
|
62
|
+
v-tooltip="token.value.length > colSize / 8 ? token.value : ''"
|
|
63
|
+
class="htw-my-0 htw-opacity-50 htw-truncate htw-shrink"
|
|
64
|
+
>{{ token.value }}</pre>
|
|
65
|
+
<HstCopyIcon
|
|
66
|
+
:content="token.value"
|
|
67
|
+
class="htw-hidden group-hover:htw-block htw-flex-none"
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</template>
|
|
74
|
+
|
|
75
|
+
<style scoped>
|
|
76
|
+
.htw-bind-col-size {
|
|
77
|
+
grid-template-columns: repeat(auto-fill, minmax(v-bind(colSizePx), 1fr));
|
|
78
|
+
}
|
|
79
|
+
</style>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import HstTokenList from './HstTokenList.vue'
|
|
3
|
+
|
|
4
|
+
const tokens = {
|
|
5
|
+
0: 0,
|
|
6
|
+
1: '0.25rem',
|
|
7
|
+
2: '0.5rem',
|
|
8
|
+
3: '0.75rem',
|
|
9
|
+
4: '1rem',
|
|
10
|
+
5: '1.25rem',
|
|
11
|
+
6: '1.5rem',
|
|
12
|
+
8: '2rem',
|
|
13
|
+
10: '2.5rem',
|
|
14
|
+
12: '3rem',
|
|
15
|
+
16: '4rem',
|
|
16
|
+
20: '5rem',
|
|
17
|
+
24: '6rem',
|
|
18
|
+
32: '8rem',
|
|
19
|
+
40: '10rem',
|
|
20
|
+
48: '12rem',
|
|
21
|
+
56: '14rem',
|
|
22
|
+
64: '16rem',
|
|
23
|
+
auto: 'auto',
|
|
24
|
+
px: '1px',
|
|
25
|
+
screen: '100vw',
|
|
26
|
+
'1/2': '50%',
|
|
27
|
+
'1/3': '33.333333%',
|
|
28
|
+
'2/3': '66.666667%',
|
|
29
|
+
'1/4': '25%',
|
|
30
|
+
'2/4': '50%',
|
|
31
|
+
'3/4': '75%',
|
|
32
|
+
'1/5': '20%',
|
|
33
|
+
'2/5': '40%',
|
|
34
|
+
'3/5': '60%',
|
|
35
|
+
'4/5': '80%',
|
|
36
|
+
'1/6': '16.666667%',
|
|
37
|
+
'2/6': '33.333333%',
|
|
38
|
+
'3/6': '50%',
|
|
39
|
+
'4/6': '66.666667%',
|
|
40
|
+
'5/6': '83.333333%',
|
|
41
|
+
'1/12': '8.333333%',
|
|
42
|
+
'2/12': '16.666667%',
|
|
43
|
+
'3/12': '25%',
|
|
44
|
+
'4/12': '33.333333%',
|
|
45
|
+
'5/12': '41.666667%',
|
|
46
|
+
'6/12': '50%',
|
|
47
|
+
'7/12': '58.333333%',
|
|
48
|
+
'8/12': '66.666667%',
|
|
49
|
+
'9/12': '75%',
|
|
50
|
+
'10/12': '83.333333%',
|
|
51
|
+
'11/12': '91.666667%',
|
|
52
|
+
full: '100%',
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<template>
|
|
57
|
+
<Story
|
|
58
|
+
title="design-tokens/HstTokenList"
|
|
59
|
+
responsive-disabled
|
|
60
|
+
>
|
|
61
|
+
<Variant title="default">
|
|
62
|
+
<HstTokenList
|
|
63
|
+
:tokens="tokens"
|
|
64
|
+
:get-name="key => `w-${key}`"
|
|
65
|
+
>
|
|
66
|
+
<template #default="{ token }">
|
|
67
|
+
<div class="htw-bg-gray-500/10">
|
|
68
|
+
<div
|
|
69
|
+
class="htw-h-20 htw-bg-gray-500/50"
|
|
70
|
+
:style="{
|
|
71
|
+
width: token.value,
|
|
72
|
+
}"
|
|
73
|
+
/>
|
|
74
|
+
</div>
|
|
75
|
+
</template>
|
|
76
|
+
</HstTokenList>
|
|
77
|
+
</Variant>
|
|
78
|
+
</Story>
|
|
79
|
+
</template>
|