@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.
@@ -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>
package/src/index.ts CHANGED
@@ -3,11 +3,15 @@ import HstCheckboxVue from './components/checkbox/HstCheckbox.vue'
3
3
  import HstTextVue from './components/text/HstText.vue'
4
4
  import HstNumberVue from './components/number/HstNumber.vue'
5
5
  import HstTextareaVue from './components/textarea/HstTextarea.vue'
6
+ import HstColorShadesVue from './components/design-tokens/HstColorShades.vue'
7
+ import HstCopyIconVue from './components/HstCopyIcon.vue'
6
8
 
7
9
  export const HstCheckbox = HstCheckboxVue
8
10
  export const HstText = HstTextVue
9
11
  export const HstNumber = HstNumberVue
10
12
  export const HstTextarea = HstTextareaVue
13
+ export const HstColorShades = HstColorShadesVue
14
+ export const HstCopyIcon = HstCopyIconVue
11
15
 
12
16
  export function registerVueComponents (app: App) {
13
17
  app.component('HstCheckbox', HstCheckboxVue)
package/tsconfig.json CHANGED
@@ -27,6 +27,8 @@
27
27
  "alwaysStrict": true,
28
28
  "strictBindCallApply": true,
29
29
  "strictFunctionTypes": true,
30
+ // Volar
31
+ "jsx": "preserve",
30
32
  },
31
33
  "include": [
32
34
  "src"