histoire 0.1.3 → 0.2.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/dist/client/app/App.vue +16 -1
- package/dist/client/app/components/app/AppHeader.vue +7 -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/base/BaseCheckbox.vue +76 -0
- package/dist/client/app/components/misc/HatchedPattern.vue +11 -23
- package/dist/client/app/components/search/SearchItem.vue +5 -2
- package/dist/client/app/components/search/SearchModal.vue +6 -6
- package/dist/client/app/components/story/StoryControls.vue +1 -1
- package/dist/client/app/components/story/StoryDocs.vue +1 -0
- package/dist/client/app/components/story/StoryListFolder.vue +3 -3
- package/dist/client/app/components/story/StoryListItem.vue +6 -3
- package/dist/client/app/components/story/StoryResponsivePreview.vue +53 -8
- package/dist/client/app/components/story/StorySidePanel.vue +69 -0
- package/dist/client/app/components/story/StorySourceCode.vue +4 -1
- package/dist/client/app/components/story/StoryVariantListItem.vue +6 -3
- package/dist/client/app/components/story/StoryVariantSingleView.vue +14 -10
- package/dist/client/app/components/story/StoryView.vue +10 -121
- package/dist/client/app/components/story/StoryViewer.vue +175 -0
- package/dist/client/app/stores/story.d.ts +6 -6
- package/dist/client/app/stores/story.js +2 -1
- package/dist/client/app/stores/story.ts +6 -2
- 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/types.d.ts +1 -1
- package/dist/client/app/types.ts +1 -1
- 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/node/bin.js +7 -0
- package/dist/node/build.js +1 -1
- package/dist/node/{collect.d.ts → collect/index.d.ts} +2 -2
- package/dist/node/{collect.js → collect/index.js} +37 -27
- package/dist/node/collect/worker.d.ts +14 -0
- package/dist/node/collect/worker.js +36 -0
- package/dist/node/commands/preview.d.ts +4 -0
- package/dist/node/commands/preview.js +36 -0
- package/dist/node/server.js +1 -1
- package/dist/node/types.d.ts +1 -1
- package/dist/style.css +231 -104
- package/package.json +8 -4
- package/src/client/app/App.vue +16 -1
- package/src/client/app/components/app/AppHeader.vue +7 -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/base/BaseCheckbox.vue +76 -0
- package/src/client/app/components/misc/HatchedPattern.vue +11 -23
- package/src/client/app/components/search/SearchItem.vue +5 -2
- package/src/client/app/components/search/SearchModal.vue +6 -6
- package/src/client/app/components/story/StoryControls.vue +1 -1
- package/src/client/app/components/story/StoryDocs.vue +1 -0
- package/src/client/app/components/story/StoryListFolder.vue +3 -3
- package/src/client/app/components/story/StoryListItem.vue +6 -3
- package/src/client/app/components/story/StoryResponsivePreview.vue +53 -8
- package/src/client/app/components/story/StorySidePanel.vue +69 -0
- package/src/client/app/components/story/StorySourceCode.vue +4 -1
- package/src/client/app/components/story/StoryVariantListItem.vue +6 -3
- package/src/client/app/components/story/StoryVariantSingleView.vue +14 -10
- package/src/client/app/components/story/StoryView.vue +10 -121
- package/src/client/app/components/story/StoryViewer.vue +175 -0
- package/src/client/app/stores/story.ts +6 -2
- 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/types.ts +1 -1
- package/src/client/app/util/responsive.ts +3 -0
- package/src/node/bin.ts +8 -0
- package/src/node/build.ts +1 -1
- package/src/node/{collect.ts → collect/index.ts} +48 -30
- package/src/node/collect/worker.ts +61 -0
- package/src/node/commands/preview.ts +50 -0
- package/src/node/server.ts +1 -1
- package/src/node/types.ts +1 -1
- package/dist/client/app/style/transitions.css +0 -12
- package/src/client/app/style/transitions.css +0 -12
|
@@ -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,24 @@ 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
|
+
data-test-id="search-btn"
|
|
43
44
|
@click="$emit('search')"
|
|
44
45
|
>
|
|
45
46
|
<Icon
|
|
46
47
|
icon="carbon:search"
|
|
47
|
-
class="htw-w-
|
|
48
|
+
class="htw-w-6 htw-h-6 sm:htw-w-4 sm:htw-h-4"
|
|
48
49
|
/>
|
|
49
50
|
</a>
|
|
50
51
|
|
|
51
52
|
<a
|
|
52
53
|
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"
|
|
54
|
+
class="htw-p-2 sm:htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
|
|
54
55
|
@click="toggleDark()"
|
|
55
56
|
>
|
|
56
57
|
<Icon
|
|
57
58
|
:icon="themeIcon"
|
|
58
|
-
class="htw-w-
|
|
59
|
+
class="htw-w-6 htw-h-6 sm:htw-w-4 sm:htw-h-4"
|
|
59
60
|
/>
|
|
60
61
|
</a>
|
|
61
62
|
</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>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, ref, watch } from 'vue'
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
modelValue: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: false,
|
|
8
|
+
},
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
const emit = defineEmits({
|
|
12
|
+
'update:modelValue': (newValue: boolean) => true,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
function toggle () {
|
|
16
|
+
emit('update:modelValue', !props.modelValue)
|
|
17
|
+
animationEnabled.value = true
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// SVG check
|
|
21
|
+
|
|
22
|
+
const path = ref<SVGPathElement>()
|
|
23
|
+
const dasharray = ref(0)
|
|
24
|
+
const progress = computed(() => props.modelValue ? 1 : 0)
|
|
25
|
+
const dashoffset = computed(() => (1 - progress.value) * dasharray.value)
|
|
26
|
+
const animationEnabled = ref(false)
|
|
27
|
+
|
|
28
|
+
watch(path, value => {
|
|
29
|
+
dasharray.value = path.value.getTotalLength?.() ?? 21.21
|
|
30
|
+
})
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<div
|
|
35
|
+
role="checkbox"
|
|
36
|
+
tabindex="0"
|
|
37
|
+
class="htw-flex htw-items-center htw-gap-2 htw-select-none htw-px-4 htw-py-3 htw-cursor-pointer hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700"
|
|
38
|
+
@click="toggle()"
|
|
39
|
+
@keydown.enter.prevent="toggle()"
|
|
40
|
+
@keydown.space.prevent="toggle()"
|
|
41
|
+
>
|
|
42
|
+
<div class="htw-text-white htw-w-[16px] htw-h-[16px] htw-relative">
|
|
43
|
+
<div
|
|
44
|
+
class="htw-border group-active:htw-bg-gray-500/20 htw-rounded-sm htw-box-border htw-absolute htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out"
|
|
45
|
+
:class="[
|
|
46
|
+
modelValue
|
|
47
|
+
? 'htw-border-primary-500 htw-border-8'
|
|
48
|
+
: 'htw-border-black/25 dark:htw-border-white/25 htw-delay-150',
|
|
49
|
+
]"
|
|
50
|
+
/>
|
|
51
|
+
<svg
|
|
52
|
+
width="16"
|
|
53
|
+
height="16"
|
|
54
|
+
viewBox="0 0 24 24"
|
|
55
|
+
class="htw-relative htw-z-10"
|
|
56
|
+
>
|
|
57
|
+
<path
|
|
58
|
+
ref="path"
|
|
59
|
+
d="m 4 12 l 5 5 l 10 -10"
|
|
60
|
+
fill="none"
|
|
61
|
+
class="htw-stroke-white htw-stroke-2 htw-duration-200 htw-ease-in-out"
|
|
62
|
+
:class="[
|
|
63
|
+
animationEnabled ? 'htw-transition-all' : 'htw-transition-none',
|
|
64
|
+
{
|
|
65
|
+
'htw-delay-150': modelValue,
|
|
66
|
+
},
|
|
67
|
+
]"
|
|
68
|
+
:stroke-dasharray="dasharray"
|
|
69
|
+
:stroke-dashoffset="dashoffset"
|
|
70
|
+
/>
|
|
71
|
+
</svg>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<slot />
|
|
75
|
+
</div>
|
|
76
|
+
</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>
|
|
@@ -48,7 +48,10 @@ const kindLabels = {
|
|
|
48
48
|
</script>
|
|
49
49
|
|
|
50
50
|
<template>
|
|
51
|
-
<div
|
|
51
|
+
<div
|
|
52
|
+
ref="el"
|
|
53
|
+
data-test-id="search-item"
|
|
54
|
+
>
|
|
52
55
|
<BaseListItemLink
|
|
53
56
|
:to="result.route"
|
|
54
57
|
:is-active="selected"
|
|
@@ -57,7 +60,7 @@ const kindLabels = {
|
|
|
57
60
|
>
|
|
58
61
|
<Icon
|
|
59
62
|
:icon="result.icon ?? defaultIcons[result.kind]"
|
|
60
|
-
class="htw-w-
|
|
63
|
+
class="htw-w-4 htw-h-4"
|
|
61
64
|
:class="[
|
|
62
65
|
!selected ? [
|
|
63
66
|
result.iconColor
|
|
@@ -25,8 +25,7 @@ function close () {
|
|
|
25
25
|
// Autofocus
|
|
26
26
|
|
|
27
27
|
const input = ref<HTMLInputElement>()
|
|
28
|
-
const { focused } = useFocus({
|
|
29
|
-
target: input,
|
|
28
|
+
const { focused } = useFocus(input, {
|
|
30
29
|
initialValue: true,
|
|
31
30
|
})
|
|
32
31
|
|
|
@@ -131,7 +130,8 @@ function selectPrevious () {
|
|
|
131
130
|
<template>
|
|
132
131
|
<div
|
|
133
132
|
v-show="shown"
|
|
134
|
-
class="htw-fixed htw-inset-0 htw-bg-white/80 dark:htw-bg-gray-700/80"
|
|
133
|
+
class="htw-fixed htw-inset-0 htw-bg-white/80 dark:htw-bg-gray-700/80 htw-z-20"
|
|
134
|
+
data-test-id="search-modal"
|
|
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
|
|
@@ -152,8 +152,8 @@ function selectPrevious () {
|
|
|
152
152
|
v-model="search"
|
|
153
153
|
placeholder="Search for stories, variants..."
|
|
154
154
|
class="htw-bg-transparent htw-w-full htw-flex-1 htw-pl-0 htw-pr-6 htw-py-4 htw-outline-none"
|
|
155
|
-
@keydown.down="selectNext()"
|
|
156
|
-
@keydown.up="selectPrevious()"
|
|
155
|
+
@keydown.down.prevent="selectNext()"
|
|
156
|
+
@keydown.up.prevent="selectPrevious()"
|
|
157
157
|
@keydown.escape="close()"
|
|
158
158
|
>
|
|
159
159
|
</div>
|
|
@@ -30,11 +30,11 @@ const folderPadding = computed(() => {
|
|
|
30
30
|
</script>
|
|
31
31
|
|
|
32
32
|
<template>
|
|
33
|
-
<div
|
|
33
|
+
<div data-test-id="story-list-folder">
|
|
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>
|
|
@@ -24,7 +24,10 @@ useScrollOnActive(active, el)
|
|
|
24
24
|
</script>
|
|
25
25
|
|
|
26
26
|
<template>
|
|
27
|
-
<div
|
|
27
|
+
<div
|
|
28
|
+
ref="el"
|
|
29
|
+
data-test-id="story-list-item"
|
|
30
|
+
>
|
|
28
31
|
<BaseListItemLink
|
|
29
32
|
v-slot="{ active }"
|
|
30
33
|
:to="{
|
|
@@ -33,12 +36,12 @@ useScrollOnActive(active, el)
|
|
|
33
36
|
storyId: story.id,
|
|
34
37
|
},
|
|
35
38
|
}"
|
|
36
|
-
class="htw-pl-0.5 htw-pr-2 htw-py-1.5 htw-m-1 htw-rounded-sm"
|
|
39
|
+
class="htw-pl-0.5 htw-pr-2 htw-py-2 md:htw-py-1.5 htw-m-1 htw-rounded-sm"
|
|
37
40
|
>
|
|
38
41
|
<span class="bind-tree-margin htw-flex htw-items-center htw-gap-2 htw-pl-5 htw-min-w-0">
|
|
39
42
|
<Icon
|
|
40
43
|
:icon="story.icon ?? 'carbon:cube'"
|
|
41
|
-
class="base-list-item-link-icon htw-w-5 htw-h-5 htw-flex-none"
|
|
44
|
+
class="base-list-item-link-icon htw-w-5 htw-h-5 sm:htw-w-4 sm:htw-h-4 htw-flex-none"
|
|
42
45
|
:class="{
|
|
43
46
|
'htw-text-primary-500': !active && !story.iconColor,
|
|
44
47
|
'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
|
|
@@ -211,6 +255,7 @@ const finalHeight = computed(() => props.settings.rotate ? props.settings.respon
|
|
|
211
255
|
'htw-invisible': !isIframeLoaded,
|
|
212
256
|
'htw-pointer-events-none': resizing,
|
|
213
257
|
}"
|
|
258
|
+
data-test-id="preview-iframe"
|
|
214
259
|
@load="onIframeLoad()"
|
|
215
260
|
/>
|
|
216
261
|
</div>
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
data-test-id="story-side-panel"
|
|
33
|
+
>
|
|
34
|
+
<template #first>
|
|
35
|
+
<div class="htw-flex htw-flex-col htw-h-full">
|
|
36
|
+
<nav class="htw-h-10 htw-flex-none htw-border-b htw-border-gray-100 dark:htw-border-gray-750">
|
|
37
|
+
<BaseTab
|
|
38
|
+
:to="{ ...$route, query: { ...$route.query, tab: '' } }"
|
|
39
|
+
:matched="!$route.query.tab"
|
|
40
|
+
>
|
|
41
|
+
Controls
|
|
42
|
+
</BaseTab>
|
|
43
|
+
<BaseTab
|
|
44
|
+
:to="{ ...$route, query: { ...$route.query, tab: 'docs' } }"
|
|
45
|
+
:matched="$route.query.tab === 'docs'"
|
|
46
|
+
>
|
|
47
|
+
Docs
|
|
48
|
+
</BaseTab>
|
|
49
|
+
</nav>
|
|
50
|
+
|
|
51
|
+
<component
|
|
52
|
+
:is="$route.query.tab === 'docs'
|
|
53
|
+
? StoryDocs
|
|
54
|
+
: StoryControls"
|
|
55
|
+
:story="storyStore.currentStory"
|
|
56
|
+
:variant="storyStore.currentVariant"
|
|
57
|
+
class="htw-h-full htw-overflow-auto"
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<template #last>
|
|
63
|
+
<StorySourceCode
|
|
64
|
+
:variant="storyStore.currentVariant"
|
|
65
|
+
class="htw-h-full"
|
|
66
|
+
/>
|
|
67
|
+
</template>
|
|
68
|
+
</BaseSplitPane>
|
|
69
|
+
</template>
|
|
@@ -67,7 +67,10 @@ const copySourceCode = () => copy(sourceCode.value)
|
|
|
67
67
|
</script>
|
|
68
68
|
|
|
69
69
|
<template>
|
|
70
|
-
<div
|
|
70
|
+
<div
|
|
71
|
+
class="htw-bg-gray-100 dark:htw-bg-gray-800 htw-h-full htw-overflow-hidden htw-relative"
|
|
72
|
+
data-test-id="story-source-code"
|
|
73
|
+
>
|
|
71
74
|
<div
|
|
72
75
|
v-if="error"
|
|
73
76
|
class="htw-text-red-500 htw-h-full htw-p-2 htw-overflow-auto htw-font-mono htw-text-sm"
|
|
@@ -20,16 +20,19 @@ useScrollOnActive(isActive, el)
|
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
22
|
<template>
|
|
23
|
-
<div
|
|
23
|
+
<div
|
|
24
|
+
ref="el"
|
|
25
|
+
data-test-id="story-variant-list-item"
|
|
26
|
+
>
|
|
24
27
|
<BaseListItemLink
|
|
25
28
|
v-slot="{ active }"
|
|
26
29
|
:to="targetRoute"
|
|
27
30
|
: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"
|
|
31
|
+
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
32
|
>
|
|
30
33
|
<Icon
|
|
31
34
|
:icon="variant.icon ?? 'carbon:cube'"
|
|
32
|
-
class="base-list-item-link-icon htw-w-5 htw-h-5 htw-flex-none"
|
|
35
|
+
class="base-list-item-link-icon htw-w-5 htw-h-5 sm:htw-w-4 sm:htw-h-4 htw-flex-none"
|
|
33
36
|
:class="{
|
|
34
37
|
'htw-text-gray-500': !active && !variant.iconColor,
|
|
35
38
|
'bind-icon-color': !active && variant.iconColor,
|
|
@@ -5,6 +5,8 @@ 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 BaseCheckbox from '../base/BaseCheckbox.vue'
|
|
9
|
+
import { isMobile } from '../../util/responsive'
|
|
8
10
|
|
|
9
11
|
defineProps({
|
|
10
12
|
variant: {
|
|
@@ -22,9 +24,15 @@ const settings = usePreviewSettings()
|
|
|
22
24
|
</script>
|
|
23
25
|
|
|
24
26
|
<template>
|
|
25
|
-
<div
|
|
27
|
+
<div
|
|
28
|
+
class="htw-h-full htw-flex htw-flex-col"
|
|
29
|
+
data-test-id="story-variant-single-view"
|
|
30
|
+
>
|
|
26
31
|
<!-- Toolbar -->
|
|
27
|
-
<div
|
|
32
|
+
<div
|
|
33
|
+
v-if="!isMobile"
|
|
34
|
+
class="htw-flex-none htw-flex htw-items-center htw-h-8 -htw-mt-1"
|
|
35
|
+
>
|
|
28
36
|
<!-- Variant title -->
|
|
29
37
|
<div class="htw-flex htw-items-center htw-gap-1 htw-text-gray-500 htw-flex-1 htw-truncate htw-min-w-0">
|
|
30
38
|
<Icon
|
|
@@ -63,11 +71,9 @@ const settings = usePreviewSettings()
|
|
|
63
71
|
|
|
64
72
|
<template #popper="{ hide }">
|
|
65
73
|
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
66
|
-
<
|
|
67
|
-
v-model="settings.rotate"
|
|
68
|
-
>
|
|
74
|
+
<BaseCheckbox v-model="settings.rotate">
|
|
69
75
|
Rotate
|
|
70
|
-
</
|
|
76
|
+
</BaseCheckbox>
|
|
71
77
|
|
|
72
78
|
<div class="htw-flex htw-gap-2 htw-px-4 htw-py-3">
|
|
73
79
|
<input
|
|
@@ -133,11 +139,9 @@ const settings = usePreviewSettings()
|
|
|
133
139
|
|
|
134
140
|
<template #popper="{ hide }">
|
|
135
141
|
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
136
|
-
<
|
|
137
|
-
v-model="settings.checkerboard"
|
|
138
|
-
>
|
|
142
|
+
<BaseCheckbox v-model="settings.checkerboard">
|
|
139
143
|
Checkerboard
|
|
140
|
-
</
|
|
144
|
+
</BaseCheckbox>
|
|
141
145
|
|
|
142
146
|
<button
|
|
143
147
|
v-for="(option, index) in histoireConfig.backgroundPresets"
|