histoire 0.3.1 → 0.3.2

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 (96) hide show
  1. package/dist/client/app/codegen/vue3.js +1 -0
  2. package/dist/client/app/codegen/vue3.js.map +1 -0
  3. package/dist/client/app/components/base/BaseOverflowMenu.vue +118 -0
  4. package/dist/client/app/components/base/BaseOverflowTab.vue +46 -0
  5. package/dist/client/app/components/exposed/Story.vue +12 -1
  6. package/dist/client/app/components/exposed/Variant.vue +6 -0
  7. package/dist/client/app/components/panel/PaneTabs.vue +64 -0
  8. package/dist/client/app/components/{story → panel}/StoryControls.vue +1 -1
  9. package/dist/client/app/components/{story → panel}/StoryDocs.vue +0 -0
  10. package/dist/client/app/components/{story → panel}/StoryEvent.vue +0 -0
  11. package/dist/client/app/components/{story → panel}/StoryEvents.vue +0 -0
  12. package/dist/client/app/components/{story → panel}/StorySidePanel.vue +3 -31
  13. package/dist/client/app/components/{story → panel}/StorySourceCode.vue +0 -0
  14. package/dist/client/app/components/sandbox/SandboxVue3.vue +10 -0
  15. package/dist/client/app/components/search/search-data.js +1 -0
  16. package/dist/client/app/components/search/search-data.js.map +1 -0
  17. package/dist/client/app/components/story/StoryResponsivePreview.vue +9 -131
  18. package/dist/client/app/components/story/StoryVariantSingle.vue +109 -0
  19. package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +39 -0
  20. package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
  21. package/dist/client/app/components/story/StoryVariantSingleView.vue +13 -6
  22. package/dist/client/app/components/story/StoryView.vue +2 -2
  23. package/dist/client/app/components/story/StoryViewer.vue +2 -92
  24. package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantBackground.vue +3 -3
  25. package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantNewTab.vue +2 -2
  26. package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantResponsiveSize.vue +3 -3
  27. package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantTitle.vue +1 -1
  28. package/dist/client/app/global-components.js +1 -0
  29. package/dist/client/app/global-components.js.map +1 -0
  30. package/dist/client/app/index.js +1 -0
  31. package/dist/client/app/index.js.map +1 -0
  32. package/dist/client/app/sandbox.js +1 -0
  33. package/dist/client/app/sandbox.js.map +1 -0
  34. package/dist/client/app/stores/events.d.ts +1 -1
  35. package/dist/client/app/stores/events.js +1 -0
  36. package/dist/client/app/stores/events.js.map +1 -0
  37. package/dist/client/app/stores/folder.js +1 -0
  38. package/dist/client/app/stores/folder.js.map +1 -0
  39. package/dist/client/app/stores/story.d.ts +27 -0
  40. package/dist/client/app/stores/story.js +1 -0
  41. package/dist/client/app/stores/story.js.map +1 -0
  42. package/dist/client/app/style/transitions.pcss +13 -0
  43. package/dist/client/app/types.d.ts +3 -0
  44. package/dist/client/app/types.js +1 -0
  45. package/dist/client/app/types.js.map +1 -0
  46. package/dist/client/app/util/events.js +1 -0
  47. package/dist/client/app/util/events.js.map +1 -0
  48. package/dist/client/app/util/keyboard.js +1 -0
  49. package/dist/client/app/util/keyboard.js.map +1 -0
  50. package/dist/client/app/util/mapping.js +3 -0
  51. package/dist/client/app/util/mapping.js.map +1 -0
  52. package/dist/client/app/util/preview-settings.js +1 -0
  53. package/dist/client/app/util/preview-settings.js.map +1 -0
  54. package/dist/client/app/util/reactivity.js +1 -0
  55. package/dist/client/app/util/reactivity.js.map +1 -0
  56. package/dist/client/app/util/scroll.js +1 -0
  57. package/dist/client/app/util/scroll.js.map +1 -0
  58. package/dist/client/app/util/variant.js +1 -0
  59. package/dist/client/app/util/variant.js.map +1 -0
  60. package/dist/client/index.js +1 -0
  61. package/dist/client/index.js.map +1 -0
  62. package/dist/client/server/vue3/Story.vue +1 -1
  63. package/dist/client/server/vue3/run.js +1 -0
  64. package/dist/client/server/vue3/run.js.map +1 -0
  65. package/dist/controls.js +1 -0
  66. package/dist/controls.js.map +1 -0
  67. package/dist/style.css +93 -69
  68. package/package.json +2 -2
  69. package/src/client/app/components/base/BaseOverflowMenu.vue +118 -0
  70. package/src/client/app/components/base/BaseOverflowTab.vue +46 -0
  71. package/src/client/app/components/exposed/Story.vue +12 -1
  72. package/src/client/app/components/exposed/Variant.vue +6 -0
  73. package/src/client/app/components/panel/PaneTabs.vue +64 -0
  74. package/src/client/app/components/{story → panel}/StoryControls.vue +1 -1
  75. package/src/client/app/components/{story → panel}/StoryDocs.vue +0 -0
  76. package/src/client/app/components/{story → panel}/StoryEvent.vue +0 -0
  77. package/src/client/app/components/{story → panel}/StoryEvents.vue +0 -0
  78. package/src/client/app/components/{story → panel}/StorySidePanel.vue +3 -31
  79. package/src/client/app/components/{story → panel}/StorySourceCode.vue +0 -0
  80. package/src/client/app/components/sandbox/SandboxVue3.vue +10 -0
  81. package/src/client/app/components/story/StoryResponsivePreview.vue +9 -131
  82. package/src/client/app/components/story/StoryVariantSingle.vue +109 -0
  83. package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +39 -0
  84. package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
  85. package/src/client/app/components/story/StoryVariantSingleView.vue +13 -6
  86. package/src/client/app/components/story/StoryView.vue +2 -2
  87. package/src/client/app/components/story/StoryViewer.vue +2 -92
  88. package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantBackground.vue +3 -3
  89. package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantNewTab.vue +2 -2
  90. package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantResponsiveSize.vue +3 -3
  91. package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantTitle.vue +1 -1
  92. package/src/client/app/sandbox.ts +1 -1
  93. package/src/client/app/style/transitions.pcss +13 -0
  94. package/src/client/app/types.ts +4 -0
  95. package/src/client/app/util/mapping.ts +2 -0
  96. package/src/client/server/vue3/Story.vue +1 -1
@@ -1,26 +1,17 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed, ref, watch } from 'vue'
3
3
  import { useStoryStore } from '../../stores/story'
4
- import { Icon } from '@iconify/vue'
5
- import { isMobile } from '../../util/responsive'
6
- import BaseSplitPane from '../base/BaseSplitPane.vue'
7
4
  import StoryVariantListItem from './StoryVariantListItem.vue'
8
- import StoryVariantSingleView from './StoryVariantSingleView.vue'
9
5
  import MobileOverlay from '../app/MobileOverlay.vue'
10
6
  import StoryVariantGrid from './StoryVariantGrid.vue'
7
+ import StoryVariantSingle from './StoryVariantSingle.vue'
11
8
 
12
9
  const storyStore = useStoryStore()
13
10
 
14
- const hasSingleVariant = computed(() => (storyStore.currentStory?.variants.length === 1))
15
-
16
11
  const variant = computed(() => storyStore.currentVariant)
17
12
 
18
13
  const isMenuOpened = ref(false)
19
14
 
20
- function openMenu () {
21
- isMenuOpened.value = true
22
- }
23
-
24
15
  function closeMenu () {
25
16
  isMenuOpened.value = false
26
17
  }
@@ -36,88 +27,7 @@ watch(variant, () => {
36
27
  <StoryVariantGrid
37
28
  v-if="storyStore.currentStory.layout.type === 'grid'"
38
29
  />
39
-
40
- <template v-else-if="storyStore.currentStory.layout.type === 'single'">
41
- <div
42
- v-if="hasSingleVariant && storyStore.currentVariant"
43
- class="htw-p-2 htw-h-full"
44
- >
45
- <StoryVariantSingleView
46
- v-if="storyStore.currentVariant.configReady"
47
- :variant="storyStore.currentVariant"
48
- :story="storyStore.currentStory"
49
- />
50
- </div>
51
- <template v-else>
52
- <div
53
- v-if="isMobile"
54
- class="htw-divide-y htw-divide-gray-100 dark:htw-divide-gray-800 htw-h-full htw-flex htw-flex-col"
55
- >
56
- <a
57
- class="htw-px-6 htw-h-12 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer htw-flex htw-gap-2 htw-flex-wrap htw-w-full htw-items-center"
58
- @click="openMenu"
59
- >
60
- <template v-if="variant">
61
- <Icon
62
- :icon="variant.icon ?? 'carbon:cube'"
63
- class="base-list-item-link-icon htw-w-5 htw-h-5 htw-flex-none"
64
- :class="{
65
- 'htw-text-gray-500': !variant.iconColor,
66
- 'bind-icon-color': variant.iconColor,
67
- }"
68
- />
69
- {{ variant.title }}
70
- </template>
71
- <template v-else>
72
- Select a variant...
73
- </template>
74
-
75
- <Icon
76
- icon="carbon:chevron-sort"
77
- class="htw-w-5 htw-h-5 htw-shrink-0 htw-ml-auto"
78
- />
79
- </a>
80
- <div
81
- v-if="storyStore.currentVariant"
82
- class="htw-p-2 htw-h-full"
83
- >
84
- <StoryVariantSingleView
85
- v-if="storyStore.currentVariant.configReady"
86
- :variant="storyStore.currentVariant"
87
- :story="storyStore.currentStory"
88
- />
89
- </div>
90
- </div>
91
- <BaseSplitPane
92
- v-else
93
- save-id="story-single-main-split"
94
- :min="5"
95
- :max="40"
96
- :default-split="17"
97
- >
98
- <template #first>
99
- <div class="htw-h-full htw-overflow-y-auto">
100
- <StoryVariantListItem
101
- v-for="(variant, index) of storyStore.currentStory.variants"
102
- :key="index"
103
- :variant="variant"
104
- />
105
- </div>
106
- </template>
107
- <template #last>
108
- <div
109
- v-if="storyStore.currentVariant"
110
- class="htw-p-2 htw-h-full"
111
- >
112
- <StoryVariantSingleView
113
- :variant="storyStore.currentVariant"
114
- :story="storyStore.currentStory"
115
- />
116
- </div>
117
- </template>
118
- </BaseSplitPane>
119
- </template>
120
- </template>
30
+ <StoryVariantSingle v-else-if="storyStore.currentStory.layout.type === 'single'" />
121
31
  </div>
122
32
 
123
33
  <MobileOverlay
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" setup>
2
2
  import { Icon } from '@iconify/vue'
3
- import { usePreviewSettingsStore } from '../../../stores/preview-settings'
4
- import { histoireConfig } from '../../../util/config'
5
- import BaseCheckbox from '../../base/BaseCheckbox.vue'
3
+ import { usePreviewSettingsStore } from '../../stores/preview-settings'
4
+ import { histoireConfig } from '../../util/config'
5
+ import BaseCheckbox from '../base/BaseCheckbox.vue'
6
6
 
7
7
  const settings = usePreviewSettingsStore().currentSettings
8
8
  </script>
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" setup>
2
2
  import { Icon } from '@iconify/vue'
3
- import type { Story, Variant } from '../../../types'
3
+ import type { Story, Variant } from '../../types'
4
4
  import { computed } from 'vue'
5
- import { getSandboxUrl } from '../../sandbox/lib'
5
+ import { getSandboxUrl } from '../sandbox/lib'
6
6
 
7
7
  const props = defineProps<{
8
8
  variant: Variant
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" setup>
2
2
  import { Icon } from '@iconify/vue'
3
- import { usePreviewSettingsStore } from '../../../stores/preview-settings'
4
- import { histoireConfig } from '../../../util/config'
5
- import BaseCheckbox from '../../base/BaseCheckbox.vue'
3
+ import { usePreviewSettingsStore } from '../../stores/preview-settings'
4
+ import { histoireConfig } from '../../util/config'
5
+ import BaseCheckbox from '../base/BaseCheckbox.vue'
6
6
 
7
7
  const settings = usePreviewSettingsStore().currentSettings
8
8
  </script>
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import { Icon } from '@iconify/vue'
3
- import type { Variant } from '../../../types'
3
+ import type { Variant } from '../../types'
4
4
 
5
5
  defineProps<{
6
6
  variant: Variant
@@ -1,6 +1,6 @@
1
1
  import './style/sandbox.css'
2
2
  import { parseQuery } from 'vue-router'
3
- import { computed, createApp, h, onMounted, ref, watch, isRef } from 'vue'
3
+ import { computed, createApp, h, onMounted, ref, watch } from 'vue'
4
4
  import { createPinia } from 'pinia'
5
5
  import { registerGlobalComponents } from './global-components'
6
6
  import SandboxVue3 from './components/sandbox/SandboxVue3.vue'
@@ -11,6 +11,19 @@
11
11
  }
12
12
  }
13
13
 
14
+ .__histoire-scale-y {
15
+ &-enter-active,
16
+ &-leave-active {
17
+ transition: transform .15s, opacity .15s;
18
+ }
19
+
20
+ &-enter-from,
21
+ &-leave-to {
22
+ transform: scaleY(0);
23
+ opacity: 0;
24
+ }
25
+ }
26
+
14
27
  .__histoire-fade {
15
28
  &-enter-active,
16
29
  &-leave-active {
@@ -1,3 +1,4 @@
1
+ import { App } from 'vue'
1
2
  import type { RouteLocationRaw } from 'vue-router'
2
3
 
3
4
  export interface StoryFile {
@@ -15,6 +16,7 @@ export interface Story {
15
16
  variants: Variant[]
16
17
  layout?: {
17
18
  type: 'single'
19
+ iframe?: boolean
18
20
  } | {
19
21
  type: 'grid'
20
22
  width?: number | string
@@ -24,6 +26,7 @@ export interface Story {
24
26
  docsOnly?: boolean
25
27
  file?: StoryFile
26
28
  lastSelectedVariant?: Variant
29
+ slots?: () => Readonly<any>
27
30
  }
28
31
 
29
32
  export interface Variant {
@@ -32,6 +35,7 @@ export interface Variant {
32
35
  icon?: string
33
36
  iconColor?: string
34
37
  initState?: () => any
38
+ setupApp?: (payload: any) => unknown
35
39
  slots?: () => Readonly<any>
36
40
  state?: any
37
41
  source?: string
@@ -10,6 +10,7 @@ export function mapFile (file: StoryFile, existingFile?: StoryFile): StoryFile {
10
10
  title: file.story.title,
11
11
  file: markRaw(file),
12
12
  variants: file.story.variants.map(v => mapVariant(v)),
13
+ slots: () => ({}),
13
14
  },
14
15
  }
15
16
 
@@ -42,6 +43,7 @@ export function mapVariant (variant: Variant): Variant {
42
43
  ...variant,
43
44
  state: null,
44
45
  initState: null,
46
+ setupApp: null,
45
47
  slots: () => ({}),
46
48
  previewReady: false,
47
49
  }
@@ -23,7 +23,7 @@ export default defineComponent({
23
23
 
24
24
  layout: {
25
25
  type: Object as PropType<Story['layout']>,
26
- default: () => ({ type: 'single' }),
26
+ default: () => ({ type: 'single', iframe: true }),
27
27
  },
28
28
 
29
29
  icon: {