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,9 +1,12 @@
1
1
  <script lang="ts" setup>
2
- import { PropType, toRefs } from 'vue'
2
+ import { PropType, ref, toRefs } from 'vue'
3
+ import { Icon } from '@iconify/vue'
4
+ import { useRouter } from 'vue-router'
5
+ import { useResizeObserver } from '@vueuse/core'
3
6
  import { useCurrentVariantRoute } from '../../util/variant'
4
7
  import type { Story, Variant } from '../../types'
5
8
  import SandboxVue3 from '../sandbox/SandboxVue3.vue'
6
- import { Icon } from '@iconify/vue'
9
+ import { useScrollOnActive } from '../../util/scroll.js'
7
10
 
8
11
  const props = defineProps({
9
12
  variant: {
@@ -17,21 +20,47 @@ const props = defineProps({
17
20
  },
18
21
  })
19
22
 
23
+ const emit = defineEmits({
24
+ resize: (width: number, height: number) => true,
25
+ })
26
+
20
27
  const { variant } = toRefs(props)
21
28
  const { isActive, targetRoute } = useCurrentVariantRoute(variant)
22
29
 
23
30
  Object.assign(props.variant, {
24
- ready: false,
31
+ previewReady: false,
25
32
  })
26
33
  function onReady () {
27
34
  Object.assign(props.variant, {
28
- ready: true,
35
+ previewReady: true,
29
36
  })
30
37
  }
38
+
39
+ const router = useRouter()
40
+
41
+ function selectVariant () {
42
+ router.push(targetRoute.value)
43
+ }
44
+
45
+ const el = ref<HTMLDivElement>()
46
+
47
+ const { autoScroll } = useScrollOnActive(isActive, el)
48
+
49
+ useResizeObserver(el, () => {
50
+ if (props.variant.previewReady) {
51
+ emit('resize', el.value!.clientWidth, el.value!.clientHeight)
52
+ if (isActive.value) {
53
+ autoScroll()
54
+ }
55
+ }
56
+ })
31
57
  </script>
32
58
 
33
59
  <template>
34
- <div class="htw-cursor-default htw-flex htw-flex-col htw-gap-y-1">
60
+ <div
61
+ ref="el"
62
+ class="htw-cursor-default htw-flex htw-flex-col htw-gap-y-1"
63
+ >
35
64
  <!-- Header -->
36
65
  <div class="htw-flex-none htw-flex htw-items-center">
37
66
  <RouterLink
@@ -61,7 +90,8 @@ function onReady () {
61
90
  'htw-border-gray-100 dark:htw-border-gray-800': !isActive,
62
91
  'htw-border-primary-200 dark:htw-border-primary-900': isActive,
63
92
  }"
64
- @click.stop.prevent
93
+ @click.stop.prevent="selectVariant()"
94
+ @keyup="selectVariant()"
65
95
  >
66
96
  <SandboxVue3
67
97
  :variant="variant"
@@ -1,20 +1,16 @@
1
1
  <script lang="ts" setup>
2
- import { PropType } from 'vue'
3
2
  import type { Story, Variant } from '../../types'
4
- import { usePreviewSettings } from '../../util/preview-settings'
5
3
  import StoryResponsivePreview from './StoryResponsivePreview.vue'
6
4
  import { isMobile } from '../../util/responsive'
7
- import StoryVariantTitle from './variant/StoryVariantTitle.vue'
8
- import StoryVariantResponsiveSize from './variant/StoryVariantResponsiveSize.vue'
9
- import StoryVariantBackground from './variant/StoryVariantBackground.vue'
10
- import StoryVariantNewTab from './variant/StoryVariantNewTab.vue'
5
+ import StoryVariantTitle from './toolbar/StoryVariantTitle.vue'
6
+ import StoryVariantResponsiveSize from './toolbar/StoryVariantResponsiveSize.vue'
7
+ import StoryVariantBackground from './toolbar/StoryVariantBackground.vue'
8
+ import StoryVariantNewTab from './toolbar/StoryVariantNewTab.vue'
11
9
 
12
10
  defineProps<{
13
11
  variant: Variant
14
12
  story: Story
15
13
  }>()
16
-
17
- const settings = usePreviewSettings()
18
14
  </script>
19
15
 
20
16
  <template>
@@ -27,8 +23,12 @@ const settings = usePreviewSettings()
27
23
  v-if="!isMobile"
28
24
  class="htw-flex-none htw-flex htw-items-center htw-h-8 -htw-mt-1"
29
25
  >
30
- <StoryVariantTitle :variant="variant" />
31
- <StoryVariantResponsiveSize />
26
+ <StoryVariantTitle
27
+ :variant="variant"
28
+ />
29
+ <StoryVariantResponsiveSize
30
+ v-if="!variant.responsiveDisabled"
31
+ />
32
32
  <StoryVariantBackground />
33
33
  <StoryVariantNewTab
34
34
  :variant="variant"
@@ -38,7 +38,6 @@ const settings = usePreviewSettings()
38
38
 
39
39
  <!-- Preview -->
40
40
  <StoryResponsivePreview
41
- v-model:settings="settings"
42
41
  :story="story"
43
42
  :variant="variant"
44
43
  />
@@ -1,21 +1,16 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed, ref, watch } from 'vue'
3
- import { useRoute, useRouter } from 'vue-router'
4
3
  import { useStoryStore } from '../../stores/story'
5
-
4
+ import { Icon } from '@iconify/vue'
5
+ import { isMobile } from '../../util/responsive'
6
6
  import BaseSplitPane from '../base/BaseSplitPane.vue'
7
7
  import StoryVariantListItem from './StoryVariantListItem.vue'
8
- import StoryVariantGridItem from './StoryVariantGridItem.vue'
9
8
  import StoryVariantSingleView from './StoryVariantSingleView.vue'
10
- import { isMobile } from '../../util/responsive'
11
- import { Icon } from '@iconify/vue'
12
9
  import MobileOverlay from '../app/MobileOverlay.vue'
10
+ import StoryVariantGrid from './StoryVariantGrid.vue'
13
11
 
14
12
  const storyStore = useStoryStore()
15
13
 
16
- const router = useRouter()
17
- const route = useRoute()
18
-
19
14
  const hasSingleVariant = computed(() => (storyStore.currentStory?.variants.length === 1))
20
15
 
21
16
  const variant = computed(() => storyStore.currentVariant)
@@ -34,45 +29,13 @@ watch(variant, () => {
34
29
  isMenuOpened.value = false
35
30
  })
36
31
 
37
- const templateWidth = computed(() => {
38
- if (storyStore.currentStory.layout.type !== 'grid') {
39
- return
40
- }
41
-
42
- const layoutWidth = storyStore.currentStory.layout.width
43
-
44
- if (!layoutWidth) {
45
- return '200px'
46
- }
47
-
48
- if (typeof layoutWidth === 'number') {
49
- return layoutWidth + 'px'
50
- }
51
-
52
- return layoutWidth
53
- })
54
32
  </script>
55
33
 
56
34
  <template>
57
35
  <div class="htw-bg-gray-50 htw-h-full dark:htw-bg-gray-750">
58
- <div
36
+ <StoryVariantGrid
59
37
  v-if="storyStore.currentStory.layout.type === 'grid'"
60
- class="htw-h-full htw-overflow-y-auto"
61
- >
62
- <div
63
- class="htw-grid htw-gap-4 htw-m-4"
64
- :style="{
65
- gridTemplateColumns: `repeat(auto-fill, ${templateWidth})`,
66
- }"
67
- >
68
- <StoryVariantGridItem
69
- v-for="(variant, index) of storyStore.currentStory.variants"
70
- :key="index"
71
- :variant="variant"
72
- :story="storyStore.currentStory"
73
- />
74
- </div>
75
- </div>
38
+ />
76
39
 
77
40
  <template v-else-if="storyStore.currentStory.layout.type === 'single'">
78
41
  <div
@@ -80,6 +43,7 @@ const templateWidth = computed(() => {
80
43
  class="htw-p-2 htw-h-full"
81
44
  >
82
45
  <StoryVariantSingleView
46
+ v-if="storyStore.currentVariant.configReady"
83
47
  :variant="storyStore.currentVariant"
84
48
  :story="storyStore.currentStory"
85
49
  />
@@ -118,6 +82,7 @@ const templateWidth = computed(() => {
118
82
  class="htw-p-2 htw-h-full"
119
83
  >
120
84
  <StoryVariantSingleView
85
+ v-if="storyStore.currentVariant.configReady"
121
86
  :variant="storyStore.currentVariant"
122
87
  :story="storyStore.currentStory"
123
88
  />
@@ -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>
@@ -16,14 +16,14 @@ const settings = usePreviewSettings()
16
16
  >
17
17
  <div
18
18
  v-tooltip="'Background color'"
19
- class="htw-cursor-pointer hover:htw-text-primary-500 htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2"
19
+ class="htw-cursor-pointer hover:htw-text-primary-500 htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 htw-group"
20
20
  >
21
21
  <div
22
22
  class="bind-preview-bg htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/50 dark:htw-border-white/50"
23
23
  />
24
24
  <Icon
25
25
  icon="carbon:caret-down"
26
- class="htw-w-4 htw-h-4 htw-opacity-50"
26
+ class="htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
27
27
  />
28
28
  </div>
29
29
 
@@ -19,11 +19,11 @@ const sandboxUrl = computed(() => {
19
19
  v-tooltip="'Open variant in new tab'"
20
20
  :href="sandboxUrl"
21
21
  target="_blank"
22
- class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 hover:htw-text-primary-500"
22
+ class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 hover:htw-text-primary-500 htw-opacity-50 hover:htw-opacity-100 dark:hover:htw-text-primary-400 htw-text-gray-900 dark:htw-text-gray-100"
23
23
  >
24
24
  <Icon
25
25
  icon="carbon:launch"
26
- class="base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50"
26
+ class="base-list-item-link-icon htw-w-4 htw-h-4"
27
27
  />
28
28
  </a>
29
29
  </template>
@@ -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,8 @@
1
+ import type { PreviewSettings } from '../types';
2
+ export declare const usePreviewSettingsStore: import("pinia").StoreDefinition<"preview-settings", import("pinia")._UnwrapAll<Pick<{
3
+ currentSettings: import("@vueuse/shared").RemovableRef<PreviewSettings>;
4
+ }, "currentSettings">>, import("pinia")._UnwrapAll<Pick<{
5
+ currentSettings: import("@vueuse/shared").RemovableRef<PreviewSettings>;
6
+ }, never>>, Pick<{
7
+ currentSettings: import("@vueuse/shared").RemovableRef<PreviewSettings>;
8
+ }, never>>;
@@ -0,0 +1,14 @@
1
+ import { defineStore } from 'pinia';
2
+ import { useStorage } from '@vueuse/core';
3
+ export const usePreviewSettingsStore = defineStore('preview-settings', () => {
4
+ const currentSettings = useStorage('_histoire-sandbox-settings-v2', {
5
+ responsiveWidth: 720,
6
+ responsiveHeight: null,
7
+ rotate: false,
8
+ backgroundColor: 'transparent',
9
+ checkerboard: false,
10
+ });
11
+ return {
12
+ currentSettings,
13
+ };
14
+ });
@@ -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
+ })
@@ -12,7 +12,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
12
12
  slots?: () => Readonly<any>;
13
13
  state?: any;
14
14
  source?: string;
15
- ready?: boolean;
15
+ responsiveDisabled?: boolean;
16
+ configReady?: boolean;
17
+ previewReady?: boolean;
16
18
  }[];
17
19
  layout?: {
18
20
  type: "single";
@@ -38,7 +40,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
38
40
  slots?: () => Readonly<any>;
39
41
  state?: any;
40
42
  source?: string;
41
- ready?: boolean;
43
+ responsiveDisabled?: boolean;
44
+ configReady?: boolean;
45
+ previewReady?: boolean;
42
46
  };
43
47
  }[]>;
44
48
  setStories: (value: Story[]) => void;
@@ -54,7 +58,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
54
58
  slots?: () => Readonly<any>;
55
59
  state?: any;
56
60
  source?: string;
57
- ready?: boolean;
61
+ responsiveDisabled?: boolean;
62
+ configReady?: boolean;
63
+ previewReady?: boolean;
58
64
  }[];
59
65
  layout?: {
60
66
  type: "single";
@@ -80,7 +86,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
80
86
  slots?: () => Readonly<any>;
81
87
  state?: any;
82
88
  source?: string;
83
- ready?: boolean;
89
+ responsiveDisabled?: boolean;
90
+ configReady?: boolean;
91
+ previewReady?: boolean;
84
92
  };
85
93
  }>;
86
94
  currentVariant: import("vue").ComputedRef<{
@@ -92,7 +100,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
92
100
  slots?: () => Readonly<any>;
93
101
  state?: any;
94
102
  source?: string;
95
- ready?: boolean;
103
+ responsiveDisabled?: boolean;
104
+ configReady?: boolean;
105
+ previewReady?: boolean;
96
106
  }>;
97
107
  isFolderOpened: (path: Array<string>) => boolean;
98
108
  toggleFolder: (path: Array<string>, force?: boolean) => void;
@@ -109,7 +119,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
109
119
  slots?: () => Readonly<any>;
110
120
  state?: any;
111
121
  source?: string;
112
- ready?: boolean;
122
+ responsiveDisabled?: boolean;
123
+ configReady?: boolean;
124
+ previewReady?: boolean;
113
125
  }[];
114
126
  layout?: {
115
127
  type: "single";
@@ -135,7 +147,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
135
147
  slots?: () => Readonly<any>;
136
148
  state?: any;
137
149
  source?: string;
138
- ready?: boolean;
150
+ responsiveDisabled?: boolean;
151
+ configReady?: boolean;
152
+ previewReady?: boolean;
139
153
  };
140
154
  }[]>;
141
155
  setStories: (value: Story[]) => void;
@@ -151,7 +165,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
151
165
  slots?: () => Readonly<any>;
152
166
  state?: any;
153
167
  source?: string;
154
- ready?: boolean;
168
+ responsiveDisabled?: boolean;
169
+ configReady?: boolean;
170
+ previewReady?: boolean;
155
171
  }[];
156
172
  layout?: {
157
173
  type: "single";
@@ -177,7 +193,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
177
193
  slots?: () => Readonly<any>;
178
194
  state?: any;
179
195
  source?: string;
180
- ready?: boolean;
196
+ responsiveDisabled?: boolean;
197
+ configReady?: boolean;
198
+ previewReady?: boolean;
181
199
  };
182
200
  }>;
183
201
  currentVariant: import("vue").ComputedRef<{
@@ -189,7 +207,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
189
207
  slots?: () => Readonly<any>;
190
208
  state?: any;
191
209
  source?: string;
192
- ready?: boolean;
210
+ responsiveDisabled?: boolean;
211
+ configReady?: boolean;
212
+ previewReady?: boolean;
193
213
  }>;
194
214
  isFolderOpened: (path: Array<string>) => boolean;
195
215
  toggleFolder: (path: Array<string>, force?: boolean) => void;
@@ -206,7 +226,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
206
226
  slots?: () => Readonly<any>;
207
227
  state?: any;
208
228
  source?: string;
209
- ready?: boolean;
229
+ responsiveDisabled?: boolean;
230
+ configReady?: boolean;
231
+ previewReady?: boolean;
210
232
  }[];
211
233
  layout?: {
212
234
  type: "single";
@@ -232,7 +254,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
232
254
  slots?: () => Readonly<any>;
233
255
  state?: any;
234
256
  source?: string;
235
- ready?: boolean;
257
+ responsiveDisabled?: boolean;
258
+ configReady?: boolean;
259
+ previewReady?: boolean;
236
260
  };
237
261
  }[]>;
238
262
  setStories: (value: Story[]) => void;
@@ -248,7 +272,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
248
272
  slots?: () => Readonly<any>;
249
273
  state?: any;
250
274
  source?: string;
251
- ready?: boolean;
275
+ responsiveDisabled?: boolean;
276
+ configReady?: boolean;
277
+ previewReady?: boolean;
252
278
  }[];
253
279
  layout?: {
254
280
  type: "single";
@@ -274,7 +300,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
274
300
  slots?: () => Readonly<any>;
275
301
  state?: any;
276
302
  source?: string;
277
- ready?: boolean;
303
+ responsiveDisabled?: boolean;
304
+ configReady?: boolean;
305
+ previewReady?: boolean;
278
306
  };
279
307
  }>;
280
308
  currentVariant: import("vue").ComputedRef<{
@@ -286,7 +314,9 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
286
314
  slots?: () => Readonly<any>;
287
315
  state?: any;
288
316
  source?: string;
289
- ready?: boolean;
317
+ responsiveDisabled?: boolean;
318
+ configReady?: boolean;
319
+ previewReady?: boolean;
290
320
  }>;
291
321
  isFolderOpened: (path: Array<string>) => boolean;
292
322
  toggleFolder: (path: Array<string>, force?: boolean) => void;
@@ -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
  }
@@ -30,7 +30,9 @@ export interface Variant {
30
30
  slots?: () => Readonly<any>;
31
31
  state?: any;
32
32
  source?: string;
33
- ready?: boolean;
33
+ responsiveDisabled?: boolean;
34
+ configReady?: boolean;
35
+ previewReady?: boolean;
34
36
  }
35
37
  export declare type TreeLeaf = {
36
38
  title: string;
@@ -51,3 +53,10 @@ export interface SearchResult {
51
53
  icon?: string;
52
54
  iconColor?: string;
53
55
  }
56
+ export interface PreviewSettings {
57
+ responsiveWidth: number;
58
+ responsiveHeight: number;
59
+ rotate: boolean;
60
+ backgroundColor: string;
61
+ checkerboard: boolean;
62
+ }
@@ -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
+ }
@@ -15,14 +15,15 @@ export function mapFile(file, existingFile) {
15
15
  const variant = result.story.variants[index];
16
16
  const existingVariant = existingFile.story.variants[index];
17
17
  if (existingVariant) {
18
- if (existingVariant.state)
19
- Object.assign(variant.state, existingVariant.state);
20
- if (existingVariant.initState)
21
- variant.initState = existingVariant.initState;
22
- if (existingVariant.slots)
23
- variant.slots = existingVariant.slots;
24
- if (existingVariant.ready)
25
- variant.ready = existingVariant.ready;
18
+ for (const key in existingVariant) {
19
+ if (typeof existingVariant[key] !== 'undefined') {
20
+ if (key === 'state') {
21
+ Object.assign(variant.state, existingVariant.state);
22
+ continue;
23
+ }
24
+ variant[key] = existingVariant[key];
25
+ }
26
+ }
26
27
  }
27
28
  }
28
29
  if (existingFile.story.lastSelectedVariant) {
@@ -37,6 +38,6 @@ export function mapVariant(variant) {
37
38
  state: {},
38
39
  initState: null,
39
40
  slots: () => ({}),
40
- ready: false,
41
+ previewReady: false,
41
42
  };
42
43
  }
@@ -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,11 +1,4 @@
1
- export interface PreviewSettings {
2
- responsiveWidth: number;
3
- responsiveHeight: number;
4
- rotate: boolean;
5
- backgroundColor: string;
6
- checkerboard: boolean;
7
- }
8
- export declare function usePreviewSettings(): import("@vueuse/shared").RemovableRef<PreviewSettings>;
1
+ import type { PreviewSettings } from '../types';
9
2
  export declare const receivedSettings: {
10
3
  responsiveWidth: number;
11
4
  responsiveHeight: number;
@@ -1,14 +1,4 @@
1
- import { useStorage } from '@vueuse/core';
2
1
  import { reactive } from 'vue';
3
- export function usePreviewSettings() {
4
- return useStorage('_histoire-sandbox-settings-v1', {
5
- responsiveWidth: 720,
6
- responsiveHeight: null,
7
- rotate: false,
8
- backgroundColor: 'transparent',
9
- checkerboard: false,
10
- });
11
- }
12
2
  export const receivedSettings = reactive({});
13
3
  export function applyPreviewSettings(settings) {
14
4
  Object.assign(receivedSettings, settings);
@@ -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