histoire 0.1.3 → 0.1.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.
- package/dist/client/app/App.vue +15 -0
- package/dist/client/app/components/app/AppHeader.vue +6 -6
- package/dist/client/app/components/app/Breadcrumb.vue +98 -0
- package/dist/client/app/components/app/MobileOverlay.vue +34 -0
- package/dist/client/app/components/misc/HatchedPattern.vue +11 -23
- package/dist/client/app/components/search/SearchItem.vue +1 -1
- package/dist/client/app/components/search/SearchModal.vue +2 -2
- package/dist/client/app/components/story/StoryListFolder.vue +2 -2
- package/dist/client/app/components/story/StoryListItem.vue +2 -2
- package/dist/client/app/components/story/StoryResponsivePreview.vue +52 -8
- package/dist/client/app/components/story/StorySidePanel.vue +68 -0
- package/dist/client/app/components/story/StoryVariantListItem.vue +2 -2
- package/dist/client/app/components/story/StoryVariantSingleView.vue +5 -1
- package/dist/client/app/components/story/StoryView.vue +10 -121
- package/dist/client/app/components/story/StoryViewer.vue +157 -0
- package/dist/client/app/stores/story.ts +1 -1
- package/dist/client/app/style/{floating-vue.css → floating-vue.pcss} +0 -0
- package/dist/client/app/style/{main.css → main.pcss} +13 -3
- package/dist/client/app/style/transitions.pcss +26 -0
- package/dist/client/app/util/responsive.d.ts +1 -0
- package/dist/client/app/util/responsive.js +2 -0
- package/dist/client/app/util/responsive.ts +3 -0
- package/dist/style.css +158 -67
- package/package.json +3 -3
- package/src/client/app/App.vue +15 -0
- package/src/client/app/components/app/AppHeader.vue +6 -6
- package/src/client/app/components/app/Breadcrumb.vue +98 -0
- package/src/client/app/components/app/MobileOverlay.vue +34 -0
- package/src/client/app/components/misc/HatchedPattern.vue +11 -23
- package/src/client/app/components/search/SearchItem.vue +1 -1
- package/src/client/app/components/search/SearchModal.vue +2 -2
- package/src/client/app/components/story/StoryListFolder.vue +2 -2
- package/src/client/app/components/story/StoryListItem.vue +2 -2
- package/src/client/app/components/story/StoryResponsivePreview.vue +52 -8
- package/src/client/app/components/story/StorySidePanel.vue +68 -0
- package/src/client/app/components/story/StoryVariantListItem.vue +2 -2
- package/src/client/app/components/story/StoryVariantSingleView.vue +5 -1
- package/src/client/app/components/story/StoryView.vue +10 -121
- package/src/client/app/components/story/StoryViewer.vue +157 -0
- package/src/client/app/stores/story.ts +1 -1
- package/src/client/app/style/{floating-vue.css → floating-vue.pcss} +0 -0
- package/src/client/app/style/{main.css → main.pcss} +13 -3
- package/src/client/app/style/transitions.pcss +26 -0
- package/src/client/app/util/responsive.ts +3 -0
- package/dist/client/app/style/transitions.css +0 -12
- package/src/client/app/style/transitions.css +0 -12
package/dist/client/app/App.vue
CHANGED
|
@@ -11,6 +11,8 @@ import { mapFile } from './util/mapping'
|
|
|
11
11
|
import { useTitle } from '@vueuse/core'
|
|
12
12
|
import { histoireConfig } from './util/config.js'
|
|
13
13
|
import { onKeyboardShortcut } from './util/keyboard.js'
|
|
14
|
+
import { isMobile } from './util/responsive'
|
|
15
|
+
import Breadcrumb from './components/app/Breadcrumb.vue'
|
|
14
16
|
|
|
15
17
|
const SearchModal = defineAsyncComponent(() => import('./components/search/SearchModal.vue'))
|
|
16
18
|
|
|
@@ -79,7 +81,20 @@ onKeyboardShortcut(['ctrl+k', 'meta+k'], (event) => {
|
|
|
79
81
|
</div>
|
|
80
82
|
|
|
81
83
|
<div class="htw-h-screen dark:htw-bg-gray-700 dark:htw-text-gray-100">
|
|
84
|
+
<div
|
|
85
|
+
v-if="isMobile"
|
|
86
|
+
class="htw-h-full htw-flex htw-flex-col htw-divide-y htw-divide-gray-100 dark:htw-divide-gray-800"
|
|
87
|
+
>
|
|
88
|
+
<AppHeader @search="isSearchOpen = true" />
|
|
89
|
+
<Breadcrumb
|
|
90
|
+
:tree="tree"
|
|
91
|
+
:stories="stories"
|
|
92
|
+
/>
|
|
93
|
+
<RouterView class="htw-grow" />
|
|
94
|
+
</div>
|
|
95
|
+
|
|
82
96
|
<BaseSplitPane
|
|
97
|
+
v-else
|
|
83
98
|
save-id="main-horiz"
|
|
84
99
|
:min="5"
|
|
85
100
|
:max="50"
|
|
@@ -16,8 +16,8 @@ const themeIcon = computed(() => {
|
|
|
16
16
|
})
|
|
17
17
|
|
|
18
18
|
onKeyboardShortcut(['ctrl+shift+d', 'meta+shift+d'], (event) => {
|
|
19
|
-
toggleDark()
|
|
20
19
|
event.preventDefault()
|
|
20
|
+
toggleDark()
|
|
21
21
|
})
|
|
22
22
|
</script>
|
|
23
23
|
|
|
@@ -25,7 +25,7 @@ onKeyboardShortcut(['ctrl+shift+d', 'meta+shift+d'], (event) => {
|
|
|
25
25
|
<div
|
|
26
26
|
class="htw-px-4 htw-h-16 htw-flex htw-items-center htw-gap-2"
|
|
27
27
|
>
|
|
28
|
-
<div class="htw-py-4 htw-flex-1 htw-h-full htw-flex htw-items-center htw-pr-2">
|
|
28
|
+
<div class="htw-py-3 sm:htw-py-4 htw-flex-1 htw-h-full htw-flex htw-items-center htw-pr-2">
|
|
29
29
|
<a
|
|
30
30
|
:href="histoireConfig.theme?.logoHref"
|
|
31
31
|
target="_blank"
|
|
@@ -39,23 +39,23 @@ onKeyboardShortcut(['ctrl+shift+d', 'meta+shift+d'], (event) => {
|
|
|
39
39
|
<div class="htw-ml-auto htw-flex-none htw-flex">
|
|
40
40
|
<a
|
|
41
41
|
v-tooltip="makeTooltip('Search', ({ isMac }) => isMac ? 'meta+k' : 'ctrl+k')"
|
|
42
|
-
class="htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
|
|
42
|
+
class="htw-p-2 sm:htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
|
|
43
43
|
@click="$emit('search')"
|
|
44
44
|
>
|
|
45
45
|
<Icon
|
|
46
46
|
icon="carbon:search"
|
|
47
|
-
class="htw-w-
|
|
47
|
+
class="htw-w-6 htw-h-6 sm:htw-w-4 sm:htw-h-4"
|
|
48
48
|
/>
|
|
49
49
|
</a>
|
|
50
50
|
|
|
51
51
|
<a
|
|
52
52
|
v-tooltip="makeTooltip('Toggle dark mode', ({ isMac }) => isMac ? 'meta+shift+d' : 'ctrl+shift+d')"
|
|
53
|
-
class="htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
|
|
53
|
+
class="htw-p-2 sm:htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
|
|
54
54
|
@click="toggleDark()"
|
|
55
55
|
>
|
|
56
56
|
<Icon
|
|
57
57
|
:icon="themeIcon"
|
|
58
|
-
class="htw-w-
|
|
58
|
+
class="htw-w-6 htw-h-6 sm:htw-w-4 sm:htw-h-4"
|
|
59
59
|
/>
|
|
60
60
|
</a>
|
|
61
61
|
</div>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, ref, watch } from 'vue'
|
|
3
|
+
import { Icon } from '@iconify/vue'
|
|
4
|
+
import { useStoryStore } from '../../stores/story'
|
|
5
|
+
import { Story, Tree } from '../../types'
|
|
6
|
+
import MobileOverlay from './MobileOverlay.vue'
|
|
7
|
+
import StoryList from '../story/StoryList.vue'
|
|
8
|
+
|
|
9
|
+
const props = defineProps<{
|
|
10
|
+
tree: Tree
|
|
11
|
+
stories: Story[]
|
|
12
|
+
}>()
|
|
13
|
+
|
|
14
|
+
const storyStore = useStoryStore()
|
|
15
|
+
|
|
16
|
+
const story = computed(() => storyStore.currentStory)
|
|
17
|
+
|
|
18
|
+
const folders = computed(() => {
|
|
19
|
+
return story.value.file.path.slice(0, -1)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const isMenuOpened = ref(false)
|
|
23
|
+
|
|
24
|
+
function openMenu () {
|
|
25
|
+
isMenuOpened.value = true
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function closeMenu () {
|
|
29
|
+
isMenuOpened.value = false
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
watch(story, () => {
|
|
33
|
+
isMenuOpened.value = false
|
|
34
|
+
})
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<div>
|
|
39
|
+
<a
|
|
40
|
+
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"
|
|
41
|
+
@click="openMenu"
|
|
42
|
+
>
|
|
43
|
+
<template v-if="story">
|
|
44
|
+
<template
|
|
45
|
+
v-for="(file, key) of folders"
|
|
46
|
+
:key="key"
|
|
47
|
+
>
|
|
48
|
+
<span>
|
|
49
|
+
{{ file }}
|
|
50
|
+
</span>
|
|
51
|
+
<span class="htw-opacity-40">
|
|
52
|
+
/
|
|
53
|
+
</span>
|
|
54
|
+
</template>
|
|
55
|
+
<span class="htw-flex htw-items-center htw-gap-2">
|
|
56
|
+
<Icon
|
|
57
|
+
:icon="story.icon ?? 'carbon:cube'"
|
|
58
|
+
class="base-list-item-link-icon htw-w-5 htw-h-5 htw-flex-none"
|
|
59
|
+
:class="{
|
|
60
|
+
'htw-text-primary-500': !story.iconColor,
|
|
61
|
+
'bind-icon-color': story.iconColor,
|
|
62
|
+
}"
|
|
63
|
+
/>
|
|
64
|
+
{{ story.title }}
|
|
65
|
+
<span class="htw-opacity-40 htw-text-sm">
|
|
66
|
+
{{ story.variants.length }}
|
|
67
|
+
</span>
|
|
68
|
+
</span>
|
|
69
|
+
</template>
|
|
70
|
+
<template v-else>
|
|
71
|
+
Select a story...
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<Icon
|
|
75
|
+
icon="carbon:chevron-sort"
|
|
76
|
+
class="htw-w-5 htw-h-5 htw-shrink-0 htw-ml-auto"
|
|
77
|
+
/>
|
|
78
|
+
</a>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<MobileOverlay
|
|
82
|
+
title="Select a story"
|
|
83
|
+
:opened="isMenuOpened"
|
|
84
|
+
@close="closeMenu"
|
|
85
|
+
>
|
|
86
|
+
<StoryList
|
|
87
|
+
:tree="tree"
|
|
88
|
+
:stories="stories"
|
|
89
|
+
class="htw-flex-1 htw-overflow-y-scroll"
|
|
90
|
+
/>
|
|
91
|
+
</MobileOverlay>
|
|
92
|
+
</template>
|
|
93
|
+
|
|
94
|
+
<style scoped>
|
|
95
|
+
.bind-icon-color {
|
|
96
|
+
color: v-bind('story?.iconColor');
|
|
97
|
+
}
|
|
98
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { Icon } from '@iconify/vue'
|
|
3
|
+
import { defineEmits } from '@vue/runtime-core'
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
title: string
|
|
7
|
+
opened: boolean
|
|
8
|
+
}>()
|
|
9
|
+
|
|
10
|
+
const emits = defineEmits<{(e: 'close'): void}>()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<transition name="__histoire-fade">
|
|
15
|
+
<div
|
|
16
|
+
v-if="opened"
|
|
17
|
+
class="htw-absolute htw-z-10 htw-bg-white dark:htw-bg-gray-700 htw-w-screen htw-h-screen htw-inset-0 htw-overflow-hidden htw-flex htw-flex-col"
|
|
18
|
+
>
|
|
19
|
+
<div class="htw-p-4 htw-h-16 htw-flex htw-border-b htw-border-gray-100 dark:htw-border-gray-800 htw-items-center htw-place-content-between">
|
|
20
|
+
<span class="htw-text-gray-500">{{ title }}</span>
|
|
21
|
+
<a
|
|
22
|
+
class="htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
|
|
23
|
+
@click="emits('close')"
|
|
24
|
+
>
|
|
25
|
+
<Icon
|
|
26
|
+
icon="carbon:close"
|
|
27
|
+
class="htw-w-8 htw-h-8 htw-shrink-0"
|
|
28
|
+
/>
|
|
29
|
+
</a>
|
|
30
|
+
</div>
|
|
31
|
+
<slot />
|
|
32
|
+
</div>
|
|
33
|
+
</transition>
|
|
34
|
+
</template>
|
|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<pattern
|
|
4
|
-
id="hatch"
|
|
5
|
-
width="32"
|
|
6
|
-
height="32"
|
|
7
|
-
patternUnits="userSpaceOnUse"
|
|
8
|
-
>
|
|
9
|
-
<path
|
|
10
|
-
d="M32,0 L0,32
|
|
11
|
-
M-1,1 l2,-2
|
|
12
|
-
M31,33 l2,-2"
|
|
13
|
-
stroke-width="2"
|
|
14
|
-
stroke="currentColor"
|
|
15
|
-
/>
|
|
16
|
-
</pattern>
|
|
17
|
-
<rect
|
|
18
|
-
x="0"
|
|
19
|
-
y="0"
|
|
20
|
-
width="100%"
|
|
21
|
-
height="100%"
|
|
22
|
-
fill="url(#hatch)"
|
|
23
|
-
/>
|
|
24
|
-
</svg>
|
|
2
|
+
<div class="__histoire-hatched-pattern" />
|
|
25
3
|
</template>
|
|
4
|
+
|
|
5
|
+
<style scoped>
|
|
6
|
+
.__histoire-hatched-pattern {
|
|
7
|
+
background: repeating-linear-gradient(135deg,
|
|
8
|
+
transparent 0px,
|
|
9
|
+
transparent 32px,
|
|
10
|
+
currentColor 32px,
|
|
11
|
+
currentColor 64px);
|
|
12
|
+
}
|
|
13
|
+
</style>
|
|
@@ -131,7 +131,7 @@ function selectPrevious () {
|
|
|
131
131
|
<template>
|
|
132
132
|
<div
|
|
133
133
|
v-show="shown"
|
|
134
|
-
class="htw-fixed htw-inset-0 htw-bg-white/80 dark:htw-bg-gray-700/80"
|
|
134
|
+
class="htw-fixed htw-inset-0 htw-bg-white/80 dark:htw-bg-gray-700/80 htw-z-20"
|
|
135
135
|
>
|
|
136
136
|
<div
|
|
137
137
|
class="htw-absolute htw-inset-0"
|
|
@@ -144,7 +144,7 @@ function selectPrevious () {
|
|
|
144
144
|
>
|
|
145
145
|
<Icon
|
|
146
146
|
icon="carbon:search"
|
|
147
|
-
class="flex-none htw-w-
|
|
147
|
+
class="flex-none htw-w-4 htw-h-4"
|
|
148
148
|
/>
|
|
149
149
|
|
|
150
150
|
<input
|
|
@@ -34,7 +34,7 @@ const folderPadding = computed(() => {
|
|
|
34
34
|
<div
|
|
35
35
|
role="button"
|
|
36
36
|
tabindex="0"
|
|
37
|
-
class="htw-px-0.5 htw-py-1.5 htw-m-1 htw-rounded-sm hover:htw-bg-primary-100 dark:hover:htw-bg-primary-900 htw-cursor-pointer htw-select-none htw-flex"
|
|
37
|
+
class="htw-px-0.5 htw-py-2 md:htw-py-1.5 htw-m-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"
|
|
@@ -50,7 +50,7 @@ const folderPadding = computed(() => {
|
|
|
50
50
|
/>
|
|
51
51
|
<Icon
|
|
52
52
|
icon="carbon:folder"
|
|
53
|
-
class="htw-w-5 htw-h-5"
|
|
53
|
+
class="htw-w-5 htw-h-5 sm:htw-w-4 sm:htw-h-4"
|
|
54
54
|
/>
|
|
55
55
|
</span>
|
|
56
56
|
<span class="htw-truncate">{{ folder.title }}</span>
|
|
@@ -33,12 +33,12 @@ useScrollOnActive(active, el)
|
|
|
33
33
|
storyId: story.id,
|
|
34
34
|
},
|
|
35
35
|
}"
|
|
36
|
-
class="htw-pl-0.5 htw-pr-2 htw-py-1.5 htw-m-1 htw-rounded-sm"
|
|
36
|
+
class="htw-pl-0.5 htw-pr-2 htw-py-2 md:htw-py-1.5 htw-m-1 htw-rounded-sm"
|
|
37
37
|
>
|
|
38
38
|
<span class="bind-tree-margin htw-flex htw-items-center htw-gap-2 htw-pl-5 htw-min-w-0">
|
|
39
39
|
<Icon
|
|
40
40
|
:icon="story.icon ?? 'carbon:cube'"
|
|
41
|
-
class="base-list-item-link-icon htw-w-5 htw-h-5 htw-flex-none"
|
|
41
|
+
class="base-list-item-link-icon htw-w-5 htw-h-5 sm:htw-w-4 sm:htw-h-4 htw-flex-none"
|
|
42
42
|
:class="{
|
|
43
43
|
'htw-text-primary-500': !active && !story.iconColor,
|
|
44
44
|
'bind-icon-color': !active && story.iconColor,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed, Ref, ref, toRaw, watch } from 'vue'
|
|
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
5
|
import { STATE_SYNC, PREVIEW_SETTINGS_SYNC, SANDBOX_READY } from '../../util/const'
|
|
@@ -103,26 +103,70 @@ function onIframeLoad () {
|
|
|
103
103
|
|
|
104
104
|
const resizing = ref(false)
|
|
105
105
|
|
|
106
|
+
const onUnmountedCleanupFns: (() => unknown)[] = []
|
|
107
|
+
onUnmounted(() => {
|
|
108
|
+
onUnmountedCleanupFns.forEach(fn => fn())
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
function addWindowListener (event: string, listener: (event: any) => unknown) {
|
|
112
|
+
window.addEventListener(event, listener)
|
|
113
|
+
const removeListener = () => window.removeEventListener(event, listener)
|
|
114
|
+
onUnmountedCleanupFns.push(removeListener)
|
|
115
|
+
return () => {
|
|
116
|
+
removeListener()
|
|
117
|
+
onUnmountedCleanupFns.splice(onUnmountedCleanupFns.indexOf(removeListener), 1)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
106
121
|
function useDragger (el: Ref<HTMLDivElement>, value: Ref<number>, min: number, max: number, axis: 'x' | 'y') {
|
|
107
|
-
|
|
122
|
+
function onMouseDown (event: MouseEvent) {
|
|
108
123
|
event.preventDefault()
|
|
109
124
|
event.stopPropagation()
|
|
110
125
|
const start = axis === 'x' ? event.clientX : event.clientY
|
|
111
126
|
const startValue = value.value || (axis === 'x' ? iframe.value.offsetWidth : iframe.value.offsetHeight)
|
|
112
127
|
resizing.value = true
|
|
113
|
-
|
|
128
|
+
|
|
129
|
+
const removeListeners = [
|
|
130
|
+
addWindowListener('mousemove', onMouseMove),
|
|
131
|
+
addWindowListener('mouseup', onMouseUp),
|
|
132
|
+
]
|
|
133
|
+
|
|
134
|
+
function onMouseMove (event: MouseEvent) {
|
|
114
135
|
const delta = (axis === 'x' ? event.clientX : event.clientY) - start
|
|
115
136
|
value.value = Math.max(min, Math.min(max, startValue + delta))
|
|
116
137
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
138
|
+
|
|
139
|
+
function onMouseUp () {
|
|
140
|
+
removeListeners.forEach(fn => fn())
|
|
120
141
|
resizing.value = false
|
|
121
142
|
}
|
|
122
|
-
window.addEventListener('mousemove', onMouseMove)
|
|
123
|
-
window.addEventListener('mouseup', onMouseUp)
|
|
124
143
|
}
|
|
125
144
|
useEventListener(el, 'mousedown', onMouseDown)
|
|
145
|
+
|
|
146
|
+
function onTouchStart (event: TouchEvent) {
|
|
147
|
+
event.preventDefault()
|
|
148
|
+
event.stopPropagation()
|
|
149
|
+
const start = axis === 'x' ? event.touches[0].clientX : event.touches[0].clientY
|
|
150
|
+
const startValue = value.value || (axis === 'x' ? iframe.value.offsetWidth : iframe.value.offsetHeight)
|
|
151
|
+
resizing.value = true
|
|
152
|
+
|
|
153
|
+
const removeListeners = [
|
|
154
|
+
addWindowListener('touchmove', onTouchMove),
|
|
155
|
+
addWindowListener('touchend', onTouchEnd),
|
|
156
|
+
addWindowListener('touchcancel', onTouchEnd),
|
|
157
|
+
]
|
|
158
|
+
|
|
159
|
+
function onTouchMove (event: TouchEvent) {
|
|
160
|
+
const delta = (axis === 'x' ? event.touches[0].clientX : event.touches[0].clientY) - start
|
|
161
|
+
value.value = Math.max(min, Math.min(max, startValue + delta))
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function onTouchEnd () {
|
|
165
|
+
removeListeners.forEach(fn => fn())
|
|
166
|
+
resizing.value = false
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
useEventListener(el, 'touchstart', onTouchStart)
|
|
126
170
|
}
|
|
127
171
|
|
|
128
172
|
// Optimize by batching settings updates to the next frame
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
3
|
+
import { useStoryStore } from '../../stores/story'
|
|
4
|
+
|
|
5
|
+
import BaseSplitPane from '../base/BaseSplitPane.vue'
|
|
6
|
+
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
7
|
+
import BaseTab from '../base/BaseTab.vue'
|
|
8
|
+
import StoryControls from './StoryControls.vue'
|
|
9
|
+
import StoryDocs from './StoryDocs.vue'
|
|
10
|
+
import StorySourceCode from './StorySourceCode.vue'
|
|
11
|
+
|
|
12
|
+
const storyStore = useStoryStore()
|
|
13
|
+
|
|
14
|
+
const router = useRouter()
|
|
15
|
+
const route = useRoute()
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<BaseEmpty v-if="!storyStore.currentVariant">
|
|
20
|
+
<span>Select a variant</span>
|
|
21
|
+
</BaseEmpty>
|
|
22
|
+
|
|
23
|
+
<BaseEmpty v-else-if="!storyStore.currentVariant.ready">
|
|
24
|
+
<span>Loading...</span>
|
|
25
|
+
</BaseEmpty>
|
|
26
|
+
|
|
27
|
+
<BaseSplitPane
|
|
28
|
+
v-else
|
|
29
|
+
save-id="story-sidepane"
|
|
30
|
+
orientation="portrait"
|
|
31
|
+
class="htw-h-full"
|
|
32
|
+
>
|
|
33
|
+
<template #first>
|
|
34
|
+
<div class="htw-flex htw-flex-col htw-h-full">
|
|
35
|
+
<nav class="htw-h-10 htw-flex-none htw-border-b htw-border-gray-100 dark:htw-border-gray-750">
|
|
36
|
+
<BaseTab
|
|
37
|
+
:to="{ ...$route, query: { ...$route.query, tab: '' } }"
|
|
38
|
+
:matched="!$route.query.tab"
|
|
39
|
+
>
|
|
40
|
+
Controls
|
|
41
|
+
</BaseTab>
|
|
42
|
+
<BaseTab
|
|
43
|
+
:to="{ ...$route, query: { ...$route.query, tab: 'docs' } }"
|
|
44
|
+
:matched="$route.query.tab === 'docs'"
|
|
45
|
+
>
|
|
46
|
+
Docs
|
|
47
|
+
</BaseTab>
|
|
48
|
+
</nav>
|
|
49
|
+
|
|
50
|
+
<component
|
|
51
|
+
:is="$route.query.tab === 'docs'
|
|
52
|
+
? StoryDocs
|
|
53
|
+
: StoryControls"
|
|
54
|
+
:story="storyStore.currentStory"
|
|
55
|
+
:variant="storyStore.currentVariant"
|
|
56
|
+
class="htw-h-full htw-overflow-auto"
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<template #last>
|
|
62
|
+
<StorySourceCode
|
|
63
|
+
:variant="storyStore.currentVariant"
|
|
64
|
+
class="htw-h-full"
|
|
65
|
+
/>
|
|
66
|
+
</template>
|
|
67
|
+
</BaseSplitPane>
|
|
68
|
+
</template>
|
|
@@ -25,11 +25,11 @@ useScrollOnActive(isActive, el)
|
|
|
25
25
|
v-slot="{ active }"
|
|
26
26
|
:to="targetRoute"
|
|
27
27
|
:is-active="isActive"
|
|
28
|
-
class="htw-px-2 htw-py-1.5 htw-m-1 htw-rounded-sm htw-flex htw-items-center htw-gap-2"
|
|
28
|
+
class="htw-px-2 htw-py-2 md:htw-py-1.5 htw-m-1 htw-rounded-sm htw-flex htw-items-center htw-gap-2"
|
|
29
29
|
>
|
|
30
30
|
<Icon
|
|
31
31
|
:icon="variant.icon ?? 'carbon:cube'"
|
|
32
|
-
class="base-list-item-link-icon htw-w-5 htw-h-5 htw-flex-none"
|
|
32
|
+
class="base-list-item-link-icon htw-w-5 htw-h-5 sm:htw-w-4 sm:htw-h-4 htw-flex-none"
|
|
33
33
|
:class="{
|
|
34
34
|
'htw-text-gray-500': !active && !variant.iconColor,
|
|
35
35
|
'bind-icon-color': !active && variant.iconColor,
|
|
@@ -5,6 +5,7 @@ import type { Story, Variant } from '../../types'
|
|
|
5
5
|
import { histoireConfig } from '../../util/config'
|
|
6
6
|
import { usePreviewSettings } from '../../util/preview-settings'
|
|
7
7
|
import StoryResponsivePreview from './StoryResponsivePreview.vue'
|
|
8
|
+
import { isMobile } from '../../util/responsive'
|
|
8
9
|
|
|
9
10
|
defineProps({
|
|
10
11
|
variant: {
|
|
@@ -24,7 +25,10 @@ const settings = usePreviewSettings()
|
|
|
24
25
|
<template>
|
|
25
26
|
<div class="htw-h-full htw-flex htw-flex-col">
|
|
26
27
|
<!-- Toolbar -->
|
|
27
|
-
<div
|
|
28
|
+
<div
|
|
29
|
+
v-if="!isMobile"
|
|
30
|
+
class="htw-flex-none htw-flex htw-items-center htw-h-8 -htw-mt-1"
|
|
31
|
+
>
|
|
28
32
|
<!-- Variant title -->
|
|
29
33
|
<div class="htw-flex htw-items-center htw-gap-1 htw-text-gray-500 htw-flex-1 htw-truncate htw-min-w-0">
|
|
30
34
|
<Icon
|
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import { watch } from 'vue'
|
|
3
3
|
import { useRoute, useRouter } from 'vue-router'
|
|
4
4
|
import { useStoryStore } from '../../stores/story'
|
|
5
5
|
|
|
6
6
|
import BaseSplitPane from '../base/BaseSplitPane.vue'
|
|
7
7
|
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import StoryVariantSingleView from './StoryVariantSingleView.vue'
|
|
12
|
-
import StoryControls from './StoryControls.vue'
|
|
13
|
-
import StoryDocs from './StoryDocs.vue'
|
|
14
|
-
import StorySourceCode from './StorySourceCode.vue'
|
|
8
|
+
import { isMobile } from '../../util/responsive'
|
|
9
|
+
import StoryViewer from './StoryViewer.vue'
|
|
10
|
+
import StorySidePanel from './StorySidePanel.vue'
|
|
15
11
|
|
|
16
12
|
const storyStore = useStoryStore()
|
|
17
13
|
|
|
18
14
|
const router = useRouter()
|
|
19
15
|
const route = useRoute()
|
|
20
16
|
|
|
21
|
-
// Selected variant
|
|
22
|
-
|
|
23
|
-
const hasSingleVariant = computed(() => (storyStore.currentStory?.variants.length === 1))
|
|
24
|
-
|
|
25
17
|
// Restore variant selection
|
|
26
18
|
|
|
27
19
|
watch(() => storyStore.currentVariant, value => {
|
|
@@ -67,7 +59,11 @@ function setVariant (variantId: string) {
|
|
|
67
59
|
v-else
|
|
68
60
|
class="htw-h-full"
|
|
69
61
|
>
|
|
62
|
+
<template v-if="isMobile">
|
|
63
|
+
<StoryViewer />
|
|
64
|
+
</template>
|
|
70
65
|
<BaseSplitPane
|
|
66
|
+
v-else
|
|
71
67
|
save-id="story-main"
|
|
72
68
|
:min="30"
|
|
73
69
|
:max="95"
|
|
@@ -75,118 +71,11 @@ function setVariant (variantId: string) {
|
|
|
75
71
|
class="htw-h-full"
|
|
76
72
|
>
|
|
77
73
|
<template #first>
|
|
78
|
-
<
|
|
79
|
-
<div
|
|
80
|
-
v-if="storyStore.currentStory.layout.type === 'grid'"
|
|
81
|
-
class="htw-h-full htw-overflow-y-auto"
|
|
82
|
-
>
|
|
83
|
-
<div
|
|
84
|
-
class="htw-grid htw-gap-4 htw-m-4"
|
|
85
|
-
:style="{
|
|
86
|
-
gridTemplateColumns: `repeat(auto-fill, ${storyStore.currentStory.layout.width ?? 200}px)`,
|
|
87
|
-
}"
|
|
88
|
-
>
|
|
89
|
-
<StoryVariantGridItem
|
|
90
|
-
v-for="(variant, index) of storyStore.currentStory.variants"
|
|
91
|
-
:key="index"
|
|
92
|
-
:variant="variant"
|
|
93
|
-
:story="storyStore.currentStory"
|
|
94
|
-
/>
|
|
95
|
-
</div>
|
|
96
|
-
</div>
|
|
97
|
-
|
|
98
|
-
<template v-else-if="storyStore.currentStory.layout.type === 'single'">
|
|
99
|
-
<div
|
|
100
|
-
v-if="hasSingleVariant && storyStore.currentVariant"
|
|
101
|
-
class="htw-p-2 htw-h-full"
|
|
102
|
-
>
|
|
103
|
-
<StoryVariantSingleView
|
|
104
|
-
:variant="storyStore.currentVariant"
|
|
105
|
-
:story="storyStore.currentStory"
|
|
106
|
-
/>
|
|
107
|
-
</div>
|
|
108
|
-
<BaseSplitPane
|
|
109
|
-
v-else
|
|
110
|
-
save-id="story-single-main-split"
|
|
111
|
-
:min="5"
|
|
112
|
-
:max="40"
|
|
113
|
-
:default-split="17"
|
|
114
|
-
>
|
|
115
|
-
<template #first>
|
|
116
|
-
<div class="htw-h-full htw-overflow-y-auto">
|
|
117
|
-
<StoryVariantListItem
|
|
118
|
-
v-for="(variant, index) of storyStore.currentStory.variants"
|
|
119
|
-
:key="index"
|
|
120
|
-
:variant="variant"
|
|
121
|
-
/>
|
|
122
|
-
</div>
|
|
123
|
-
</template>
|
|
124
|
-
<template #last>
|
|
125
|
-
<div
|
|
126
|
-
v-if="storyStore.currentVariant"
|
|
127
|
-
class="htw-p-2 htw-h-full"
|
|
128
|
-
>
|
|
129
|
-
<StoryVariantSingleView
|
|
130
|
-
:variant="storyStore.currentVariant"
|
|
131
|
-
:story="storyStore.currentStory"
|
|
132
|
-
/>
|
|
133
|
-
</div>
|
|
134
|
-
</template>
|
|
135
|
-
</BaseSplitPane>
|
|
136
|
-
</template>
|
|
137
|
-
</div>
|
|
74
|
+
<StoryViewer />
|
|
138
75
|
</template>
|
|
139
76
|
|
|
140
77
|
<template #last>
|
|
141
|
-
<
|
|
142
|
-
<span>Select a variant</span>
|
|
143
|
-
</BaseEmpty>
|
|
144
|
-
|
|
145
|
-
<BaseEmpty v-else-if="!storyStore.currentVariant.ready">
|
|
146
|
-
<span>Loading...</span>
|
|
147
|
-
</BaseEmpty>
|
|
148
|
-
|
|
149
|
-
<BaseSplitPane
|
|
150
|
-
v-else
|
|
151
|
-
save-id="story-sidepane"
|
|
152
|
-
orientation="portrait"
|
|
153
|
-
class="htw-h-full"
|
|
154
|
-
>
|
|
155
|
-
<template #first>
|
|
156
|
-
<div class="htw-flex htw-flex-col htw-h-full">
|
|
157
|
-
<nav class="htw-h-10 htw-flex-none htw-border-b htw-border-gray-100 dark:htw-border-gray-750">
|
|
158
|
-
<BaseTab
|
|
159
|
-
:to="{ ...$route, query: { ...$route.query, tab: '' } }"
|
|
160
|
-
:matched="!$route.query.tab"
|
|
161
|
-
>
|
|
162
|
-
Controls
|
|
163
|
-
</BaseTab>
|
|
164
|
-
<BaseTab
|
|
165
|
-
:to="{ ...$route, query: { ...$route.query, tab: 'docs' } }"
|
|
166
|
-
:matched="$route.query.tab === 'docs'"
|
|
167
|
-
>
|
|
168
|
-
Docs
|
|
169
|
-
</BaseTab>
|
|
170
|
-
</nav>
|
|
171
|
-
|
|
172
|
-
<component
|
|
173
|
-
:is="$route.query.tab === 'docs'
|
|
174
|
-
? StoryDocs
|
|
175
|
-
: StoryControls"
|
|
176
|
-
:story="storyStore.currentStory"
|
|
177
|
-
:variant="storyStore.currentVariant"
|
|
178
|
-
class="htw-h-full htw-overflow-auto"
|
|
179
|
-
/>
|
|
180
|
-
</div>
|
|
181
|
-
</template>
|
|
182
|
-
|
|
183
|
-
<template #last>
|
|
184
|
-
<StorySourceCode
|
|
185
|
-
:variant="storyStore.currentVariant"
|
|
186
|
-
class="htw-h-full"
|
|
187
|
-
/>
|
|
188
|
-
</template>
|
|
189
|
-
</BaseSplitPane>
|
|
78
|
+
<StorySidePanel />
|
|
190
79
|
</template>
|
|
191
80
|
</BaseSplitPane>
|
|
192
81
|
</div>
|