histoire 0.0.0 → 0.0.1
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 +114 -0
- package/dist/client/app/codegen/serialize-js.js.map +1 -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 +71 -0
- package/dist/client/app/codegen/util.js.map +1 -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 +239 -0
- package/dist/client/app/codegen/vue3.js.map +1 -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 +80 -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 +117 -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.ts +20 -0
- package/dist/client/app/global-components.ts +10 -0
- package/dist/client/app/index.d.ts +1 -0
- package/dist/client/app/index.js +4 -1
- package/dist/client/app/index.js.map +1 -1
- package/dist/client/app/index.ts +18 -0
- package/dist/client/app/router.ts +17 -0
- package/dist/client/app/sandbox.d.ts +1 -0
- package/dist/client/app/sandbox.js +54 -0
- package/dist/client/app/sandbox.js.map +1 -0
- package/dist/client/app/sandbox.ts +60 -0
- package/dist/client/app/stores/story.d.ts +161 -50
- package/dist/client/app/stores/story.js +5 -16
- package/dist/client/app/stores/story.js.map +1 -1
- package/dist/client/app/stores/story.ts +22 -0
- package/dist/client/app/style/main.css +16 -2
- package/dist/client/app/style/sandbox.css +14 -0
- package/dist/client/app/types.d.ts +36 -4
- package/dist/client/app/types.ts +45 -0
- package/dist/client/app/util/config.d.ts +3 -0
- package/dist/client/app/util/config.js +5 -0
- package/dist/client/app/util/config.js.map +1 -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 +2 -0
- package/dist/client/app/util/const.js.map +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 +4 -0
- package/dist/client/app/util/dark.js.map +1 -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 +2 -0
- package/dist/client/app/util/env.js.map +1 -0
- package/dist/client/app/util/keyboard.d.ts +8 -0
- package/dist/client/app/util/keyboard.js +83 -0
- package/dist/client/app/util/keyboard.js.map +1 -0
- package/dist/client/app/util/mapping.d.ts +3 -0
- package/dist/client/app/util/mapping.js +37 -0
- package/dist/client/app/util/mapping.js.map +1 -0
- package/dist/client/app/util/mapping.ts +38 -0
- package/dist/client/app/util/tooltip.d.ts +6 -0
- package/dist/client/app/util/tooltip.js +12 -0
- package/dist/client/app/util/tooltip.js.map +1 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +4 -0
- package/dist/client/index.js.map +1 -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 +26 -0
- package/dist/client/server/index.js.map +1 -0
- package/dist/client/server/index.ts +29 -0
- package/dist/client/shim.d.ts +5 -0
- package/dist/node/bin.js +8 -2
- package/dist/node/bin.js.map +1 -1
- package/dist/node/build.d.ts +2 -0
- package/dist/node/build.js +72 -0
- package/dist/node/build.js.map +1 -0
- package/dist/node/collect.d.ts +12 -0
- package/dist/node/collect.js +66 -0
- package/dist/node/collect.js.map +1 -0
- package/dist/node/colors.d.ts +274 -0
- package/dist/node/colors.js +313 -0
- package/dist/node/colors.js.map +1 -0
- package/dist/node/commands/build.d.ts +1 -0
- package/dist/node/commands/build.js +11 -0
- package/dist/node/commands/build.js.map +1 -0
- package/dist/node/commands/dev.d.ts +1 -1
- package/dist/node/commands/dev.js +6 -11
- package/dist/node/commands/dev.js.map +1 -1
- package/dist/node/config.d.ts +99 -1
- package/dist/node/config.js +90 -1
- package/dist/node/config.js.map +1 -1
- package/dist/node/context.d.ts +13 -0
- package/dist/node/context.js +12 -1
- package/dist/node/context.js.map +1 -1
- package/dist/node/dom/dom-keys.d.ts +4 -0
- package/dist/node/dom/dom-keys.js +224 -0
- package/dist/node/dom/dom-keys.js.map +1 -0
- package/dist/node/dom/env.d.ts +5 -0
- package/dist/node/dom/env.js +23 -0
- package/dist/node/dom/env.js.map +1 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/plugin.d.ts +8 -2
- package/dist/node/plugin.js +142 -21
- package/dist/node/plugin.js.map +1 -1
- package/dist/node/server.d.ts +4 -1
- package/dist/node/server.js +80 -20
- package/dist/node/server.js.map +1 -1
- package/dist/node/stories.d.ts +8 -9
- package/dist/node/stories.js +42 -22
- package/dist/node/stories.js.map +1 -1
- package/dist/node/tree.d.ts +19 -0
- package/dist/node/tree.js +55 -0
- package/dist/node/tree.js.map +1 -0
- package/dist/node/types.d.ts +38 -0
- package/dist/node/types.js +2 -0
- package/dist/node/types.js.map +1 -0
- package/dist/style.css +558 -52
- package/package.json +42 -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 +80 -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 +117 -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 +4 -1
- package/src/client/app/sandbox.ts +60 -0
- package/src/client/app/stores/story.ts +6 -18
- package/src/client/app/style/main.css +16 -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 +38 -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 +328 -0
- package/src/node/commands/build.ts +12 -0
- package/src/node/commands/dev.ts +6 -13
- package/src/node/config.ts +193 -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 +146 -22
- package/src/node/server.ts +95 -20
- package/src/node/stories.ts +53 -31
- package/src/node/tree.ts +88 -0
- package/src/node/types.ts +40 -0
- package/tailwind.config.cjs +41 -1
- package/dist/client/app/components/StoryVariantItem.vue +0 -29
- package/src/client/app/components/StoryVariantItem.vue +0 -29
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { PropType } from 'vue'
|
|
3
3
|
import { Story, Variant } from '../types'
|
|
4
|
-
import
|
|
4
|
+
import SandboxVue3 from './sandbox/SandboxVue3.vue'
|
|
5
|
+
import BaseEmpty from './base/BaseEmpty.vue'
|
|
5
6
|
|
|
6
7
|
defineProps({
|
|
7
8
|
variant: {
|
|
@@ -19,11 +20,15 @@ defineProps({
|
|
|
19
20
|
<template>
|
|
20
21
|
<div>
|
|
21
22
|
<!-- Custom controls -->
|
|
22
|
-
<
|
|
23
|
+
<SandboxVue3
|
|
23
24
|
v-if="variant.slots().controls"
|
|
24
25
|
slot-name="controls"
|
|
25
26
|
:variant="variant"
|
|
26
27
|
:story="story"
|
|
27
28
|
/>
|
|
29
|
+
|
|
30
|
+
<BaseEmpty v-else>
|
|
31
|
+
<span>No controls available for this story</span>
|
|
32
|
+
</BaseEmpty>
|
|
28
33
|
</div>
|
|
29
34
|
</template>
|
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
import { Story } from '../types'
|
|
2
|
+
import { Story, Tree } from '../types'
|
|
4
3
|
import StoryListItem from './StoryListItem.vue'
|
|
4
|
+
import StoryListFolder from './StoryListFolder.vue'
|
|
5
5
|
|
|
6
|
-
const props = defineProps
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
})
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
tree: Tree
|
|
8
|
+
stories: Story[]
|
|
9
|
+
}>()
|
|
12
10
|
</script>
|
|
13
11
|
|
|
14
12
|
<template>
|
|
15
13
|
<div class="htw-overflow-y-auto">
|
|
16
|
-
<
|
|
17
|
-
v-for="
|
|
18
|
-
:key="
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
<template
|
|
15
|
+
v-for="element of tree"
|
|
16
|
+
:key="element.title"
|
|
17
|
+
>
|
|
18
|
+
<StoryListFolder
|
|
19
|
+
v-if="element.children"
|
|
20
|
+
:folder="element"
|
|
21
|
+
:stories="stories"
|
|
22
|
+
/>
|
|
23
|
+
<StoryListItem
|
|
24
|
+
v-else
|
|
25
|
+
:story="stories[element.index]"
|
|
26
|
+
/>
|
|
27
|
+
</template>
|
|
21
28
|
</div>
|
|
22
29
|
</template>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { Story, TreeFolder } from '../types'
|
|
3
|
+
import StoryListItem from './StoryListItem.vue'
|
|
4
|
+
import { Icon } from '@iconify/vue'
|
|
5
|
+
import { computed, ref, withDefaults } from 'vue'
|
|
6
|
+
|
|
7
|
+
const props = withDefaults(defineProps<{
|
|
8
|
+
folder: TreeFolder
|
|
9
|
+
stories: Story[]
|
|
10
|
+
depth?: number
|
|
11
|
+
}>(), {
|
|
12
|
+
depth: 0,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const isFolderOpen = ref(false)
|
|
16
|
+
|
|
17
|
+
function toggleOpen () {
|
|
18
|
+
isFolderOpen.value = !isFolderOpen.value
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const folderPadding = computed(() => {
|
|
22
|
+
return (props.depth * 16) + 'px'
|
|
23
|
+
})
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<div class="toast">
|
|
28
|
+
<div
|
|
29
|
+
role="button"
|
|
30
|
+
tabindex="0"
|
|
31
|
+
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"
|
|
32
|
+
@click="toggleOpen"
|
|
33
|
+
@keyup.enter="toggleOpen"
|
|
34
|
+
@keyup.space="toggleOpen"
|
|
35
|
+
>
|
|
36
|
+
<span class="bind-tree-padding htw-flex htw-items-center htw-gap-2 htw-min-w-0">
|
|
37
|
+
<span class="htw-flex htw-gap-1 htw-flex-none htw-items-center">
|
|
38
|
+
<Icon
|
|
39
|
+
icon="carbon:caret-right"
|
|
40
|
+
class="htw-w-4 htw-h-4 htw-transition-transform htw-duration-150 htw-opacity-30"
|
|
41
|
+
:class="{
|
|
42
|
+
'htw-rotate-90': isFolderOpen,
|
|
43
|
+
}"
|
|
44
|
+
/>
|
|
45
|
+
<Icon
|
|
46
|
+
icon="carbon:folder"
|
|
47
|
+
class="htw-w-5 htw-h-5"
|
|
48
|
+
/>
|
|
49
|
+
</span>
|
|
50
|
+
<span class="htw-truncate">{{ folder.title }}</span>
|
|
51
|
+
</span>
|
|
52
|
+
</div>
|
|
53
|
+
<div
|
|
54
|
+
v-if="isFolderOpen"
|
|
55
|
+
>
|
|
56
|
+
<template
|
|
57
|
+
v-for="element of folder.children"
|
|
58
|
+
:key="element.title"
|
|
59
|
+
>
|
|
60
|
+
<StoryListFolder
|
|
61
|
+
v-if="element.children"
|
|
62
|
+
:folder="element"
|
|
63
|
+
:stories="stories"
|
|
64
|
+
:depth="depth + 1"
|
|
65
|
+
/>
|
|
66
|
+
<StoryListItem
|
|
67
|
+
v-else
|
|
68
|
+
:story="stories[element.index]"
|
|
69
|
+
:depth="depth + 1"
|
|
70
|
+
/>
|
|
71
|
+
</template>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<style scoped>
|
|
77
|
+
.bind-tree-padding {
|
|
78
|
+
padding-left: v-bind(folderPadding);
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
@@ -1,34 +1,60 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { PropType } from 'vue'
|
|
3
2
|
import { Story } from '../types'
|
|
3
|
+
import BaseListItemLink from './base/BaseListItemLink.vue'
|
|
4
|
+
import { Icon } from '@iconify/vue'
|
|
5
|
+
import { computed, withDefaults } from 'vue'
|
|
4
6
|
|
|
5
|
-
defineProps
|
|
6
|
-
story:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const props = withDefaults(defineProps<{
|
|
8
|
+
story: Story
|
|
9
|
+
depth?: number
|
|
10
|
+
}>(), {
|
|
11
|
+
depth: 0,
|
|
10
12
|
})
|
|
13
|
+
|
|
14
|
+
const filePadding = computed(() => {
|
|
15
|
+
return (props.depth * 16) + 'px'
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const iconColor = computed(() => props.story.iconColor)
|
|
11
19
|
</script>
|
|
12
20
|
|
|
13
21
|
<template>
|
|
14
22
|
<div>
|
|
15
|
-
<
|
|
23
|
+
<BaseListItemLink
|
|
24
|
+
v-slot="{ active }"
|
|
16
25
|
:to="{
|
|
17
26
|
name: 'story',
|
|
18
27
|
params: {
|
|
19
28
|
storyId: story.id,
|
|
20
29
|
},
|
|
21
30
|
}"
|
|
22
|
-
class="htw-
|
|
23
|
-
active-class="htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white htw-font-bold"
|
|
31
|
+
class="htw-pl-0.5 htw-pr-2 htw-py-1.5 htw-m-1 htw-rounded-sm"
|
|
24
32
|
>
|
|
25
|
-
<span>
|
|
26
|
-
|
|
33
|
+
<span class="bind-tree-margin htw-flex htw-items-center htw-gap-2 htw-pl-5 htw-min-w-0">
|
|
34
|
+
<Icon
|
|
35
|
+
:icon="story.icon ?? 'carbon:cube'"
|
|
36
|
+
class="base-list-item-link-icon htw-w-5 htw-h-5 htw-flex-none"
|
|
37
|
+
:class="{
|
|
38
|
+
'htw-text-primary-500': !active && !story.iconColor,
|
|
39
|
+
'bind-icon-color': !active && story.iconColor,
|
|
40
|
+
}"
|
|
41
|
+
/>
|
|
42
|
+
<span class="htw-truncate">{{ story.title }}</span>
|
|
27
43
|
</span>
|
|
28
44
|
|
|
29
45
|
<span class="htw-opacity-40 htw-text-sm">
|
|
30
46
|
{{ story.variants.length }}
|
|
31
47
|
</span>
|
|
32
|
-
</
|
|
48
|
+
</BaseListItemLink>
|
|
33
49
|
</div>
|
|
34
50
|
</template>
|
|
51
|
+
|
|
52
|
+
<style scoped>
|
|
53
|
+
.bind-tree-margin {
|
|
54
|
+
margin-left: v-bind(filePadding);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.bind-icon-color {
|
|
58
|
+
color: v-bind(iconColor);
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, onMounted, PropType, ref, shallowRef, watch } from 'vue'
|
|
3
|
+
import { getHighlighter, Highlighter, setCDN } from 'shiki'
|
|
4
|
+
import { Icon } from '@iconify/vue'
|
|
5
|
+
import { generateSourceCode } from '../codegen/vue3'
|
|
6
|
+
import { Variant } from '../types'
|
|
7
|
+
import { isDark } from '../util/dark'
|
|
8
|
+
import { unindent } from '../codegen/util'
|
|
9
|
+
import { useClipboard } from '@vueuse/core'
|
|
10
|
+
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
variant: {
|
|
13
|
+
type: Object as PropType<Variant>,
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const sourceCode = ref('')
|
|
19
|
+
const highlighter = shallowRef<Highlighter>()
|
|
20
|
+
const error = ref<string>(null)
|
|
21
|
+
|
|
22
|
+
onMounted(async () => {
|
|
23
|
+
setCDN('https://unpkg.com/shiki/')
|
|
24
|
+
highlighter.value = await getHighlighter({
|
|
25
|
+
langs: [
|
|
26
|
+
'html',
|
|
27
|
+
'jsx',
|
|
28
|
+
],
|
|
29
|
+
themes: [
|
|
30
|
+
'github-light',
|
|
31
|
+
'github-dark',
|
|
32
|
+
],
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
watch(() => props.variant, async (value) => {
|
|
37
|
+
error.value = null
|
|
38
|
+
try {
|
|
39
|
+
if (value.source) {
|
|
40
|
+
sourceCode.value = value.source
|
|
41
|
+
} else if (value.slots?.().source) {
|
|
42
|
+
const source = value.slots?.().source()[0].children
|
|
43
|
+
if (source) {
|
|
44
|
+
sourceCode.value = await unindent(source)
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
sourceCode.value = await generateSourceCode(value)
|
|
48
|
+
}
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.error(e)
|
|
51
|
+
error.value = e.message
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
deep: true,
|
|
55
|
+
immediate: true,
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const sourceHtml = computed(() => highlighter.value?.codeToHtml(sourceCode.value, {
|
|
59
|
+
lang: 'html',
|
|
60
|
+
theme: isDark.value ? 'github-dark' : 'github-light',
|
|
61
|
+
}))
|
|
62
|
+
|
|
63
|
+
// Copy
|
|
64
|
+
const { copy, copied } = useClipboard()
|
|
65
|
+
|
|
66
|
+
const copySourceCode = () => copy(sourceCode.value)
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<template>
|
|
70
|
+
<div class="htw-bg-gray-100 dark:htw-bg-gray-800 htw-h-full htw-overflow-hidden htw-relative">
|
|
71
|
+
<div
|
|
72
|
+
v-if="error"
|
|
73
|
+
class="htw-text-red-500 htw-h-full htw-p-2 htw-overflow-auto htw-font-mono htw-text-sm"
|
|
74
|
+
>
|
|
75
|
+
Error: {{ error }}
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<textarea
|
|
79
|
+
v-else-if="!sourceHtml"
|
|
80
|
+
class="__histoire-code-placeholder htw-w-full htw-h-full htw-p-2.5 htw-outline-none htw-bg-transparent htw-resize-none htw-m-0"
|
|
81
|
+
:value="sourceCode"
|
|
82
|
+
readonly
|
|
83
|
+
/>
|
|
84
|
+
<!-- eslint-disable vue/no-v-html -->
|
|
85
|
+
<div
|
|
86
|
+
v-else
|
|
87
|
+
class="__histoire-code htw-w-full htw-h-full htw-p-2.5 htw-overflow-auto"
|
|
88
|
+
v-html="sourceHtml"
|
|
89
|
+
/>
|
|
90
|
+
<!-- eslint-enable vue/no-v-html -->
|
|
91
|
+
|
|
92
|
+
<!-- Toolbar -->
|
|
93
|
+
<div
|
|
94
|
+
v-if="!error"
|
|
95
|
+
class="htw-absolute htw-top-2 htw-right-6 htw-p-1 htw-bg-gray-100 dark:htw-bg-gray-800"
|
|
96
|
+
>
|
|
97
|
+
<Icon
|
|
98
|
+
v-tooltip="{
|
|
99
|
+
content: 'Copied!',
|
|
100
|
+
triggers: [],
|
|
101
|
+
shown: copied,
|
|
102
|
+
distance: 12,
|
|
103
|
+
}"
|
|
104
|
+
icon="cil:copy"
|
|
105
|
+
class="htw-w-4 htw-h-4 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
|
|
106
|
+
@click="copySourceCode()"
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
</template>
|
|
111
|
+
|
|
112
|
+
<style scoped>
|
|
113
|
+
.__histoire-code-placeholder {
|
|
114
|
+
color: inherit;
|
|
115
|
+
font-size: inherit;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.__histoire-code:deep(.shiki) {
|
|
119
|
+
background: transparent !important;
|
|
120
|
+
}
|
|
121
|
+
</style>
|
|
@@ -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,13 @@
|
|
|
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'
|
|
5
7
|
import BaseSplitPane from './base/BaseSplitPane.vue'
|
|
8
|
+
import HatchedPattern from './misc/HatchedPattern.vue'
|
|
6
9
|
|
|
7
|
-
defineProps({
|
|
10
|
+
const props = defineProps({
|
|
8
11
|
variant: {
|
|
9
12
|
type: Object as PropType<Variant>,
|
|
10
13
|
required: true,
|
|
@@ -15,28 +18,127 @@ defineProps({
|
|
|
15
18
|
required: true,
|
|
16
19
|
},
|
|
17
20
|
})
|
|
21
|
+
|
|
22
|
+
// Iframe
|
|
23
|
+
|
|
24
|
+
const iframe = ref<HTMLIFrameElement>()
|
|
25
|
+
|
|
26
|
+
function syncState () {
|
|
27
|
+
if (iframe.value) {
|
|
28
|
+
iframe.value.contentWindow.postMessage({
|
|
29
|
+
type: STATE_SYNC,
|
|
30
|
+
state: toRaw(props.variant.state),
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
watch(() => props.variant.state, () => {
|
|
36
|
+
syncState()
|
|
37
|
+
}, {
|
|
38
|
+
deep: true,
|
|
39
|
+
immediate: true,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
useEventListener(window, 'message', (event) => {
|
|
43
|
+
if (event.data.type === STATE_SYNC) {
|
|
44
|
+
Object.assign(props.variant.state, event.data.state)
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const sandboxUrl = computed(() => {
|
|
49
|
+
const url = new URLSearchParams()
|
|
50
|
+
url.append('storyId', props.story.id)
|
|
51
|
+
url.append('variantId', props.variant.id)
|
|
52
|
+
return '/__sandbox?' + url.toString()
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const isIframeLoaded = ref(false)
|
|
56
|
+
|
|
57
|
+
watch(sandboxUrl, () => {
|
|
58
|
+
isIframeLoaded.value = false
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
function onIframeLoad () {
|
|
62
|
+
isIframeLoaded.value = true
|
|
63
|
+
syncState()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Responsive
|
|
67
|
+
|
|
68
|
+
const responsiveWidth = ref<number>(undefined)
|
|
18
69
|
</script>
|
|
19
70
|
|
|
20
71
|
<template>
|
|
21
|
-
<div class="htw-
|
|
72
|
+
<div class="htw-h-full htw-flex htw-flex-col htw-gap-2">
|
|
73
|
+
<div class="htw-flex-none htw-flex htw-items-center htw-gap-2">
|
|
74
|
+
<!-- Variant title -->
|
|
75
|
+
<div class="htw-flex htw-items-center htw-gap-1 htw-text-gray-500 htw-flex-1 htw-truncate htw-min-w-0">
|
|
76
|
+
<Icon
|
|
77
|
+
:icon="variant.icon ?? 'carbon:cube'"
|
|
78
|
+
class="base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50"
|
|
79
|
+
:class="[
|
|
80
|
+
variant.iconColor ? 'bind-icon-color' : 'htw-text-gray-500',
|
|
81
|
+
]"
|
|
82
|
+
/>
|
|
83
|
+
<span>{{ variant.title }}</span>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<!-- Responsive size -->
|
|
87
|
+
<div class="htw-flex-none htw-flex htw-gap-1 htw-items-center">
|
|
88
|
+
<Icon
|
|
89
|
+
icon="ic:baseline-phone-android"
|
|
90
|
+
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
91
|
+
/>
|
|
92
|
+
|
|
93
|
+
<input
|
|
94
|
+
v-model.number="responsiveWidth"
|
|
95
|
+
v-tooltip="'Responsive width (px)'"
|
|
96
|
+
type="number"
|
|
97
|
+
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"
|
|
98
|
+
step="16"
|
|
99
|
+
>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
22
103
|
<BaseSplitPane
|
|
104
|
+
v-model:split="responsiveWidth"
|
|
23
105
|
save-id="story-single-responsive"
|
|
24
|
-
:min="
|
|
25
|
-
:max="
|
|
26
|
-
:default-split="
|
|
27
|
-
|
|
28
|
-
class="htw-w-full"
|
|
106
|
+
:min="30"
|
|
107
|
+
:max="6000"
|
|
108
|
+
:default-split="720"
|
|
109
|
+
fixed
|
|
110
|
+
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
111
|
>
|
|
30
112
|
<template #first>
|
|
31
|
-
<div class="htw-p-4 htw-h-full htw-overflow-
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
113
|
+
<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">
|
|
114
|
+
<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">
|
|
115
|
+
<iframe
|
|
116
|
+
ref="iframe"
|
|
117
|
+
:src="sandboxUrl"
|
|
118
|
+
class="htw-w-full htw-h-full"
|
|
119
|
+
:class="{'htw-invisible': !isIframeLoaded}"
|
|
120
|
+
@load="onIframeLoad()"
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
<!-- Markers -->
|
|
124
|
+
<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" />
|
|
125
|
+
<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" />
|
|
126
|
+
<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" />
|
|
127
|
+
<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" />
|
|
128
|
+
<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" />
|
|
129
|
+
<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" />
|
|
130
|
+
<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" />
|
|
131
|
+
<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
132
|
</div>
|
|
37
133
|
</template>
|
|
38
134
|
<template #last>
|
|
39
|
-
<div
|
|
135
|
+
<div
|
|
136
|
+
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"
|
|
137
|
+
>
|
|
138
|
+
<HatchedPattern
|
|
139
|
+
class="htw-w-full htw-h-full htw-text-black/[2%] dark:htw-text-white/[2%]"
|
|
140
|
+
/>
|
|
141
|
+
</div>
|
|
40
142
|
</template>
|
|
41
143
|
</BaseSplitPane>
|
|
42
144
|
</div>
|