histoire 0.0.0 → 0.0.1

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 (208) hide show
  1. package/LICENSE +21 -0
  2. package/client.d.ts +2 -0
  3. package/dist/client/app/App.vue +84 -21
  4. package/dist/client/app/assets/histoire-text-dark.svg +89 -0
  5. package/dist/client/app/assets/histoire-text.svg +89 -0
  6. package/dist/client/app/assets/histoire.svg +51 -0
  7. package/dist/client/app/codegen/serialize-js.d.ts +1 -0
  8. package/dist/client/app/codegen/serialize-js.js +114 -0
  9. package/dist/client/app/codegen/serialize-js.js.map +1 -0
  10. package/dist/client/app/codegen/serialize-js.ts +119 -0
  11. package/dist/client/app/codegen/util.d.ts +10 -0
  12. package/dist/client/app/codegen/util.js +71 -0
  13. package/dist/client/app/codegen/util.js.map +1 -0
  14. package/dist/client/app/codegen/util.ts +79 -0
  15. package/dist/client/app/codegen/vue3.d.ts +2 -0
  16. package/dist/client/app/codegen/vue3.js +239 -0
  17. package/dist/client/app/codegen/vue3.js.map +1 -0
  18. package/dist/client/app/codegen/vue3.ts +240 -0
  19. package/dist/client/app/components/HomeView.vue +15 -1
  20. package/dist/client/app/components/StoryControls.vue +7 -2
  21. package/dist/client/app/components/StoryList.vue +20 -13
  22. package/dist/client/app/components/StoryListFolder.vue +80 -0
  23. package/dist/client/app/components/StoryListItem.vue +38 -12
  24. package/dist/client/app/components/StorySourceCode.vue +121 -0
  25. package/dist/client/app/components/StoryVariantGridItem.vue +32 -17
  26. package/dist/client/app/components/StoryVariantListItem.vue +46 -0
  27. package/dist/client/app/components/StoryVariantSingleView.vue +117 -15
  28. package/dist/client/app/components/StoryView.vue +88 -54
  29. package/dist/client/app/components/app/AppHeader.vue +56 -0
  30. package/dist/client/app/components/app/AppLogo.vue +24 -0
  31. package/dist/client/app/components/base/BaseEmpty.vue +1 -1
  32. package/dist/client/app/components/base/BaseListItemLink.vue +55 -0
  33. package/dist/client/app/components/base/BaseSplitPane.vue +57 -21
  34. package/dist/client/app/components/exposed/Story.vue +23 -58
  35. package/dist/client/app/components/exposed/Variant.vue +24 -47
  36. package/dist/client/app/components/misc/HatchedPattern.vue +25 -0
  37. package/dist/client/app/components/{SandboxVue.vue → sandbox/SandboxVue3.vue} +31 -12
  38. package/dist/client/app/components/search/SearchItem.vue +110 -0
  39. package/dist/client/app/components/search/SearchModal.vue +179 -0
  40. package/dist/client/app/composable/variant.ts +20 -0
  41. package/dist/client/app/global-components.ts +10 -0
  42. package/dist/client/app/index.d.ts +1 -0
  43. package/dist/client/app/index.js +4 -1
  44. package/dist/client/app/index.js.map +1 -1
  45. package/dist/client/app/index.ts +18 -0
  46. package/dist/client/app/router.ts +17 -0
  47. package/dist/client/app/sandbox.d.ts +1 -0
  48. package/dist/client/app/sandbox.js +54 -0
  49. package/dist/client/app/sandbox.js.map +1 -0
  50. package/dist/client/app/sandbox.ts +60 -0
  51. package/dist/client/app/stores/story.d.ts +161 -50
  52. package/dist/client/app/stores/story.js +5 -16
  53. package/dist/client/app/stores/story.js.map +1 -1
  54. package/dist/client/app/stores/story.ts +22 -0
  55. package/dist/client/app/style/main.css +16 -2
  56. package/dist/client/app/style/sandbox.css +14 -0
  57. package/dist/client/app/types.d.ts +36 -4
  58. package/dist/client/app/types.ts +45 -0
  59. package/dist/client/app/util/config.d.ts +3 -0
  60. package/dist/client/app/util/config.js +5 -0
  61. package/dist/client/app/util/config.js.map +1 -0
  62. package/dist/client/app/util/config.ts +6 -0
  63. package/dist/client/app/util/const.d.ts +1 -0
  64. package/dist/client/app/util/const.js +2 -0
  65. package/dist/client/app/util/const.js.map +1 -0
  66. package/dist/client/app/util/const.ts +1 -0
  67. package/dist/client/app/util/dark.d.ts +2 -0
  68. package/dist/client/app/util/dark.js +4 -0
  69. package/dist/client/app/util/dark.js.map +1 -0
  70. package/dist/client/app/util/dark.ts +4 -0
  71. package/dist/client/app/util/env.d.ts +1 -0
  72. package/dist/client/app/util/env.js +2 -0
  73. package/dist/client/app/util/env.js.map +1 -0
  74. package/dist/client/app/util/keyboard.d.ts +8 -0
  75. package/dist/client/app/util/keyboard.js +83 -0
  76. package/dist/client/app/util/keyboard.js.map +1 -0
  77. package/dist/client/app/util/mapping.d.ts +3 -0
  78. package/dist/client/app/util/mapping.js +37 -0
  79. package/dist/client/app/util/mapping.js.map +1 -0
  80. package/dist/client/app/util/mapping.ts +38 -0
  81. package/dist/client/app/util/tooltip.d.ts +6 -0
  82. package/dist/client/app/util/tooltip.js +12 -0
  83. package/dist/client/app/util/tooltip.js.map +1 -0
  84. package/dist/client/index.d.ts +8 -0
  85. package/dist/client/index.js +4 -0
  86. package/dist/client/index.js.map +1 -0
  87. package/dist/client/index.ts +12 -0
  88. package/dist/client/server/Story.server.vue +65 -0
  89. package/dist/client/server/Variant.server.vue +50 -0
  90. package/dist/client/server/index.d.ts +2 -0
  91. package/dist/client/server/index.js +26 -0
  92. package/dist/client/server/index.js.map +1 -0
  93. package/dist/client/server/index.ts +29 -0
  94. package/dist/client/shim.d.ts +5 -0
  95. package/dist/node/bin.js +8 -2
  96. package/dist/node/bin.js.map +1 -1
  97. package/dist/node/build.d.ts +2 -0
  98. package/dist/node/build.js +72 -0
  99. package/dist/node/build.js.map +1 -0
  100. package/dist/node/collect.d.ts +12 -0
  101. package/dist/node/collect.js +66 -0
  102. package/dist/node/collect.js.map +1 -0
  103. package/dist/node/colors.d.ts +274 -0
  104. package/dist/node/colors.js +313 -0
  105. package/dist/node/colors.js.map +1 -0
  106. package/dist/node/commands/build.d.ts +1 -0
  107. package/dist/node/commands/build.js +11 -0
  108. package/dist/node/commands/build.js.map +1 -0
  109. package/dist/node/commands/dev.d.ts +1 -1
  110. package/dist/node/commands/dev.js +6 -11
  111. package/dist/node/commands/dev.js.map +1 -1
  112. package/dist/node/config.d.ts +99 -1
  113. package/dist/node/config.js +90 -1
  114. package/dist/node/config.js.map +1 -1
  115. package/dist/node/context.d.ts +13 -0
  116. package/dist/node/context.js +12 -1
  117. package/dist/node/context.js.map +1 -1
  118. package/dist/node/dom/dom-keys.d.ts +4 -0
  119. package/dist/node/dom/dom-keys.js +224 -0
  120. package/dist/node/dom/dom-keys.js.map +1 -0
  121. package/dist/node/dom/env.d.ts +5 -0
  122. package/dist/node/dom/env.js +23 -0
  123. package/dist/node/dom/env.js.map +1 -0
  124. package/dist/node/index.d.ts +2 -0
  125. package/dist/node/index.js +2 -1
  126. package/dist/node/index.js.map +1 -1
  127. package/dist/node/plugin.d.ts +8 -2
  128. package/dist/node/plugin.js +142 -21
  129. package/dist/node/plugin.js.map +1 -1
  130. package/dist/node/server.d.ts +4 -1
  131. package/dist/node/server.js +80 -20
  132. package/dist/node/server.js.map +1 -1
  133. package/dist/node/stories.d.ts +8 -9
  134. package/dist/node/stories.js +42 -22
  135. package/dist/node/stories.js.map +1 -1
  136. package/dist/node/tree.d.ts +19 -0
  137. package/dist/node/tree.js +55 -0
  138. package/dist/node/tree.js.map +1 -0
  139. package/dist/node/types.d.ts +38 -0
  140. package/dist/node/types.js +2 -0
  141. package/dist/node/types.js.map +1 -0
  142. package/dist/style.css +558 -52
  143. package/package.json +42 -25
  144. package/scripts/copy.mjs +11 -0
  145. package/src/client/app/App.vue +84 -21
  146. package/src/client/app/assets/histoire-text-dark.svg +89 -0
  147. package/src/client/app/assets/histoire-text.svg +89 -0
  148. package/src/client/app/assets/histoire.svg +51 -0
  149. package/src/client/app/codegen/serialize-js.ts +119 -0
  150. package/src/client/app/codegen/util.ts +79 -0
  151. package/src/client/app/codegen/vue3.ts +240 -0
  152. package/src/client/app/components/HomeView.vue +15 -1
  153. package/src/client/app/components/StoryControls.vue +7 -2
  154. package/src/client/app/components/StoryList.vue +20 -13
  155. package/src/client/app/components/StoryListFolder.vue +80 -0
  156. package/src/client/app/components/StoryListItem.vue +38 -12
  157. package/src/client/app/components/StorySourceCode.vue +121 -0
  158. package/src/client/app/components/StoryVariantGridItem.vue +32 -17
  159. package/src/client/app/components/StoryVariantListItem.vue +46 -0
  160. package/src/client/app/components/StoryVariantSingleView.vue +117 -15
  161. package/src/client/app/components/StoryView.vue +88 -54
  162. package/src/client/app/components/app/AppHeader.vue +56 -0
  163. package/src/client/app/components/app/AppLogo.vue +24 -0
  164. package/src/client/app/components/base/BaseEmpty.vue +1 -1
  165. package/src/client/app/components/base/BaseListItemLink.vue +55 -0
  166. package/src/client/app/components/base/BaseSplitPane.vue +57 -21
  167. package/src/client/app/components/exposed/Story.vue +23 -58
  168. package/src/client/app/components/exposed/Variant.vue +24 -47
  169. package/src/client/app/components/misc/HatchedPattern.vue +25 -0
  170. package/src/client/app/components/{SandboxVue.vue → sandbox/SandboxVue3.vue} +31 -12
  171. package/src/client/app/components/search/SearchItem.vue +110 -0
  172. package/src/client/app/components/search/SearchModal.vue +179 -0
  173. package/src/client/app/index.ts +4 -1
  174. package/src/client/app/sandbox.ts +60 -0
  175. package/src/client/app/stores/story.ts +6 -18
  176. package/src/client/app/style/main.css +16 -2
  177. package/src/client/app/style/sandbox.css +14 -0
  178. package/src/client/app/types.ts +42 -4
  179. package/src/client/app/util/config.ts +6 -0
  180. package/src/client/app/util/const.ts +1 -0
  181. package/src/client/app/util/dark.ts +4 -0
  182. package/src/client/app/util/env.ts +1 -0
  183. package/src/client/app/util/keyboard.ts +99 -0
  184. package/src/client/app/util/mapping.ts +38 -0
  185. package/src/client/app/util/tooltip.ts +13 -0
  186. package/src/client/index.ts +12 -0
  187. package/src/client/server/Story.server.vue +65 -0
  188. package/src/client/server/Variant.server.vue +50 -0
  189. package/src/client/server/index.ts +29 -0
  190. package/src/node/bin.ts +9 -2
  191. package/src/node/build.ts +80 -0
  192. package/src/node/collect.ts +78 -0
  193. package/src/node/colors.ts +328 -0
  194. package/src/node/commands/build.ts +12 -0
  195. package/src/node/commands/dev.ts +6 -13
  196. package/src/node/config.ts +193 -1
  197. package/src/node/context.ts +21 -1
  198. package/src/node/dom/dom-keys.ts +227 -0
  199. package/src/node/dom/env.ts +26 -0
  200. package/src/node/index.ts +2 -0
  201. package/src/node/plugin.ts +146 -22
  202. package/src/node/server.ts +95 -20
  203. package/src/node/stories.ts +53 -31
  204. package/src/node/tree.ts +88 -0
  205. package/src/node/types.ts +40 -0
  206. package/tailwind.config.cjs +41 -1
  207. package/dist/client/app/components/StoryVariantItem.vue +0 -29
  208. package/src/client/app/components/StoryVariantItem.vue +0 -29
@@ -0,0 +1,60 @@
1
+ import './style/sandbox.css'
2
+ import { parseQuery } from 'vue-router'
3
+ import { computed, createApp, h, ref, toRaw, watch } from 'vue'
4
+ import { createPinia } from 'pinia'
5
+ import { registerGlobalComponents } from './global-components'
6
+ import SandboxVue3 from './components/sandbox/SandboxVue3.vue'
7
+ import type { StoryFile } from './types'
8
+ import { mapFile } from './util/mapping'
9
+ // @ts-expect-error virtual module
10
+ import { files } from '$histoire-stories'
11
+ import { STATE_SYNC } from './util/const.js'
12
+
13
+ const query = parseQuery(window.location.search)
14
+ const file = ref<StoryFile>(mapFile(files.find(f => f.id === query.storyId)))
15
+
16
+ const app = createApp({
17
+ setup () {
18
+ const story = computed(() => file.value.story)
19
+ const variant = computed(() => story.value?.variants.find(v => v.id === query.variantId))
20
+
21
+ window.addEventListener('message', event => {
22
+ if (event.data?.type === STATE_SYNC) {
23
+ Object.assign(variant.value.state, event.data.state)
24
+ }
25
+ })
26
+
27
+ watch(() => variant.value.state, value => {
28
+ window.parent?.postMessage({
29
+ type: STATE_SYNC,
30
+ state: toRaw(value),
31
+ })
32
+ }, {
33
+ deep: true,
34
+ })
35
+
36
+ return {
37
+ story,
38
+ variant,
39
+ }
40
+ },
41
+
42
+ render () {
43
+ return [
44
+ h('div', { class: 'htw-sandbox-hidden' }, [
45
+ h(file.value.component, {
46
+ story: file.value.story,
47
+ }),
48
+ ]),
49
+ this.story && this.variant
50
+ ? h(SandboxVue3, {
51
+ story: this.story,
52
+ variant: this.variant,
53
+ })
54
+ : null,
55
+ ]
56
+ },
57
+ })
58
+ app.use(createPinia())
59
+ registerGlobalComponents(app)
60
+ app.mount('#app')
@@ -6,9 +6,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
6
6
  variants: {
7
7
  id: string;
8
8
  title: string;
9
- initState: () => any;
10
- slots: () => Readonly<any>;
11
- state: any;
9
+ icon?: string;
10
+ iconColor?: string;
11
+ initState?: () => any;
12
+ slots?: () => Readonly<any>;
13
+ state?: any;
14
+ source?: string;
12
15
  }[];
13
16
  layout?: {
14
17
  type: "single";
@@ -16,26 +19,39 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
16
19
  type: "grid";
17
20
  width: number;
18
21
  };
22
+ icon?: string;
23
+ iconColor?: string;
24
+ file?: {
25
+ id: string;
26
+ framework: string;
27
+ component: any;
28
+ story: any;
29
+ path: string[];
30
+ };
19
31
  lastSelectedVariant?: {
20
32
  id: string;
21
33
  title: string;
22
- initState: () => any;
23
- slots: () => Readonly<any>;
24
- state: any;
34
+ icon?: string;
35
+ iconColor?: string;
36
+ initState?: () => any;
37
+ slots?: () => Readonly<any>;
38
+ state?: any;
39
+ source?: string;
25
40
  };
26
- mountTime: number;
27
41
  }[]>;
28
- addStory: (story: Story) => Story;
29
- removeStory: (story: Story) => void;
42
+ setStories: (value: Story[]) => void;
30
43
  currentStory: import("vue").ComputedRef<{
31
44
  id: string;
32
45
  title: string;
33
46
  variants: {
34
47
  id: string;
35
48
  title: string;
36
- initState: () => any;
37
- slots: () => Readonly<any>;
38
- state: any;
49
+ icon?: string;
50
+ iconColor?: string;
51
+ initState?: () => any;
52
+ slots?: () => Readonly<any>;
53
+ state?: any;
54
+ source?: string;
39
55
  }[];
40
56
  layout?: {
41
57
  type: "single";
@@ -43,14 +59,35 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
43
59
  type: "grid";
44
60
  width: number;
45
61
  };
62
+ icon?: string;
63
+ iconColor?: string;
64
+ file?: {
65
+ id: string;
66
+ framework: string;
67
+ component: any;
68
+ story: any;
69
+ path: string[];
70
+ };
46
71
  lastSelectedVariant?: {
47
72
  id: string;
48
73
  title: string;
49
- initState: () => any;
50
- slots: () => Readonly<any>;
51
- state: any;
74
+ icon?: string;
75
+ iconColor?: string;
76
+ initState?: () => any;
77
+ slots?: () => Readonly<any>;
78
+ state?: any;
79
+ source?: string;
52
80
  };
53
- mountTime: number;
81
+ }>;
82
+ currentVariant: import("vue").ComputedRef<{
83
+ id: string;
84
+ title: string;
85
+ icon?: string;
86
+ iconColor?: string;
87
+ initState?: () => any;
88
+ slots?: () => Readonly<any>;
89
+ state?: any;
90
+ source?: string;
54
91
  }>;
55
92
  }, "stories">>, import("pinia")._UnwrapAll<Pick<{
56
93
  stories: import("vue").Ref<{
@@ -59,9 +96,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
59
96
  variants: {
60
97
  id: string;
61
98
  title: string;
62
- initState: () => any;
63
- slots: () => Readonly<any>;
64
- state: any;
99
+ icon?: string;
100
+ iconColor?: string;
101
+ initState?: () => any;
102
+ slots?: () => Readonly<any>;
103
+ state?: any;
104
+ source?: string;
65
105
  }[];
66
106
  layout?: {
67
107
  type: "single";
@@ -69,26 +109,39 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
69
109
  type: "grid";
70
110
  width: number;
71
111
  };
112
+ icon?: string;
113
+ iconColor?: string;
114
+ file?: {
115
+ id: string;
116
+ framework: string;
117
+ component: any;
118
+ story: any;
119
+ path: string[];
120
+ };
72
121
  lastSelectedVariant?: {
73
122
  id: string;
74
123
  title: string;
75
- initState: () => any;
76
- slots: () => Readonly<any>;
77
- state: any;
124
+ icon?: string;
125
+ iconColor?: string;
126
+ initState?: () => any;
127
+ slots?: () => Readonly<any>;
128
+ state?: any;
129
+ source?: string;
78
130
  };
79
- mountTime: number;
80
131
  }[]>;
81
- addStory: (story: Story) => Story;
82
- removeStory: (story: Story) => void;
132
+ setStories: (value: Story[]) => void;
83
133
  currentStory: import("vue").ComputedRef<{
84
134
  id: string;
85
135
  title: string;
86
136
  variants: {
87
137
  id: string;
88
138
  title: string;
89
- initState: () => any;
90
- slots: () => Readonly<any>;
91
- state: any;
139
+ icon?: string;
140
+ iconColor?: string;
141
+ initState?: () => any;
142
+ slots?: () => Readonly<any>;
143
+ state?: any;
144
+ source?: string;
92
145
  }[];
93
146
  layout?: {
94
147
  type: "single";
@@ -96,25 +149,49 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
96
149
  type: "grid";
97
150
  width: number;
98
151
  };
152
+ icon?: string;
153
+ iconColor?: string;
154
+ file?: {
155
+ id: string;
156
+ framework: string;
157
+ component: any;
158
+ story: any;
159
+ path: string[];
160
+ };
99
161
  lastSelectedVariant?: {
100
162
  id: string;
101
163
  title: string;
102
- initState: () => any;
103
- slots: () => Readonly<any>;
104
- state: any;
164
+ icon?: string;
165
+ iconColor?: string;
166
+ initState?: () => any;
167
+ slots?: () => Readonly<any>;
168
+ state?: any;
169
+ source?: string;
105
170
  };
106
- mountTime: number;
107
171
  }>;
108
- }, "currentStory">>, Pick<{
172
+ currentVariant: import("vue").ComputedRef<{
173
+ id: string;
174
+ title: string;
175
+ icon?: string;
176
+ iconColor?: string;
177
+ initState?: () => any;
178
+ slots?: () => Readonly<any>;
179
+ state?: any;
180
+ source?: string;
181
+ }>;
182
+ }, "currentStory" | "currentVariant">>, Pick<{
109
183
  stories: import("vue").Ref<{
110
184
  id: string;
111
185
  title: string;
112
186
  variants: {
113
187
  id: string;
114
188
  title: string;
115
- initState: () => any;
116
- slots: () => Readonly<any>;
117
- state: any;
189
+ icon?: string;
190
+ iconColor?: string;
191
+ initState?: () => any;
192
+ slots?: () => Readonly<any>;
193
+ state?: any;
194
+ source?: string;
118
195
  }[];
119
196
  layout?: {
120
197
  type: "single";
@@ -122,26 +199,39 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
122
199
  type: "grid";
123
200
  width: number;
124
201
  };
202
+ icon?: string;
203
+ iconColor?: string;
204
+ file?: {
205
+ id: string;
206
+ framework: string;
207
+ component: any;
208
+ story: any;
209
+ path: string[];
210
+ };
125
211
  lastSelectedVariant?: {
126
212
  id: string;
127
213
  title: string;
128
- initState: () => any;
129
- slots: () => Readonly<any>;
130
- state: any;
214
+ icon?: string;
215
+ iconColor?: string;
216
+ initState?: () => any;
217
+ slots?: () => Readonly<any>;
218
+ state?: any;
219
+ source?: string;
131
220
  };
132
- mountTime: number;
133
221
  }[]>;
134
- addStory: (story: Story) => Story;
135
- removeStory: (story: Story) => void;
222
+ setStories: (value: Story[]) => void;
136
223
  currentStory: import("vue").ComputedRef<{
137
224
  id: string;
138
225
  title: string;
139
226
  variants: {
140
227
  id: string;
141
228
  title: string;
142
- initState: () => any;
143
- slots: () => Readonly<any>;
144
- state: any;
229
+ icon?: string;
230
+ iconColor?: string;
231
+ initState?: () => any;
232
+ slots?: () => Readonly<any>;
233
+ state?: any;
234
+ source?: string;
145
235
  }[];
146
236
  layout?: {
147
237
  type: "single";
@@ -149,13 +239,34 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
149
239
  type: "grid";
150
240
  width: number;
151
241
  };
242
+ icon?: string;
243
+ iconColor?: string;
244
+ file?: {
245
+ id: string;
246
+ framework: string;
247
+ component: any;
248
+ story: any;
249
+ path: string[];
250
+ };
152
251
  lastSelectedVariant?: {
153
252
  id: string;
154
253
  title: string;
155
- initState: () => any;
156
- slots: () => Readonly<any>;
157
- state: any;
254
+ icon?: string;
255
+ iconColor?: string;
256
+ initState?: () => any;
257
+ slots?: () => Readonly<any>;
258
+ state?: any;
259
+ source?: string;
158
260
  };
159
- mountTime: number;
160
261
  }>;
161
- }, "addStory" | "removeStory">>;
262
+ currentVariant: import("vue").ComputedRef<{
263
+ id: string;
264
+ title: string;
265
+ icon?: string;
266
+ iconColor?: string;
267
+ initState?: () => any;
268
+ slots?: () => Readonly<any>;
269
+ state?: any;
270
+ source?: string;
271
+ }>;
272
+ }, "setStories">>;
@@ -3,27 +3,16 @@ import { computed, ref } from 'vue';
3
3
  import { router } from '../router';
4
4
  export const useStoryStore = defineStore('story', () => {
5
5
  const stories = ref([]);
6
- function addStory(story) {
7
- const existing = stories.value.find(s => s.id === story.id);
8
- if (existing) {
9
- Object.assign(existing, story);
10
- return existing;
11
- }
12
- stories.value.push(story);
13
- return story;
14
- }
15
- function removeStory(story) {
16
- const index = stories.value.findIndex(s => s.id === story.id);
17
- if (index !== -1) {
18
- stories.value.splice(index, 1);
19
- }
6
+ function setStories(value) {
7
+ stories.value = value;
20
8
  }
21
9
  const currentStory = computed(() => stories.value.find(s => s.id === router.currentRoute.value.params.storyId));
10
+ const currentVariant = computed(() => currentStory.value?.variants.find(v => v.id === router.currentRoute.value.query.variantId));
22
11
  return {
23
12
  stories,
24
- addStory,
25
- removeStory,
13
+ setStories,
26
14
  currentStory,
15
+ currentVariant,
27
16
  };
28
17
  });
29
18
  //# sourceMappingURL=story.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"story.js","sourceRoot":"","sources":["../../../../src/client/app/stores/story.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAGlC,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE;IACrD,MAAM,OAAO,GAAG,GAAG,CAAU,EAAE,CAAC,CAAA;IAEhC,SAAS,QAAQ,CAAE,KAAY;QAC7B,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,CAAA;QAC3D,IAAI,QAAQ,EAAE;YACZ,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;YAC9B,OAAO,QAAQ,CAAA;SAChB;QACD,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACzB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,SAAS,WAAW,CAAE,KAAY;QAChC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,CAAA;QAC7D,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YAChB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;SAC/B;IACH,CAAC;IAED,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;IAE/G,OAAO;QACL,OAAO;QACP,QAAQ;QACR,WAAW;QACX,YAAY;KACb,CAAA;AACH,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"story.js","sourceRoot":"","sources":["../../../../src/client/app/stores/story.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAGlC,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE;IACrD,MAAM,OAAO,GAAG,GAAG,CAAU,EAAE,CAAC,CAAA;IAChC,SAAS,UAAU,CAAE,KAAc;QACjC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAA;IACvB,CAAC;IAED,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;IAE/G,MAAM,cAAc,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAA;IAEjI,OAAO;QACL,OAAO;QACP,UAAU;QACV,YAAY;QACZ,cAAc;KACf,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { defineStore } from 'pinia'
2
+ import { computed, ref } from 'vue'
3
+ import { router } from '../router'
4
+ import { Story } from '../types'
5
+
6
+ export const useStoryStore = defineStore('story', () => {
7
+ const stories = ref<Story[]>([])
8
+ function setStories (value: Story[]) {
9
+ stories.value = value
10
+ }
11
+
12
+ const currentStory = computed(() => stories.value.find(s => s.id === router.currentRoute.value.params.storyId))
13
+
14
+ const currentVariant = computed(() => currentStory.value?.variants.find(v => v.id === router.currentRoute.value.query.variantId))
15
+
16
+ return {
17
+ stories,
18
+ setStories,
19
+ currentStory,
20
+ currentVariant,
21
+ }
22
+ })
@@ -11,16 +11,30 @@
11
11
  border-color: #e5e7eb;
12
12
  }
13
13
 
14
- a {
14
+ a,
15
+ input {
15
16
  color: inherit;
17
+ }
18
+
19
+ a {
16
20
  text-decoration: inherit;
17
21
  }
18
22
 
23
+ input {
24
+ font-family: inherit;
25
+ }
26
+
27
+ a,
28
+ button {
29
+ user-select: none;
30
+ }
31
+
19
32
  @tailwind base;
20
33
  @tailwind components;
21
34
  @tailwind utilities;
22
35
 
23
- body {
36
+ body,
37
+ pre {
24
38
  margin: 0;
25
39
  }
26
40
 
@@ -0,0 +1,14 @@
1
+ body {
2
+ margin: 0;
3
+ }
4
+
5
+ html,
6
+ body,
7
+ #app {
8
+ font-family: 'Lato', sans-serif;
9
+ font-size: 14px;
10
+ }
11
+
12
+ .htw-sandbox-hidden {
13
+ display: none;
14
+ }
@@ -1,3 +1,11 @@
1
+ import type { RouteLocationRaw } from 'vue-router';
2
+ export interface StoryFile {
3
+ id: string;
4
+ framework: string;
5
+ component: any;
6
+ story: Story;
7
+ path: string[];
8
+ }
1
9
  export interface Story {
2
10
  id: string;
3
11
  title: string;
@@ -8,13 +16,37 @@ export interface Story {
8
16
  type: 'grid';
9
17
  width: number;
10
18
  };
19
+ icon?: string;
20
+ iconColor?: string;
21
+ file?: StoryFile;
11
22
  lastSelectedVariant?: Variant;
12
- mountTime: number;
13
23
  }
14
24
  export interface Variant {
15
25
  id: string;
16
26
  title: string;
17
- initState: () => any;
18
- slots: () => Readonly<any>;
19
- state: any;
27
+ icon?: string;
28
+ iconColor?: string;
29
+ initState?: () => any;
30
+ slots?: () => Readonly<any>;
31
+ state?: any;
32
+ source?: string;
33
+ }
34
+ export declare type TreeLeaf = {
35
+ title: string;
36
+ index: number;
37
+ };
38
+ export declare type TreeFolder = {
39
+ title: string;
40
+ children: (TreeFolder | TreeLeaf)[];
41
+ };
42
+ export declare type Tree = (TreeFolder | TreeLeaf)[];
43
+ export interface SearchResult {
44
+ kind: 'story' | 'variant';
45
+ rank: number;
46
+ id: string;
47
+ title: string;
48
+ route: RouteLocationRaw;
49
+ path?: string[];
50
+ icon?: string;
51
+ iconColor?: string;
20
52
  }
@@ -0,0 +1,45 @@
1
+ export interface StoryFile {
2
+ id: string
3
+ framework: string
4
+ component: any
5
+ story: Story
6
+ }
7
+
8
+ export interface Story {
9
+ id: string
10
+ title: string
11
+ variants: Variant[]
12
+ layout?: {
13
+ type: 'single'
14
+ } | {
15
+ type: 'grid'
16
+ width: number
17
+ }
18
+ icon?: string
19
+ iconColor?: string
20
+ file?: StoryFile
21
+ lastSelectedVariant?: Variant
22
+ }
23
+
24
+ export interface Variant {
25
+ id: string
26
+ title: string
27
+ icon?: string
28
+ iconColor?: string
29
+ initState?: () => any
30
+ slots?: () => Readonly<any>
31
+ state?: any
32
+ source?: string
33
+ }
34
+
35
+ export type TreeLeaf = {
36
+ title: string
37
+ index: number
38
+ }
39
+
40
+ export type TreeFolder = {
41
+ title: string
42
+ children: (TreeFolder | TreeLeaf)[]
43
+ }
44
+
45
+ export type Tree = (TreeFolder | TreeLeaf)[]
@@ -0,0 +1,3 @@
1
+ import type { HistoireConfig } from '../../../node/config';
2
+ export declare const histoireConfig: HistoireConfig;
3
+ export declare const customLogos: HistoireConfig['theme']['logo'];
@@ -0,0 +1,5 @@
1
+ // @ts-expect-error virtual module
2
+ import { config as configRaw, logos as logosRaw } from '$histoire-config';
3
+ export const histoireConfig = configRaw;
4
+ export const customLogos = logosRaw;
5
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/client/app/util/config.ts"],"names":[],"mappings":"AACA,kCAAkC;AAClC,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEzE,MAAM,CAAC,MAAM,cAAc,GAAmB,SAAS,CAAA;AACvD,MAAM,CAAC,MAAM,WAAW,GAAoC,QAAQ,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { HistoireConfig } from '../../../node/config'
2
+ // @ts-expect-error virtual module
3
+ import { config as configRaw, logos as logosRaw } from '$histoire-config'
4
+
5
+ export const histoireConfig: HistoireConfig = configRaw
6
+ export const customLogos: HistoireConfig['theme']['logo'] = logosRaw
@@ -0,0 +1 @@
1
+ export declare const STATE_SYNC = "__histoire:state-sync";
@@ -0,0 +1,2 @@
1
+ export const STATE_SYNC = '__histoire:state-sync';
2
+ //# sourceMappingURL=const.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../src/client/app/util/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,uBAAuB,CAAA"}
@@ -0,0 +1 @@
1
+ export const STATE_SYNC = '__histoire:state-sync'
@@ -0,0 +1,2 @@
1
+ export declare const isDark: import("vue").WritableComputedRef<boolean>;
2
+ export declare const toggleDark: (value?: boolean) => boolean;
@@ -0,0 +1,4 @@
1
+ import { useDark, useToggle } from '@vueuse/core';
2
+ export const isDark = useDark({ valueDark: 'htw-dark' });
3
+ export const toggleDark = useToggle(isDark);
4
+ //# sourceMappingURL=dark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dark.js","sourceRoot":"","sources":["../../../../src/client/app/util/dark.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEjD,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAA;AACxD,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { useDark, useToggle } from '@vueuse/core'
2
+
3
+ export const isDark = useDark({ valueDark: 'htw-dark' })
4
+ export const toggleDark = useToggle(isDark)
@@ -0,0 +1 @@
1
+ export declare const isMac: boolean;
@@ -0,0 +1,2 @@
1
+ export const isMac = navigator.platform.toLowerCase().includes('mac');
2
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../../../src/client/app/util/env.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { Ref } from 'vue';
2
+ export declare type KeyboardShortcut = string[];
3
+ export declare type KeyboardHandler = (event: KeyboardEvent) => unknown;
4
+ export interface KeyboardShortcutOptions {
5
+ event?: 'keyup' | 'keydown' | 'keypress';
6
+ }
7
+ export declare function onKeyboardShortcut(shortcut: KeyboardShortcut | Ref<KeyboardShortcut>, handler: KeyboardHandler, options?: KeyboardShortcutOptions): void;
8
+ export declare function formatKey(key: string): string;