poveste 0.1.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.
Files changed (251) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +11 -0
  3. package/bin.mjs +4 -0
  4. package/client.d.ts +19 -0
  5. package/client.js +15 -0
  6. package/dist/controls.d.ts +2 -0
  7. package/dist/controls.d.ts.map +1 -0
  8. package/dist/controls.js +1 -0
  9. package/dist/node/alias.d.ts +3 -0
  10. package/dist/node/alias.d.ts.map +1 -0
  11. package/dist/node/alias.js +5 -0
  12. package/dist/node/bin.d.ts +2 -0
  13. package/dist/node/bin.d.ts.map +1 -0
  14. package/dist/node/bin.js +35 -0
  15. package/dist/node/build-serialize.d.ts +22 -0
  16. package/dist/node/build-serialize.d.ts.map +1 -0
  17. package/dist/node/build-serialize.js +36 -0
  18. package/dist/node/build.d.ts +3 -0
  19. package/dist/node/build.d.ts.map +1 -0
  20. package/dist/node/build.js +228 -0
  21. package/dist/node/builtin-plugins/pinceau-tokens.d.ts +7 -0
  22. package/dist/node/builtin-plugins/pinceau-tokens.d.ts.map +1 -0
  23. package/dist/node/builtin-plugins/pinceau-tokens.js +505 -0
  24. package/dist/node/builtin-plugins/tailwind-tokens.d.ts +6 -0
  25. package/dist/node/builtin-plugins/tailwind-tokens.d.ts.map +1 -0
  26. package/dist/node/builtin-plugins/tailwind-tokens.js +523 -0
  27. package/dist/node/builtin-plugins/vanilla-support/MountStory.d.ts +15 -0
  28. package/dist/node/builtin-plugins/vanilla-support/MountStory.d.ts.map +1 -0
  29. package/dist/node/builtin-plugins/vanilla-support/MountStory.js +39 -0
  30. package/dist/node/builtin-plugins/vanilla-support/RenderStory.d.ts +39 -0
  31. package/dist/node/builtin-plugins/vanilla-support/RenderStory.d.ts.map +1 -0
  32. package/dist/node/builtin-plugins/vanilla-support/RenderStory.js +129 -0
  33. package/dist/node/builtin-plugins/vanilla-support/client.d.ts +4 -0
  34. package/dist/node/builtin-plugins/vanilla-support/client.d.ts.map +1 -0
  35. package/dist/node/builtin-plugins/vanilla-support/client.js +5 -0
  36. package/dist/node/builtin-plugins/vanilla-support/collect.d.ts +3 -0
  37. package/dist/node/builtin-plugins/vanilla-support/collect.d.ts.map +1 -0
  38. package/dist/node/builtin-plugins/vanilla-support/collect.js +33 -0
  39. package/dist/node/builtin-plugins/vanilla-support/plugin.d.ts +3 -0
  40. package/dist/node/builtin-plugins/vanilla-support/plugin.d.ts.map +1 -0
  41. package/dist/node/builtin-plugins/vanilla-support/plugin.js +29 -0
  42. package/dist/node/builtin-plugins/vanilla-support/types.d.ts +36 -0
  43. package/dist/node/builtin-plugins/vanilla-support/types.d.ts.map +1 -0
  44. package/dist/node/builtin-plugins/vanilla-support/types.js +3 -0
  45. package/dist/node/builtin-plugins/vanilla-support/vanilla.story.d.ts +4 -0
  46. package/dist/node/builtin-plugins/vanilla-support/vanilla.story.d.ts.map +1 -0
  47. package/dist/node/builtin-plugins/vanilla-support/vanilla.story.js +55 -0
  48. package/dist/node/collect/index.d.ts +14 -0
  49. package/dist/node/collect/index.d.ts.map +1 -0
  50. package/dist/node/collect/index.js +129 -0
  51. package/dist/node/collect/run.d.ts +3 -0
  52. package/dist/node/collect/run.d.ts.map +1 -0
  53. package/dist/node/collect/run.js +7 -0
  54. package/dist/node/collect/worker.d.ts +14 -0
  55. package/dist/node/collect/worker.d.ts.map +1 -0
  56. package/dist/node/collect/worker.js +64 -0
  57. package/dist/node/colors.d.ts +287 -0
  58. package/dist/node/colors.d.ts.map +1 -0
  59. package/dist/node/colors.js +324 -0
  60. package/dist/node/commands/build.d.ts +5 -0
  61. package/dist/node/commands/build.d.ts.map +1 -0
  62. package/dist/node/commands/build.js +9 -0
  63. package/dist/node/commands/dev.d.ts +8 -0
  64. package/dist/node/commands/dev.d.ts.map +1 -0
  65. package/dist/node/commands/dev.js +52 -0
  66. package/dist/node/commands/preview.d.ts +5 -0
  67. package/dist/node/commands/preview.d.ts.map +1 -0
  68. package/dist/node/commands/preview.js +15 -0
  69. package/dist/node/config.d.ts +40 -0
  70. package/dist/node/config.d.ts.map +1 -0
  71. package/dist/node/config.js +330 -0
  72. package/dist/node/context.d.ts +18 -0
  73. package/dist/node/context.d.ts.map +1 -0
  74. package/dist/node/context.js +28 -0
  75. package/dist/node/dom/dom-keys.d.ts +5 -0
  76. package/dist/node/dom/dom-keys.d.ts.map +1 -0
  77. package/dist/node/dom/dom-keys.js +233 -0
  78. package/dist/node/dom/env.d.ts +5 -0
  79. package/dist/node/dom/env.d.ts.map +1 -0
  80. package/dist/node/dom/env.js +47 -0
  81. package/dist/node/dom/util.d.ts +11 -0
  82. package/dist/node/dom/util.d.ts.map +1 -0
  83. package/dist/node/dom/util.js +65 -0
  84. package/dist/node/index.d.ts +12 -0
  85. package/dist/node/index.d.ts.map +1 -0
  86. package/dist/node/index.js +4 -0
  87. package/dist/node/load.d.ts +9 -0
  88. package/dist/node/load.d.ts.map +1 -0
  89. package/dist/node/load.js +42 -0
  90. package/dist/node/markdown.d.ts +11 -0
  91. package/dist/node/markdown.d.ts.map +1 -0
  92. package/dist/node/markdown.js +228 -0
  93. package/dist/node/plugin.d.ts +42 -0
  94. package/dist/node/plugin.d.ts.map +1 -0
  95. package/dist/node/plugin.js +67 -0
  96. package/dist/node/preview.d.ts +8 -0
  97. package/dist/node/preview.d.ts.map +1 -0
  98. package/dist/node/preview.js +41 -0
  99. package/dist/node/search.d.ts +17 -0
  100. package/dist/node/search.d.ts.map +1 -0
  101. package/dist/node/search.js +72 -0
  102. package/dist/node/server.d.ts +12 -0
  103. package/dist/node/server.d.ts.map +1 -0
  104. package/dist/node/server.js +189 -0
  105. package/dist/node/stories.d.ts +22 -0
  106. package/dist/node/stories.d.ts.map +1 -0
  107. package/dist/node/stories.js +125 -0
  108. package/dist/node/tree.d.ts +4 -0
  109. package/dist/node/tree.d.ts.map +1 -0
  110. package/dist/node/tree.js +117 -0
  111. package/dist/node/util/find-up.d.ts +2 -0
  112. package/dist/node/util/find-up.d.ts.map +1 -0
  113. package/dist/node/util/find-up.js +20 -0
  114. package/dist/node/util/fs.d.ts +2 -0
  115. package/dist/node/util/fs.d.ts.map +1 -0
  116. package/dist/node/util/fs.js +1 -0
  117. package/dist/node/util/log.d.ts +2 -0
  118. package/dist/node/util/log.d.ts.map +1 -0
  119. package/dist/node/util/log.js +9 -0
  120. package/dist/node/util/slugify.d.ts +2 -0
  121. package/dist/node/util/slugify.d.ts.map +1 -0
  122. package/dist/node/util/slugify.js +22 -0
  123. package/dist/node/util/vendors.d.ts +3 -0
  124. package/dist/node/util/vendors.d.ts.map +1 -0
  125. package/dist/node/util/vendors.js +22 -0
  126. package/dist/node/vendors/controls.d.ts +2 -0
  127. package/dist/node/vendors/controls.d.ts.map +1 -0
  128. package/dist/node/vendors/controls.js +1 -0
  129. package/dist/node/vendors/vue.d.ts +2 -0
  130. package/dist/node/vendors/vue.d.ts.map +1 -0
  131. package/dist/node/vendors/vue.js +1 -0
  132. package/dist/node/virtual/index.d.ts +38 -0
  133. package/dist/node/virtual/index.d.ts.map +1 -0
  134. package/dist/node/virtual/index.js +49 -0
  135. package/dist/node/virtual/markdown.d.ts +3 -0
  136. package/dist/node/virtual/markdown.d.ts.map +1 -0
  137. package/dist/node/virtual/markdown.js +19 -0
  138. package/dist/node/virtual/noop.d.ts +2 -0
  139. package/dist/node/virtual/noop.d.ts.map +1 -0
  140. package/dist/node/virtual/noop.js +1 -0
  141. package/dist/node/virtual/resolved-commands.d.ts +3 -0
  142. package/dist/node/virtual/resolved-commands.d.ts.map +1 -0
  143. package/dist/node/virtual/resolved-commands.js +32 -0
  144. package/dist/node/virtual/resolved-config.d.ts +3 -0
  145. package/dist/node/virtual/resolved-config.d.ts.map +1 -0
  146. package/dist/node/virtual/resolved-config.js +10 -0
  147. package/dist/node/virtual/resolved-generated-global-setup.d.ts +3 -0
  148. package/dist/node/virtual/resolved-generated-global-setup.d.ts.map +1 -0
  149. package/dist/node/virtual/resolved-generated-global-setup.js +23 -0
  150. package/dist/node/virtual/resolved-generated-setup-code.d.ts +3 -0
  151. package/dist/node/virtual/resolved-generated-setup-code.d.ts.map +1 -0
  152. package/dist/node/virtual/resolved-generated-setup-code.js +5 -0
  153. package/dist/node/virtual/resolved-markdown-files.d.ts +3 -0
  154. package/dist/node/virtual/resolved-markdown-files.d.ts.map +1 -0
  155. package/dist/node/virtual/resolved-markdown-files.js +17 -0
  156. package/dist/node/virtual/resolved-stories.d.ts +3 -0
  157. package/dist/node/virtual/resolved-stories.d.ts.map +1 -0
  158. package/dist/node/virtual/resolved-stories.js +42 -0
  159. package/dist/node/virtual/resolved-support-plugins-client.d.ts +3 -0
  160. package/dist/node/virtual/resolved-support-plugins-client.d.ts.map +1 -0
  161. package/dist/node/virtual/resolved-support-plugins-client.js +11 -0
  162. package/dist/node/virtual/resolved-support-plugins-collect.d.ts +3 -0
  163. package/dist/node/virtual/resolved-support-plugins-collect.d.ts.map +1 -0
  164. package/dist/node/virtual/resolved-support-plugins-collect.js +11 -0
  165. package/dist/node/virtual/resolved-theme.d.ts +3 -0
  166. package/dist/node/virtual/resolved-theme.d.ts.map +1 -0
  167. package/dist/node/virtual/resolved-theme.js +12 -0
  168. package/dist/node/virtual/story-source.d.ts +3 -0
  169. package/dist/node/virtual/story-source.d.ts.map +1 -0
  170. package/dist/node/virtual/story-source.js +16 -0
  171. package/dist/node/virtual/story.d.ts +3 -0
  172. package/dist/node/virtual/story.d.ts.map +1 -0
  173. package/dist/node/virtual/story.js +7 -0
  174. package/dist/node/virtual/util.d.ts +3 -0
  175. package/dist/node/virtual/util.d.ts.map +1 -0
  176. package/dist/node/virtual/util.js +4 -0
  177. package/dist/node/virtual/vite-plugin.d.ts +4 -0
  178. package/dist/node/virtual/vite-plugin.d.ts.map +1 -0
  179. package/dist/node/virtual/vite-plugin.js +126 -0
  180. package/dist/node/vite.d.ts +9 -0
  181. package/dist/node/vite.d.ts.map +1 -0
  182. package/dist/node/vite.js +337 -0
  183. package/index.d.ts +1 -0
  184. package/package.json +89 -0
  185. package/plugin.d.ts +3 -0
  186. package/plugin.js +11 -0
  187. package/src/controls.ts +1 -0
  188. package/src/node/__tests__/markdown/test1.story.md +7 -0
  189. package/src/node/__tests__/markdown/test2.story.md +5 -0
  190. package/src/node/__tests__/markdown.spec.ts +61 -0
  191. package/src/node/__tests__/tree.spec.ts +109 -0
  192. package/src/node/alias.ts +8 -0
  193. package/src/node/bin.ts +43 -0
  194. package/src/node/build-serialize.ts +62 -0
  195. package/src/node/build.ts +283 -0
  196. package/src/node/builtin-plugins/pinceau-tokens.ts +521 -0
  197. package/src/node/builtin-plugins/tailwind-tokens.ts +536 -0
  198. package/src/node/builtin-plugins/vanilla-support/MountStory.ts +49 -0
  199. package/src/node/builtin-plugins/vanilla-support/RenderStory.ts +164 -0
  200. package/src/node/builtin-plugins/vanilla-support/client.ts +6 -0
  201. package/src/node/builtin-plugins/vanilla-support/collect.ts +43 -0
  202. package/src/node/builtin-plugins/vanilla-support/plugin.ts +35 -0
  203. package/src/node/builtin-plugins/vanilla-support/types.ts +40 -0
  204. package/src/node/builtin-plugins/vanilla-support/vanilla.story.ts +63 -0
  205. package/src/node/collect/index.ts +160 -0
  206. package/src/node/collect/run.ts +9 -0
  207. package/src/node/collect/worker.ts +97 -0
  208. package/src/node/colors.ts +340 -0
  209. package/src/node/commands/build.ts +14 -0
  210. package/src/node/commands/dev.ts +67 -0
  211. package/src/node/commands/preview.ts +22 -0
  212. package/src/node/config.ts +385 -0
  213. package/src/node/context.ts +60 -0
  214. package/src/node/dom/dom-keys.ts +238 -0
  215. package/src/node/dom/env.ts +60 -0
  216. package/src/node/dom/util.ts +83 -0
  217. package/src/node/index.ts +12 -0
  218. package/src/node/load.ts +59 -0
  219. package/src/node/markdown.ts +267 -0
  220. package/src/node/plugin.ts +95 -0
  221. package/src/node/preview.ts +57 -0
  222. package/src/node/search.ts +84 -0
  223. package/src/node/server.ts +235 -0
  224. package/src/node/stories.ts +154 -0
  225. package/src/node/tree.ts +158 -0
  226. package/src/node/util/find-up.ts +24 -0
  227. package/src/node/util/fs.ts +1 -0
  228. package/src/node/util/log.ts +10 -0
  229. package/src/node/util/slugify.ts +26 -0
  230. package/src/node/util/vendors.ts +27 -0
  231. package/src/node/vendors/controls.ts +1 -0
  232. package/src/node/vendors/vue.ts +1 -0
  233. package/src/node/virtual/index.ts +50 -0
  234. package/src/node/virtual/markdown.ts +21 -0
  235. package/src/node/virtual/noop.ts +1 -0
  236. package/src/node/virtual/resolved-commands.ts +42 -0
  237. package/src/node/virtual/resolved-config.ts +12 -0
  238. package/src/node/virtual/resolved-generated-global-setup.ts +25 -0
  239. package/src/node/virtual/resolved-generated-setup-code.ts +7 -0
  240. package/src/node/virtual/resolved-markdown-files.ts +19 -0
  241. package/src/node/virtual/resolved-stories.ts +44 -0
  242. package/src/node/virtual/resolved-support-plugins-client.ts +14 -0
  243. package/src/node/virtual/resolved-support-plugins-collect.ts +14 -0
  244. package/src/node/virtual/resolved-theme.ts +14 -0
  245. package/src/node/virtual/story-source.ts +18 -0
  246. package/src/node/virtual/story.ts +9 -0
  247. package/src/node/virtual/util.ts +5 -0
  248. package/src/node/virtual/vite-plugin.ts +146 -0
  249. package/src/node/vite.ts +379 -0
  250. package/tsconfig.json +44 -0
  251. package/vitest.config.ts +10 -0
@@ -0,0 +1,521 @@
1
+ import type { Plugin, PluginApiBase } from '@poveste/shared'
2
+ import { join } from 'pathe'
3
+ import { getInjectedImport } from '../util/vendors.js'
4
+
5
+ export interface PinceauTokensOptions {
6
+ configOrPaths?: string | string[]
7
+ configFileName?: string
8
+ }
9
+
10
+ export function pinceauTokens(_options: PinceauTokensOptions = {}): Plugin {
11
+ const themePath = join(process.cwd(), 'node_modules/.vite/pinceau/index.js')
12
+
13
+ async function generate(api: PluginApiBase) {
14
+ try {
15
+ await api.fs.ensureDir(api.pluginTempDir)
16
+ await api.fs.emptyDir(api.pluginTempDir)
17
+ api.moduleLoader.clearCache()
18
+ await api.fs.writeFile(api.path.resolve(api.pluginTempDir, 'style.css'), css)
19
+ const theme = await api.moduleLoader.loadModule(themePath)
20
+ const storyFile = api.path.resolve(api.pluginTempDir, 'Pinceau.story.js')
21
+ await api.fs.writeFile(storyFile, storyTemplate(theme))
22
+ api.addStoryFile(storyFile)
23
+ }
24
+ catch (e) {
25
+ api.error(e.stack ?? e.message)
26
+ }
27
+ }
28
+
29
+ return {
30
+ name: 'builtin:pinceau-tokens',
31
+
32
+ config(config) {
33
+ // Add 'design-system' group
34
+ if (!config.tree) {
35
+ config.tree = {}
36
+ }
37
+ if (!config.tree.groups) {
38
+ config.tree.groups = []
39
+ }
40
+ if (!config.tree.groups.some(g => g.id === 'design-system')) {
41
+ let index = 0
42
+ // After 'top' group
43
+ const topIndex = config.tree.groups.findIndex(g => g.id === 'top')
44
+ if (topIndex > -1) {
45
+ index = topIndex + 1
46
+ }
47
+ // Insert group
48
+ config.tree.groups.splice(index, 0, {
49
+ id: 'design-system',
50
+ title: 'Design System',
51
+ })
52
+ }
53
+ },
54
+
55
+ onDev(api, onCleanup) {
56
+ const watcher = api.watcher.watch(themePath)
57
+ .on('change', () => generate(api))
58
+ .on('add', () => generate(api))
59
+
60
+ onCleanup(() => {
61
+ watcher.close()
62
+ })
63
+ },
64
+
65
+ async onBuild(api) {
66
+ await generate(api)
67
+ },
68
+ }
69
+ }
70
+
71
+ function storyTemplate(pinceauConfig: any) {
72
+ pinceauConfig = pinceauConfig?.theme || pinceauConfig?.default?.theme || {}
73
+
74
+ return `import 'histoire-style'
75
+ import './style.css'
76
+ import { createApp, h, markRaw, ref } from ${getInjectedImport('@poveste/vendors/vue')}
77
+ import {
78
+ HstColorShades,
79
+ HstTokenList,
80
+ HstTokenGrid,
81
+ HstText,
82
+ HstTextarea,
83
+ HstNumber,
84
+ } from ${getInjectedImport('@poveste/controls')}
85
+
86
+ const config = markRaw(${JSON.stringify(pinceauConfig, 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
+ const flattenTokens = (data, transformValue = (value) => (value?.value || value)) => {
91
+ const output = {}
92
+ function step(obj, prev) {
93
+ Object.keys(obj).forEach((key) => {
94
+ const value = obj[key]
95
+ const isarray = Array.isArray(value)
96
+ const type = Object.prototype.toString.call(value)
97
+ const isobject
98
+ = type === '[object Object]'
99
+ || type === '[object Array]'
100
+
101
+ const newKey = prev ? prev + '.' + key : key
102
+
103
+ if (value.value && !output[newKey]) {
104
+ output[newKey] = transformValue(value)
105
+ }
106
+
107
+ if (!isarray && isobject && Object.keys(value).length) { return step(value, newKey) }
108
+ })
109
+ }
110
+ step(data)
111
+ return output
112
+ }
113
+
114
+ function mountApp ({ el, state, onUnmount }, render) {
115
+ Object.assign(state, {
116
+ search,
117
+ sampleText,
118
+ fontSize,
119
+ })
120
+
121
+ const app = createApp({
122
+ render,
123
+ })
124
+ app.mount(el)
125
+
126
+ onUnmount(() => {
127
+ app.unmount()
128
+ })
129
+ }
130
+
131
+ /*
132
+ media?: PinceauTokens
133
+ colors?: ScaleTokens
134
+ fonts?: PinceauTokens
135
+ fontWeights?: FontWeightTokens
136
+ fontSizes?: BreakpointsTokens
137
+ size?: BreakpointsTokens
138
+ space?: BreakpointsTokens
139
+ radii?: BreakpointsTokens
140
+ borders?: BreakpointsTokens
141
+ borderWidths?: BreakpointsTokens
142
+ borderStyles?: BreakpointsTokens
143
+ shadows?: BreakpointsTokens
144
+ opacity?: BreakpointsTokens
145
+ leads?: BreakpointsTokens
146
+ letterSpacings?: BreakpointsTokens
147
+ transitions?: PinceauTokens
148
+ zIndices?: PinceauTokens
149
+ */
150
+
151
+ export default {
152
+ id: 'pinceau',
153
+ title: 'Pinceau',
154
+ group: 'design-system',
155
+ icon: 'noto:paintbrush',
156
+ responsiveDisabled: true,
157
+ layout: { type: 'single', iframe: false },
158
+ variants: [
159
+ {
160
+ id: 'media-queries',
161
+ title: 'Media Queries',
162
+ icon: 'carbon:screen',
163
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
164
+ tokens: flattenTokens(config.media),
165
+ getName: key => '@mq.' + key,
166
+ colSize: 180,
167
+ }, ({ token }) => h('div', {
168
+ class: '__hst-drop-shadow',
169
+ }))),
170
+ },
171
+ {
172
+ id: 'colors',
173
+ title: 'Colors',
174
+ icon: 'carbon:color-palette',
175
+ onMount: (api) => mountApp(api, () => Object.entries(config.colors).map(([key, shades]) => h(HstColorShades, {
176
+ key,
177
+ shades: shades.value ? { DEFAULT: shades.value } : flattenTokens(shades),
178
+ getName: shade => '{colors.' + key + '.' + shade + '}',
179
+ search: search.value,
180
+ }, ({ color}) => h('div', {
181
+ class: '__hst-shade',
182
+ style: {
183
+ backgroundColor: color,
184
+ },
185
+ })))),
186
+ onMountControls: (api) => mountApp(api, () => [
187
+ h(HstText, {
188
+ title: 'Filter...',
189
+ modelValue: search.value,
190
+ 'onUpdate:modelValue': value => { search.value = value },
191
+ }),
192
+ ]),
193
+ },
194
+ // SPACES
195
+ {
196
+ id: 'Spaces',
197
+ title: 'Spaces',
198
+ icon: 'carbon:area',
199
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
200
+ tokens: flattenTokens(config.space),
201
+ getName: key => '{space.' + key + '}',
202
+ }, ({ token }) => h('div', {
203
+ class: '__hst-spaces',
204
+ style: {
205
+ padding: token.value,
206
+ },
207
+ }, [
208
+ h('div', {
209
+ class: '__hst-spaces-box',
210
+ }),
211
+ ]))),
212
+ },
213
+ // SIZES
214
+ {
215
+ id: 'sizes',
216
+ title: 'Sizes',
217
+ icon: 'carbon:pan-horizontal',
218
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
219
+ tokens: flattenTokens(config.size),
220
+ getName: key => '{size.' + key + '}',
221
+ }, ({ token }) => h('div', {
222
+ class: '__hst-width',
223
+ }, [
224
+ h('div', {
225
+ class: '__hst-width-box',
226
+ style: {
227
+ width: token.value,
228
+ },
229
+ }),
230
+ ]))),
231
+ },
232
+ // FONTSIZES
233
+ {
234
+ id: 'font-size',
235
+ title: 'Font Size',
236
+ icon: 'carbon:text-font',
237
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
238
+ tokens: flattenTokens(config.fontSizes),
239
+ getName: key => '{fontSizes.' + key + '}',
240
+ }, ({ token }) => h('div', {
241
+ class: '__hst-truncate',
242
+ style: {
243
+ fontSize: token.value,
244
+ },
245
+ }, sampleText.value))),
246
+ onMountControls: (api) => mountApp(api, () => [
247
+ h(HstTextarea, {
248
+ title: 'Sample text',
249
+ modelValue: sampleText.value,
250
+ 'onUpdate:modelValue': value => { sampleText.value = value },
251
+ rows: 5,
252
+ }),
253
+ ]),
254
+ },
255
+ // FONTWEIGHTS
256
+ {
257
+ id: 'font-weight',
258
+ title: 'Font Weight',
259
+ icon: 'carbon:text-font',
260
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
261
+ tokens: flattenTokens(config.fontWeights),
262
+ getName: key => '{fontWeights.' + key + '}',
263
+ }, ({ token }) => h('div', {
264
+ class: '__hst-truncate',
265
+ style: {
266
+ fontWeight: token.value,
267
+ fontSize: \`\${fontSize.value}px\`,
268
+ },
269
+ }, sampleText.value))),
270
+ onMountControls: (api) => mountApp(api, () => [
271
+ h(HstTextarea, {
272
+ title: 'Sample text',
273
+ modelValue: sampleText.value,
274
+ 'onUpdate:modelValue': value => { sampleText.value = value },
275
+ rows: 5,
276
+ }),
277
+ h(HstNumber, {
278
+ title: 'Font size',
279
+ modelValue: fontSize.value,
280
+ 'onUpdate:modelValue': value => { fontSize.value = value },
281
+ min: 1,
282
+ }),
283
+ ]),
284
+ },
285
+ // FONTS
286
+ {
287
+ id: 'fonts',
288
+ title: 'Fonts',
289
+ icon: 'carbon:text-font',
290
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
291
+ tokens: flattenTokens(config.fonts),
292
+ getName: key => '{fonts.' + key + '}',
293
+ }, ({ token }) => h('div', {
294
+ class: '__hst-truncate',
295
+ style: {
296
+ fontFamily: token.value,
297
+ fontSize: \`\${fontSize.value}px\`,
298
+ },
299
+ }, sampleText.value))),
300
+ onMountControls: (api) => mountApp(api, () => [
301
+ h(HstTextarea, {
302
+ title: 'Sample text',
303
+ modelValue: sampleText.value,
304
+ 'onUpdate:modelValue': value => { sampleText.value = value },
305
+ rows: 5,
306
+ }),
307
+ h(HstNumber, {
308
+ title: 'Font size',
309
+ modelValue: fontSize.value,
310
+ 'onUpdate:modelValue': value => { fontSize.value = value },
311
+ min: 1,
312
+ }),
313
+ ]),
314
+ },
315
+ // LETTERSPACINGS
316
+ {
317
+ id: 'letter-spacing',
318
+ title: 'Letter Spacing',
319
+ icon: 'carbon:text-font',
320
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
321
+ tokens: flattenTokens(config.letterSpacings),
322
+ getName: key => '{letterSpacings.' + key + '}',
323
+ }, ({ token }) => h('div', {
324
+ class: '__hst-truncate',
325
+ style: {
326
+ letterSpacing: token.value,
327
+ fontSize: \`\${fontSize.value}px\`,
328
+ },
329
+ }, sampleText.value))),
330
+ onMountControls: (api) => mountApp(api, () => [
331
+ h(HstTextarea, {
332
+ title: 'Sample text',
333
+ modelValue: sampleText.value,
334
+ 'onUpdate:modelValue': value => { sampleText.value = value },
335
+ rows: 5,
336
+ }),
337
+ h(HstNumber, {
338
+ title: 'Font size',
339
+ modelValue: fontSize.value,
340
+ 'onUpdate:modelValue': value => { fontSize.value = value },
341
+ min: 1,
342
+ }),
343
+ ]),
344
+ },
345
+ // LEADS
346
+ {
347
+ id: 'leads',
348
+ title: 'Leads',
349
+ icon: 'carbon:text-font',
350
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
351
+ tokens: flattenTokens(config.leads),
352
+ getName: key => '{leads.' + key + '}',
353
+ }, ({ token }) => h('div', {
354
+ style: {
355
+ lineHeight: token.value,
356
+ },
357
+ }, sampleText.value))),
358
+ onMountControls: (api) => mountApp(api, () => [
359
+ h(HstTextarea, {
360
+ title: 'Sample text',
361
+ modelValue: sampleText.value,
362
+ 'onUpdate:modelValue': value => { sampleText.value = value },
363
+ rows: 5,
364
+ }),
365
+ // @TODO select font size
366
+ ]),
367
+ },
368
+ // SHADOWS
369
+ {
370
+ id: 'shadows',
371
+ title: 'Shadows',
372
+ icon: 'carbon:shape-except',
373
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
374
+ tokens: flattenTokens(config.shadows),
375
+ getName: key => '{shadows.' + key + '}',
376
+ colSize: 180,
377
+ }, ({ token }) => h('div', {
378
+ class: '__hst-drop-shadow',
379
+ style: 'box-shadow:' + token.value,
380
+ }))),
381
+ },
382
+ // OPACITIES
383
+ {
384
+ id: 'opacities',
385
+ title: 'Opacities',
386
+ icon: 'carbon:bring-forward',
387
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
388
+ tokens: flattenTokens(config.opacity),
389
+ getName: key => '{opacity.' + key + '}',
390
+ colSize: 180,
391
+ }, ({ token }) => h('div', {
392
+ class: '__hst-drop-shadow',
393
+ style: 'opacity:' + token.value,
394
+ }))),
395
+ },
396
+ // RADII
397
+ {
398
+ id: 'border-radius',
399
+ title: 'Border Radius',
400
+ icon: 'carbon:condition-wait-point',
401
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
402
+ tokens: flattenTokens(config.radii),
403
+ getName: key => '{radii.' + key + '}',
404
+ colSize: 180,
405
+ }, ({ token }) => h('div', {
406
+ class: '__hst-border-radius',
407
+ style: {
408
+ borderRadius: token.value,
409
+ },
410
+ }))),
411
+ },
412
+ // BORDERWIDTHS
413
+ {
414
+ id: 'border-width',
415
+ title: 'Border Width',
416
+ icon: 'carbon:checkbox',
417
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
418
+ tokens: flattenTokens(config.borderWidths),
419
+ getName: key => '{borderWidths.' + key + '}',
420
+ colSize: 180,
421
+ }, ({ token }) => h('div', {
422
+ class: '__hst-border-width',
423
+ style: {
424
+ borderWidth: token.value,
425
+ },
426
+ }))),
427
+ },
428
+ // FULL CONFIG
429
+ {
430
+ id: 'full-config',
431
+ title: 'Full Config',
432
+ icon: 'carbon:code',
433
+ onMount: (api) => mountApp(api, () => h('pre', JSON.stringify(config, null, 2))),
434
+ },
435
+ ],
436
+ }`
437
+ }
438
+
439
+ const css = `.__hst-shade {
440
+ height: 80px;
441
+ border-radius: 4px;
442
+ }
443
+
444
+ .__hst-text {
445
+ font-size: 4rem;
446
+ display: flex;
447
+ align-items: flex-end;
448
+ }
449
+
450
+ .__hst-border {
451
+ border-style: solid;
452
+ border-width: 2px;
453
+ }
454
+
455
+ .__hst-spaces {
456
+ background-color: rgb(113 113 122 / 0.1);
457
+ width: min-content;
458
+ }
459
+
460
+ .__hst-margin {
461
+ border: dashed 1px rgb(113 113 122 / 0.5);
462
+ width: min-content;
463
+ }
464
+
465
+ .__hst-spaces-box,
466
+ .__hst-margin-box {
467
+ width: 5rem;
468
+ height: 5rem;
469
+ background-color: rgb(113 113 122 / 0.5);
470
+ }
471
+
472
+ .__hst-spaces,
473
+ .__hst-spaces-box,
474
+ .__hst-margin,
475
+ .__hst-margin-box,
476
+ .__hst-drop-shadow {
477
+ border-radius: 4px;
478
+ }
479
+
480
+ .__hst-truncate {
481
+ overflow: hidden;
482
+ text-overflow: ellipsis;
483
+ white-space: nowrap;
484
+ }
485
+
486
+ .__hst-drop-shadow {
487
+ width: 8rem;
488
+ height: 8rem;
489
+ background: white;
490
+ margin-bottom: 0.5rem;
491
+ }
492
+
493
+ .__hst-drop-shadow {
494
+ background: #4e4e57;
495
+ }
496
+
497
+ .__hst-border-radius {
498
+ width: 8rem;
499
+ height: 8rem;
500
+ background-color: rgb(113 113 122 / 0.5);
501
+ }
502
+
503
+ .__hst-border-width {
504
+ width: 8rem;
505
+ height: 8rem;
506
+ border-color: rgb(113 113 122 / 0.5);
507
+ background-color: rgb(113 113 122 / 0.1);
508
+ }
509
+
510
+ .__hst-width {
511
+ background-color: rgb(113 113 122 / 0.1);
512
+ }
513
+
514
+ .__hst-width-box,
515
+ .__hst-height {
516
+ background-color: rgb(113 113 122 / 0.5);
517
+ }
518
+
519
+ .__hst-width-box {
520
+ height: 5rem;
521
+ }`