@histoire/app 0.9.0
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.
- package/LICENSE +21 -0
- package/dist/app/assets/histoire-text-dark.svg +89 -0
- package/dist/app/assets/histoire-text.svg +89 -0
- package/dist/app/assets/histoire.svg +51 -0
- package/dist/app/style/floating-vue.pcss +34 -0
- package/dist/app/style/main.pcss +86 -0
- package/dist/app/style/sandbox.css +19 -0
- package/dist/app/style/transitions.pcss +51 -0
- package/dist/bundle-index.js +1 -0
- package/dist/bundle-main.js +5 -0
- package/dist/bundle-sandbox.js +2 -0
- package/dist/bundled/App.js +148 -0
- package/dist/bundled/_virtual/plugin-vue_export-helper.js +8 -0
- package/dist/bundled/api.js +1 -0
- package/dist/bundled/assets/histoire-text-dark.js +2 -0
- package/dist/bundled/assets/histoire-text.js +2 -0
- package/dist/bundled/assets/histoire.js +2 -0
- package/dist/bundled/components/HomeView.js +24 -0
- package/dist/bundled/components/app/AppHeader.js +67 -0
- package/dist/bundled/components/app/AppLogo.js +26 -0
- package/dist/bundled/components/app/Breadcrumb.js +95 -0
- package/dist/bundled/components/app/Breadcrumb.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/app/InitialLoading.js +48 -0
- package/dist/bundled/components/app/MobileOverlay.js +41 -0
- package/dist/bundled/components/base/BaseCheckbox.js +75 -0
- package/dist/bundled/components/base/BaseEmpty.js +13 -0
- package/dist/bundled/components/base/BaseEmpty.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/base/BaseListItemLink.js +50 -0
- package/dist/bundled/components/base/BaseOverflowMenu.js +97 -0
- package/dist/bundled/components/base/BaseOverflowTab.js +45 -0
- package/dist/bundled/components/base/BaseSelect.js +69 -0
- package/dist/bundled/components/base/BaseSplitPane.js +184 -0
- package/dist/bundled/components/base/BaseSplitPane.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/base/BaseTab.js +45 -0
- package/dist/bundled/components/misc/CheckerboardPattern.js +41 -0
- package/dist/bundled/components/misc/HatchedPattern.js +11 -0
- package/dist/bundled/components/misc/HatchedPattern.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/panel/ControlsComponentPropItem.js +98 -0
- package/dist/bundled/components/panel/ControlsComponentProps.js +42 -0
- package/dist/bundled/components/panel/PaneTabs.js +112 -0
- package/dist/bundled/components/panel/StatePresets.js +190 -0
- package/dist/bundled/components/panel/StoryControls.js +66 -0
- package/dist/bundled/components/panel/StoryDocs.js +57 -0
- package/dist/bundled/components/panel/StoryEvent.js +56 -0
- package/dist/bundled/components/panel/StoryEvents.js +49 -0
- package/dist/bundled/components/panel/StorySidePanel.js +72 -0
- package/dist/bundled/components/panel/StorySourceCode.js +119 -0
- package/dist/bundled/components/panel/StorySourceCode.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/search/SearchItem.js +113 -0
- package/dist/bundled/components/search/SearchItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/search/SearchLoading.js +19 -0
- package/dist/bundled/components/search/SearchModal.js +46 -0
- package/dist/bundled/components/search/SearchPane.js +263 -0
- package/dist/bundled/components/search/search-docs-data.js +7 -0
- package/dist/bundled/components/search/search-title-data.js +7 -0
- package/dist/bundled/components/story/GenericMountStory.js +27 -0
- package/dist/bundled/components/story/GenericRenderStory.js +27 -0
- package/dist/bundled/components/story/StoryResponsivePreview.js +180 -0
- package/dist/bundled/components/story/StoryResponsivePreview.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/story/StoryVariantGrid.js +94 -0
- package/dist/bundled/components/story/StoryVariantGridItem.js +106 -0
- package/dist/bundled/components/story/StoryVariantGridItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/story/StoryVariantListItem.js +58 -0
- package/dist/bundled/components/story/StoryVariantListItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/story/StoryVariantSingle.js +115 -0
- package/dist/bundled/components/story/StoryVariantSingle.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/story/StoryVariantSinglePreviewNative.js +43 -0
- package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.js +119 -0
- package/dist/bundled/components/story/StoryVariantSingleView.js +49 -0
- package/dist/bundled/components/story/StoryView.js +90 -0
- package/dist/bundled/components/story/StoryViewer.js +57 -0
- package/dist/bundled/components/story/StoryViewer.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/toolbar/StoryVariantBackground.js +85 -0
- package/dist/bundled/components/toolbar/StoryVariantBackground.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/toolbar/StoryVariantNewTab.js +33 -0
- package/dist/bundled/components/toolbar/StoryVariantResponsiveSize.js +129 -0
- package/dist/bundled/components/toolbar/StoryVariantTitle.js +24 -0
- package/dist/bundled/components/tree/StoryGroup.js +74 -0
- package/dist/bundled/components/tree/StoryList.js +37 -0
- package/dist/bundled/components/tree/StoryListFolder.js +89 -0
- package/dist/bundled/components/tree/StoryListFolder.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/tree/StoryListItem.js +72 -0
- package/dist/bundled/components/tree/StoryListItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/index.js +29 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/common.js +40 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/en.js +5 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/advanced.js +11 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/balance.js +26 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/simple.js +10 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang.js +50 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/type.js +8 -0
- package/dist/bundled/router.js +28 -0
- package/dist/bundled/sandbox.js +88 -0
- package/dist/bundled/stores/events.js +29 -0
- package/dist/bundled/stores/folder.js +49 -0
- package/dist/bundled/stores/preview-settings.js +15 -0
- package/dist/bundled/stores/story.js +43 -0
- package/dist/bundled/style.css +102 -0
- package/dist/bundled/util/config.js +4 -0
- package/dist/bundled/util/const.js +5 -0
- package/dist/bundled/util/dark.js +4 -0
- package/dist/bundled/util/env.js +2 -0
- package/dist/bundled/util/events.js +32 -0
- package/dist/bundled/util/keyboard.js +84 -0
- package/dist/bundled/util/mapping.js +65 -0
- package/dist/bundled/util/preview-settings.js +6 -0
- package/dist/bundled/util/responsive.js +3 -0
- package/dist/bundled/util/sandbox.js +8 -0
- package/dist/bundled/util/scroll.js +28 -0
- package/dist/bundled/util/state.js +31 -0
- package/dist/bundled/util/tooltip.js +12 -0
- package/dist/bundled/util/variant.js +18 -0
- package/dist/style.css +2697 -0
- package/package.json +57 -0
- package/postcss.config.cjs +8 -0
- package/scripts/copy.mjs +12 -0
- package/scripts/watchAndCopy.mjs +15 -0
- package/src/app/App.vue +162 -0
- package/src/app/api.ts +1 -0
- package/src/app/assets/histoire-text-dark.svg +89 -0
- package/src/app/assets/histoire-text.svg +89 -0
- package/src/app/assets/histoire.svg +51 -0
- package/src/app/components/HomeView.vue +17 -0
- package/src/app/components/app/AppHeader.vue +64 -0
- package/src/app/components/app/AppLogo.vue +24 -0
- package/src/app/components/app/Breadcrumb.vue +98 -0
- package/src/app/components/app/InitialLoading.vue +44 -0
- package/src/app/components/app/MobileOverlay.vue +33 -0
- package/src/app/components/base/BaseCheckbox.vue +77 -0
- package/src/app/components/base/BaseCopyIcon.vue +34 -0
- package/src/app/components/base/BaseEmpty.vue +21 -0
- package/src/app/components/base/BaseListItemLink.vue +55 -0
- package/src/app/components/base/BaseOverflowMenu.vue +119 -0
- package/src/app/components/base/BaseOverflowTab.vue +46 -0
- package/src/app/components/base/BaseSelect.vue +72 -0
- package/src/app/components/base/BaseSplitPane.vue +240 -0
- package/src/app/components/base/BaseTab.vue +46 -0
- package/src/app/components/misc/CheckerboardPattern.vue +32 -0
- package/src/app/components/misc/HatchedPattern.vue +13 -0
- package/src/app/components/panel/ControlsComponentPropItem.vue +103 -0
- package/src/app/components/panel/ControlsComponentProps.vue +34 -0
- package/src/app/components/panel/PaneTabs.vue +89 -0
- package/src/app/components/panel/StatePresets.vue +196 -0
- package/src/app/components/panel/StoryControls.vue +68 -0
- package/src/app/components/panel/StoryDocs.vue +60 -0
- package/src/app/components/panel/StoryEvent.vue +54 -0
- package/src/app/components/panel/StoryEvents.vue +45 -0
- package/src/app/components/panel/StorySidePanel.vue +70 -0
- package/src/app/components/panel/StorySourceCode.vue +126 -0
- package/src/app/components/search/SearchItem.vue +110 -0
- package/src/app/components/search/SearchLoading.vue +16 -0
- package/src/app/components/search/SearchModal.vue +43 -0
- package/src/app/components/search/SearchPane.vue +293 -0
- package/src/app/components/search/search-docs-data.ts +10 -0
- package/src/app/components/search/search-title-data.ts +10 -0
- package/src/app/components/search/types.ts +4 -0
- package/src/app/components/story/GenericMountStory.vue +28 -0
- package/src/app/components/story/GenericRenderStory.vue +29 -0
- package/src/app/components/story/StoryResponsivePreview.vue +204 -0
- package/src/app/components/story/StoryVariantGrid.vue +112 -0
- package/src/app/components/story/StoryVariantGridItem.vue +110 -0
- package/src/app/components/story/StoryVariantListItem.vue +50 -0
- package/src/app/components/story/StoryVariantSingle.vue +105 -0
- package/src/app/components/story/StoryVariantSinglePreviewNative.vue +42 -0
- package/src/app/components/story/StoryVariantSinglePreviewRemote.vue +139 -0
- package/src/app/components/story/StoryVariantSingleView.vue +52 -0
- package/src/app/components/story/StoryView.vue +96 -0
- package/src/app/components/story/StoryViewer.vue +53 -0
- package/src/app/components/toolbar/StoryVariantBackground.vue +67 -0
- package/src/app/components/toolbar/StoryVariantNewTab.vue +29 -0
- package/src/app/components/toolbar/StoryVariantResponsiveSize.vue +82 -0
- package/src/app/components/toolbar/StoryVariantTitle.vue +21 -0
- package/src/app/components/tree/StoryGroup.vue +75 -0
- package/src/app/components/tree/StoryList.vue +35 -0
- package/src/app/components/tree/StoryListFolder.vue +89 -0
- package/src/app/components/tree/StoryListItem.vue +71 -0
- package/src/app/index.ts +30 -0
- package/src/app/router.ts +29 -0
- package/src/app/sandbox.ts +96 -0
- package/src/app/stores/events.ts +36 -0
- package/src/app/stores/folder.ts +59 -0
- package/src/app/stores/preview-settings.ts +17 -0
- package/src/app/stores/story.ts +47 -0
- package/src/app/style/floating-vue.pcss +34 -0
- package/src/app/style/main.pcss +86 -0
- package/src/app/style/sandbox.css +19 -0
- package/src/app/style/transitions.pcss +51 -0
- package/src/app/types.ts +46 -0
- package/src/app/util/config.ts +6 -0
- package/src/app/util/const.ts +4 -0
- package/src/app/util/dark.ts +4 -0
- package/src/app/util/env.ts +1 -0
- package/src/app/util/events.ts +30 -0
- package/src/app/util/keyboard.ts +99 -0
- package/src/app/util/mapping.ts +76 -0
- package/src/app/util/preview-settings.ts +8 -0
- package/src/app/util/responsive.ts +3 -0
- package/src/app/util/sandbox.ts +10 -0
- package/src/app/util/scroll.ts +31 -0
- package/src/app/util/state.ts +37 -0
- package/src/app/util/tooltip.ts +13 -0
- package/src/app/util/variant.ts +20 -0
- package/src/bundle-index.js +1 -0
- package/src/bundle-main.js +5 -0
- package/src/bundle-sandbox.js +2 -0
- package/src/index.ts +1 -0
- package/src/shim.d.ts +7 -0
- package/tailwind.config.cjs +126 -0
- package/tsconfig.json +54 -0
- package/vite.config.ts +87 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, ref, toRaw, watch } from 'vue'
|
|
3
|
+
import { useEventListener } from '@vueuse/core'
|
|
4
|
+
import { applyState } from '@histoire/shared'
|
|
5
|
+
import { STATE_SYNC, PREVIEW_SETTINGS_SYNC, SANDBOX_READY, EVENT_SEND } from '../../util/const'
|
|
6
|
+
import type { Story, Variant } from '../../types'
|
|
7
|
+
import { getSandboxUrl } from '../../util/sandbox'
|
|
8
|
+
import { usePreviewSettingsStore } from '../../stores/preview-settings'
|
|
9
|
+
import { HstEvent, useEventsStore } from '../../stores/events'
|
|
10
|
+
import StoryResponsivePreview from './StoryResponsivePreview.vue'
|
|
11
|
+
import { toRawDeep } from '../../util/state'
|
|
12
|
+
|
|
13
|
+
const props = defineProps<{
|
|
14
|
+
story: Story
|
|
15
|
+
variant: Variant
|
|
16
|
+
}>()
|
|
17
|
+
|
|
18
|
+
const settings = usePreviewSettingsStore().currentSettings
|
|
19
|
+
|
|
20
|
+
// Iframe
|
|
21
|
+
|
|
22
|
+
const iframe = ref<HTMLIFrameElement>()
|
|
23
|
+
|
|
24
|
+
function syncState () {
|
|
25
|
+
if (iframe.value && props.variant.previewReady) {
|
|
26
|
+
iframe.value.contentWindow.postMessage({
|
|
27
|
+
type: STATE_SYNC,
|
|
28
|
+
state: toRawDeep(props.variant.state),
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let synced = false
|
|
34
|
+
|
|
35
|
+
watch(() => props.variant.state, () => {
|
|
36
|
+
if (synced) {
|
|
37
|
+
synced = false
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
syncState()
|
|
41
|
+
}, {
|
|
42
|
+
deep: true,
|
|
43
|
+
immediate: true,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
Object.assign(props.variant, {
|
|
47
|
+
previewReady: false,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
useEventListener(window, 'message', (event) => {
|
|
51
|
+
switch (event.data.type) {
|
|
52
|
+
case STATE_SYNC:
|
|
53
|
+
updateVariantState(event.data.state)
|
|
54
|
+
break
|
|
55
|
+
case EVENT_SEND:
|
|
56
|
+
logEvent(event.data.event)
|
|
57
|
+
break
|
|
58
|
+
case SANDBOX_READY:
|
|
59
|
+
setPreviewReady()
|
|
60
|
+
break
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
function updateVariantState (state: any) {
|
|
65
|
+
synced = true
|
|
66
|
+
applyState(props.variant.state, state)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function logEvent (event: HstEvent) {
|
|
70
|
+
const eventsStore = useEventsStore()
|
|
71
|
+
eventsStore.addEvent(event)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function setPreviewReady () {
|
|
75
|
+
Object.assign(props.variant, {
|
|
76
|
+
previewReady: true,
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const sandboxUrl = computed(() => {
|
|
81
|
+
return getSandboxUrl(props.story, props.variant)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const isIframeLoaded = ref(false)
|
|
85
|
+
|
|
86
|
+
watch(sandboxUrl, () => {
|
|
87
|
+
isIframeLoaded.value = false
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
// Settings
|
|
91
|
+
|
|
92
|
+
function syncSettings () {
|
|
93
|
+
if (iframe.value) {
|
|
94
|
+
iframe.value.contentWindow.postMessage({
|
|
95
|
+
type: PREVIEW_SETTINGS_SYNC,
|
|
96
|
+
settings: toRaw(settings),
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
watch(() => settings, () => {
|
|
102
|
+
syncSettings()
|
|
103
|
+
}, {
|
|
104
|
+
deep: true,
|
|
105
|
+
immediate: true,
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
// Iframe load
|
|
109
|
+
|
|
110
|
+
function onIframeLoad () {
|
|
111
|
+
isIframeLoaded.value = true
|
|
112
|
+
syncState()
|
|
113
|
+
syncSettings()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
<template>
|
|
119
|
+
<StoryResponsivePreview
|
|
120
|
+
v-slot="{ isResponsiveEnabled, finalWidth, finalHeight, resizing }"
|
|
121
|
+
:variant="variant"
|
|
122
|
+
>
|
|
123
|
+
<iframe
|
|
124
|
+
ref="iframe"
|
|
125
|
+
:src="sandboxUrl"
|
|
126
|
+
class="htw-w-full htw-h-full htw-relative"
|
|
127
|
+
:class="{
|
|
128
|
+
'htw-invisible': !isIframeLoaded,
|
|
129
|
+
'htw-pointer-events-none': resizing,
|
|
130
|
+
}"
|
|
131
|
+
:style="isResponsiveEnabled ? {
|
|
132
|
+
width: finalWidth ? `${finalWidth}px` : null,
|
|
133
|
+
height: finalHeight ? `${finalHeight}px` : null,
|
|
134
|
+
} : undefined"
|
|
135
|
+
data-test-id="preview-iframe"
|
|
136
|
+
@load="onIframeLoad()"
|
|
137
|
+
/>
|
|
138
|
+
</StoryResponsivePreview>
|
|
139
|
+
</template>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { Story, Variant } from '../../types'
|
|
3
|
+
import { isMobile } from '../../util/responsive'
|
|
4
|
+
import StoryVariantTitle from '../toolbar/StoryVariantTitle.vue'
|
|
5
|
+
import StoryVariantResponsiveSize from '../toolbar/StoryVariantResponsiveSize.vue'
|
|
6
|
+
import StoryVariantBackground from '../toolbar/StoryVariantBackground.vue'
|
|
7
|
+
import StoryVariantNewTab from '../toolbar/StoryVariantNewTab.vue'
|
|
8
|
+
import StoryVariantSinglePreviewNative from './StoryVariantSinglePreviewNative.vue'
|
|
9
|
+
import StoryVariantSinglePreviewRemote from './StoryVariantSinglePreviewRemote.vue'
|
|
10
|
+
|
|
11
|
+
defineProps<{
|
|
12
|
+
variant: Variant
|
|
13
|
+
story: Story
|
|
14
|
+
}>()
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<div
|
|
19
|
+
class="htw-h-full htw-flex htw-flex-col"
|
|
20
|
+
data-test-id="story-variant-single-view"
|
|
21
|
+
>
|
|
22
|
+
<!-- Toolbar -->
|
|
23
|
+
<div
|
|
24
|
+
v-if="!isMobile"
|
|
25
|
+
class="htw-flex-none htw-flex htw-items-center htw-h-8 -htw-mt-1"
|
|
26
|
+
>
|
|
27
|
+
<StoryVariantTitle
|
|
28
|
+
:variant="variant"
|
|
29
|
+
/>
|
|
30
|
+
<StoryVariantResponsiveSize
|
|
31
|
+
v-if="!variant.responsiveDisabled"
|
|
32
|
+
/>
|
|
33
|
+
<StoryVariantBackground />
|
|
34
|
+
<StoryVariantNewTab
|
|
35
|
+
:variant="variant"
|
|
36
|
+
:story="story"
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<!-- Preview -->
|
|
41
|
+
<StoryVariantSinglePreviewNative
|
|
42
|
+
v-if="story.layout?.iframe === false"
|
|
43
|
+
:story="story"
|
|
44
|
+
:variant="variant"
|
|
45
|
+
/>
|
|
46
|
+
<StoryVariantSinglePreviewRemote
|
|
47
|
+
v-else
|
|
48
|
+
:story="story"
|
|
49
|
+
:variant="variant"
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { watch } from 'vue'
|
|
3
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
4
|
+
import { Icon } from '@iconify/vue'
|
|
5
|
+
import { useStoryStore } from '../../stores/story'
|
|
6
|
+
|
|
7
|
+
import BaseSplitPane from '../base/BaseSplitPane.vue'
|
|
8
|
+
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
9
|
+
import { isMobile } from '../../util/responsive'
|
|
10
|
+
import StoryViewer from './StoryViewer.vue'
|
|
11
|
+
import StorySidePanel from '../panel/StorySidePanel.vue'
|
|
12
|
+
import StoryDocs from '../panel/StoryDocs.vue'
|
|
13
|
+
|
|
14
|
+
const storyStore = useStoryStore()
|
|
15
|
+
|
|
16
|
+
const router = useRouter()
|
|
17
|
+
const route = useRoute()
|
|
18
|
+
|
|
19
|
+
// Restore variant selection
|
|
20
|
+
|
|
21
|
+
watch(() => storyStore.currentVariant, value => {
|
|
22
|
+
if (value) {
|
|
23
|
+
storyStore.currentStory.lastSelectedVariant = value
|
|
24
|
+
}
|
|
25
|
+
}, {
|
|
26
|
+
immediate: true,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
watch(() => [storyStore.currentStory, storyStore.currentVariant], () => {
|
|
30
|
+
if (!storyStore.currentVariant) {
|
|
31
|
+
if (storyStore.currentStory?.lastSelectedVariant) {
|
|
32
|
+
setVariant(storyStore.currentStory.lastSelectedVariant.id)
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (storyStore.currentStory?.variants.length === 1) {
|
|
37
|
+
setVariant(storyStore.currentStory.variants[0].id)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
immediate: true,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
function setVariant (variantId: string) {
|
|
45
|
+
router.replace({
|
|
46
|
+
...route,
|
|
47
|
+
query: {
|
|
48
|
+
...route.query,
|
|
49
|
+
variantId,
|
|
50
|
+
},
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<template>
|
|
56
|
+
<BaseEmpty v-if="!storyStore.currentStory">
|
|
57
|
+
<Icon
|
|
58
|
+
icon="carbon:software-resource-resource"
|
|
59
|
+
class="htw-w-16 htw-h-16 htw-opacity-50"
|
|
60
|
+
/>
|
|
61
|
+
</BaseEmpty>
|
|
62
|
+
|
|
63
|
+
<div
|
|
64
|
+
v-else
|
|
65
|
+
class="htw-h-full"
|
|
66
|
+
>
|
|
67
|
+
<div
|
|
68
|
+
v-if="storyStore.currentStory.docsOnly"
|
|
69
|
+
class="htw-h-full htw-overflow-auto"
|
|
70
|
+
>
|
|
71
|
+
<StoryDocs
|
|
72
|
+
:story="storyStore.currentStory"
|
|
73
|
+
class="md:htw-p-12 htw-w-full md:htw-max-w-[600px] lg:htw-max-w-[800px] xl:htw-max-w-[900px]"
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
<template v-else-if="isMobile">
|
|
77
|
+
<StoryViewer />
|
|
78
|
+
</template>
|
|
79
|
+
<BaseSplitPane
|
|
80
|
+
v-else
|
|
81
|
+
save-id="story-main"
|
|
82
|
+
:min="30"
|
|
83
|
+
:max="95"
|
|
84
|
+
:default-split="75"
|
|
85
|
+
class="htw-h-full"
|
|
86
|
+
>
|
|
87
|
+
<template #first>
|
|
88
|
+
<StoryViewer />
|
|
89
|
+
</template>
|
|
90
|
+
|
|
91
|
+
<template #last>
|
|
92
|
+
<StorySidePanel />
|
|
93
|
+
</template>
|
|
94
|
+
</BaseSplitPane>
|
|
95
|
+
</div>
|
|
96
|
+
</template>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, ref, watch } from 'vue'
|
|
3
|
+
import { useStoryStore } from '../../stores/story'
|
|
4
|
+
import StoryVariantListItem from './StoryVariantListItem.vue'
|
|
5
|
+
import MobileOverlay from '../app/MobileOverlay.vue'
|
|
6
|
+
import StoryVariantGrid from './StoryVariantGrid.vue'
|
|
7
|
+
import StoryVariantSingle from './StoryVariantSingle.vue'
|
|
8
|
+
|
|
9
|
+
const storyStore = useStoryStore()
|
|
10
|
+
|
|
11
|
+
const variant = computed(() => storyStore.currentVariant)
|
|
12
|
+
|
|
13
|
+
const isMenuOpened = ref(false)
|
|
14
|
+
|
|
15
|
+
function closeMenu () {
|
|
16
|
+
isMenuOpened.value = false
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
watch(variant, () => {
|
|
20
|
+
isMenuOpened.value = false
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<div class="htw-bg-gray-50 htw-h-full dark:htw-bg-gray-750">
|
|
27
|
+
<StoryVariantGrid
|
|
28
|
+
v-if="storyStore.currentStory.layout.type === 'grid'"
|
|
29
|
+
/>
|
|
30
|
+
<StoryVariantSingle
|
|
31
|
+
v-else-if="storyStore.currentStory.layout.type === 'single'"
|
|
32
|
+
@open-variant-menu="isMenuOpened = true"
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<MobileOverlay
|
|
37
|
+
title="Select a variant"
|
|
38
|
+
:opened="isMenuOpened"
|
|
39
|
+
@close="closeMenu"
|
|
40
|
+
>
|
|
41
|
+
<StoryVariantListItem
|
|
42
|
+
v-for="(v, index) of storyStore.currentStory.variants"
|
|
43
|
+
:key="index"
|
|
44
|
+
:variant="v"
|
|
45
|
+
/>
|
|
46
|
+
</MobileOverlay>
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<style scoped>
|
|
50
|
+
.bind-icon-color {
|
|
51
|
+
color: v-bind('variant?.iconColor');
|
|
52
|
+
}
|
|
53
|
+
</style>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
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'
|
|
6
|
+
|
|
7
|
+
const settings = usePreviewSettingsStore().currentSettings
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<VDropdown
|
|
12
|
+
v-if="histoireConfig.backgroundPresets.length"
|
|
13
|
+
placement="bottom-end"
|
|
14
|
+
:skidding="6"
|
|
15
|
+
class="htw-h-full htw-flex-none"
|
|
16
|
+
>
|
|
17
|
+
<div
|
|
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 htw-group"
|
|
20
|
+
>
|
|
21
|
+
<div
|
|
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
|
+
/>
|
|
24
|
+
<Icon
|
|
25
|
+
icon="carbon:caret-down"
|
|
26
|
+
class="htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
|
|
27
|
+
/>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<template #popper="{ hide }">
|
|
31
|
+
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
32
|
+
<BaseCheckbox v-model="settings.checkerboard">
|
|
33
|
+
Checkerboard
|
|
34
|
+
</BaseCheckbox>
|
|
35
|
+
|
|
36
|
+
<button
|
|
37
|
+
v-for="(option, index) in histoireConfig.backgroundPresets"
|
|
38
|
+
:key="index"
|
|
39
|
+
class="htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-4"
|
|
40
|
+
:class="[
|
|
41
|
+
settings.backgroundColor === option.color
|
|
42
|
+
? 'htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black'
|
|
43
|
+
: 'htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700',
|
|
44
|
+
]"
|
|
45
|
+
@click="settings.backgroundColor = option.color;hide()"
|
|
46
|
+
>
|
|
47
|
+
<span class="htw-mr-auto">{{ option.label }}</span>
|
|
48
|
+
<template v-if="option.color !== '$checkerboard'">
|
|
49
|
+
<span class="htw-ml-auto htw-opacity-70">{{ option.color }}</span>
|
|
50
|
+
<div
|
|
51
|
+
class="htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/20 dark:htw-border-white/20"
|
|
52
|
+
:style="{
|
|
53
|
+
backgroundColor: option.color,
|
|
54
|
+
}"
|
|
55
|
+
/>
|
|
56
|
+
</template>
|
|
57
|
+
</button>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
</VDropdown>
|
|
61
|
+
</template>
|
|
62
|
+
|
|
63
|
+
<style scoped>
|
|
64
|
+
.bind-preview-bg {
|
|
65
|
+
background-color: v-bind('settings.backgroundColor');
|
|
66
|
+
}
|
|
67
|
+
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { Icon } from '@iconify/vue'
|
|
3
|
+
import type { Story, Variant } from '../../types'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
import { getSandboxUrl } from '../../util/sandbox'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
variant: Variant
|
|
9
|
+
story: Story
|
|
10
|
+
}>()
|
|
11
|
+
|
|
12
|
+
const sandboxUrl = computed(() => {
|
|
13
|
+
return getSandboxUrl(props.story, props.variant)
|
|
14
|
+
})
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<a
|
|
19
|
+
v-tooltip="'Open variant in new tab'"
|
|
20
|
+
:href="sandboxUrl"
|
|
21
|
+
target="_blank"
|
|
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
|
+
>
|
|
24
|
+
<Icon
|
|
25
|
+
icon="carbon:launch"
|
|
26
|
+
class="base-list-item-link-icon htw-w-4 htw-h-4"
|
|
27
|
+
/>
|
|
28
|
+
</a>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
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'
|
|
6
|
+
|
|
7
|
+
const settings = usePreviewSettingsStore().currentSettings
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<!-- Responsive size -->
|
|
12
|
+
<VDropdown
|
|
13
|
+
placement="bottom-end"
|
|
14
|
+
:skidding="6"
|
|
15
|
+
:disabled="!histoireConfig.responsivePresets?.length"
|
|
16
|
+
class="htw-h-full htw-flex-none"
|
|
17
|
+
>
|
|
18
|
+
<div
|
|
19
|
+
v-tooltip="'Responsive sizes'"
|
|
20
|
+
class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 htw-group"
|
|
21
|
+
:class="{
|
|
22
|
+
'htw-cursor-pointer hover:htw-text-primary-500': histoireConfig.responsivePresets?.length,
|
|
23
|
+
}"
|
|
24
|
+
>
|
|
25
|
+
<Icon
|
|
26
|
+
icon="carbon:devices"
|
|
27
|
+
class="htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
|
|
28
|
+
/>
|
|
29
|
+
<Icon
|
|
30
|
+
icon="carbon:caret-down"
|
|
31
|
+
class="htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<template #popper="{ hide }">
|
|
36
|
+
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
37
|
+
<BaseCheckbox v-model="settings.rotate">
|
|
38
|
+
Rotate
|
|
39
|
+
</BaseCheckbox>
|
|
40
|
+
|
|
41
|
+
<div class="htw-flex htw-gap-2 htw-px-4 htw-py-3">
|
|
42
|
+
<input
|
|
43
|
+
v-model.number="settings.responsiveWidth"
|
|
44
|
+
v-tooltip="'Responsive width (px)'"
|
|
45
|
+
type="number"
|
|
46
|
+
class="htw-bg-transparent htw-border htw-border-gray-200 dark:htw-border-gray-850 htw-rounded htw-w-20 htw-opacity-50 focus:htw-opacity-100 htw-flex-1 htw-min-w-0"
|
|
47
|
+
step="16"
|
|
48
|
+
placeholder="Auto"
|
|
49
|
+
>
|
|
50
|
+
<span class="htw-opacity-50">x</span>
|
|
51
|
+
<input
|
|
52
|
+
v-model.number="settings.responsiveHeight"
|
|
53
|
+
v-tooltip="'Responsive height (px)'"
|
|
54
|
+
type="number"
|
|
55
|
+
class="htw-bg-transparent htw-border htw-border-gray-200 dark:htw-border-gray-850 htw-rounded htw-w-20 htw-opacity-50 focus:htw-opacity-100 htw-flex-1 htw-min-w-0"
|
|
56
|
+
step="16"
|
|
57
|
+
placeholder="Auto"
|
|
58
|
+
>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<button
|
|
62
|
+
v-for="(preset, index) in histoireConfig.responsivePresets"
|
|
63
|
+
:key="index"
|
|
64
|
+
class="htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-4"
|
|
65
|
+
:class="[
|
|
66
|
+
settings.responsiveWidth === preset.width && settings.responsiveHeight === preset.height
|
|
67
|
+
? 'htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black'
|
|
68
|
+
: 'htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700',
|
|
69
|
+
]"
|
|
70
|
+
@click="settings.responsiveWidth = preset.width;settings.responsiveHeight = preset.height;hide()"
|
|
71
|
+
>
|
|
72
|
+
{{ preset.label }}
|
|
73
|
+
<span class="htw-ml-auto htw-opacity-70 htw-flex htw-gap-1">
|
|
74
|
+
<span v-if="preset.width">{{ preset.width }}<span v-if="!preset.height">px</span></span>
|
|
75
|
+
<span v-if="preset.width && preset.height">x</span>
|
|
76
|
+
<span v-if="preset.height">{{ preset.height }}<span v-if="!preset.width">px</span></span>
|
|
77
|
+
</span>
|
|
78
|
+
</button>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
81
|
+
</VDropdown>
|
|
82
|
+
</template>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { Icon } from '@iconify/vue'
|
|
3
|
+
import type { Variant } from '../../types'
|
|
4
|
+
|
|
5
|
+
defineProps<{
|
|
6
|
+
variant: Variant
|
|
7
|
+
}>()
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div class="htw-flex htw-items-center htw-gap-1 htw-text-gray-500 htw-flex-1 htw-truncate htw-min-w-0">
|
|
12
|
+
<Icon
|
|
13
|
+
:icon="variant.icon ?? 'carbon:cube'"
|
|
14
|
+
class="base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50"
|
|
15
|
+
:class="[
|
|
16
|
+
variant.iconColor ? 'bind-icon-color' : 'htw-text-gray-500',
|
|
17
|
+
]"
|
|
18
|
+
/>
|
|
19
|
+
<span>{{ variant.title }}</span>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { Story, TreeGroup } from '../../types'
|
|
3
|
+
import StoryListItem from './StoryListItem.vue'
|
|
4
|
+
import StoryListFolder from './StoryListFolder.vue'
|
|
5
|
+
import { Icon } from '@iconify/vue'
|
|
6
|
+
import { computed, withDefaults } from 'vue'
|
|
7
|
+
import { useFolderStore } from '../../stores/folder'
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(defineProps<{
|
|
10
|
+
path?: Array<string>
|
|
11
|
+
group: TreeGroup
|
|
12
|
+
stories: Story[]
|
|
13
|
+
}>(), {
|
|
14
|
+
path: () => [],
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const folderStore = useFolderStore()
|
|
18
|
+
|
|
19
|
+
const folderPath = computed(() => [...props.path, props.group.title])
|
|
20
|
+
const isFolderOpen = computed(() => folderStore.isFolderOpened(folderPath.value, true))
|
|
21
|
+
|
|
22
|
+
function toggleOpen () {
|
|
23
|
+
folderStore.toggleFolder(folderPath.value, false)
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<div
|
|
29
|
+
data-test-id="story-group"
|
|
30
|
+
class="htw-my-2 first:htw-mt-0 last:htw-mb-0"
|
|
31
|
+
>
|
|
32
|
+
<div
|
|
33
|
+
v-if="group.title"
|
|
34
|
+
role="button"
|
|
35
|
+
tabindex="0"
|
|
36
|
+
class="htw-px-0.5 htw-py-2 md:htw-py-1.5 htw-mx-1 htw-rounded-sm hover:htw-bg-primary-100 dark:hover:htw-bg-primary-900 htw-cursor-pointer htw-select-none htw-flex htw-items-center htw-gap-1 htw-min-w-0"
|
|
37
|
+
@click="toggleOpen"
|
|
38
|
+
@keyup.enter="toggleOpen"
|
|
39
|
+
@keyup.space="toggleOpen"
|
|
40
|
+
>
|
|
41
|
+
<Icon
|
|
42
|
+
icon="carbon:caret-right"
|
|
43
|
+
class="htw-w-4 htw-h-4 htw-transition-transform htw-duration-150 htw-opacity-30 htw-flex-none"
|
|
44
|
+
:class="{
|
|
45
|
+
'htw-rotate-90': isFolderOpen,
|
|
46
|
+
}"
|
|
47
|
+
/>
|
|
48
|
+
<span class="htw-truncate htw-opacity-50">{{ group.title }}</span>
|
|
49
|
+
<span class="htw-h-[1px] htw-flex-1 htw-bg-gray-500/10 htw-mx-2" />
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<!-- Children -->
|
|
53
|
+
<div
|
|
54
|
+
v-if="isFolderOpen"
|
|
55
|
+
>
|
|
56
|
+
<template
|
|
57
|
+
v-for="element of group.children"
|
|
58
|
+
:key="element.title"
|
|
59
|
+
>
|
|
60
|
+
<StoryListFolder
|
|
61
|
+
v-if="(element as TreeFolder).children"
|
|
62
|
+
:path="folderPath"
|
|
63
|
+
:folder="(element as TreeFolder)"
|
|
64
|
+
:stories="stories"
|
|
65
|
+
:depth="0"
|
|
66
|
+
/>
|
|
67
|
+
<StoryListItem
|
|
68
|
+
v-else
|
|
69
|
+
:story="stories[(element as TreeLeaf).index]"
|
|
70
|
+
:depth="0"
|
|
71
|
+
/>
|
|
72
|
+
</template>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</template>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { Story, Tree, TreeGroup, TreeFolder, TreeLeaf } from '../../types'
|
|
3
|
+
import StoryListItem from './StoryListItem.vue'
|
|
4
|
+
import StoryListFolder from './StoryListFolder.vue'
|
|
5
|
+
import StoryGroup from './StoryGroup.vue'
|
|
6
|
+
|
|
7
|
+
defineProps<{
|
|
8
|
+
tree: Tree
|
|
9
|
+
stories: Story[]
|
|
10
|
+
}>()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<div class="htw-overflow-y-auto">
|
|
15
|
+
<template
|
|
16
|
+
v-for="element of tree"
|
|
17
|
+
:key="element.title"
|
|
18
|
+
>
|
|
19
|
+
<StoryGroup
|
|
20
|
+
v-if="(element as TreeGroup).group"
|
|
21
|
+
:group="(element as TreeGroup)"
|
|
22
|
+
:stories="stories"
|
|
23
|
+
/>
|
|
24
|
+
<StoryListFolder
|
|
25
|
+
v-else-if="(element as TreeFolder).children"
|
|
26
|
+
:folder="(element as TreeFolder)"
|
|
27
|
+
:stories="stories"
|
|
28
|
+
/>
|
|
29
|
+
<StoryListItem
|
|
30
|
+
v-else
|
|
31
|
+
:story="stories[(element as TreeLeaf).index]"
|
|
32
|
+
/>
|
|
33
|
+
</template>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|