histoire 0.2.1 → 0.2.4

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 (67) hide show
  1. package/dist/client/app/App.vue +1 -1
  2. package/dist/client/app/codegen/vue3.js +11 -1
  3. package/dist/client/app/codegen/vue3.ts +9 -1
  4. package/dist/client/app/components/app/AppHeader.vue +3 -3
  5. package/dist/client/app/components/base/BaseListItemLink.vue +1 -1
  6. package/dist/client/app/components/base/BaseTab.vue +1 -1
  7. package/dist/client/app/components/exposed/Story.vue +25 -14
  8. package/dist/client/app/components/exposed/Variant.vue +7 -0
  9. package/dist/client/app/components/search/SearchModal.vue +7 -6
  10. package/dist/client/app/components/story/StoryResponsivePreview.vue +72 -77
  11. package/dist/client/app/components/story/StorySidePanel.vue +1 -1
  12. package/dist/client/app/components/story/StorySourceCode.vue +3 -17
  13. package/dist/client/app/components/story/StoryVariantGrid.vue +112 -0
  14. package/dist/client/app/components/story/StoryVariantGridItem.vue +36 -6
  15. package/dist/client/app/components/story/StoryVariantSingleView.vue +10 -11
  16. package/dist/client/app/components/story/StoryViewer.vue +7 -42
  17. package/dist/client/app/components/story/{variant → toolbar}/StoryVariantBackground.vue +4 -4
  18. package/{src/client/app/components/story/variant → dist/client/app/components/story/toolbar}/StoryVariantNewTab.vue +2 -2
  19. package/dist/client/app/components/story/{variant → toolbar}/StoryVariantResponsiveSize.vue +5 -5
  20. package/dist/client/app/components/story/{variant → toolbar}/StoryVariantTitle.vue +0 -0
  21. package/dist/client/app/stores/preview-settings.d.ts +8 -0
  22. package/dist/client/app/stores/preview-settings.js +14 -0
  23. package/dist/client/app/stores/preview-settings.ts +17 -0
  24. package/dist/client/app/stores/story.d.ts +45 -15
  25. package/dist/client/app/style/main.pcss +4 -0
  26. package/dist/client/app/types.d.ts +10 -1
  27. package/dist/client/app/types.ts +11 -1
  28. package/dist/client/app/util/mapping.js +10 -9
  29. package/dist/client/app/util/mapping.ts +10 -5
  30. package/dist/client/app/util/preview-settings.d.ts +1 -8
  31. package/dist/client/app/util/preview-settings.js +0 -10
  32. package/dist/client/app/util/preview-settings.ts +1 -19
  33. package/dist/client/app/util/scroll.d.ts +3 -1
  34. package/dist/client/app/util/scroll.js +3 -0
  35. package/dist/client/app/util/scroll.ts +4 -0
  36. package/dist/node/config.d.ts +2 -2
  37. package/dist/node/plugin.js +14 -6
  38. package/dist/style.css +67 -4
  39. package/package.json +21 -21
  40. package/src/client/app/App.vue +1 -1
  41. package/src/client/app/codegen/vue3.ts +9 -1
  42. package/src/client/app/components/app/AppHeader.vue +3 -3
  43. package/src/client/app/components/base/BaseListItemLink.vue +1 -1
  44. package/src/client/app/components/base/BaseTab.vue +1 -1
  45. package/src/client/app/components/exposed/Story.vue +25 -14
  46. package/src/client/app/components/exposed/Variant.vue +7 -0
  47. package/src/client/app/components/search/SearchModal.vue +7 -6
  48. package/src/client/app/components/story/StoryResponsivePreview.vue +72 -77
  49. package/src/client/app/components/story/StorySidePanel.vue +1 -1
  50. package/src/client/app/components/story/StorySourceCode.vue +3 -17
  51. package/src/client/app/components/story/StoryVariantGrid.vue +112 -0
  52. package/src/client/app/components/story/StoryVariantGridItem.vue +36 -6
  53. package/src/client/app/components/story/StoryVariantSingleView.vue +10 -11
  54. package/src/client/app/components/story/StoryViewer.vue +7 -42
  55. package/src/client/app/components/story/{variant → toolbar}/StoryVariantBackground.vue +4 -4
  56. package/{dist/client/app/components/story/variant → src/client/app/components/story/toolbar}/StoryVariantNewTab.vue +2 -2
  57. package/src/client/app/components/story/{variant → toolbar}/StoryVariantResponsiveSize.vue +5 -5
  58. package/src/client/app/components/story/{variant → toolbar}/StoryVariantTitle.vue +0 -0
  59. package/src/client/app/stores/preview-settings.ts +17 -0
  60. package/src/client/app/style/main.pcss +4 -0
  61. package/src/client/app/types.ts +11 -1
  62. package/src/client/app/util/mapping.ts +10 -5
  63. package/src/client/app/util/preview-settings.ts +1 -19
  64. package/src/client/app/util/scroll.ts +4 -0
  65. package/src/node/config.ts +2 -2
  66. package/src/node/plugin.ts +15 -6
  67. package/tsconfig.json +2 -0
@@ -1,10 +1,10 @@
1
1
  <script lang="ts" setup>
2
2
  import { Icon } from '@iconify/vue'
3
+ import { usePreviewSettingsStore } from '../../../stores/preview-settings'
3
4
  import { histoireConfig } from '../../../util/config'
4
- import { usePreviewSettings } from '../../../util/preview-settings'
5
5
  import BaseCheckbox from '../../base/BaseCheckbox.vue'
6
6
 
7
- const settings = usePreviewSettings()
7
+ const settings = usePreviewSettingsStore().currentSettings
8
8
  </script>
9
9
 
10
10
  <template>
@@ -17,18 +17,18 @@ const settings = usePreviewSettings()
17
17
  >
18
18
  <div
19
19
  v-tooltip="'Responsive sizes'"
20
- class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2"
20
+ class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 htw-group"
21
21
  :class="{
22
22
  'htw-cursor-pointer hover:htw-text-primary-500': histoireConfig.responsivePresets?.length,
23
23
  }"
24
24
  >
25
25
  <Icon
26
26
  icon="carbon:devices"
27
- class="htw-w-4 htw-h-4 htw-opacity-50"
27
+ class="htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
28
28
  />
29
29
  <Icon
30
30
  icon="carbon:caret-down"
31
- class="htw-w-4 htw-h-4 htw-opacity-50"
31
+ class="htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
32
32
  />
33
33
  </div>
34
34
 
@@ -0,0 +1,17 @@
1
+ import { defineStore } from 'pinia'
2
+ import { useStorage } from '@vueuse/core'
3
+ import type { PreviewSettings } from '../types'
4
+
5
+ export const usePreviewSettingsStore = defineStore('preview-settings', () => {
6
+ const currentSettings = useStorage<PreviewSettings>('_histoire-sandbox-settings-v2', {
7
+ responsiveWidth: 720,
8
+ responsiveHeight: null,
9
+ rotate: false,
10
+ backgroundColor: 'transparent',
11
+ checkerboard: false,
12
+ })
13
+
14
+ return {
15
+ currentSettings,
16
+ }
17
+ })
@@ -48,6 +48,10 @@ body,
48
48
  font-family: 'Lato', sans-serif;
49
49
  }
50
50
 
51
+ html {
52
+ font-size: 16px;
53
+ }
54
+
51
55
  body {
52
56
  font-size: 18px;
53
57
  }
@@ -33,7 +33,9 @@ export interface Variant {
33
33
  slots?: () => Readonly<any>
34
34
  state?: any
35
35
  source?: string
36
- ready?: boolean
36
+ responsiveDisabled?: boolean
37
+ configReady?: boolean
38
+ previewReady?: boolean
37
39
  }
38
40
 
39
41
  export type TreeLeaf = {
@@ -58,3 +60,11 @@ export interface SearchResult {
58
60
  icon?: string
59
61
  iconColor?: string
60
62
  }
63
+
64
+ export interface PreviewSettings {
65
+ responsiveWidth: number
66
+ responsiveHeight: number
67
+ rotate: boolean
68
+ backgroundColor: string
69
+ checkerboard: boolean
70
+ }
@@ -18,10 +18,15 @@ export function mapFile (file: StoryFile, existingFile?: StoryFile): StoryFile {
18
18
  const variant = result.story.variants[index]
19
19
  const existingVariant = existingFile.story.variants[index]
20
20
  if (existingVariant) {
21
- if (existingVariant.state) Object.assign(variant.state, existingVariant.state)
22
- if (existingVariant.initState) variant.initState = existingVariant.initState
23
- if (existingVariant.slots) variant.slots = existingVariant.slots
24
- if (existingVariant.ready) variant.ready = existingVariant.ready
21
+ for (const key in existingVariant) {
22
+ if (typeof existingVariant[key] !== 'undefined') {
23
+ if (key === 'state') {
24
+ Object.assign(variant.state, existingVariant.state)
25
+ continue
26
+ }
27
+ variant[key] = existingVariant[key]
28
+ }
29
+ }
25
30
  }
26
31
  }
27
32
  if (existingFile.story.lastSelectedVariant) {
@@ -38,6 +43,6 @@ export function mapVariant (variant: Variant): Variant {
38
43
  state: {},
39
44
  initState: null,
40
45
  slots: () => ({}),
41
- ready: false,
46
+ previewReady: false,
42
47
  }
43
48
  }
@@ -1,23 +1,5 @@
1
- import { useStorage } from '@vueuse/core'
2
1
  import { reactive } from 'vue'
3
-
4
- export interface PreviewSettings {
5
- responsiveWidth: number
6
- responsiveHeight: number
7
- rotate: boolean
8
- backgroundColor: string
9
- checkerboard: boolean
10
- }
11
-
12
- export function usePreviewSettings () {
13
- return useStorage<PreviewSettings>('_histoire-sandbox-settings-v1', {
14
- responsiveWidth: 720,
15
- responsiveHeight: null,
16
- rotate: false,
17
- backgroundColor: 'transparent',
18
- checkerboard: false,
19
- })
20
- }
2
+ import type { PreviewSettings } from '../types'
21
3
 
22
4
  export const receivedSettings = reactive<PreviewSettings>({} as PreviewSettings)
23
5
 
@@ -24,4 +24,8 @@ export function useScrollOnActive (active: Ref<boolean>, el: Ref<HTMLElement>) {
24
24
  autoScroll()
25
25
  }
26
26
  })
27
+
28
+ return {
29
+ autoScroll,
30
+ }
27
31
  }
@@ -77,7 +77,7 @@ export interface HistoireConfig {
77
77
  dark?: string
78
78
  }
79
79
  /**
80
- * Href to the favicon file (**not** processed by Vite). Put the file in the public directory.
80
+ * Href to the favicon file (**not** processed by Vite). Put the file in the `public` directory.
81
81
  *
82
82
  * Example: `'/favicon.ico'`
83
83
  */
@@ -102,7 +102,7 @@ export interface HistoireConfig {
102
102
  logoHref?: string
103
103
  }
104
104
  /**
105
- * Setup file exposting a default function executed when setting up each story preview.
105
+ * Setup file exporting a default function executed when setting up each story preview.
106
106
  *
107
107
  * Import custom CSS files from this file.
108
108
  *
@@ -149,10 +149,10 @@ if (import.meta.hot) {
149
149
  },
150
150
 
151
151
  configureServer (server) {
152
- server.middlewares.use((req, res, next) => {
152
+ server.middlewares.use(async (req, res, next) => {
153
153
  if (req.url!.startsWith('/__sandbox')) {
154
154
  res.statusCode = 200
155
- res.end(`
155
+ let html = `
156
156
  <!DOCTYPE html>
157
157
  <html>
158
158
  <head>
@@ -174,7 +174,11 @@ if (import.meta.hot) {
174
174
  </script>
175
175
  <script type="module" src="/@fs/${APP_PATH}/sandbox.js"></script>
176
176
  </body>
177
- </html>`)
177
+ </html>`
178
+ // Apply Vite HTML transforms. This injects the Vite HMR client, and
179
+ // also applies HTML transforms from Vite plugins
180
+ html = await server.transformIndexHtml(req.url, html)
181
+ res.end(html)
178
182
  return
179
183
  }
180
184
  next()
@@ -182,10 +186,11 @@ if (import.meta.hot) {
182
186
 
183
187
  // serve our index.html after vite history fallback
184
188
  return () => {
185
- server.middlewares.use((req, res, next) => {
189
+ server.middlewares.use(async (req, res, next) => {
186
190
  if (req.url!.endsWith('.html')) {
187
191
  res.statusCode = 200
188
- res.end(`
192
+
193
+ let html = `
189
194
  <!DOCTYPE html>
190
195
  <html>
191
196
  <head>
@@ -200,7 +205,11 @@ if (import.meta.hot) {
200
205
  <div id="app"></div>
201
206
  <script type="module" src="/@fs/${APP_PATH}/index.js"></script>
202
207
  </body>
203
- </html>`)
208
+ </html>`
209
+ // Apply Vite HTML transforms. This injects the Vite HMR client, and
210
+ // also applies HTML transforms from Vite plugins
211
+ html = await server.transformIndexHtml(req.url, html)
212
+ res.end(html)
204
213
  return
205
214
  }
206
215
  next()
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"