histoire 0.7.1 → 0.7.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 (118) hide show
  1. package/client.d.ts +1 -1
  2. package/dist/bundled/MobileOverlay.js +2 -2
  3. package/dist/bundled/StoryView.js +22 -19
  4. package/dist/bundled/dark.js +4 -0
  5. package/dist/bundled/index.js +0 -1
  6. package/dist/bundled/index2.js +6 -6
  7. package/dist/bundled/mapping.js +78 -0
  8. package/dist/bundled/sandbox.js +7 -6
  9. package/dist/bundled/state.js +13 -44
  10. package/dist/bundled/style.css +17 -17
  11. package/dist/client/app/App.vue +2 -2
  12. package/dist/client/app/components/base/BaseSplitPane.vue +6 -6
  13. package/dist/client/app/components/panel/ControlsComponentPropItem.vue +13 -6
  14. package/dist/client/app/components/panel/ControlsComponentProps.vue +2 -1
  15. package/dist/client/app/components/panel/StatePresets.vue +2 -1
  16. package/dist/client/app/components/panel/StoryControls.vue +1 -1
  17. package/dist/client/app/components/panel/StorySourceCode.vue +2 -2
  18. package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -1
  19. package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +1 -1
  20. package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -2
  21. package/dist/client/app/components/story/StoryVariantSingleView.vue +1 -1
  22. package/dist/client/app/components/toolbar/StoryVariantNewTab.vue +1 -1
  23. package/dist/client/app/components/tree/StoryGroup.vue +1 -1
  24. package/dist/client/app/index.js +0 -2
  25. package/dist/client/app/sandbox.js +4 -5
  26. package/dist/client/app/style/main.pcss +3 -3
  27. package/dist/client/app/style/sandbox.css +1 -1
  28. package/dist/client/app/types.d.ts +1 -52
  29. package/dist/client/app/util/mapping.d.ts +1 -1
  30. package/dist/client/app/util/mapping.js +50 -36
  31. package/dist/client/app/{components/sandbox/lib.d.ts → util/sandbox.d.ts} +1 -1
  32. package/dist/client/app/{components/sandbox/lib.js → util/sandbox.js} +1 -1
  33. package/dist/client/app/util/state.d.ts +1 -5
  34. package/dist/client/app/util/state.js +12 -44
  35. package/dist/node/collect/index.d.ts +2 -2
  36. package/dist/node/collect/index.js +3 -0
  37. package/dist/node/collect/run.d.ts +2 -0
  38. package/dist/{client/server/index.js → node/collect/run.js} +1 -1
  39. package/dist/node/collect/worker.d.ts +3 -3
  40. package/dist/node/collect/worker.js +4 -1
  41. package/dist/node/config.d.ts +3 -3
  42. package/dist/node/context.d.ts +2 -2
  43. package/dist/node/plugin.d.ts +3 -3
  44. package/dist/node/stories.d.ts +4 -4
  45. package/dist/node/tree.d.ts +3 -22
  46. package/dist/style.css +80 -4
  47. package/package.json +4 -2
  48. package/src/client/app/App.vue +2 -2
  49. package/src/client/app/components/base/BaseSplitPane.vue +6 -6
  50. package/src/client/app/components/panel/ControlsComponentPropItem.vue +13 -6
  51. package/src/client/app/components/panel/ControlsComponentProps.vue +2 -1
  52. package/src/client/app/components/panel/StatePresets.vue +2 -1
  53. package/src/client/app/components/panel/StoryControls.vue +1 -1
  54. package/src/client/app/components/panel/StorySourceCode.vue +2 -2
  55. package/src/client/app/components/story/StoryVariantGridItem.vue +1 -1
  56. package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +1 -1
  57. package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -2
  58. package/src/client/app/components/story/StoryVariantSingleView.vue +1 -1
  59. package/src/client/app/components/toolbar/StoryVariantNewTab.vue +1 -1
  60. package/src/client/app/components/tree/StoryGroup.vue +1 -1
  61. package/src/client/app/index.ts +0 -2
  62. package/src/client/app/sandbox.ts +4 -5
  63. package/src/client/app/style/main.pcss +3 -3
  64. package/src/client/app/style/sandbox.css +1 -1
  65. package/src/client/app/types.ts +6 -57
  66. package/src/client/app/util/mapping.ts +47 -34
  67. package/src/client/app/{components/sandbox/lib.ts → util/sandbox.ts} +2 -2
  68. package/src/client/app/util/state.ts +15 -44
  69. package/src/node/collect/index.ts +5 -2
  70. package/src/node/collect/run.ts +13 -0
  71. package/src/node/collect/worker.ts +8 -6
  72. package/src/node/config.ts +3 -3
  73. package/src/node/context.ts +2 -2
  74. package/src/node/plugin.ts +2 -2
  75. package/src/node/server.ts +2 -2
  76. package/src/node/stories.ts +4 -4
  77. package/src/node/tree.ts +7 -31
  78. package/tailwind.config.cjs +1 -1
  79. package/vite.config.ts +12 -7
  80. package/dist/bundled/SandboxVue3.js +0 -706
  81. package/dist/bundled/global-components.js +0 -213
  82. package/dist/client/app/codegen/const.d.ts +0 -1
  83. package/dist/client/app/codegen/const.js +0 -3
  84. package/dist/client/app/codegen/serialize-js.d.ts +0 -1
  85. package/dist/client/app/codegen/serialize-js.js +0 -113
  86. package/dist/client/app/codegen/util.d.ts +0 -10
  87. package/dist/client/app/codegen/util.js +0 -70
  88. package/dist/client/app/codegen/vue3.d.ts +0 -4
  89. package/dist/client/app/codegen/vue3.js +0 -357
  90. package/dist/client/app/components/exposed/Story.vue +0 -106
  91. package/dist/client/app/components/exposed/Variant.vue +0 -78
  92. package/dist/client/app/components/sandbox/RouterLinkStub.d.ts +0 -21
  93. package/dist/client/app/components/sandbox/RouterLinkStub.js +0 -43
  94. package/dist/client/app/components/sandbox/SandboxVue3.vue +0 -185
  95. package/dist/client/app/global-components.d.ts +0 -2
  96. package/dist/client/app/global-components.js +0 -10
  97. package/dist/client/server/index.d.ts +0 -7
  98. package/dist/client/server/vue3/Story.vue +0 -120
  99. package/dist/client/server/vue3/Variant.vue +0 -52
  100. package/dist/client/server/vue3/run.d.ts +0 -2
  101. package/dist/client/server/vue3/run.js +0 -45
  102. package/dist/node/types.d.ts +0 -50
  103. package/dist/node/types.js +0 -1
  104. package/src/client/app/codegen/const.ts +0 -3
  105. package/src/client/app/codegen/serialize-js.ts +0 -119
  106. package/src/client/app/codegen/util.ts +0 -79
  107. package/src/client/app/codegen/vue3.ts +0 -361
  108. package/src/client/app/components/exposed/Story.vue +0 -106
  109. package/src/client/app/components/exposed/Variant.vue +0 -78
  110. package/src/client/app/components/sandbox/RouterLinkStub.ts +0 -49
  111. package/src/client/app/components/sandbox/SandboxVue3.vue +0 -185
  112. package/src/client/app/global-components.ts +0 -13
  113. package/src/client/server/index.ts +0 -19
  114. package/src/client/server/vue3/Story.vue +0 -120
  115. package/src/client/server/vue3/Variant.vue +0 -52
  116. package/src/client/server/vue3/run.ts +0 -55
  117. package/src/components.d.ts +0 -143
  118. package/src/node/types.ts +0 -53
package/dist/style.css CHANGED
@@ -205,6 +205,58 @@
205
205
  border-color:#000c
206
206
  }
207
207
 
208
+ .htw-range-input::-webkit-slider-thumb{
209
+ height:.75rem;
210
+ width:.75rem;
211
+ -webkit-appearance:none;
212
+ appearance:none;
213
+ border-radius:9999px;
214
+ border-width:1px;
215
+ border-style:solid;
216
+ border-color:#00000040;
217
+ --tw-bg-opacity: 1;
218
+ background-color:rgb(255 255 255 / var(--tw-bg-opacity))
219
+ }
220
+
221
+ .htw-dark .htw-range-input::-webkit-slider-thumb{
222
+ border-color:#ffffff40;
223
+ --tw-bg-opacity: 1;
224
+ background-color:rgb(63 63 70 / var(--tw-bg-opacity))
225
+ }
226
+
227
+ .htw-range-input:hover::-webkit-slider-thumb{
228
+ --tw-border-opacity: 1 !important;
229
+ border-color:rgb(16 185 129 / var(--tw-border-opacity))!important;
230
+ --tw-bg-opacity: 1 !important;
231
+ background-color:rgb(16 185 129 / var(--tw-bg-opacity))!important
232
+ }
233
+
234
+ .htw-range-input::-moz-range-thumb{
235
+ height:.75rem;
236
+ width:.75rem;
237
+ -moz-appearance:none;
238
+ appearance:none;
239
+ border-radius:9999px;
240
+ border-width:1px;
241
+ border-style:solid;
242
+ border-color:#00000040;
243
+ --tw-bg-opacity: 1;
244
+ background-color:rgb(255 255 255 / var(--tw-bg-opacity))
245
+ }
246
+
247
+ .htw-dark .htw-range-input::-moz-range-thumb{
248
+ border-color:#ffffff40;
249
+ --tw-bg-opacity: 1;
250
+ background-color:rgb(63 63 70 / var(--tw-bg-opacity))
251
+ }
252
+
253
+ .htw-range-input:hover::-moz-range-thumb{
254
+ --tw-border-opacity: 1 !important;
255
+ border-color:rgb(16 185 129 / var(--tw-border-opacity))!important;
256
+ --tw-bg-opacity: 1 !important;
257
+ background-color:rgb(16 185 129 / var(--tw-bg-opacity))!important
258
+ }
259
+
208
260
  .v-popper{
209
261
  line-height:0
210
262
  }
@@ -506,7 +558,7 @@ button {
506
558
  margin-left:0;
507
559
  margin-right:0;
508
560
  background-color:rgb(var(--_histoire-color-gray-100));
509
- padding:4px 6px;
561
+ padding:.25rem .375rem;
510
562
  }
511
563
 
512
564
  .htw-prose :where(blockquote):not(:where([class~="htw-not-prose"] *)) p:first-child{
@@ -1123,6 +1175,10 @@ button {
1123
1175
  height:5rem
1124
1176
  }
1125
1177
 
1178
+ .htw-h-1{
1179
+ height:0.25rem
1180
+ }
1181
+
1126
1182
  .htw-max-h-full{
1127
1183
  max-height:100%
1128
1184
  }
@@ -1313,6 +1369,12 @@ button {
1313
1369
  resize:vertical
1314
1370
  }
1315
1371
 
1372
+ .htw-appearance-none{
1373
+ -webkit-appearance:none;
1374
+ -moz-appearance:none;
1375
+ appearance:none
1376
+ }
1377
+
1316
1378
  .htw-grid-cols-\[repeat\(auto-fill\,minmax\(200px\,1fr\)\)\]{
1317
1379
  grid-template-columns:repeat(auto-fill,minmax(200px,1fr))
1318
1380
  }
@@ -1467,6 +1529,10 @@ button {
1467
1529
  border-width:2px
1468
1530
  }
1469
1531
 
1532
+ .htw-border-0{
1533
+ border-width:0px
1534
+ }
1535
+
1470
1536
  .htw-border-b-2{
1471
1537
  border-bottom-width:2px
1472
1538
  }
@@ -1610,6 +1676,11 @@ button {
1610
1676
  background-color:rgb(var(--_histoire-color-gray-700) / var(--tw-bg-opacity))
1611
1677
  }
1612
1678
 
1679
+ .\!htw-bg-primary-500{
1680
+ --tw-bg-opacity:1 !important;
1681
+ background-color:rgb(var(--_histoire-color-primary-500) / var(--tw-bg-opacity)) !important
1682
+ }
1683
+
1613
1684
  .htw-stroke-white{
1614
1685
  stroke:#fff
1615
1686
  }
@@ -1815,6 +1886,11 @@ button {
1815
1886
  color:rgb(var(--_histoire-color-primary-800) / var(--tw-text-opacity))
1816
1887
  }
1817
1888
 
1889
+ .htw-text-gray-700{
1890
+ --tw-text-opacity:1;
1891
+ color:rgb(var(--_histoire-color-gray-700) / var(--tw-text-opacity))
1892
+ }
1893
+
1818
1894
  .htw-opacity-25{
1819
1895
  opacity:0.25
1820
1896
  }
@@ -1917,16 +1993,16 @@ body,
1917
1993
 
1918
1994
  html {
1919
1995
  font-family: 'Lato', sans-serif;
1920
- font-size: 16px;
1996
+ font-size: 1rem;
1921
1997
  }
1922
1998
 
1923
1999
  body {
1924
- font-size: 18px;
2000
+ font-size: 1.125rem;
1925
2001
  }
1926
2002
 
1927
2003
  @media (min-width: 640px) {
1928
2004
  body {
1929
- font-size: 14px;
2005
+ font-size: .875rem;
1930
2006
  }
1931
2007
  }
1932
2008
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "histoire",
3
- "version": "0.7.1",
3
+ "version": "0.7.4",
4
4
  "description": "A fast story book powered by Vite",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -33,7 +33,9 @@
33
33
  "histoire": "./bin.mjs"
34
34
  },
35
35
  "dependencies": {
36
- "@histoire/controls": "^0.7.1",
36
+ "@histoire/controls": "^0.7.4",
37
+ "@histoire/plugin-vue": "^0.7.4",
38
+ "@histoire/shared": "^0.7.4",
37
39
  "@iconify/vue": "^3.2.1",
38
40
  "@types/markdown-it": "^12.2.3",
39
41
  "@vueuse/core": "^8.2.5",
@@ -21,6 +21,7 @@ import { isMobile } from './util/responsive'
21
21
  import Breadcrumb from './components/app/Breadcrumb.vue'
22
22
  import SearchModal from './components/search/SearchModal.vue'
23
23
  import InitialLoading from './components/app/InitialLoading.vue'
24
+ import { MountStoryVue3 } from '@histoire/plugin-vue/client'
24
25
 
25
26
  const files = ref<StoryFile[]>(rawFiles.map(file => mapFile(file)))
26
27
  const tree = ref<Tree>(rawTree)
@@ -96,8 +97,7 @@ onMounted(() => {
96
97
  v-if="storyStore.currentStory"
97
98
  class="htw-hidden"
98
99
  >
99
- <component
100
- :is="storyStore.currentStory.file.component"
100
+ <MountStoryVue3
101
101
  :story="storyStore.currentStory"
102
102
  />
103
103
  </div>
@@ -206,11 +206,11 @@ onUnmounted(() => {
206
206
 
207
207
  <style lang="postcss" scoped>
208
208
  .landscape > div > .dragger {
209
- width: 10px;
209
+ width: .625rem;
210
210
  }
211
211
 
212
212
  .portrait > div > .dragger {
213
- height: 10px;
213
+ height: .625rem;
214
214
  }
215
215
 
216
216
  .landscape > div > .dragger.dragger-offset-before {
@@ -222,18 +222,18 @@ onUnmounted(() => {
222
222
  }
223
223
 
224
224
  .landscape > div > .dragger.dragger-offset-center {
225
- right: -5px;
225
+ right: -.3125rem;
226
226
  }
227
227
 
228
228
  .portrait > div > .dragger.dragger-offset-center {
229
- bottom: -5px;
229
+ bottom: -.3125rem;
230
230
  }
231
231
 
232
232
  .landscape > div > .dragger.dragger-offset-after {
233
- right: -10px;
233
+ right: -.625rem;
234
234
  }
235
235
 
236
236
  .portrait > div > .dragger.dragger-offset-after {
237
- bottom: -10px;
237
+ bottom: -.625rem;
238
238
  }
239
239
  </style>
@@ -1,7 +1,14 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed, ref } from 'vue'
3
3
  import { Icon } from '@iconify/vue'
4
- import type { Variant, PropDefinition, AutoPropComponentDefinition } from '../../types'
4
+ import type { PropDefinition, AutoPropComponentDefinition } from '@histoire/shared'
5
+ import {
6
+ HstText,
7
+ HstNumber,
8
+ HstCheckbox,
9
+ HstTextarea,
10
+ } from '@histoire/controls'
11
+ import type { Variant } from '../../types'
5
12
 
6
13
  const props = defineProps<{
7
14
  variant: Variant
@@ -12,18 +19,18 @@ const props = defineProps<{
12
19
  const comp = computed(() => {
13
20
  switch (props.definition.types?.[0]) {
14
21
  case 'string':
15
- return 'HstText'
22
+ return HstText
16
23
  case 'number':
17
- return 'HstNumber'
24
+ return HstNumber
18
25
  case 'boolean':
19
- return 'HstCheckbox'
26
+ return HstCheckbox
20
27
  case 'object':
21
28
  default:
22
- return 'HstTextarea'
29
+ return HstTextarea
23
30
  }
24
31
  })
25
32
 
26
- const isJSON = computed(() => comp.value === 'HstTextarea')
33
+ const isJSON = computed(() => comp.value === HstTextarea)
27
34
 
28
35
  const invalidValue = ref('')
29
36
 
@@ -1,5 +1,6 @@
1
1
  <script lang="ts" setup>
2
- import type { AutoPropComponentDefinition, Variant } from '../../types'
2
+ import type { AutoPropComponentDefinition } from '@histoire/shared'
3
+ import type { Variant } from '../../types'
3
4
  import { Icon } from '@iconify/vue'
4
5
  import ControlsComponentPropItem from './ControlsComponentPropItem.vue'
5
6
 
@@ -2,8 +2,9 @@
2
2
  import { ref, computed, nextTick, onMounted } from 'vue'
3
3
  import { Icon } from '@iconify/vue'
4
4
  import { useStorage, onClickOutside, useTimeoutFn } from '@vueuse/core'
5
+ import { applyStateToVariant, clone, omit } from '@histoire/shared'
5
6
  import BaseSelect from '../base/BaseSelect.vue'
6
- import { applyStateToVariant, clone, omit, toRawDeep } from '../../util/state'
7
+ import { toRawDeep } from '../../util/state'
7
8
  import type { Story, Variant } from '../../types'
8
9
 
9
10
  const DEFAULT_ID = 'default'
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" setup>
2
2
  import { PropType } from 'vue'
3
3
  import { Icon } from '@iconify/vue'
4
+ import { SandboxVue3 } from '@histoire/plugin-vue/client'
4
5
  import type { Story, Variant } from '../../types'
5
- import SandboxVue3 from '../sandbox/SandboxVue3.vue'
6
6
  import BaseEmpty from '../base/BaseEmpty.vue'
7
7
  import StatePresets from './StatePresets.vue'
8
8
  import ControlsComponentProps from './ControlsComponentProps.vue'
@@ -2,10 +2,10 @@
2
2
  import { computed, onMounted, PropType, ref, shallowRef, watch } from 'vue'
3
3
  import { getHighlighter, Highlighter, setCDN } from 'shiki'
4
4
  import { HstCopyIcon } from '@histoire/controls'
5
- import { generateSourceCode } from '../../codegen/vue3'
5
+ import { unindent } from '@histoire/shared'
6
+ import { generateSourceCode } from '@histoire/plugin-vue/client'
6
7
  import type { Variant } from '../../types'
7
8
  import { isDark } from '../../util/dark'
8
- import { unindent } from '../../codegen/util'
9
9
 
10
10
  const props = defineProps({
11
11
  variant: {
@@ -3,9 +3,9 @@ import { PropType, ref, toRefs } from 'vue'
3
3
  import { Icon } from '@iconify/vue'
4
4
  import { useRouter } from 'vue-router'
5
5
  import { useResizeObserver } from '@vueuse/core'
6
+ import { SandboxVue3 } from '@histoire/plugin-vue/client'
6
7
  import { useCurrentVariantRoute } from '../../util/variant'
7
8
  import type { Story, Variant } from '../../types'
8
- import SandboxVue3 from '../sandbox/SandboxVue3.vue'
9
9
  import { useScrollOnActive } from '../../util/scroll'
10
10
 
11
11
  const props = defineProps({
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
+ import { SandboxVue3 } from '@histoire/plugin-vue/client'
2
3
  import type { Story, Variant } from '../../types'
3
- import SandboxVue3 from '../sandbox/SandboxVue3.vue'
4
4
  import StoryResponsivePreview from './StoryResponsivePreview.vue'
5
5
 
6
6
  const props = defineProps<{
@@ -2,15 +2,16 @@
2
2
  import { computed, onUnmounted, Ref, ref, toRaw, watch } from 'vue'
3
3
  import { useEventListener } from '@vueuse/core'
4
4
  import { Icon } from '@iconify/vue'
5
+ import { applyStateToVariant } from '@histoire/shared'
5
6
  import { STATE_SYNC, PREVIEW_SETTINGS_SYNC, SANDBOX_READY, EVENT_SEND } from '../../util/const'
6
7
  import type { Story, Variant } from '../../types'
7
8
  import HatchedPattern from '../misc/HatchedPattern.vue'
8
9
  import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
9
- import { getSandboxUrl } from '../sandbox/lib'
10
+ import { getSandboxUrl } from '../../util/sandbox'
10
11
  import { usePreviewSettingsStore } from '../../stores/preview-settings'
11
12
  import { HstEvent, useEventsStore } from '../../stores/events'
12
13
  import StoryResponsivePreview from './StoryResponsivePreview.vue'
13
- import { applyStateToVariant, toRawDeep } from '../../util/state'
14
+ import { toRawDeep } from '../../util/state'
14
15
 
15
16
  const props = defineProps<{
16
17
  story: Story
@@ -39,7 +39,7 @@ defineProps<{
39
39
 
40
40
  <!-- Preview -->
41
41
  <StoryVariantSinglePreviewNative
42
- v-if="story.layout.iframe === false"
42
+ v-if="story.layout?.iframe === false"
43
43
  :story="story"
44
44
  :variant="variant"
45
45
  />
@@ -2,7 +2,7 @@
2
2
  import { Icon } from '@iconify/vue'
3
3
  import type { Story, Variant } from '../../types'
4
4
  import { computed } from 'vue'
5
- import { getSandboxUrl } from '../sandbox/lib'
5
+ import { getSandboxUrl } from '../../util/sandbox'
6
6
 
7
7
  const props = defineProps<{
8
8
  variant: Variant
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import type { Story, TreeGroup, TreeFolder, TreeLeaf } from '../../types'
2
+ import type { Story, TreeGroup } from '../../types'
3
3
  import StoryListItem from './StoryListItem.vue'
4
4
  import StoryListFolder from './StoryListFolder.vue'
5
5
  import { Icon } from '@iconify/vue'
@@ -7,7 +7,6 @@ import { createApp } from 'vue'
7
7
  import { createPinia } from 'pinia'
8
8
  import FloatingVue from 'floating-vue'
9
9
  import App from './App.vue'
10
- import { registerGlobalComponents } from './global-components.js'
11
10
  import { router } from './router'
12
11
 
13
12
  export function mountMainApp () {
@@ -27,7 +26,6 @@ export function mountMainApp () {
27
26
  },
28
27
  })
29
28
  app.use(router)
30
- registerGlobalComponents(app)
31
29
  app.mount('#app')
32
30
 
33
31
  if (import.meta.hot) {
@@ -1,8 +1,8 @@
1
1
  import { parseQuery } from 'vue-router'
2
2
  import { computed, createApp, h, onMounted, ref, watch } from 'vue'
3
3
  import { createPinia } from 'pinia'
4
- import { registerGlobalComponents } from './global-components'
5
- import SandboxVue3 from './components/sandbox/SandboxVue3.vue'
4
+ import { applyStateToVariant } from '@histoire/shared'
5
+ import { SandboxVue3, MountStoryVue3 } from '@histoire/plugin-vue/client'
6
6
  import type { StoryFile } from './types'
7
7
  import { mapFile } from './util/mapping'
8
8
  // @ts-expect-error virtual module
@@ -11,7 +11,7 @@ import { PREVIEW_SETTINGS_SYNC, STATE_SYNC, SANDBOX_READY } from './util/const.j
11
11
  import { applyPreviewSettings } from './util/preview-settings.js'
12
12
  import { isDark } from './util/dark.js'
13
13
  import { histoireConfig } from './util/config.js'
14
- import { applyStateToVariant, toRawDeep } from './util/state'
14
+ import { toRawDeep } from './util/state.js'
15
15
 
16
16
  const query = parseQuery(window.location.search)
17
17
  const file = ref<StoryFile>(mapFile(files.find(f => f.id === query.storyId)))
@@ -62,7 +62,7 @@ const app = createApp({
62
62
  render () {
63
63
  return [
64
64
  h('div', { class: 'htw-sandbox-hidden' }, [
65
- h(file.value.component, {
65
+ h(MountStoryVue3, {
66
66
  story: file.value.story,
67
67
  }),
68
68
  ]),
@@ -81,7 +81,6 @@ const app = createApp({
81
81
  },
82
82
  })
83
83
  app.use(createPinia())
84
- registerGlobalComponents(app)
85
84
  app.mount('#app')
86
85
 
87
86
  watch(isDark, value => {
@@ -50,16 +50,16 @@ body,
50
50
 
51
51
  html {
52
52
  font-family: 'Lato', sans-serif;
53
- font-size: 16px;
53
+ font-size: 1rem;
54
54
  }
55
55
 
56
56
  body {
57
- font-size: 18px;
57
+ font-size: 1.125rem;
58
58
  }
59
59
 
60
60
  @media (min-width: 640px) {
61
61
  body {
62
- font-size: 14px;
62
+ font-size: .875rem;
63
63
  }
64
64
  }
65
65
 
@@ -10,7 +10,7 @@ body {
10
10
  }
11
11
 
12
12
  html {
13
- font-size: 14px;
13
+ font-size: .875rem;
14
14
  font-family: 'Lato', sans-serif;
15
15
  }
16
16
 
@@ -1,49 +1,11 @@
1
1
  import type { RouteLocationRaw } from 'vue-router'
2
2
 
3
- export interface StoryFile {
4
- id: string
5
- framework: string
6
- component: any
7
- story: Story
8
- path: string[]
9
- }
10
-
11
- export type StoryLayout = {
12
- type: 'single'
13
- iframe?: boolean
14
- } | {
15
- type: 'grid'
16
- width?: number | string
17
- }
18
-
19
- export interface Story {
20
- id: string
21
- title: string
22
- group?: string
23
- variants: Variant[]
24
- layout?: StoryLayout
25
- icon?: string
26
- iconColor?: string
27
- docsOnly?: boolean
28
- file?: StoryFile
29
- lastSelectedVariant?: Variant
30
- slots?: () => Readonly<any>
31
- }
32
-
33
- export interface Variant {
34
- id: string
35
- title: string
36
- icon?: string
37
- iconColor?: string
38
- initState?: () => any
39
- setupApp?: (payload: any) => unknown
40
- slots?: () => Readonly<any>
41
- state?: any
42
- source?: string
43
- responsiveDisabled?: boolean
44
- configReady?: boolean
45
- previewReady?: boolean
46
- }
3
+ export type {
4
+ StoryFile,
5
+ StoryLayout,
6
+ Story,
7
+ Variant,
8
+ } from '@histoire/shared'
47
9
 
48
10
  export type TreeLeaf = {
49
11
  title: string
@@ -82,16 +44,3 @@ export interface PreviewSettings {
82
44
  backgroundColor: string
83
45
  checkerboard: boolean
84
46
  }
85
-
86
- export interface PropDefinition {
87
- name: string
88
- types?: string[]
89
- required?: boolean
90
- default?: any
91
- }
92
-
93
- export interface AutoPropComponentDefinition {
94
- name: string
95
- index: number
96
- props: PropDefinition[]
97
- }
@@ -13,49 +13,62 @@ const copiedFromExistingVariant = [
13
13
  ]
14
14
 
15
15
  export function mapFile (file: StoryFile, existingFile?: StoryFile): StoryFile {
16
- const result: StoryFile = {
17
- ...file,
18
- component: markRaw(file.component),
19
- story: {
20
- ...file.story,
21
- title: file.story.title,
22
- file: markRaw(file),
23
- variants: file.story.variants.map(v => mapVariant(v)),
24
- slots: () => ({}),
25
- },
26
- }
16
+ let result: StoryFile
27
17
 
28
18
  if (existingFile) {
29
- for (const index in result.story.variants) {
30
- const variant = result.story.variants[index]
31
- const existingVariant = existingFile.story.variants[index]
32
- if (existingVariant) {
33
- for (const key of copiedFromExistingVariant) {
34
- if (typeof existingVariant[key] !== 'undefined') {
35
- if (key === 'state') {
36
- variant.state = existingVariant.state
37
- continue
38
- }
39
- variant[key] = existingVariant[key]
40
- }
41
- }
19
+ // Update
20
+ result = existingFile
21
+ for (const key in file) {
22
+ if (key === 'story') {
23
+ Object.assign(result.story, {
24
+ ...file.story,
25
+ file: markRaw(result),
26
+ variants: file.story.variants.map(v => mapVariant(v, existingFile.story.variants.find(item => item.id === v.id))),
27
+ })
28
+ } else if (key !== 'component') {
29
+ result[key] = file[key]
42
30
  }
43
31
  }
44
- if (existingFile.story.lastSelectedVariant) {
45
- result.story.lastSelectedVariant = result.story.variants.find(v => v.id === existingFile.story.lastSelectedVariant.id)
32
+ } else {
33
+ // Create
34
+ result = {
35
+ ...file,
36
+ component: markRaw(file.component),
37
+ story: {
38
+ ...file.story,
39
+ title: file.story.title,
40
+ file: markRaw(file),
41
+ variants: file.story.variants.map(v => mapVariant(v)),
42
+ slots: () => ({}),
43
+ },
46
44
  }
47
45
  }
48
46
 
49
47
  return result
50
48
  }
51
49
 
52
- export function mapVariant (variant: Variant): Variant {
53
- return {
54
- ...variant,
55
- state: null,
56
- initState: null,
57
- setupApp: null,
58
- slots: () => ({}),
59
- previewReady: false,
50
+ export function mapVariant (variant: Variant, existingVariant?: Variant): Variant {
51
+ let result: Variant
52
+
53
+ if (existingVariant) {
54
+ // Update
55
+ result = existingVariant
56
+ for (const key in variant) {
57
+ if (!copiedFromExistingVariant.includes(key)) {
58
+ result[key] = variant[key]
59
+ }
60
+ }
61
+ } else {
62
+ // Create
63
+ result = {
64
+ ...variant,
65
+ state: null,
66
+ initState: null,
67
+ setupApp: null,
68
+ slots: () => ({}),
69
+ previewReady: false,
70
+ }
60
71
  }
72
+
73
+ return result
61
74
  }
@@ -1,6 +1,6 @@
1
1
 
2
- import { base } from '../../router'
3
- import { Story, Variant } from '../../types'
2
+ import { base } from '../router'
3
+ import { Story, Variant } from '../types'
4
4
 
5
5
  export function getSandboxUrl (story: Story, variant: Variant) {
6
6
  const url = new URLSearchParams()