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,536 @@
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
+ configFile?: string
7
+ }
8
+
9
+ export function tailwindTokens(options: TailwindTokensOptions = {}): Plugin {
10
+ const tailwindConfigFile = options.configFile ?? findUp(process.cwd(), [
11
+ 'tailwind.config.js',
12
+ 'tailwind.config.cjs',
13
+ 'tailwind.config.mjs',
14
+ 'tailwind.config.ts',
15
+ 'tailwind-config.js',
16
+ 'tailwind-config.cjs',
17
+ 'tailwind-config.mjs',
18
+ 'tailwind-config.ts',
19
+ ])
20
+
21
+ async function generate(api: PluginApiBase) {
22
+ try {
23
+ await api.fs.ensureDir(api.pluginTempDir)
24
+ await api.fs.emptyDir(api.pluginTempDir)
25
+ api.moduleLoader.clearCache()
26
+ await api.fs.writeFile(api.path.resolve(api.pluginTempDir, 'style.css'), css)
27
+ const tailwindConfig = await api.moduleLoader.loadModule(tailwindConfigFile)
28
+ const { default: resolveConfig } = await import('tailwindcss/resolveConfig.js')
29
+ const resolvedTailwindConfig = resolveConfig(tailwindConfig.default ?? tailwindConfig)
30
+ const storyFile = api.path.resolve(api.pluginTempDir, 'Tailwind.story.js')
31
+ await api.fs.writeFile(storyFile, storyTemplate(resolvedTailwindConfig))
32
+ api.addStoryFile(storyFile)
33
+ }
34
+ catch (e) {
35
+ api.error(e.stack ?? e.message)
36
+ }
37
+ }
38
+
39
+ return {
40
+ name: 'builtin:tailwind-tokens',
41
+
42
+ config(config) {
43
+ if (tailwindConfigFile) {
44
+ // Add 'design-system' group
45
+ if (!config.tree) {
46
+ config.tree = {}
47
+ }
48
+ if (!config.tree.groups) {
49
+ config.tree.groups = []
50
+ }
51
+ if (!config.tree.groups.some(g => g.id === 'design-system')) {
52
+ let index = 0
53
+ // After 'top' group
54
+ const topIndex = config.tree.groups.findIndex(g => g.id === 'top')
55
+ if (topIndex > -1) {
56
+ index = topIndex + 1
57
+ }
58
+ // Insert group
59
+ config.tree.groups.splice(index, 0, {
60
+ id: 'design-system',
61
+ title: 'Design System',
62
+ })
63
+ }
64
+ }
65
+ },
66
+
67
+ onDev(api, onCleanup) {
68
+ if (tailwindConfigFile) {
69
+ const watcher = api.watcher.watch(tailwindConfigFile)
70
+ .on('change', () => generate(api))
71
+ .on('add', () => generate(api))
72
+ onCleanup(() => {
73
+ watcher.close()
74
+ })
75
+ }
76
+ },
77
+
78
+ async onBuild(api) {
79
+ if (tailwindConfigFile) {
80
+ await generate(api)
81
+ }
82
+ },
83
+ }
84
+ }
85
+
86
+ function storyTemplate(tailwindConfig: any) {
87
+ return `
88
+ import 'histoire-style'
89
+ import './style.css'
90
+ import { createApp, h, markRaw, ref } from ${getInjectedImport('@poveste/vendors/vue')}
91
+ import {
92
+ HstColorShades,
93
+ HstTokenList,
94
+ HstTokenGrid,
95
+ HstText,
96
+ HstTextarea,
97
+ HstNumber,
98
+ } from ${getInjectedImport('@poveste/controls')}
99
+
100
+ const config = markRaw(${JSON.stringify(tailwindConfig, null, 2)})
101
+ const search = ref('')
102
+ 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')
103
+ const fontSize = ref(16)
104
+
105
+ function mountApp ({ el, state, onUnmount }, render) {
106
+ Object.assign(state, {
107
+ search,
108
+ sampleText,
109
+ fontSize,
110
+ })
111
+
112
+ const app = createApp({
113
+ render,
114
+ })
115
+ app.mount(el)
116
+
117
+ onUnmount(() => {
118
+ app.unmount()
119
+ })
120
+ }
121
+
122
+ export default {
123
+ id: 'tailwind',
124
+ title: 'Tailwind',
125
+ group: 'design-system',
126
+ icon: 'mdi:tailwind',
127
+ responsiveDisabled: true,
128
+ layout: { type: 'single', iframe: false },
129
+ variants: [
130
+ {
131
+ id: 'background-color',
132
+ title: 'Background Color',
133
+ icon: 'carbon:color-palette',
134
+ onMount: (api) => mountApp(api, () => Object.entries(config.theme.backgroundColor).map(([key, shades]) => h(HstColorShades, {
135
+ key,
136
+ shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
137
+ getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`bg-\${key}\` : \`bg-\${key}-\${shade}\`),
138
+ search: search.value,
139
+ }, ({ color}) => h('div', {
140
+ class: '__hst-shade',
141
+ style: {
142
+ backgroundColor: color.replace('<alpha-value>', 1),
143
+ },
144
+ })))),
145
+ onMountControls: (api) => mountApp(api, () => [
146
+ h(HstText, {
147
+ title: 'Filter...',
148
+ modelValue: search.value,
149
+ 'onUpdate:modelValue': value => { search.value = value },
150
+ }),
151
+ ]),
152
+ },
153
+ {
154
+ id: 'text-color',
155
+ title: 'Text Color',
156
+ icon: 'carbon:text-color',
157
+ onMount: (api) => mountApp(api, () => Object.entries(config.theme.textColor).map(([key, shades]) => h(HstColorShades, {
158
+ key,
159
+ shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
160
+ getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`text-\${key}\` : \`text-\${key}-\${shade}\`),
161
+ search: search.value,
162
+ }, ({ color}) => h('div', {
163
+ class: '__hst-shade __hst-text',
164
+ style: {
165
+ color: color.replace('<alpha-value>', 1),
166
+ },
167
+ }, 'Aa')))),
168
+ onMountControls: (api) => mountApp(api, () => [
169
+ h(HstText, {
170
+ title: 'Filter...',
171
+ modelValue: search.value,
172
+ 'onUpdate:modelValue': value => { search.value = value },
173
+ }),
174
+ ]),
175
+ },
176
+ {
177
+ id: 'border-color',
178
+ title: 'Border Color',
179
+ icon: 'carbon:color-palette',
180
+ onMount: (api) => mountApp(api, () => Object.entries(config.theme.borderColor).map(([key, shades]) => h(HstColorShades, {
181
+ key,
182
+ shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
183
+ getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`border-\${key}\` : \`border-\${key}-\${shade}\`),
184
+ search: search.value,
185
+ }, ({ color}) => h('div', {
186
+ class: '__hst-shade __hst-border',
187
+ style: {
188
+ borderColor: color.replace('<alpha-value>', 1),
189
+ },
190
+ })))),
191
+ onMountControls: (api) => mountApp(api, () => [
192
+ h(HstText, {
193
+ title: 'Filter...',
194
+ modelValue: search.value,
195
+ 'onUpdate:modelValue': value => { search.value = value },
196
+ }),
197
+ ]),
198
+ },
199
+ {
200
+ id: 'padding',
201
+ title: 'Padding',
202
+ icon: 'carbon:area',
203
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
204
+ tokens: config.theme.padding,
205
+ getName: key => \`\${config.prefix ?? ''}p-\${key}\`,
206
+ }, ({ token }) => h('div', {
207
+ class: '__hst-padding',
208
+ style: {
209
+ padding: token.value,
210
+ },
211
+ }, [
212
+ h('div', {
213
+ class: '__hst-padding-box',
214
+ }),
215
+ ]))),
216
+ },
217
+ {
218
+ id: 'margin',
219
+ title: 'Margin',
220
+ icon: 'carbon:area',
221
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
222
+ tokens: config.theme.margin,
223
+ getName: key => \`\${config.prefix ?? ''}m-\${key}\`,
224
+ }, ({ token }) => h('div', {
225
+ class: '__hst-margin',
226
+ }, [
227
+ h('div', {
228
+ class: '__hst-margin-box',
229
+ style: {
230
+ margin: token.value,
231
+ },
232
+ }),
233
+ ]))),
234
+ },
235
+ {
236
+ id: 'font-size',
237
+ title: 'Font Size',
238
+ icon: 'carbon:text-font',
239
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
240
+ tokens: config.theme.fontSize,
241
+ getName: key => \`\${config.prefix ?? ''}text-\${key}\`,
242
+ }, ({ token }) => h('div', {
243
+ class: '__hst-truncate',
244
+ style: {
245
+ fontSize: Array.isArray(token.value) ? token.value[0] : token.value,
246
+ ...(Array.isArray(token.value) && typeof token.value[1] === "object" ? token.value[1] : { lineHeight: token.value[1] })
247
+ },
248
+ }, sampleText.value))),
249
+ onMountControls: (api) => mountApp(api, () => [
250
+ h(HstTextarea, {
251
+ title: 'Sample text',
252
+ modelValue: sampleText.value,
253
+ 'onUpdate:modelValue': value => { sampleText.value = value },
254
+ rows: 5,
255
+ }),
256
+ ]),
257
+ },
258
+ {
259
+ id: 'font-weight',
260
+ title: 'Font Weight',
261
+ icon: 'carbon:text-font',
262
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
263
+ tokens: config.theme.fontWeight,
264
+ getName: key => \`\${config.prefix ?? ''}font-\${key}\`,
265
+ }, ({ token }) => h('div', {
266
+ class: '__hst-truncate',
267
+ style: {
268
+ fontWeight: token.value,
269
+ fontSize: \`\${fontSize.value}px\`,
270
+ },
271
+ }, sampleText.value))),
272
+ onMountControls: (api) => mountApp(api, () => [
273
+ h(HstTextarea, {
274
+ title: 'Sample text',
275
+ modelValue: sampleText.value,
276
+ 'onUpdate:modelValue': value => { sampleText.value = value },
277
+ rows: 5,
278
+ }),
279
+ h(HstNumber, {
280
+ title: 'Font size',
281
+ modelValue: fontSize.value,
282
+ 'onUpdate:modelValue': value => { fontSize.value = value },
283
+ min: 1,
284
+ }),
285
+ ]),
286
+ },
287
+ {
288
+ id: 'font-family',
289
+ title: 'Font Family',
290
+ icon: 'carbon:text-font',
291
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
292
+ tokens: config.theme.fontFamily,
293
+ getName: key => \`\${config.prefix ?? ''}font-\${key}\`,
294
+ }, ({ token }) => h('div', {
295
+ class: '__hst-truncate',
296
+ style: {
297
+ fontFamily: token.value,
298
+ fontSize: \`\${fontSize.value}px\`,
299
+ },
300
+ }, sampleText.value))),
301
+ onMountControls: (api) => mountApp(api, () => [
302
+ h(HstTextarea, {
303
+ title: 'Sample text',
304
+ modelValue: sampleText.value,
305
+ 'onUpdate:modelValue': value => { sampleText.value = value },
306
+ rows: 5,
307
+ }),
308
+ h(HstNumber, {
309
+ title: 'Font size',
310
+ modelValue: fontSize.value,
311
+ 'onUpdate:modelValue': value => { fontSize.value = value },
312
+ min: 1,
313
+ }),
314
+ ]),
315
+ },
316
+ {
317
+ id: 'letter-spacing',
318
+ title: 'Letter Spacing',
319
+ icon: 'carbon:text-font',
320
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
321
+ tokens: config.theme.letterSpacing,
322
+ getName: key => \`\${config.prefix ?? ''}tracking-\${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
+ {
346
+ id: 'line-height',
347
+ title: 'Line Height',
348
+ icon: 'carbon:text-font',
349
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
350
+ tokens: config.theme.lineHeight,
351
+ getName: key => \`\${config.prefix ?? ''}leading-\${key}\`,
352
+ }, ({ token }) => h('div', {
353
+ style: {
354
+ lineHeight: token.value,
355
+ },
356
+ }, sampleText.value))),
357
+ onMountControls: (api) => mountApp(api, () => [
358
+ h(HstTextarea, {
359
+ title: 'Sample text',
360
+ modelValue: sampleText.value,
361
+ 'onUpdate:modelValue': value => { sampleText.value = value },
362
+ rows: 5,
363
+ }),
364
+ // @TODO select font size
365
+ ]),
366
+ },
367
+ {
368
+ id: 'drop-shadow',
369
+ title: 'Drop Shadow',
370
+ icon: 'carbon:shape-except',
371
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
372
+ tokens: config.theme.dropShadow,
373
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'drop-shadow' : \`drop-shadow-\${key}\`),
374
+ colSize: 180,
375
+ }, ({ token }) => h('div', {
376
+ class: '__hst-drop-shadow',
377
+ style: {
378
+ filter: \`\${(Array.isArray(token.value) ? token.value : [token.value]).map(v => \`drop-shadow(\${v})\`).join(' ')}\`,
379
+ },
380
+ }))),
381
+ },
382
+ {
383
+ id: 'border-radius',
384
+ title: 'Border Radius',
385
+ icon: 'carbon:condition-wait-point',
386
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
387
+ tokens: config.theme.borderRadius,
388
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'rounded' : \`rounded-\${key}\`),
389
+ colSize: 180,
390
+ }, ({ token }) => h('div', {
391
+ class: '__hst-border-radius',
392
+ style: {
393
+ borderRadius: token.value,
394
+ },
395
+ }))),
396
+ },
397
+ {
398
+ id: 'border-width',
399
+ title: 'Border Width',
400
+ icon: 'carbon:checkbox',
401
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
402
+ tokens: config.theme.borderWidth,
403
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'border' : \`border-\${key}\`),
404
+ colSize: 180,
405
+ }, ({ token }) => h('div', {
406
+ class: '__hst-border-width',
407
+ style: {
408
+ borderWidth: token.value,
409
+ },
410
+ }))),
411
+ },
412
+ {
413
+ id: 'width',
414
+ title: 'Width',
415
+ icon: 'carbon:pan-horizontal',
416
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
417
+ tokens: config.theme.width,
418
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'w' : \`w-\${key}\`),
419
+ }, ({ token }) => h('div', {
420
+ class: '__hst-width',
421
+ }, [
422
+ h('div', {
423
+ class: '__hst-width-box',
424
+ style: {
425
+ width: token.value,
426
+ },
427
+ }),
428
+ ]))),
429
+ },
430
+ {
431
+ id: 'height',
432
+ title: 'Height',
433
+ icon: 'carbon:pan-vertical',
434
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
435
+ tokens: config.theme.height,
436
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'h' : \`h-\${key}\`),
437
+ }, ({ token }) => h('div', {
438
+ class: '__hst-height',
439
+ style: {
440
+ height: token.value,
441
+ },
442
+ }))),
443
+ },
444
+ {
445
+ id: 'full-config',
446
+ title: 'Full Config',
447
+ icon: 'carbon:code',
448
+ onMount: (api) => mountApp(api, () => h('pre', JSON.stringify(config, null, 2))),
449
+ },
450
+ ],
451
+ }`
452
+ }
453
+
454
+ const css = `.__hst-shade {
455
+ height: 80px;
456
+ border-radius: 4px;
457
+ }
458
+
459
+ .__hst-text {
460
+ font-size: 4rem;
461
+ display: flex;
462
+ align-items: flex-end;
463
+ }
464
+
465
+ .__hst-border {
466
+ border-style: solid;
467
+ border-width: 2px;
468
+ }
469
+
470
+ .__hst-padding {
471
+ background-color: rgb(113 113 122 / 0.1);
472
+ width: min-content;
473
+ }
474
+
475
+ .__hst-margin {
476
+ border: dashed 1px rgb(113 113 122 / 0.5);
477
+ width: min-content;
478
+ }
479
+
480
+ .__hst-padding-box,
481
+ .__hst-margin-box {
482
+ width: 5rem;
483
+ height: 5rem;
484
+ background-color: rgb(113 113 122 / 0.5);
485
+ }
486
+
487
+ .__hst-padding,
488
+ .__hst-padding-box,
489
+ .__hst-margin,
490
+ .__hst-margin-box,
491
+ .__hst-drop-shadow {
492
+ border-radius: 4px;
493
+ }
494
+
495
+ .__hst-truncate {
496
+ overflow: hidden;
497
+ text-overflow: ellipsis;
498
+ white-space: nowrap;
499
+ }
500
+
501
+ .__hst-drop-shadow {
502
+ width: 8rem;
503
+ height: 8rem;
504
+ background: white;
505
+ margin-bottom: 0.5rem;
506
+ }
507
+
508
+ .__hst-drop-shadow {
509
+ background: #4e4e57;
510
+ }
511
+
512
+ .__hst-border-radius {
513
+ width: 8rem;
514
+ height: 8rem;
515
+ background-color: rgb(113 113 122 / 0.5);
516
+ }
517
+
518
+ .__hst-border-width {
519
+ width: 8rem;
520
+ height: 8rem;
521
+ border-color: rgb(113 113 122 / 0.5);
522
+ background-color: rgb(113 113 122 / 0.1);
523
+ }
524
+
525
+ .__hst-width {
526
+ background-color: rgb(113 113 122 / 0.1);
527
+ }
528
+
529
+ .__hst-width-box,
530
+ .__hst-height {
531
+ background-color: rgb(113 113 122 / 0.5);
532
+ }
533
+
534
+ .__hst-width-box {
535
+ height: 5rem;
536
+ }`
@@ -0,0 +1,49 @@
1
+ import type { Story } from '@poveste/shared'
2
+ import type { PropType as _PropType } from '@poveste/vendors/vue'
3
+ import type { StoryOptions, VariantOptions } from './types'
4
+ import { defineComponent as _defineComponent } from '@poveste/vendors/vue'
5
+
6
+ export default _defineComponent({
7
+ name: 'MountStory',
8
+
9
+ props: {
10
+ story: {
11
+ type: Object as _PropType<Story>,
12
+ required: true,
13
+ },
14
+ },
15
+
16
+ setup(props) {
17
+ const options = props.story.file.component as StoryOptions
18
+
19
+ let rawVariants: VariantOptions[] = []
20
+
21
+ if (options.onMount) {
22
+ rawVariants = [{
23
+ id: '_default',
24
+ title: 'default',
25
+ onMount: options.onMount,
26
+ onMountControls: options.onMountControls,
27
+ }]
28
+ }
29
+ else {
30
+ rawVariants = options.variants
31
+ }
32
+
33
+ for (const index in props.story.variants) {
34
+ const rawVariant = rawVariants[index]
35
+ Object.assign(props.story.variants[index], {
36
+ slots: () => ({ default: rawVariant.onMount, controls: rawVariant.onMountControls }),
37
+ source: rawVariant.source ?? options.source,
38
+ responsiveDisabled: rawVariant.responsiveDisabled ?? options.responsiveDisabled,
39
+ autoPropsDisabled: rawVariant.autoPropsDisabled ?? options.autoPropsDisabled,
40
+ setupApp: rawVariant.setupApp ?? options.setupApp,
41
+ configReady: true,
42
+ })
43
+ }
44
+ },
45
+
46
+ render() {
47
+ return null
48
+ },
49
+ })