@histoire/controls 0.2.4 → 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.
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
2
+ export default _default;
@@ -0,0 +1,33 @@
1
+ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
2
+ tokens: Record<string, string | number>;
3
+ colSize?: number;
4
+ getName?: (key: string, value: string | number) => string;
5
+ }>, {
6
+ colSize: number;
7
+ getName: any;
8
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
9
+ tokens: Record<string, string | number>;
10
+ colSize?: number;
11
+ getName?: (key: string, value: string | number) => string;
12
+ }>, {
13
+ colSize: number;
14
+ getName: any;
15
+ }>>>, {
16
+ getName: (key: string, value: string | number) => string;
17
+ colSize: number;
18
+ }>;
19
+ export default _default;
20
+ declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
21
+ declare type __VLS_TypePropsToRuntimeProps<T> = {
22
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
23
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
24
+ } : {
25
+ type: import('vue').PropType<T[K]>;
26
+ required: true;
27
+ };
28
+ };
29
+ declare type __VLS_WithDefaults<P, D> = {
30
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? P[K] & {
31
+ default: D[K];
32
+ } : P[K];
33
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
2
+ export default _default;
@@ -0,0 +1,17 @@
1
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
2
+ tokens: Record<string, string | number>;
3
+ getName?: (key: string, value: string | number) => string;
4
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
5
+ tokens: Record<string, string | number>;
6
+ getName?: (key: string, value: string | number) => string;
7
+ }>>>, {}>;
8
+ export default _default;
9
+ declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
10
+ declare type __VLS_TypePropsToRuntimeProps<T> = {
11
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
12
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
13
+ } : {
14
+ type: import('vue').PropType<T[K]>;
15
+ required: true;
16
+ };
17
+ };
package/dist/index.es.js CHANGED
@@ -5027,12 +5027,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
5027
5027
  }));
5028
5028
  const _hoisted_1 = {
5029
5029
  key: 0,
5030
- class: "htw-grid htw-gap-4 htw-grid-cols-[repeat(auto-fill,minmax(100px,1fr))] htw-m-4"
5030
+ class: "htw-grid htw-gap-4 htw-grid-cols-[repeat(auto-fill,minmax(200px,1fr))] htw-m-4"
5031
5031
  };
5032
5032
  const _hoisted_2 = { class: "htw-flex htw-gap-1" };
5033
- const _hoisted_3 = { class: "htw-my-0" };
5033
+ const _hoisted_3 = { class: "htw-my-0 htw-truncate htw-shrink" };
5034
5034
  const _hoisted_4 = { class: "htw-flex htw-gap-1" };
5035
- const _hoisted_5 = { class: "htw-my-0 htw-opacity-50" };
5035
+ const _hoisted_5 = { class: "htw-my-0 htw-opacity-50 htw-truncate htw-shrink" };
5036
5036
  const __default__ = {
5037
5037
  name: "HstColorShades"
5038
5038
  };
@@ -5083,17 +5083,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
5083
5083
  ]),
5084
5084
  createElementVNode("div", null, [
5085
5085
  createElementVNode("div", _hoisted_2, [
5086
- createElementVNode("pre", _hoisted_3, toDisplayString(shade.name), 1),
5086
+ withDirectives((openBlock(), createElementBlock("pre", _hoisted_3, [
5087
+ createTextVNode(toDisplayString(shade.name), 1)
5088
+ ])), [
5089
+ [unref(VTooltip), shade.name.length > 23 ? shade.name : ""]
5090
+ ]),
5087
5091
  createVNode(_sfc_main$1, {
5088
5092
  content: shade.name,
5089
- class: "htw-hidden group-hover:htw-block"
5093
+ class: "htw-hidden group-hover:htw-block htw-flex-none"
5090
5094
  }, null, 8, ["content"])
5091
5095
  ]),
5092
5096
  createElementVNode("div", _hoisted_4, [
5093
- createElementVNode("pre", _hoisted_5, toDisplayString(shade.color), 1),
5097
+ withDirectives((openBlock(), createElementBlock("pre", _hoisted_5, [
5098
+ createTextVNode(toDisplayString(shade.color), 1)
5099
+ ])), [
5100
+ [unref(VTooltip), shade.color.length > 23 ? shade.color : ""]
5101
+ ]),
5094
5102
  createVNode(_sfc_main$1, {
5095
5103
  content: shade.color,
5096
- class: "htw-hidden group-hover:htw-block"
5104
+ class: "htw-hidden group-hover:htw-block htw-flex-none"
5097
5105
  }, null, 8, ["content"])
5098
5106
  ])
5099
5107
  ])
package/dist/style.css CHANGED
@@ -275,11 +275,25 @@
275
275
  margin-bottom:0px
276
276
  }
277
277
 
278
+ .htw-my-8{
279
+ margin-top:2rem;
280
+ margin-bottom:2rem
281
+ }
282
+
283
+ .htw-mx-4{
284
+ margin-left:1rem;
285
+ margin-right:1rem
286
+ }
287
+
278
288
  .-htw-my-1{
279
289
  margin-top:-0.25rem;
280
290
  margin-bottom:-0.25rem
281
291
  }
282
292
 
293
+ .htw-mb-2{
294
+ margin-bottom:0.5rem
295
+ }
296
+
283
297
  .htw-box-border{
284
298
  box-sizing:border-box
285
299
  }
@@ -316,6 +330,14 @@
316
330
  height:4rem
317
331
  }
318
332
 
333
+ .htw-h-32{
334
+ height:8rem
335
+ }
336
+
337
+ .htw-h-20{
338
+ height:5rem
339
+ }
340
+
319
341
  .htw-min-h-\[26px\]{
320
342
  min-height:26px
321
343
  }
@@ -336,14 +358,26 @@
336
358
  width:4rem
337
359
  }
338
360
 
361
+ .htw-w-32{
362
+ width:8rem
363
+ }
364
+
339
365
  .htw-w-full{
340
366
  width:100%
341
367
  }
342
368
 
369
+ .htw-flex-none{
370
+ flex:none
371
+ }
372
+
343
373
  .htw-shrink-0{
344
374
  flex-shrink:0
345
375
  }
346
376
 
377
+ .htw-shrink{
378
+ flex-shrink:1
379
+ }
380
+
347
381
  .htw-grow{
348
382
  flex-grow:1
349
383
  }
@@ -371,8 +405,8 @@
371
405
  resize:vertical
372
406
  }
373
407
 
374
- .htw-grid-cols-\[repeat\(auto-fill\,minmax\(100px\,1fr\)\)\]{
375
- grid-template-columns:repeat(auto-fill,minmax(100px,1fr))
408
+ .htw-grid-cols-\[repeat\(auto-fill\,minmax\(200px\,1fr\)\)\]{
409
+ grid-template-columns:repeat(auto-fill,minmax(200px,1fr))
376
410
  }
377
411
 
378
412
  .htw-flex-col{
@@ -407,6 +441,12 @@
407
441
  overflow:hidden
408
442
  }
409
443
 
444
+ .htw-truncate{
445
+ overflow:hidden;
446
+ text-overflow:ellipsis;
447
+ white-space:nowrap
448
+ }
449
+
410
450
  .htw-text-ellipsis{
411
451
  text-overflow:ellipsis
412
452
  }
@@ -452,6 +492,19 @@
452
492
  border-color:rgb(0 0 0 / 0.25)
453
493
  }
454
494
 
495
+ .htw-bg-white{
496
+ --tw-bg-opacity:1;
497
+ background-color:rgb(255 255 255 / var(--tw-bg-opacity))
498
+ }
499
+
500
+ .htw-bg-gray-500\/10{
501
+ background-color:rgb(113 113 122 / 0.1)
502
+ }
503
+
504
+ .htw-bg-gray-500\/50{
505
+ background-color:rgb(113 113 122 / 0.5)
506
+ }
507
+
455
508
  .htw-bg-transparent{
456
509
  background-color:transparent
457
510
  }
@@ -587,6 +640,11 @@ body {
587
640
  border-color:rgb(255 255 255 / 0.25)
588
641
  }
589
642
 
643
+ .htw-dark .dark\:htw-bg-black{
644
+ --tw-bg-opacity:1;
645
+ background-color:rgb(0 0 0 / var(--tw-bg-opacity))
646
+ }
647
+
590
648
  .htw-dark .dark\:hover\:htw-bg-primary-800:hover{
591
649
  --tw-bg-opacity:1;
592
650
  background-color:rgb(6 95 70 / var(--tw-bg-opacity))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@histoire/controls",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Prebuilt controls components",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -59,7 +59,7 @@
59
59
  "build:types": "vue-tsc --declaration --emitDeclarationOnly",
60
60
  "watch": "concurrently \"vite build --watch\" \"pnpm run build:types -- --watch\"",
61
61
  "watch:full": "concurrently \"vite build --watch\" \"pnpm run build:css -- --watch\" \"pnpm run build:types -- --watch\"",
62
- "test:open": "peeky open",
62
+ "test:open": "peeky open --port 5010",
63
63
  "test": "peeky run",
64
64
  "story:dev": "histoire dev",
65
65
  "story:build": "histoire build"
@@ -377,5 +377,14 @@ const colors = {
377
377
  />
378
378
  </template>
379
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>
380
389
  </Story>
381
390
  </template>
@@ -5,7 +5,8 @@ export default {
5
5
  </script>
6
6
 
7
7
  <script lang="ts" setup>
8
- import { computed, ref } from 'vue'
8
+ import { computed } from 'vue'
9
+ import { VTooltip as vTooltip } from 'floating-vue'
9
10
  import HstCopyIcon from '../HstCopyIcon.vue'
10
11
 
11
12
  const props = defineProps<{
@@ -42,7 +43,7 @@ const displayedShades = computed(() => {
42
43
  <template>
43
44
  <div
44
45
  v-if="displayedShades.length"
45
- class="htw-grid htw-gap-4 htw-grid-cols-[repeat(auto-fill,minmax(100px,1fr))] htw-m-4"
46
+ class="htw-grid htw-gap-4 htw-grid-cols-[repeat(auto-fill,minmax(200px,1fr))] htw-m-4"
46
47
  >
47
48
  <div
48
49
  v-for="shade of displayedShades"
@@ -61,17 +62,23 @@ const displayedShades = computed(() => {
61
62
  </slot>
62
63
  <div>
63
64
  <div class="htw-flex htw-gap-1">
64
- <pre class="htw-my-0">{{ shade.name }}</pre>
65
+ <pre
66
+ v-tooltip="shade.name.length > 23 ? shade.name : ''"
67
+ class="htw-my-0 htw-truncate htw-shrink"
68
+ >{{ shade.name }}</pre>
65
69
  <HstCopyIcon
66
70
  :content="shade.name"
67
- class="htw-hidden group-hover:htw-block"
71
+ class="htw-hidden group-hover:htw-block htw-flex-none"
68
72
  />
69
73
  </div>
70
74
  <div class="htw-flex htw-gap-1">
71
- <pre class="htw-my-0 htw-opacity-50">{{ shade.color }}</pre>
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>
72
79
  <HstCopyIcon
73
80
  :content="shade.color"
74
- class="htw-hidden group-hover:htw-block"
81
+ class="htw-hidden group-hover:htw-block htw-flex-none"
75
82
  />
76
83
  </div>
77
84
  </div>
@@ -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>
@@ -0,0 +1,58 @@
1
+ <script lang="ts">
2
+ export default {
3
+ name: 'HstDesignTokens',
4
+ }
5
+ </script>
6
+
7
+ <script lang="ts" setup>
8
+ import { computed } from 'vue'
9
+ import HstCopyIcon from '../HstCopyIcon.vue'
10
+
11
+ const props = defineProps<{
12
+ tokens: Record<string, string | number>
13
+ // @TODO report eslint bug
14
+ // eslint-disable-next-line func-call-spacing
15
+ getName?: (key: string, value: string | number) => string
16
+ }>()
17
+
18
+ const processedTokens = computed(() => {
19
+ const list = props.tokens
20
+ const getName = props.getName
21
+ return Object.entries(list).map(([key, value]) => {
22
+ const name = getName ? getName(key, value) : key
23
+ return {
24
+ key,
25
+ name,
26
+ value: typeof value === 'string' ? value : value.toString(),
27
+ }
28
+ })
29
+ })
30
+ </script>
31
+
32
+ <template>
33
+ <div
34
+ v-for="token of processedTokens"
35
+ :key="token.key"
36
+ class="htw-flex htw-flex-col htw-gap-2 htw-group htw-my-8"
37
+ >
38
+ <slot
39
+ :token="token"
40
+ />
41
+ <div class="htw-mx-4">
42
+ <div class="htw-flex htw-gap-1">
43
+ <pre class="htw-my-0 htw-truncate htw-shrink">{{ token.name }}</pre>
44
+ <HstCopyIcon
45
+ :content="token.name"
46
+ class="htw-hidden group-hover:htw-block htw-flex-none"
47
+ />
48
+ </div>
49
+ <div class="htw-flex htw-gap-1">
50
+ <pre class="htw-my-0 htw-opacity-50 htw-truncate htw-shrink">{{ token.value }}</pre>
51
+ <HstCopyIcon
52
+ :content="token.value"
53
+ class="htw-hidden group-hover:htw-block htw-flex-none"
54
+ />
55
+ </div>
56
+ </div>
57
+ </div>
58
+ </template>