histoire 0.0.0 → 0.0.3
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/client.d.ts +2 -0
- package/dist/client/app/App.vue +84 -21
- package/dist/client/app/assets/histoire-text-dark.svg +89 -0
- package/dist/client/app/assets/histoire-text.svg +89 -0
- package/dist/client/app/assets/histoire.svg +51 -0
- package/dist/client/app/codegen/serialize-js.d.ts +1 -0
- package/dist/client/app/codegen/serialize-js.js +113 -0
- package/dist/client/app/codegen/serialize-js.ts +119 -0
- package/dist/client/app/codegen/util.d.ts +10 -0
- package/dist/client/app/codegen/util.js +70 -0
- package/dist/client/app/codegen/util.ts +79 -0
- package/dist/client/app/codegen/vue3.d.ts +2 -0
- package/dist/client/app/codegen/vue3.js +238 -0
- package/dist/client/app/codegen/vue3.ts +240 -0
- package/dist/client/app/components/HomeView.vue +15 -1
- package/dist/client/app/components/StoryControls.vue +7 -2
- package/dist/client/app/components/StoryList.vue +20 -13
- package/dist/client/app/components/StoryListFolder.vue +87 -0
- package/dist/client/app/components/StoryListItem.vue +38 -12
- package/dist/client/app/components/StorySourceCode.vue +121 -0
- package/dist/client/app/components/StoryVariantGridItem.vue +32 -17
- package/dist/client/app/components/StoryVariantListItem.vue +46 -0
- package/dist/client/app/components/StoryVariantSingleView.vue +145 -15
- package/dist/client/app/components/StoryView.vue +88 -54
- package/dist/client/app/components/app/AppHeader.vue +56 -0
- package/dist/client/app/components/app/AppLogo.vue +24 -0
- package/dist/client/app/components/base/BaseEmpty.vue +1 -1
- package/dist/client/app/components/base/BaseListItemLink.vue +55 -0
- package/dist/client/app/components/base/BaseSplitPane.vue +57 -21
- package/dist/client/app/components/exposed/Story.vue +23 -58
- package/dist/client/app/components/exposed/Variant.vue +24 -47
- package/dist/client/app/components/misc/HatchedPattern.vue +25 -0
- package/dist/client/app/components/{SandboxVue.vue → sandbox/SandboxVue3.vue} +31 -12
- package/dist/client/app/components/search/SearchItem.vue +110 -0
- package/dist/client/app/components/search/SearchModal.vue +179 -0
- package/dist/client/app/composable/variant.js +0 -1
- package/dist/client/app/composable/variant.ts +20 -0
- package/dist/client/app/global-components.js +0 -1
- package/dist/client/app/global-components.ts +10 -0
- package/dist/client/app/index.d.ts +1 -0
- package/dist/client/app/index.js +10 -2
- package/dist/client/app/index.ts +24 -0
- package/dist/client/app/router.js +0 -1
- package/dist/client/app/router.ts +17 -0
- package/dist/client/app/sandbox.d.ts +1 -0
- package/dist/client/app/sandbox.js +53 -0
- package/dist/client/app/sandbox.ts +60 -0
- package/dist/client/app/stores/story.d.ts +167 -50
- package/dist/client/app/stores/story.js +33 -16
- package/dist/client/app/stores/story.ts +58 -0
- package/dist/client/app/style/floating-vue.css +31 -0
- package/dist/client/app/style/main.css +17 -2
- package/dist/client/app/style/sandbox.css +14 -0
- package/dist/client/app/types.d.ts +36 -4
- package/dist/client/app/types.js +0 -1
- package/dist/client/app/types.ts +59 -0
- package/dist/client/app/util/config.d.ts +3 -0
- package/dist/client/app/util/config.js +4 -0
- package/dist/client/app/util/config.ts +6 -0
- package/dist/client/app/util/const.d.ts +1 -0
- package/dist/client/app/util/const.js +1 -0
- package/dist/client/app/util/const.ts +1 -0
- package/dist/client/app/util/dark.d.ts +2 -0
- package/dist/client/app/util/dark.js +3 -0
- package/dist/client/app/util/dark.ts +4 -0
- package/dist/client/app/util/env.d.ts +1 -0
- package/dist/client/app/util/env.js +1 -0
- package/dist/client/app/util/env.ts +1 -0
- package/dist/client/app/util/keyboard.d.ts +8 -0
- package/dist/client/app/util/keyboard.js +82 -0
- package/dist/client/app/util/keyboard.ts +99 -0
- package/dist/client/app/util/mapping.d.ts +3 -0
- package/dist/client/app/util/mapping.js +39 -0
- package/dist/client/app/util/mapping.ts +41 -0
- package/dist/client/app/util/tooltip.d.ts +6 -0
- package/dist/client/app/util/tooltip.js +11 -0
- package/dist/client/app/util/tooltip.ts +13 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.ts +12 -0
- package/dist/client/server/Story.server.vue +65 -0
- package/dist/client/server/Variant.server.vue +50 -0
- package/dist/client/server/index.d.ts +2 -0
- package/dist/client/server/index.js +25 -0
- package/dist/client/server/index.ts +29 -0
- package/dist/client/shim.d.ts +5 -0
- package/dist/node/alias.js +0 -1
- package/dist/node/bin.js +8 -3
- package/dist/node/build.d.ts +2 -0
- package/dist/node/build.js +71 -0
- package/dist/node/collect.d.ts +12 -0
- package/dist/node/collect.js +65 -0
- package/dist/node/colors.d.ts +286 -0
- package/dist/node/colors.js +324 -0
- package/dist/node/commands/build.d.ts +1 -0
- package/dist/node/commands/build.js +10 -0
- package/dist/node/commands/dev.d.ts +1 -1
- package/dist/node/commands/dev.js +45 -13
- package/dist/node/config.d.ts +112 -1
- package/dist/node/config.js +124 -2
- package/dist/node/context.d.ts +13 -0
- package/dist/node/context.js +12 -2
- package/dist/node/dom/dom-keys.d.ts +4 -0
- package/dist/node/dom/dom-keys.js +223 -0
- package/dist/node/dom/env.d.ts +5 -0
- package/dist/node/dom/env.js +22 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +2 -2
- package/dist/node/plugin.d.ts +8 -2
- package/dist/node/plugin.js +150 -22
- package/dist/node/server.d.ts +4 -1
- package/dist/node/server.js +80 -21
- package/dist/node/stories.d.ts +8 -9
- package/dist/node/stories.js +42 -23
- package/dist/node/tree.d.ts +19 -0
- package/dist/node/tree.js +54 -0
- package/dist/node/types.d.ts +38 -0
- package/dist/node/types.js +1 -0
- package/dist/style.css +610 -53
- package/package.json +45 -25
- package/scripts/copy.mjs +11 -0
- package/src/client/app/App.vue +84 -21
- package/src/client/app/assets/histoire-text-dark.svg +89 -0
- package/src/client/app/assets/histoire-text.svg +89 -0
- package/src/client/app/assets/histoire.svg +51 -0
- package/src/client/app/codegen/serialize-js.ts +119 -0
- package/src/client/app/codegen/util.ts +79 -0
- package/src/client/app/codegen/vue3.ts +240 -0
- package/src/client/app/components/HomeView.vue +15 -1
- package/src/client/app/components/StoryControls.vue +7 -2
- package/src/client/app/components/StoryList.vue +20 -13
- package/src/client/app/components/StoryListFolder.vue +87 -0
- package/src/client/app/components/StoryListItem.vue +38 -12
- package/src/client/app/components/StorySourceCode.vue +121 -0
- package/src/client/app/components/StoryVariantGridItem.vue +32 -17
- package/src/client/app/components/StoryVariantListItem.vue +46 -0
- package/src/client/app/components/StoryVariantSingleView.vue +145 -15
- package/src/client/app/components/StoryView.vue +88 -54
- package/src/client/app/components/app/AppHeader.vue +56 -0
- package/src/client/app/components/app/AppLogo.vue +24 -0
- package/src/client/app/components/base/BaseEmpty.vue +1 -1
- package/src/client/app/components/base/BaseListItemLink.vue +55 -0
- package/src/client/app/components/base/BaseSplitPane.vue +57 -21
- package/src/client/app/components/exposed/Story.vue +23 -58
- package/src/client/app/components/exposed/Variant.vue +24 -47
- package/src/client/app/components/misc/HatchedPattern.vue +25 -0
- package/src/client/app/components/{SandboxVue.vue → sandbox/SandboxVue3.vue} +31 -12
- package/src/client/app/components/search/SearchItem.vue +110 -0
- package/src/client/app/components/search/SearchModal.vue +179 -0
- package/src/client/app/index.ts +10 -1
- package/src/client/app/sandbox.ts +60 -0
- package/src/client/app/stores/story.ts +39 -15
- package/src/client/app/style/floating-vue.css +31 -0
- package/src/client/app/style/main.css +17 -2
- package/src/client/app/style/sandbox.css +14 -0
- package/src/client/app/types.ts +42 -4
- package/src/client/app/util/config.ts +6 -0
- package/src/client/app/util/const.ts +1 -0
- package/src/client/app/util/dark.ts +4 -0
- package/src/client/app/util/env.ts +1 -0
- package/src/client/app/util/keyboard.ts +99 -0
- package/src/client/app/util/mapping.ts +41 -0
- package/src/client/app/util/tooltip.ts +13 -0
- package/src/client/index.ts +12 -0
- package/src/client/server/Story.server.vue +65 -0
- package/src/client/server/Variant.server.vue +50 -0
- package/src/client/server/index.ts +29 -0
- package/src/node/bin.ts +9 -2
- package/src/node/build.ts +80 -0
- package/src/node/collect.ts +78 -0
- package/src/node/colors.ts +340 -0
- package/src/node/commands/build.ts +12 -0
- package/src/node/commands/dev.ts +49 -12
- package/src/node/config.ts +240 -1
- package/src/node/context.ts +21 -1
- package/src/node/dom/dom-keys.ts +227 -0
- package/src/node/dom/env.ts +26 -0
- package/src/node/index.ts +2 -0
- package/src/node/plugin.ts +155 -22
- package/src/node/server.ts +95 -20
- package/src/node/stories.ts +53 -31
- package/src/node/tree.spec.ts +28 -0
- package/src/node/tree.ts +88 -0
- package/src/node/types.ts +40 -0
- package/tailwind.config.cjs +41 -1
- package/tsconfig.json +2 -1
- package/dist/client/app/components/StoryVariantItem.vue +0 -29
- package/dist/client/app/composable/variant.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/router.js.map +0 -1
- package/dist/client/app/stores/story.js.map +0 -1
- package/dist/client/app/types.js.map +0 -1
- package/dist/node/alias.js.map +0 -1
- package/dist/node/bin.js.map +0 -1
- package/dist/node/commands/dev.js.map +0 -1
- package/dist/node/config.js.map +0 -1
- package/dist/node/context.js.map +0 -1
- package/dist/node/index.js.map +0 -1
- package/dist/node/plugin.js.map +0 -1
- package/dist/node/server.js.map +0 -1
- package/dist/node/stories.js.map +0 -1
- package/src/client/app/components/StoryVariantItem.vue +0 -29
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { PropType, toRefs } from 'vue'
|
|
2
|
+
import { computed, PropType, toRefs } from 'vue'
|
|
3
3
|
import { useCurrentVariantRoute } from '../composable/variant'
|
|
4
4
|
import { Story, Variant } from '../types'
|
|
5
|
-
import
|
|
5
|
+
import SandboxVue3 from './sandbox/SandboxVue3.vue'
|
|
6
|
+
import { Icon } from '@iconify/vue'
|
|
6
7
|
|
|
7
8
|
const props = defineProps({
|
|
8
9
|
variant: {
|
|
@@ -18,39 +19,53 @@ const props = defineProps({
|
|
|
18
19
|
|
|
19
20
|
const { variant } = toRefs(props)
|
|
20
21
|
const { isActive, targetRoute } = useCurrentVariantRoute(variant)
|
|
22
|
+
|
|
23
|
+
const iconColor = computed(() => props.variant.iconColor)
|
|
21
24
|
</script>
|
|
22
25
|
|
|
23
26
|
<template>
|
|
24
|
-
<
|
|
25
|
-
:to="targetRoute"
|
|
26
|
-
class="htw-cursor-default htw-flex htw-flex-col htw-space-y-1"
|
|
27
|
-
>
|
|
27
|
+
<div class="htw-cursor-default htw-flex htw-flex-col htw-gap-y-1">
|
|
28
28
|
<!-- Header -->
|
|
29
|
-
<div>
|
|
30
|
-
<
|
|
29
|
+
<div class="htw-flex-none htw-flex htw-items-center">
|
|
30
|
+
<RouterLink
|
|
31
31
|
:to="targetRoute"
|
|
32
|
-
class="htw-rounded htw-w-max htw-px-
|
|
32
|
+
class="htw-rounded htw-w-max htw-px-2 htw-py-0.5 htw-min-w-16 htw-cursor-pointer htw-flex htw-items-center htw-gap-1"
|
|
33
33
|
:class="{
|
|
34
|
-
'hover:htw-bg-gray-200 htw-text-gray-500': !isActive,
|
|
35
|
-
'htw-bg-primary-200 hover:htw-bg-primary-300 htw-text-primary-800': isActive,
|
|
34
|
+
'hover:htw-bg-gray-200 htw-text-gray-500 dark:hover:htw-bg-gray-800': !isActive,
|
|
35
|
+
'htw-bg-primary-200 hover:htw-bg-primary-300 htw-text-primary-800 dark:htw-bg-primary-700 dark:hover:htw-bg-primary-800 dark:htw-text-primary-200': isActive,
|
|
36
36
|
}"
|
|
37
37
|
>
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
<Icon
|
|
39
|
+
:icon="variant.icon ?? 'carbon:cube'"
|
|
40
|
+
class="base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50"
|
|
41
|
+
:class="{
|
|
42
|
+
'htw-text-gray-500': !isActive && !variant.iconColor,
|
|
43
|
+
'bind-icon-color': !isActive && variant.iconColor,
|
|
44
|
+
}"
|
|
45
|
+
/>
|
|
46
|
+
<span>{{ variant.title }}</span>
|
|
47
|
+
</RouterLink>
|
|
40
48
|
</div>
|
|
41
49
|
|
|
42
50
|
<!-- Body -->
|
|
43
51
|
<div
|
|
44
|
-
class="htw-border htw-
|
|
52
|
+
class="htw-border htw-bg-white dark:htw-bg-gray-700 htw-rounded-lg htw-flex-1 htw-p-4"
|
|
45
53
|
:class="{
|
|
46
|
-
'htw-border-
|
|
54
|
+
'htw-border-gray-100 dark:htw-border-gray-800': !isActive,
|
|
55
|
+
'htw-border-primary-200 dark:htw-border-primary-900': isActive,
|
|
47
56
|
}"
|
|
48
57
|
@click.stop.prevent
|
|
49
58
|
>
|
|
50
|
-
<
|
|
59
|
+
<SandboxVue3
|
|
51
60
|
:variant="variant"
|
|
52
61
|
:story="story"
|
|
53
62
|
/>
|
|
54
63
|
</div>
|
|
55
|
-
</
|
|
64
|
+
</div>
|
|
56
65
|
</template>
|
|
66
|
+
|
|
67
|
+
<style scoped>
|
|
68
|
+
.bind-icon-color {
|
|
69
|
+
color: v-bind(iconColor);
|
|
70
|
+
}
|
|
71
|
+
</style>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, PropType, toRefs } from 'vue'
|
|
3
|
+
import { useCurrentVariantRoute } from '../composable/variant'
|
|
4
|
+
import { Variant } from '../types'
|
|
5
|
+
import BaseListItemLink from './base/BaseListItemLink.vue'
|
|
6
|
+
import { Icon } from '@iconify/vue'
|
|
7
|
+
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
variant: {
|
|
10
|
+
type: Object as PropType<Variant>,
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const { variant } = toRefs(props)
|
|
16
|
+
const { isActive, targetRoute } = useCurrentVariantRoute(variant)
|
|
17
|
+
|
|
18
|
+
const iconColor = computed(() => props.variant.iconColor)
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<div>
|
|
23
|
+
<BaseListItemLink
|
|
24
|
+
v-slot="{ active }"
|
|
25
|
+
:to="targetRoute"
|
|
26
|
+
:is-active="isActive"
|
|
27
|
+
class="htw-px-2 htw-py-1.5 htw-m-1 htw-rounded-sm htw-flex htw-items-center htw-gap-2"
|
|
28
|
+
>
|
|
29
|
+
<Icon
|
|
30
|
+
:icon="variant.icon ?? 'carbon:cube'"
|
|
31
|
+
class="base-list-item-link-icon htw-w-5 htw-h-5 htw-flex-none"
|
|
32
|
+
:class="{
|
|
33
|
+
'htw-text-gray-500': !active && !variant.iconColor,
|
|
34
|
+
'bind-icon-color': !active && variant.iconColor,
|
|
35
|
+
}"
|
|
36
|
+
/>
|
|
37
|
+
<span class="htw-truncate">{{ variant.title }}</span>
|
|
38
|
+
</BaseListItemLink>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<style scoped>
|
|
43
|
+
.bind-icon-color {
|
|
44
|
+
color: v-bind(iconColor);
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import { useEventListener } from '@vueuse/core'
|
|
3
|
+
import { PropType, ref, watch, toRaw, computed } from 'vue'
|
|
4
|
+
import { Icon } from '@iconify/vue'
|
|
3
5
|
import { Story, Variant } from '../types'
|
|
4
|
-
import
|
|
6
|
+
import { STATE_SYNC } from '../util/const.js'
|
|
7
|
+
import { histoireConfig } from '../util/config.js'
|
|
5
8
|
import BaseSplitPane from './base/BaseSplitPane.vue'
|
|
9
|
+
import HatchedPattern from './misc/HatchedPattern.vue'
|
|
6
10
|
|
|
7
|
-
defineProps({
|
|
11
|
+
const props = defineProps({
|
|
8
12
|
variant: {
|
|
9
13
|
type: Object as PropType<Variant>,
|
|
10
14
|
required: true,
|
|
@@ -15,28 +19,154 @@ defineProps({
|
|
|
15
19
|
required: true,
|
|
16
20
|
},
|
|
17
21
|
})
|
|
22
|
+
|
|
23
|
+
// Iframe
|
|
24
|
+
|
|
25
|
+
const iframe = ref<HTMLIFrameElement>()
|
|
26
|
+
|
|
27
|
+
function syncState () {
|
|
28
|
+
if (iframe.value) {
|
|
29
|
+
iframe.value.contentWindow.postMessage({
|
|
30
|
+
type: STATE_SYNC,
|
|
31
|
+
state: toRaw(props.variant.state),
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
watch(() => props.variant.state, () => {
|
|
37
|
+
syncState()
|
|
38
|
+
}, {
|
|
39
|
+
deep: true,
|
|
40
|
+
immediate: true,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
useEventListener(window, 'message', (event) => {
|
|
44
|
+
if (event.data.type === STATE_SYNC) {
|
|
45
|
+
Object.assign(props.variant.state, event.data.state)
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const sandboxUrl = computed(() => {
|
|
50
|
+
const url = new URLSearchParams()
|
|
51
|
+
url.append('storyId', props.story.id)
|
|
52
|
+
url.append('variantId', props.variant.id)
|
|
53
|
+
return '/__sandbox?' + url.toString()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const isIframeLoaded = ref(false)
|
|
57
|
+
|
|
58
|
+
watch(sandboxUrl, () => {
|
|
59
|
+
isIframeLoaded.value = false
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
function onIframeLoad () {
|
|
63
|
+
isIframeLoaded.value = true
|
|
64
|
+
syncState()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Responsive
|
|
68
|
+
|
|
69
|
+
const responsiveWidth = ref<number>(undefined)
|
|
18
70
|
</script>
|
|
19
71
|
|
|
20
72
|
<template>
|
|
21
|
-
<div class="htw-
|
|
73
|
+
<div class="htw-h-full htw-flex htw-flex-col htw-gap-2">
|
|
74
|
+
<div class="htw-flex-none htw-flex htw-items-center htw-gap-2">
|
|
75
|
+
<!-- Variant title -->
|
|
76
|
+
<div class="htw-flex htw-items-center htw-gap-1 htw-text-gray-500 htw-flex-1 htw-truncate htw-min-w-0">
|
|
77
|
+
<Icon
|
|
78
|
+
:icon="variant.icon ?? 'carbon:cube'"
|
|
79
|
+
class="base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50"
|
|
80
|
+
:class="[
|
|
81
|
+
variant.iconColor ? 'bind-icon-color' : 'htw-text-gray-500',
|
|
82
|
+
]"
|
|
83
|
+
/>
|
|
84
|
+
<span>{{ variant.title }}</span>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<!-- Responsive size -->
|
|
88
|
+
<div class="htw-flex-none htw-flex htw-gap-1 htw-items-center">
|
|
89
|
+
<VDropdown
|
|
90
|
+
placement="bottom-end"
|
|
91
|
+
:distance="10"
|
|
92
|
+
:skidding="6"
|
|
93
|
+
:disabled="!histoireConfig.responsivePresets?.length"
|
|
94
|
+
>
|
|
95
|
+
<Icon
|
|
96
|
+
icon="ic:baseline-phone-android"
|
|
97
|
+
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
98
|
+
:class="{
|
|
99
|
+
'htw-cursor-pointer hover:htw-text-primary-500': histoireConfig.responsivePresets?.length,
|
|
100
|
+
}"
|
|
101
|
+
/>
|
|
102
|
+
|
|
103
|
+
<template #popper="{ hide }">
|
|
104
|
+
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
105
|
+
<button
|
|
106
|
+
v-for="(preset, index) in histoireConfig.responsivePresets"
|
|
107
|
+
:key="index"
|
|
108
|
+
class="htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700 htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-2"
|
|
109
|
+
:class="{
|
|
110
|
+
'htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black': responsiveWidth === preset.width,
|
|
111
|
+
}"
|
|
112
|
+
@click="responsiveWidth = preset.width;hide()"
|
|
113
|
+
>
|
|
114
|
+
{{ preset.label }}
|
|
115
|
+
<span class="htw-ml-auto htw-opacity-70">{{ preset.width }}px</span>
|
|
116
|
+
</button>
|
|
117
|
+
</div>
|
|
118
|
+
</template>
|
|
119
|
+
</VDropdown>
|
|
120
|
+
|
|
121
|
+
<input
|
|
122
|
+
v-model.number="responsiveWidth"
|
|
123
|
+
v-tooltip="'Responsive width (px)'"
|
|
124
|
+
type="number"
|
|
125
|
+
class="htw-bg-transparent htw-border htw-border-gray-200 dark:htw-border-gray-850 htw-rounded htw-w-16 htw-opacity-50 focus:htw-opacity-100"
|
|
126
|
+
step="16"
|
|
127
|
+
>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
22
131
|
<BaseSplitPane
|
|
132
|
+
v-model:split="responsiveWidth"
|
|
23
133
|
save-id="story-single-responsive"
|
|
24
|
-
:min="
|
|
25
|
-
:max="
|
|
26
|
-
:default-split="
|
|
27
|
-
|
|
28
|
-
class="htw-w-full"
|
|
134
|
+
:min="30"
|
|
135
|
+
:max="6000"
|
|
136
|
+
:default-split="720"
|
|
137
|
+
fixed
|
|
138
|
+
class="htw-w-full htw-h-full htw-flex-1 htw-border htw-border-gray-100 dark:htw-border-gray-800 htw-rounded-lg"
|
|
29
139
|
>
|
|
30
140
|
<template #first>
|
|
31
|
-
<div class="htw-p-4 htw-h-full htw-overflow-
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
141
|
+
<div class="htw-p-4 htw-h-full htw-overflow-hidden htw-bg-white dark:htw-bg-gray-700 htw-rounded-l-lg htw-relative">
|
|
142
|
+
<div class="htw-w-full htw-h-full htw-border htw-border-gray-100 dark:htw-border-gray-800 htw-bg-white htw-rounded-sm">
|
|
143
|
+
<iframe
|
|
144
|
+
ref="iframe"
|
|
145
|
+
:src="sandboxUrl"
|
|
146
|
+
class="htw-w-full htw-h-full"
|
|
147
|
+
:class="{'htw-invisible': !isIframeLoaded}"
|
|
148
|
+
@load="onIframeLoad()"
|
|
149
|
+
/>
|
|
150
|
+
</div>
|
|
151
|
+
<!-- Markers -->
|
|
152
|
+
<div class="htw-absolute htw-top-1 htw-left-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" />
|
|
153
|
+
<div class="htw-absolute htw-top-1 htw-right-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" />
|
|
154
|
+
<div class="htw-absolute htw-bottom-1 htw-left-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" />
|
|
155
|
+
<div class="htw-absolute htw-bottom-1 htw-right-4 htw-h-2 htw-w-px htw-bg-gray-200 dark:htw-bg-gray-800" />
|
|
156
|
+
<div class="htw-absolute htw-left-1 htw-top-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" />
|
|
157
|
+
<div class="htw-absolute htw-left-1 htw-bottom-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" />
|
|
158
|
+
<div class="htw-absolute htw-right-1 htw-top-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" />
|
|
159
|
+
<div class="htw-absolute htw-right-1 htw-bottom-4 htw-w-2 htw-h-px htw-bg-gray-200 dark:htw-bg-gray-800" />
|
|
36
160
|
</div>
|
|
37
161
|
</template>
|
|
38
162
|
<template #last>
|
|
39
|
-
<div
|
|
163
|
+
<div
|
|
164
|
+
class="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"
|
|
165
|
+
>
|
|
166
|
+
<HatchedPattern
|
|
167
|
+
class="htw-w-full htw-h-full htw-text-black/[2%] dark:htw-text-white/[2%]"
|
|
168
|
+
/>
|
|
169
|
+
</div>
|
|
40
170
|
</template>
|
|
41
171
|
</BaseSplitPane>
|
|
42
172
|
</div>
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { useStoryStore } from '../stores/story'
|
|
3
3
|
import BaseSplitPane from './base/BaseSplitPane.vue'
|
|
4
|
-
import
|
|
4
|
+
import StoryVariantListItem from './StoryVariantListItem.vue'
|
|
5
5
|
import StoryVariantGridItem from './StoryVariantGridItem.vue'
|
|
6
6
|
import { computed, watch } from 'vue'
|
|
7
7
|
import { useRoute, useRouter } from 'vue-router'
|
|
8
8
|
import StoryVariantSingleView from './StoryVariantSingleView.vue'
|
|
9
9
|
import BaseEmpty from './base/BaseEmpty.vue'
|
|
10
10
|
import StoryControls from './StoryControls.vue'
|
|
11
|
+
import StorySourceCode from './StorySourceCode.vue'
|
|
11
12
|
|
|
12
13
|
const storyStore = useStoryStore()
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const router = useRouter()
|
|
16
16
|
const route = useRoute()
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// Selected variant
|
|
19
|
+
|
|
20
|
+
const hasSingleVariant = computed(() => (storyStore.currentStory?.variants.length === 1))
|
|
19
21
|
|
|
20
22
|
// Restore variant selection
|
|
21
23
|
|
|
22
|
-
watch(currentVariant, value => {
|
|
24
|
+
watch(() => storyStore.currentVariant, value => {
|
|
23
25
|
if (value) {
|
|
24
26
|
storyStore.currentStory.lastSelectedVariant = value
|
|
25
27
|
}
|
|
@@ -27,19 +29,30 @@ watch(currentVariant, value => {
|
|
|
27
29
|
immediate: true,
|
|
28
30
|
})
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
watch(() => [storyStore.currentStory, storyStore.currentVariant], () => {
|
|
33
|
+
if (!storyStore.currentVariant) {
|
|
34
|
+
if (storyStore.currentStory?.lastSelectedVariant) {
|
|
35
|
+
setVariant(storyStore.currentStory.lastSelectedVariant.id)
|
|
36
|
+
return
|
|
37
|
+
}
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
...route,
|
|
36
|
-
query: {
|
|
37
|
-
...route.query,
|
|
38
|
-
variantId: storyStore.currentStory.lastSelectedVariant.id,
|
|
39
|
-
},
|
|
40
|
-
})
|
|
39
|
+
if (storyStore.currentStory?.variants.length === 1) {
|
|
40
|
+
setVariant(storyStore.currentStory.variants[0].id)
|
|
41
|
+
}
|
|
41
42
|
}
|
|
43
|
+
}, {
|
|
44
|
+
immediate: true,
|
|
42
45
|
})
|
|
46
|
+
|
|
47
|
+
function setVariant (variantId: string) {
|
|
48
|
+
router.replace({
|
|
49
|
+
...route,
|
|
50
|
+
query: {
|
|
51
|
+
...route.query,
|
|
52
|
+
variantId,
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
}
|
|
43
56
|
</script>
|
|
44
57
|
|
|
45
58
|
<template>
|
|
@@ -49,7 +62,6 @@ watch(() => storyStore.currentStory, () => {
|
|
|
49
62
|
|
|
50
63
|
<div
|
|
51
64
|
v-else
|
|
52
|
-
:key="storyStore.currentStory.mountTime"
|
|
53
65
|
class="htw-h-full"
|
|
54
66
|
>
|
|
55
67
|
<BaseSplitPane
|
|
@@ -60,10 +72,10 @@ watch(() => storyStore.currentStory, () => {
|
|
|
60
72
|
class="htw-h-full"
|
|
61
73
|
>
|
|
62
74
|
<template #first>
|
|
63
|
-
<div class="htw-bg-gray-50 htw-h-full">
|
|
75
|
+
<div class="htw-bg-gray-50 htw-h-full dark:htw-bg-gray-750">
|
|
64
76
|
<div
|
|
65
77
|
v-if="storyStore.currentStory.layout.type === 'grid'"
|
|
66
|
-
class="htw-
|
|
78
|
+
class="htw-h-full htw-overflow-y-auto"
|
|
67
79
|
>
|
|
68
80
|
<div
|
|
69
81
|
class="htw-grid htw-gap-4 htw-m-4"
|
|
@@ -80,52 +92,74 @@ watch(() => storyStore.currentStory, () => {
|
|
|
80
92
|
</div>
|
|
81
93
|
</div>
|
|
82
94
|
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
95
|
+
<template v-else-if="storyStore.currentStory.layout.type === 'single'">
|
|
96
|
+
<div
|
|
97
|
+
v-if="hasSingleVariant && storyStore.currentVariant"
|
|
98
|
+
class="htw-p-2 htw-h-full"
|
|
99
|
+
>
|
|
100
|
+
<StoryVariantSingleView
|
|
101
|
+
:variant="storyStore.currentVariant"
|
|
102
|
+
:story="storyStore.currentStory"
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
<BaseSplitPane
|
|
106
|
+
v-else
|
|
107
|
+
save-id="story-single-main-split"
|
|
108
|
+
:min="5"
|
|
109
|
+
:max="40"
|
|
110
|
+
:default-split="17"
|
|
111
|
+
>
|
|
112
|
+
<template #first>
|
|
113
|
+
<div class="htw-h-full htw-overflow-y-auto">
|
|
114
|
+
<StoryVariantListItem
|
|
115
|
+
v-for="(variant, index) of storyStore.currentStory.variants"
|
|
116
|
+
:key="index"
|
|
117
|
+
:variant="variant"
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
</template>
|
|
121
|
+
<template #last>
|
|
122
|
+
<div
|
|
123
|
+
v-if="storyStore.currentVariant"
|
|
124
|
+
class="htw-p-2 htw-h-full"
|
|
125
|
+
>
|
|
126
|
+
<StoryVariantSingleView
|
|
127
|
+
:variant="storyStore.currentVariant"
|
|
128
|
+
:story="storyStore.currentStory"
|
|
129
|
+
/>
|
|
130
|
+
</div>
|
|
131
|
+
</template>
|
|
132
|
+
</BaseSplitPane>
|
|
133
|
+
</template>
|
|
112
134
|
</div>
|
|
113
135
|
</template>
|
|
114
136
|
|
|
115
137
|
<template #last>
|
|
116
|
-
<BaseEmpty v-if="!currentVariant">
|
|
138
|
+
<BaseEmpty v-if="!storyStore.currentVariant">
|
|
117
139
|
<span>Select a variant</span>
|
|
118
140
|
</BaseEmpty>
|
|
119
141
|
|
|
120
|
-
<
|
|
142
|
+
<BaseSplitPane
|
|
121
143
|
v-else
|
|
144
|
+
save-id="story-sidepane"
|
|
145
|
+
orientation="portrait"
|
|
122
146
|
class="htw-h-full"
|
|
123
147
|
>
|
|
124
|
-
<
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
148
|
+
<template #first>
|
|
149
|
+
<StoryControls
|
|
150
|
+
:story="storyStore.currentStory"
|
|
151
|
+
:variant="storyStore.currentVariant"
|
|
152
|
+
class="htw-h-full htw-overflow-auto"
|
|
153
|
+
/>
|
|
154
|
+
</template>
|
|
155
|
+
|
|
156
|
+
<template #last>
|
|
157
|
+
<StorySourceCode
|
|
158
|
+
:variant="storyStore.currentVariant"
|
|
159
|
+
class="htw-h-full"
|
|
160
|
+
/>
|
|
161
|
+
</template>
|
|
162
|
+
</BaseSplitPane>
|
|
129
163
|
</template>
|
|
130
164
|
</BaseSplitPane>
|
|
131
165
|
</div>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Icon } from '@iconify/vue'
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import AppLogo from './AppLogo.vue'
|
|
5
|
+
import { isDark, toggleDark } from '../../util/dark'
|
|
6
|
+
import { onKeyboardShortcut } from '../../util/keyboard'
|
|
7
|
+
import { makeTooltip } from '../../util/tooltip'
|
|
8
|
+
|
|
9
|
+
defineEmits({
|
|
10
|
+
search: () => true,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const themeIcon = computed(() => {
|
|
14
|
+
return isDark.value ? 'carbon:moon' : 'carbon:sun'
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
onKeyboardShortcut(['ctrl+shift+d', 'meta+shift+d'], (event) => {
|
|
18
|
+
toggleDark()
|
|
19
|
+
event.preventDefault()
|
|
20
|
+
})
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<div
|
|
25
|
+
class="htw-px-4 htw-h-16 htw-flex htw-items-center htw-gap-2"
|
|
26
|
+
>
|
|
27
|
+
<div class="htw-py-4 htw-flex-1 htw-h-full htw-flex htw-items-center htw-pr-2">
|
|
28
|
+
<AppLogo
|
|
29
|
+
class="htw-max-w-full htw-max-h-full"
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="htw-ml-auto htw-flex-none htw-flex">
|
|
33
|
+
<a
|
|
34
|
+
v-tooltip="makeTooltip('Search', ({ isMac }) => isMac ? 'meta+k' : 'ctrl+k')"
|
|
35
|
+
class="htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
|
|
36
|
+
@click="$emit('search')"
|
|
37
|
+
>
|
|
38
|
+
<Icon
|
|
39
|
+
icon="carbon:search"
|
|
40
|
+
class="htw-w-5 htw-h-5"
|
|
41
|
+
/>
|
|
42
|
+
</a>
|
|
43
|
+
|
|
44
|
+
<a
|
|
45
|
+
v-tooltip="makeTooltip('Toggle dark mode', ({ isMac }) => isMac ? 'meta+shift+d' : 'ctrl+shift+d')"
|
|
46
|
+
class="htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
|
|
47
|
+
@click="toggleDark()"
|
|
48
|
+
>
|
|
49
|
+
<Icon
|
|
50
|
+
:icon="themeIcon"
|
|
51
|
+
class="htw-w-5 htw-h-5"
|
|
52
|
+
/>
|
|
53
|
+
</a>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { isDark } from '../../util/dark'
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import { histoireConfig, customLogos } from '../../util/config.js'
|
|
5
|
+
|
|
6
|
+
import HistoireLogoDark from '../../assets/histoire-text-dark.svg'
|
|
7
|
+
import HistoireLogoLight from '../../assets/histoire-text.svg'
|
|
8
|
+
|
|
9
|
+
const logoUrl = computed(() => {
|
|
10
|
+
if (isDark.value) {
|
|
11
|
+
return histoireConfig.theme.logo?.dark ? customLogos.dark : HistoireLogoDark
|
|
12
|
+
}
|
|
13
|
+
return histoireConfig.theme.logo?.light ? customLogos.light : HistoireLogoLight
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const altText = computed(() => histoireConfig.theme.title + ' logo')
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<img
|
|
21
|
+
:src="logoUrl"
|
|
22
|
+
:alt="altText"
|
|
23
|
+
>
|
|
24
|
+
</template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="htw-flex htw-flex-col htw-items-center htw-justify-center htw-space-y-4 htw-py-12 htw-h-full htw-text-center htw-text-gray-400
|
|
2
|
+
<div class="htw-flex htw-flex-col htw-items-center htw-justify-center htw-space-y-4 htw-py-12 htw-h-full htw-text-center htw-text-gray-400 htw-text-lg">
|
|
3
3
|
<slot />
|
|
4
4
|
</div>
|
|
5
5
|
</template>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
|
|
7
|
+
props: {
|
|
8
|
+
isActive: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
default: undefined,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
emits: {
|
|
15
|
+
navigate: () => true,
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
setup (props, { emit }) {
|
|
19
|
+
function handleNavigate (event, navigate: (event) => unknown) {
|
|
20
|
+
emit('navigate')
|
|
21
|
+
navigate(event)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
handleNavigate,
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<RouterLink
|
|
33
|
+
v-slot="{ isActive: linkIsActive, href, navigate }"
|
|
34
|
+
v-bind="$attrs"
|
|
35
|
+
custom
|
|
36
|
+
>
|
|
37
|
+
<a
|
|
38
|
+
:href="href"
|
|
39
|
+
class="htw-flex htw-items-center htw-gap-2"
|
|
40
|
+
:class="[
|
|
41
|
+
$attrs.class,
|
|
42
|
+
(isActive != null ? isActive : linkIsActive)
|
|
43
|
+
? 'active htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black'
|
|
44
|
+
: 'hover:htw-bg-primary-100 dark:hover:htw-bg-primary-900'
|
|
45
|
+
]"
|
|
46
|
+
@click="handleNavigate($event, navigate)"
|
|
47
|
+
@keyup.enter="handleNavigate($event, navigate)"
|
|
48
|
+
@keyup.space="handleNavigate($event, navigate)"
|
|
49
|
+
>
|
|
50
|
+
<slot
|
|
51
|
+
:active="isActive != null ? isActive : linkIsActive"
|
|
52
|
+
/>
|
|
53
|
+
</a>
|
|
54
|
+
</RouterLink>
|
|
55
|
+
</template>
|