histoire 0.2.2 → 0.2.5
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/dist/client/app/App.vue +2 -2
- package/dist/client/app/codegen/vue3.js +11 -2
- package/dist/client/app/codegen/vue3.ts +9 -1
- package/dist/client/app/components/app/AppHeader.vue +2 -2
- package/dist/client/app/components/app/Breadcrumb.vue +1 -1
- package/dist/client/app/components/base/BaseListItemLink.vue +1 -1
- package/dist/client/app/components/base/BaseTab.vue +1 -1
- package/dist/client/app/components/exposed/Story.vue +5 -0
- package/dist/client/app/components/exposed/Variant.vue +7 -0
- package/dist/client/app/components/search/SearchItem.vue +1 -0
- package/dist/client/app/components/search/SearchModal.vue +7 -6
- package/dist/client/app/components/story/StoryResponsivePreview.vue +72 -77
- package/dist/client/app/components/story/StorySidePanel.vue +1 -1
- package/dist/client/app/components/story/StorySourceCode.vue +3 -17
- package/dist/client/app/components/story/StoryVariantGridItem.vue +3 -3
- package/dist/client/app/components/story/StoryVariantSingleView.vue +10 -11
- package/dist/client/app/components/story/StoryViewer.vue +2 -0
- package/dist/client/app/components/story/{variant → toolbar}/StoryVariantBackground.vue +4 -4
- package/dist/client/app/components/story/{variant → toolbar}/StoryVariantNewTab.vue +2 -2
- package/dist/client/app/components/story/{variant → toolbar}/StoryVariantResponsiveSize.vue +5 -5
- package/dist/client/app/components/story/{variant → toolbar}/StoryVariantTitle.vue +0 -0
- package/dist/client/app/components/tree/StoryGroup.vue +75 -0
- package/dist/client/app/components/{story → tree}/StoryList.vue +8 -2
- package/{src/client/app/components/story → dist/client/app/components/tree}/StoryListFolder.vue +6 -4
- package/{src/client/app/components/story → dist/client/app/components/tree}/StoryListItem.vue +3 -3
- package/dist/client/app/global-components.js +0 -1
- package/dist/client/app/index.js +0 -1
- package/dist/client/app/sandbox.js +0 -1
- package/dist/client/app/stores/preview-settings.d.ts +8 -0
- package/dist/client/app/stores/preview-settings.js +14 -0
- package/dist/client/app/stores/preview-settings.ts +17 -0
- package/dist/client/app/stores/story.d.ts +57 -21
- package/dist/client/app/stores/story.js +13 -9
- package/dist/client/app/stores/story.ts +13 -9
- package/dist/client/app/style/floating-vue.pcss +3 -1
- package/dist/client/app/types.d.ts +18 -2
- package/dist/client/app/types.ts +20 -2
- package/dist/client/app/util/keyboard.js +0 -1
- package/dist/client/app/util/mapping.js +10 -10
- package/dist/client/app/util/mapping.ts +10 -5
- package/dist/client/app/util/preview-settings.d.ts +1 -8
- package/dist/client/app/util/preview-settings.js +0 -11
- package/dist/client/app/util/preview-settings.ts +1 -19
- package/dist/client/app/util/reactivity.js +0 -1
- package/dist/client/app/util/scroll.js +0 -1
- package/dist/client/app/util/variant.js +0 -1
- package/dist/client/index.js +0 -1
- package/dist/client/server/Story.server.vue +8 -2
- package/dist/client/server/index.js +0 -1
- package/dist/controls.js +0 -1
- package/dist/node/collect/index.js +2 -2
- package/dist/node/config.d.ts +8 -2
- package/dist/node/plugin.js +15 -7
- package/dist/node/stories.js +6 -1
- package/dist/node/tree.d.ts +16 -12
- package/dist/node/tree.js +45 -5
- package/dist/node/types.d.ts +10 -0
- package/dist/style.css +164 -31
- package/package.json +19 -19
- package/src/client/app/App.vue +2 -2
- package/src/client/app/codegen/vue3.ts +9 -1
- package/src/client/app/components/app/AppHeader.vue +2 -2
- package/src/client/app/components/app/Breadcrumb.vue +1 -1
- package/src/client/app/components/base/BaseListItemLink.vue +1 -1
- package/src/client/app/components/base/BaseTab.vue +1 -1
- package/src/client/app/components/exposed/Story.vue +5 -0
- package/src/client/app/components/exposed/Variant.vue +7 -0
- package/src/client/app/components/search/SearchItem.vue +1 -0
- package/src/client/app/components/search/SearchModal.vue +7 -6
- package/src/client/app/components/story/StoryResponsivePreview.vue +72 -77
- package/src/client/app/components/story/StorySidePanel.vue +1 -1
- package/src/client/app/components/story/StorySourceCode.vue +3 -17
- package/src/client/app/components/story/StoryVariantGridItem.vue +3 -3
- package/src/client/app/components/story/StoryVariantSingleView.vue +10 -11
- package/src/client/app/components/story/StoryViewer.vue +2 -0
- package/src/client/app/components/story/{variant → toolbar}/StoryVariantBackground.vue +4 -4
- package/src/client/app/components/story/{variant → toolbar}/StoryVariantNewTab.vue +2 -2
- package/src/client/app/components/story/{variant → toolbar}/StoryVariantResponsiveSize.vue +5 -5
- package/src/client/app/components/story/{variant → toolbar}/StoryVariantTitle.vue +0 -0
- package/src/client/app/components/tree/StoryGroup.vue +75 -0
- package/src/client/app/components/{story → tree}/StoryList.vue +8 -2
- package/{dist/client/app/components/story → src/client/app/components/tree}/StoryListFolder.vue +6 -4
- package/{dist/client/app/components/story → src/client/app/components/tree}/StoryListItem.vue +3 -3
- package/src/client/app/stores/preview-settings.ts +17 -0
- package/src/client/app/stores/story.ts +13 -9
- package/src/client/app/style/floating-vue.pcss +3 -1
- package/src/client/app/types.ts +20 -2
- package/src/client/app/util/mapping.ts +10 -5
- package/src/client/app/util/preview-settings.ts +1 -19
- package/src/client/server/Story.server.vue +8 -2
- package/src/node/collect/index.ts +3 -3
- package/src/node/config.ts +9 -2
- package/src/node/plugin.ts +16 -7
- package/src/node/stories.ts +6 -1
- package/src/node/tree.spec.ts +35 -17
- package/src/node/tree.ts +64 -10
- package/src/node/types.ts +11 -0
- package/tsconfig.json +2 -0
- package/dist/client/app/codegen/vue3.js.map +0 -1
- package/dist/client/app/global-components.js.map +0 -1
- package/dist/client/app/index.js.map +0 -1
- package/dist/client/app/sandbox.js.map +0 -1
- package/dist/client/app/stores/story.js.map +0 -1
- package/dist/client/app/util/keyboard.js.map +0 -1
- package/dist/client/app/util/mapping.js.map +0 -1
- package/dist/client/app/util/preview-settings.js.map +0 -1
- package/dist/client/app/util/reactivity.js.map +0 -1
- package/dist/client/app/util/scroll.js.map +0 -1
- package/dist/client/app/util/variant.js.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/client/server/index.js.map +0 -1
- package/dist/controls.js.map +0 -1
|
@@ -3,30 +3,26 @@ import { computed, onUnmounted, Ref, ref, toRaw, watch } from 'vue'
|
|
|
3
3
|
import { useEventListener } from '@vueuse/core'
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
5
|
import { STATE_SYNC, PREVIEW_SETTINGS_SYNC, SANDBOX_READY } from '../../util/const'
|
|
6
|
-
import { PreviewSettings } from '../../util/preview-settings'
|
|
7
6
|
import type { Story, Variant } from '../../types'
|
|
8
7
|
import HatchedPattern from '../misc/HatchedPattern.vue'
|
|
9
8
|
import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
|
|
10
9
|
import { toRawDeep } from '../../util/reactivity'
|
|
11
|
-
import { Settings } from 'http2'
|
|
12
10
|
import { getSandboxUrl } from '../sandbox/lib'
|
|
11
|
+
import { usePreviewSettingsStore } from '../../stores/preview-settings'
|
|
13
12
|
|
|
14
13
|
const props = defineProps<{
|
|
15
14
|
story: Story
|
|
16
15
|
variant: Variant
|
|
17
|
-
settings: PreviewSettings
|
|
18
16
|
}>()
|
|
19
17
|
|
|
20
|
-
const
|
|
21
|
-
'update:settings': (settings: PreviewSettings) => true,
|
|
22
|
-
})
|
|
18
|
+
const settings = usePreviewSettingsStore().currentSettings
|
|
23
19
|
|
|
24
20
|
// Iframe
|
|
25
21
|
|
|
26
22
|
const iframe = ref<HTMLIFrameElement>()
|
|
27
23
|
|
|
28
24
|
function syncState () {
|
|
29
|
-
if (iframe.value && props.variant.
|
|
25
|
+
if (iframe.value && props.variant.previewReady) {
|
|
30
26
|
iframe.value.contentWindow.postMessage({
|
|
31
27
|
type: STATE_SYNC,
|
|
32
28
|
state: toRawDeep(props.variant.state),
|
|
@@ -48,7 +44,7 @@ watch(() => props.variant.state, () => {
|
|
|
48
44
|
})
|
|
49
45
|
|
|
50
46
|
Object.assign(props.variant, {
|
|
51
|
-
|
|
47
|
+
previewReady: false,
|
|
52
48
|
})
|
|
53
49
|
useEventListener(window, 'message', (event) => {
|
|
54
50
|
if (event.data.type === STATE_SYNC) {
|
|
@@ -56,7 +52,7 @@ useEventListener(window, 'message', (event) => {
|
|
|
56
52
|
Object.assign(props.variant.state, event.data.state)
|
|
57
53
|
} else if (event.data.type === SANDBOX_READY) {
|
|
58
54
|
Object.assign(props.variant, {
|
|
59
|
-
|
|
55
|
+
previewReady: true,
|
|
60
56
|
})
|
|
61
57
|
}
|
|
62
58
|
})
|
|
@@ -77,12 +73,12 @@ function syncSettings () {
|
|
|
77
73
|
if (iframe.value) {
|
|
78
74
|
iframe.value.contentWindow.postMessage({
|
|
79
75
|
type: PREVIEW_SETTINGS_SYNC,
|
|
80
|
-
settings: toRaw(
|
|
76
|
+
settings: toRaw(settings),
|
|
81
77
|
})
|
|
82
78
|
}
|
|
83
79
|
}
|
|
84
80
|
|
|
85
|
-
watch(() =>
|
|
81
|
+
watch(() => settings, () => {
|
|
86
82
|
syncSettings()
|
|
87
83
|
}, {
|
|
88
84
|
deep: true,
|
|
@@ -130,8 +126,13 @@ function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, m
|
|
|
130
126
|
]
|
|
131
127
|
|
|
132
128
|
function onMouseMove (event: MouseEvent) {
|
|
129
|
+
const snapTarget = (axis === 'x' ? previewWrapper.value.clientWidth : previewWrapper.value.clientHeight)
|
|
133
130
|
const delta = (axis === 'x' ? event.clientX : event.clientY) - start
|
|
134
131
|
value.value = Math.max(min, Math.min(max, startValue + delta))
|
|
132
|
+
|
|
133
|
+
if (Math.abs(value.value - (snapTarget - 67)) < 16) {
|
|
134
|
+
value.value = null
|
|
135
|
+
}
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
function onMouseUp () {
|
|
@@ -167,74 +168,56 @@ function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, m
|
|
|
167
168
|
useEventListener(el, 'touchstart', onTouchStart)
|
|
168
169
|
}
|
|
169
170
|
|
|
170
|
-
// Optimize by batching settings updates to the next frame
|
|
171
|
-
// Prevents sync issues with `useStorage`
|
|
172
|
-
let settingsUpdate: Partial<Settings> = {}
|
|
173
|
-
let settingsUpdateQueued = false
|
|
174
|
-
|
|
175
|
-
function updateSettings (settings: Partial<PreviewSettings>) {
|
|
176
|
-
Object.assign(settingsUpdate, settings)
|
|
177
|
-
|
|
178
|
-
if (!settingsUpdateQueued) {
|
|
179
|
-
settingsUpdateQueued = true
|
|
180
|
-
requestAnimationFrame(() => {
|
|
181
|
-
emit('update:settings', {
|
|
182
|
-
...props.settings,
|
|
183
|
-
...settingsUpdate,
|
|
184
|
-
})
|
|
185
|
-
settingsUpdate = {}
|
|
186
|
-
settingsUpdateQueued = false
|
|
187
|
-
})
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
171
|
const responsiveWidth = computed({
|
|
192
|
-
get: () =>
|
|
193
|
-
set: (value) => {
|
|
194
|
-
updateSettings({
|
|
195
|
-
[props.settings.rotate ? 'responsiveHeight' : 'responsiveWidth']: value,
|
|
196
|
-
})
|
|
197
|
-
},
|
|
172
|
+
get: () => settings[settings.rotate ? 'responsiveHeight' : 'responsiveWidth'],
|
|
173
|
+
set: (value) => { settings[settings.rotate ? 'responsiveHeight' : 'responsiveWidth'] = value },
|
|
198
174
|
})
|
|
199
175
|
const responsiveHeight = computed({
|
|
200
|
-
get: () =>
|
|
201
|
-
set: (value) => {
|
|
202
|
-
updateSettings({
|
|
203
|
-
[props.settings.rotate ? 'responsiveWidth' : 'responsiveHeight']: value,
|
|
204
|
-
})
|
|
205
|
-
},
|
|
176
|
+
get: () => settings[settings.rotate ? 'responsiveWidth' : 'responsiveHeight'],
|
|
177
|
+
set: (value) => { settings[settings.rotate ? 'responsiveWidth' : 'responsiveHeight'] = value },
|
|
206
178
|
})
|
|
207
179
|
|
|
208
180
|
const horizontalDragger = ref<HTMLDivElement>()
|
|
209
181
|
const verticalDragger = ref<HTMLDivElement>()
|
|
210
182
|
const cornerDragger = ref<HTMLDivElement>()
|
|
183
|
+
const previewWrapper = ref<HTMLDivElement>()
|
|
211
184
|
|
|
212
|
-
useDragger(horizontalDragger, responsiveWidth,
|
|
213
|
-
useDragger(verticalDragger, responsiveHeight,
|
|
214
|
-
useDragger(cornerDragger, responsiveWidth,
|
|
215
|
-
useDragger(cornerDragger, responsiveHeight,
|
|
185
|
+
useDragger(horizontalDragger, responsiveWidth, 32, 20000, 'x')
|
|
186
|
+
useDragger(verticalDragger, responsiveHeight, 32, 20000, 'y')
|
|
187
|
+
useDragger(cornerDragger, responsiveWidth, 32, 20000, 'x')
|
|
188
|
+
useDragger(cornerDragger, responsiveHeight, 32, 20000, 'y')
|
|
216
189
|
|
|
217
190
|
// Handle rotate
|
|
218
191
|
|
|
219
|
-
const finalWidth = computed(() =>
|
|
220
|
-
const finalHeight = computed(() =>
|
|
192
|
+
const finalWidth = computed(() => settings.rotate ? settings.responsiveHeight : settings.responsiveWidth)
|
|
193
|
+
const finalHeight = computed(() => settings.rotate ? settings.responsiveWidth : settings.responsiveHeight)
|
|
194
|
+
|
|
195
|
+
// Disabled responsive
|
|
196
|
+
|
|
197
|
+
const isResponsiveEnabled = computed(() => !props.variant.responsiveDisabled)
|
|
221
198
|
</script>
|
|
222
199
|
|
|
223
200
|
<template>
|
|
224
201
|
<div class="htw-w-full htw-h-full htw-flex-1 htw-border htw-border-gray-100 dark:htw-border-gray-800 htw-rounded-lg htw-relative htw-overflow-hidden">
|
|
225
|
-
<div
|
|
202
|
+
<div
|
|
203
|
+
v-if="isResponsiveEnabled"
|
|
204
|
+
class="htw-absolute htw-inset-0 htw-w-full htw-h-full htw-bg-gray-200 dark:htw-bg-gray-850 htw-rounded-r-lg htw-border-l-2 htw-border-gray-500/10 dark:htw-border-gray-700/30 htw-overflow-hidden"
|
|
205
|
+
>
|
|
226
206
|
<HatchedPattern
|
|
227
207
|
class="htw-w-full htw-h-full htw-text-black/[2%] dark:htw-text-white/[2%]"
|
|
228
208
|
/>
|
|
229
209
|
</div>
|
|
230
210
|
|
|
231
|
-
<div
|
|
211
|
+
<div
|
|
212
|
+
ref="previewWrapper"
|
|
213
|
+
class="htw-h-full htw-overflow-auto htw-relative"
|
|
214
|
+
>
|
|
232
215
|
<div
|
|
233
216
|
class="htw-h-full htw-p-4 htw-overflow-hidden htw-bg-white dark:htw-bg-gray-700 htw-rounded-lg htw-relative"
|
|
234
|
-
:
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}"
|
|
217
|
+
:class="isResponsiveEnabled ? {
|
|
218
|
+
'htw-w-fit': !!finalWidth,
|
|
219
|
+
'htw-h-fit': !!finalHeight
|
|
220
|
+
} : undefined"
|
|
238
221
|
>
|
|
239
222
|
<div class="htw-p-4 htw-h-full htw-relative">
|
|
240
223
|
<div class="htw-w-full htw-h-full htw-border htw-border-gray-100 dark:htw-border-gray-800 htw-rounded-sm htw-relative">
|
|
@@ -253,6 +236,10 @@ const finalHeight = computed(() => props.settings.rotate ? props.settings.respon
|
|
|
253
236
|
'htw-invisible': !isIframeLoaded,
|
|
254
237
|
'htw-pointer-events-none': resizing,
|
|
255
238
|
}"
|
|
239
|
+
:style="isResponsiveEnabled ? {
|
|
240
|
+
width: finalWidth ? `${finalWidth}px` : null,
|
|
241
|
+
height: finalHeight ? `${finalHeight}px` : null,
|
|
242
|
+
} : undefined"
|
|
256
243
|
data-test-id="preview-iframe"
|
|
257
244
|
@load="onIframeLoad()"
|
|
258
245
|
/>
|
|
@@ -270,29 +257,37 @@ const finalHeight = computed(() => props.settings.rotate ? props.settings.respon
|
|
|
270
257
|
</div>
|
|
271
258
|
|
|
272
259
|
<!-- Resize Dragger -->
|
|
273
|
-
<
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
260
|
+
<template v-if="isResponsiveEnabled">
|
|
261
|
+
<div
|
|
262
|
+
ref="horizontalDragger"
|
|
263
|
+
class="htw-absolute htw-w-4 htw-top-0 htw-bottom-4 htw-right-0 hover:htw-bg-primary-100 dark:hover:htw-bg-primary-800 htw-flex htw-items-center htw-justify-center htw-cursor-ew-resize htw-group hover:htw-text-primary-500"
|
|
264
|
+
>
|
|
265
|
+
<Icon
|
|
266
|
+
icon="mdi:drag-vertical-variant"
|
|
267
|
+
class="htw-w-4 htw-h-4 htw-opacity-20 group-hover:htw-opacity-90"
|
|
268
|
+
/>
|
|
269
|
+
</div>
|
|
270
|
+
<div
|
|
271
|
+
ref="verticalDragger"
|
|
272
|
+
class="htw-absolute htw-h-4 htw-left-0 htw-right-4 htw-bottom-0 hover:htw-bg-primary-100 dark:hover:htw-bg-primary-800 htw-flex htw-items-center htw-justify-center htw-cursor-ns-resize htw-group hover:htw-text-primary-500"
|
|
273
|
+
>
|
|
274
|
+
<Icon
|
|
275
|
+
icon="mdi:drag-horizontal-variant"
|
|
276
|
+
class="htw-w-4 htw-h-4 htw-opacity-20 group-hover:htw-opacity-90"
|
|
277
|
+
/>
|
|
278
|
+
</div>
|
|
279
|
+
<div
|
|
280
|
+
ref="cornerDragger"
|
|
281
|
+
class="htw-absolute htw-w-4 htw-h-4 htw-right-0 htw-bottom-0 hover:htw-bg-primary-100 dark:hover:htw-bg-primary-800 htw-flex htw-items-center htw-justify-center htw-cursor-nwse-resize htw-group hover:htw-text-primary-500"
|
|
289
282
|
/>
|
|
290
|
-
</
|
|
291
|
-
<div
|
|
292
|
-
ref="cornerDragger"
|
|
293
|
-
class="htw-absolute htw-w-4 htw-h-4 htw-right-0 htw-bottom-0 hover:htw-bg-primary-100 dark:hover:htw-bg-primary-800 htw-flex htw-items-center htw-justify-center htw-cursor-nwse-resize htw-group hover:htw-text-primary-500"
|
|
294
|
-
/>
|
|
283
|
+
</template>
|
|
295
284
|
</div>
|
|
296
285
|
</div>
|
|
297
286
|
</div>
|
|
298
287
|
</template>
|
|
288
|
+
|
|
289
|
+
<style scoped>
|
|
290
|
+
.bind-preview-bg {
|
|
291
|
+
background-color: v-bind('settings.backgroundColor');
|
|
292
|
+
}
|
|
293
|
+
</style>
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { computed, onMounted, PropType, ref, shallowRef, watch } from 'vue'
|
|
3
3
|
import { getHighlighter, Highlighter, setCDN } from 'shiki'
|
|
4
|
-
import {
|
|
4
|
+
import { HstCopyIcon } from '@histoire/controls'
|
|
5
5
|
import { generateSourceCode } from '../../codegen/vue3'
|
|
6
6
|
import type { Variant } from '../../types'
|
|
7
7
|
import { isDark } from '../../util/dark'
|
|
8
8
|
import { unindent } from '../../codegen/util'
|
|
9
|
-
import { useClipboard } from '@vueuse/core'
|
|
10
9
|
|
|
11
10
|
const props = defineProps({
|
|
12
11
|
variant: {
|
|
@@ -59,11 +58,6 @@ const sourceHtml = computed(() => highlighter.value?.codeToHtml(sourceCode.value
|
|
|
59
58
|
lang: 'html',
|
|
60
59
|
theme: isDark.value ? 'github-dark' : 'github-light',
|
|
61
60
|
}))
|
|
62
|
-
|
|
63
|
-
// Copy
|
|
64
|
-
const { copy, copied } = useClipboard()
|
|
65
|
-
|
|
66
|
-
const copySourceCode = () => copy(sourceCode.value)
|
|
67
61
|
</script>
|
|
68
62
|
|
|
69
63
|
<template>
|
|
@@ -97,16 +91,8 @@ const copySourceCode = () => copy(sourceCode.value)
|
|
|
97
91
|
v-if="!error"
|
|
98
92
|
class="htw-absolute htw-top-2 htw-right-6 htw-p-1 htw-bg-gray-100 dark:htw-bg-gray-800"
|
|
99
93
|
>
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
content: 'Copied!',
|
|
103
|
-
triggers: [],
|
|
104
|
-
shown: copied,
|
|
105
|
-
distance: 12,
|
|
106
|
-
}"
|
|
107
|
-
icon="cil:copy"
|
|
108
|
-
class="htw-w-4 htw-h-4 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
|
|
109
|
-
@click="copySourceCode()"
|
|
94
|
+
<HstCopyIcon
|
|
95
|
+
:content="sourceCode"
|
|
110
96
|
/>
|
|
111
97
|
</div>
|
|
112
98
|
</div>
|
|
@@ -28,11 +28,11 @@ const { variant } = toRefs(props)
|
|
|
28
28
|
const { isActive, targetRoute } = useCurrentVariantRoute(variant)
|
|
29
29
|
|
|
30
30
|
Object.assign(props.variant, {
|
|
31
|
-
|
|
31
|
+
previewReady: false,
|
|
32
32
|
})
|
|
33
33
|
function onReady () {
|
|
34
34
|
Object.assign(props.variant, {
|
|
35
|
-
|
|
35
|
+
previewReady: true,
|
|
36
36
|
})
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -47,7 +47,7 @@ const el = ref<HTMLDivElement>()
|
|
|
47
47
|
const { autoScroll } = useScrollOnActive(isActive, el)
|
|
48
48
|
|
|
49
49
|
useResizeObserver(el, () => {
|
|
50
|
-
if (props.variant.
|
|
50
|
+
if (props.variant.previewReady) {
|
|
51
51
|
emit('resize', el.value!.clientWidth, el.value!.clientHeight)
|
|
52
52
|
if (isActive.value) {
|
|
53
53
|
autoScroll()
|
|
@@ -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 './
|
|
8
|
-
import StoryVariantResponsiveSize from './
|
|
9
|
-
import StoryVariantBackground from './
|
|
10
|
-
import StoryVariantNewTab from './
|
|
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
|
|
31
|
-
|
|
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
|
/>
|
|
@@ -43,6 +43,7 @@ watch(variant, () => {
|
|
|
43
43
|
class="htw-p-2 htw-h-full"
|
|
44
44
|
>
|
|
45
45
|
<StoryVariantSingleView
|
|
46
|
+
v-if="storyStore.currentVariant.configReady"
|
|
46
47
|
:variant="storyStore.currentVariant"
|
|
47
48
|
:story="storyStore.currentStory"
|
|
48
49
|
/>
|
|
@@ -81,6 +82,7 @@ watch(variant, () => {
|
|
|
81
82
|
class="htw-p-2 htw-h-full"
|
|
82
83
|
>
|
|
83
84
|
<StoryVariantSingleView
|
|
85
|
+
v-if="storyStore.currentVariant.configReady"
|
|
84
86
|
:variant="storyStore.currentVariant"
|
|
85
87
|
:story="storyStore.currentStory"
|
|
86
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 =
|
|
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
|
|
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 =
|
|
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
|
|
|
File without changes
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { Story, TreeGroup, TreeFolder, TreeLeaf } 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 { useStoryStore } from '../../stores/story'
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(defineProps<{
|
|
10
|
+
path?: Array<string>
|
|
11
|
+
group: TreeGroup
|
|
12
|
+
stories: Story[]
|
|
13
|
+
}>(), {
|
|
14
|
+
path: () => [],
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const storyStore = useStoryStore()
|
|
18
|
+
|
|
19
|
+
const folderPath = computed(() => [...props.path, props.group.title])
|
|
20
|
+
const isFolderOpen = computed(() => storyStore.isFolderOpened(folderPath.value, true))
|
|
21
|
+
|
|
22
|
+
function toggleOpen () {
|
|
23
|
+
storyStore.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>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type { Story, Tree, TreeFolder, TreeLeaf } from '../../types'
|
|
2
|
+
import type { Story, Tree, TreeGroup, TreeFolder, TreeLeaf } from '../../types'
|
|
3
3
|
import StoryListItem from './StoryListItem.vue'
|
|
4
4
|
import StoryListFolder from './StoryListFolder.vue'
|
|
5
|
+
import StoryGroup from './StoryGroup.vue'
|
|
5
6
|
|
|
6
7
|
const props = defineProps<{
|
|
7
8
|
tree: Tree
|
|
@@ -15,8 +16,13 @@ const props = defineProps<{
|
|
|
15
16
|
v-for="element of tree"
|
|
16
17
|
:key="element.title"
|
|
17
18
|
>
|
|
19
|
+
<StoryGroup
|
|
20
|
+
v-if="(element as TreeGroup).group"
|
|
21
|
+
:group="(element as TreeGroup)"
|
|
22
|
+
:stories="stories"
|
|
23
|
+
/>
|
|
18
24
|
<StoryListFolder
|
|
19
|
-
v-if="(element as TreeFolder).children"
|
|
25
|
+
v-else-if="(element as TreeFolder).children"
|
|
20
26
|
:folder="(element as TreeFolder)"
|
|
21
27
|
:stories="stories"
|
|
22
28
|
/>
|
package/{dist/client/app/components/story → src/client/app/components/tree}/StoryListFolder.vue
RENAMED
|
@@ -25,7 +25,7 @@ function toggleOpen () {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const folderPadding = computed(() => {
|
|
28
|
-
return (props.depth *
|
|
28
|
+
return (props.depth * 12) + 'px'
|
|
29
29
|
})
|
|
30
30
|
</script>
|
|
31
31
|
|
|
@@ -34,13 +34,13 @@ const folderPadding = computed(() => {
|
|
|
34
34
|
<div
|
|
35
35
|
role="button"
|
|
36
36
|
tabindex="0"
|
|
37
|
-
class="htw-px-0.5 htw-py-2 md:htw-py-1.5 htw-
|
|
37
|
+
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"
|
|
38
38
|
@click="toggleOpen"
|
|
39
39
|
@keyup.enter="toggleOpen"
|
|
40
40
|
@keyup.space="toggleOpen"
|
|
41
41
|
>
|
|
42
42
|
<span class="bind-tree-padding htw-flex htw-items-center htw-gap-2 htw-min-w-0">
|
|
43
|
-
<span class="htw-flex htw-
|
|
43
|
+
<span class="htw-flex htw-flex-none htw-items-center">
|
|
44
44
|
<Icon
|
|
45
45
|
icon="carbon:caret-right"
|
|
46
46
|
class="htw-w-4 htw-h-4 htw-transition-transform htw-duration-150 htw-opacity-30"
|
|
@@ -56,6 +56,8 @@ const folderPadding = computed(() => {
|
|
|
56
56
|
<span class="htw-truncate">{{ folder.title }}</span>
|
|
57
57
|
</span>
|
|
58
58
|
</div>
|
|
59
|
+
|
|
60
|
+
<!-- Children -->
|
|
59
61
|
<div
|
|
60
62
|
v-if="isFolderOpen"
|
|
61
63
|
>
|
|
@@ -66,7 +68,7 @@ const folderPadding = computed(() => {
|
|
|
66
68
|
<StoryListFolder
|
|
67
69
|
v-if="(element as TreeFolder).children"
|
|
68
70
|
:path="folderPath"
|
|
69
|
-
:folder="element"
|
|
71
|
+
:folder="(element as TreeFolder)"
|
|
70
72
|
:stories="stories"
|
|
71
73
|
:depth="depth + 1"
|
|
72
74
|
/>
|
package/{dist/client/app/components/story → src/client/app/components/tree}/StoryListItem.vue
RENAMED
|
@@ -14,7 +14,7 @@ const props = withDefaults(defineProps<{
|
|
|
14
14
|
})
|
|
15
15
|
|
|
16
16
|
const filePadding = computed(() => {
|
|
17
|
-
return (props.depth *
|
|
17
|
+
return (props.depth * 12) + 'px'
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
const route = useRoute()
|
|
@@ -36,9 +36,9 @@ useScrollOnActive(active, el)
|
|
|
36
36
|
storyId: story.id,
|
|
37
37
|
},
|
|
38
38
|
}"
|
|
39
|
-
class="htw-pl-0.5 htw-pr-2 htw-py-2 md:htw-py-1.5 htw-
|
|
39
|
+
class="htw-pl-0.5 htw-pr-2 htw-py-2 md:htw-py-1.5 htw-mx-1 htw-rounded-sm"
|
|
40
40
|
>
|
|
41
|
-
<span class="bind-tree-margin htw-flex htw-items-center htw-gap-2 htw-pl-
|
|
41
|
+
<span class="bind-tree-margin htw-flex htw-items-center htw-gap-2 htw-pl-4 htw-min-w-0">
|
|
42
42
|
<Icon
|
|
43
43
|
:icon="story.icon ?? 'carbon:cube'"
|
|
44
44
|
class="base-list-item-link-icon htw-w-5 htw-h-5 sm:htw-w-4 sm:htw-h-4 htw-flex-none"
|
|
@@ -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
|
+
})
|