histoire 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/client/app/App.vue +1 -1
- package/dist/client/app/codegen/vue3.js +28 -4
- package/dist/client/app/codegen/vue3.ts +32 -4
- package/dist/client/app/components/app/AppHeader.vue +10 -3
- package/dist/client/app/components/base/BaseTab.vue +46 -0
- package/dist/client/app/components/exposed/Story.vue +21 -1
- package/dist/client/app/components/exposed/Variant.vue +1 -0
- package/dist/client/app/components/misc/CheckerboardPattern.vue +32 -0
- package/dist/client/app/components/sandbox/SandboxVue3.vue +6 -0
- package/dist/client/app/components/search/SearchItem.vue +5 -9
- package/dist/client/app/components/{StoryControls.vue → story/StoryControls.vue} +3 -3
- package/dist/client/app/components/story/StoryDocs.vue +37 -0
- package/dist/client/app/components/{StoryList.vue → story/StoryList.vue} +4 -4
- package/{src/client/app/components → dist/client/app/components/story}/StoryListFolder.vue +5 -5
- package/{src/client/app/components → dist/client/app/components/story}/StoryListItem.vue +11 -6
- package/dist/client/app/components/story/StoryResponsivePreview.vue +214 -0
- package/dist/client/app/components/{StorySourceCode.vue → story/StorySourceCode.vue} +4 -8
- package/{src/client/app/components → dist/client/app/components/story}/StoryVariantGridItem.vue +14 -6
- package/dist/client/app/components/{StoryVariantListItem.vue → story/StoryVariantListItem.vue} +9 -8
- package/dist/client/app/components/story/StoryVariantSingleView.vue +182 -0
- package/dist/client/app/components/{StoryView.vue → story/StoryView.vue} +37 -10
- package/dist/client/app/global-components.js +2 -0
- package/dist/client/app/global-components.ts +3 -0
- package/dist/client/app/index.js +4 -0
- package/dist/client/app/index.ts +4 -0
- package/dist/client/app/router.js +1 -1
- package/dist/client/app/router.ts +1 -1
- package/dist/client/app/sandbox.js +37 -3
- package/dist/client/app/sandbox.ts +37 -3
- package/dist/client/app/stores/story.d.ts +15 -0
- package/dist/client/app/style/main.css +15 -0
- package/dist/client/app/style/sandbox.css +5 -0
- package/dist/client/app/style/transitions.css +12 -0
- package/dist/client/app/types.d.ts +1 -0
- package/dist/client/app/types.ts +1 -0
- package/dist/client/app/util/const.d.ts +2 -0
- package/dist/client/app/util/const.js +2 -0
- package/dist/client/app/util/const.ts +2 -0
- package/dist/client/app/util/mapping.js +3 -0
- package/dist/client/app/util/mapping.ts +2 -0
- package/dist/client/app/util/preview-settings.d.ts +16 -0
- package/dist/client/app/util/preview-settings.js +15 -0
- package/dist/client/app/util/preview-settings.ts +26 -0
- package/dist/client/app/util/reactivity.d.ts +1 -0
- package/dist/client/app/util/reactivity.js +16 -0
- package/dist/client/app/util/reactivity.ts +22 -0
- package/dist/client/app/util/scroll.d.ts +2 -0
- package/dist/client/app/util/scroll.js +24 -0
- package/dist/client/app/util/scroll.ts +27 -0
- package/dist/client/app/{composable → util}/variant.d.ts +0 -0
- package/dist/client/app/{composable → util}/variant.js +0 -0
- package/dist/client/app/{composable → util}/variant.ts +0 -0
- package/dist/client/server/Story.server.vue +25 -2
- package/dist/client/server/index.js +2 -0
- package/dist/client/server/index.ts +3 -0
- package/dist/controls.d.ts +1 -0
- package/dist/controls.js +1 -0
- package/dist/node/build.js +13 -8
- package/dist/node/collect.js +12 -3
- package/dist/node/config.d.ts +24 -2
- package/dist/node/config.js +44 -4
- package/dist/node/markdown.d.ts +2 -0
- package/dist/node/markdown.js +48 -0
- package/dist/node/plugin.js +29 -2
- package/dist/node/util/slugify.d.ts +1 -0
- package/dist/node/util/slugify.js +22 -0
- package/dist/style.css +826 -171
- package/package.json +14 -4
- package/src/client/app/App.vue +1 -1
- package/src/client/app/codegen/vue3.ts +32 -4
- package/src/client/app/components/app/AppHeader.vue +10 -3
- package/src/client/app/components/base/BaseTab.vue +46 -0
- package/src/client/app/components/exposed/Story.vue +21 -1
- package/src/client/app/components/exposed/Variant.vue +1 -0
- package/src/client/app/components/misc/CheckerboardPattern.vue +32 -0
- package/src/client/app/components/sandbox/SandboxVue3.vue +6 -0
- package/src/client/app/components/search/SearchItem.vue +5 -9
- package/src/client/app/components/{StoryControls.vue → story/StoryControls.vue} +3 -3
- package/src/client/app/components/story/StoryDocs.vue +37 -0
- package/src/client/app/components/{StoryList.vue → story/StoryList.vue} +4 -4
- package/{dist/client/app/components → src/client/app/components/story}/StoryListFolder.vue +5 -5
- package/{dist/client/app/components → src/client/app/components/story}/StoryListItem.vue +11 -6
- package/src/client/app/components/story/StoryResponsivePreview.vue +214 -0
- package/src/client/app/components/{StorySourceCode.vue → story/StorySourceCode.vue} +4 -8
- package/{dist/client/app/components → src/client/app/components/story}/StoryVariantGridItem.vue +14 -6
- package/src/client/app/components/{StoryVariantListItem.vue → story/StoryVariantListItem.vue} +9 -8
- package/src/client/app/components/story/StoryVariantSingleView.vue +182 -0
- package/src/client/app/components/{StoryView.vue → story/StoryView.vue} +37 -10
- package/src/client/app/global-components.ts +3 -0
- package/src/client/app/index.ts +4 -0
- package/src/client/app/router.ts +1 -1
- package/src/client/app/sandbox.ts +37 -3
- package/src/client/app/style/main.css +15 -0
- package/src/client/app/style/sandbox.css +5 -0
- package/src/client/app/style/transitions.css +12 -0
- package/src/client/app/types.ts +1 -0
- package/src/client/app/util/const.ts +2 -0
- package/src/client/app/util/mapping.ts +2 -0
- package/src/client/app/util/preview-settings.ts +26 -0
- package/src/client/app/util/reactivity.ts +22 -0
- package/src/client/app/util/scroll.ts +27 -0
- package/src/client/app/{composable → util}/variant.ts +0 -0
- package/src/client/server/Story.server.vue +25 -2
- package/src/client/server/index.ts +3 -0
- package/src/controls.ts +1 -0
- package/src/node/build.ts +15 -8
- package/src/node/collect.ts +12 -3
- package/src/node/config.ts +69 -6
- package/src/node/markdown.ts +56 -0
- package/src/node/plugin.ts +31 -2
- package/src/node/util/slugify.ts +26 -0
- package/tailwind.config.cjs +79 -4
- package/dist/client/app/components/StoryVariantSingleView.vue +0 -173
- package/src/client/app/components/StoryVariantSingleView.vue +0 -173
package/README.md
ADDED
package/dist/client/app/App.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
// @ts-expect-error virtual module
|
|
3
3
|
import { files as rawFiles, tree as rawTree, onUpdate } from '$histoire-stories'
|
|
4
|
-
import StoryList from './components/StoryList.vue'
|
|
4
|
+
import StoryList from './components/story/StoryList.vue'
|
|
5
5
|
import BaseSplitPane from './components/base/BaseSplitPane.vue'
|
|
6
6
|
import { computed, ref, watch, defineAsyncComponent } from 'vue'
|
|
7
7
|
import AppHeader from './components/app/AppHeader.vue'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @TODO remove no-check and fix vnode type errors
|
|
3
3
|
import { vModelText, vModelCheckbox, vModelSelect, vModelRadio, vModelDynamic } from 'vue';
|
|
4
4
|
import { Text } from '@vue/runtime-core';
|
|
5
|
-
import { pascal
|
|
5
|
+
import { pascal } from 'case';
|
|
6
6
|
import { createAutoBuildingObject, indent } from './util';
|
|
7
7
|
import { serializeJs } from './serialize-js';
|
|
8
8
|
export async function generateSourceCode(variant) {
|
|
@@ -41,7 +41,7 @@ async function printVNode(vnode) {
|
|
|
41
41
|
}
|
|
42
42
|
const valueLines = valueCode ? [valueCode] : serializeAndCleanJs(dir.value);
|
|
43
43
|
const attr = [];
|
|
44
|
-
const dirAttr = `v-${dirName}${
|
|
44
|
+
const dirAttr = `v-${dirName}${arg}${modifiers}="`;
|
|
45
45
|
if (valueLines.length > 1) {
|
|
46
46
|
attr.push(`${dirAttr}${valueLines[0]}`);
|
|
47
47
|
attr.push(...valueLines.slice(1, valueLines.length - 1));
|
|
@@ -99,7 +99,31 @@ async function printVNode(vnode) {
|
|
|
99
99
|
if (prop.startsWith('on')) {
|
|
100
100
|
directive = '@';
|
|
101
101
|
}
|
|
102
|
-
const arg =
|
|
102
|
+
const arg = directive === '@' ? `${prop[2].toLowerCase()}${prop.slice(3)}` : prop;
|
|
103
|
+
// v-model on component
|
|
104
|
+
const vmodelListener = `onUpdate:${prop}`;
|
|
105
|
+
if (directive === ':' && vnode.dynamicProps?.includes(vmodelListener)) {
|
|
106
|
+
// Listener
|
|
107
|
+
skipProps.push(vmodelListener);
|
|
108
|
+
const listener = vnode.props[vmodelListener];
|
|
109
|
+
const listenerSource = listener.toString();
|
|
110
|
+
let valueCode;
|
|
111
|
+
const result = /\(\$event\) => (.*?) = \$event/.exec(listenerSource);
|
|
112
|
+
if (result) {
|
|
113
|
+
valueCode = result[1];
|
|
114
|
+
}
|
|
115
|
+
// Modifiers
|
|
116
|
+
const modifiersKey = `${prop === 'modelValue' ? 'model' : prop}Modifiers`;
|
|
117
|
+
const modifiers = vnode.props[modifiersKey] ?? {};
|
|
118
|
+
skipProps.push(modifiersKey);
|
|
119
|
+
// Directive
|
|
120
|
+
genDirective('model', {
|
|
121
|
+
arg: prop === 'modelValue' ? null : prop,
|
|
122
|
+
modifiers,
|
|
123
|
+
value,
|
|
124
|
+
}, valueCode);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
103
127
|
let serialized;
|
|
104
128
|
if (typeof value === 'string' && value.startsWith('{{') && value.endsWith('}}')) {
|
|
105
129
|
// It was formatted from auto building object (slot props)
|
|
@@ -120,7 +144,7 @@ async function printVNode(vnode) {
|
|
|
120
144
|
}
|
|
121
145
|
}
|
|
122
146
|
else {
|
|
123
|
-
attrs.push([`${
|
|
147
|
+
attrs.push([`${prop}="${value}"`]);
|
|
124
148
|
}
|
|
125
149
|
}
|
|
126
150
|
if (attrs.length > 1) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { VNode, vModelText, vModelCheckbox, vModelSelect, vModelRadio, vModelDynamic } from 'vue'
|
|
5
5
|
import { Text } from '@vue/runtime-core'
|
|
6
|
-
import { pascal
|
|
6
|
+
import { pascal } from 'case'
|
|
7
7
|
import { createAutoBuildingObject, indent } from './util'
|
|
8
8
|
import { serializeJs } from './serialize-js'
|
|
9
9
|
import type { Variant } from '../types'
|
|
@@ -49,7 +49,7 @@ async function printVNode (vnode: VNode): Promise<string[]> {
|
|
|
49
49
|
}
|
|
50
50
|
const valueLines = valueCode ? [valueCode] : serializeAndCleanJs(dir.value)
|
|
51
51
|
const attr: string[] = []
|
|
52
|
-
const dirAttr = `v-${dirName}${
|
|
52
|
+
const dirAttr = `v-${dirName}${arg}${modifiers}="`
|
|
53
53
|
if (valueLines.length > 1) {
|
|
54
54
|
attr.push(`${dirAttr}${valueLines[0]}`)
|
|
55
55
|
attr.push(...valueLines.slice(1, valueLines.length - 1))
|
|
@@ -105,7 +105,35 @@ async function printVNode (vnode: VNode): Promise<string[]> {
|
|
|
105
105
|
if (prop.startsWith('on')) {
|
|
106
106
|
directive = '@'
|
|
107
107
|
}
|
|
108
|
-
const arg =
|
|
108
|
+
const arg = directive === '@' ? `${prop[2].toLowerCase()}${prop.slice(3)}` : prop
|
|
109
|
+
|
|
110
|
+
// v-model on component
|
|
111
|
+
const vmodelListener = `onUpdate:${prop}`
|
|
112
|
+
if (directive === ':' && vnode.dynamicProps?.includes(vmodelListener)) {
|
|
113
|
+
// Listener
|
|
114
|
+
skipProps.push(vmodelListener)
|
|
115
|
+
const listener = vnode.props[vmodelListener]
|
|
116
|
+
const listenerSource = listener.toString()
|
|
117
|
+
let valueCode: string
|
|
118
|
+
const result = /\(\$event\) => (.*?) = \$event/.exec(listenerSource)
|
|
119
|
+
if (result) {
|
|
120
|
+
valueCode = result[1]
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Modifiers
|
|
124
|
+
const modifiersKey = `${prop === 'modelValue' ? 'model' : prop}Modifiers`
|
|
125
|
+
const modifiers = vnode.props[modifiersKey] ?? {}
|
|
126
|
+
skipProps.push(modifiersKey)
|
|
127
|
+
|
|
128
|
+
// Directive
|
|
129
|
+
genDirective('model', {
|
|
130
|
+
arg: prop === 'modelValue' ? null : prop,
|
|
131
|
+
modifiers,
|
|
132
|
+
value,
|
|
133
|
+
}, valueCode)
|
|
134
|
+
continue
|
|
135
|
+
}
|
|
136
|
+
|
|
109
137
|
let serialized: string[]
|
|
110
138
|
if (typeof value === 'string' && value.startsWith('{{') && value.endsWith('}}')) {
|
|
111
139
|
// It was formatted from auto building object (slot props)
|
|
@@ -123,7 +151,7 @@ async function printVNode (vnode: VNode): Promise<string[]> {
|
|
|
123
151
|
attrs.push([`${directive}${arg}="${serialized[0]}"`])
|
|
124
152
|
}
|
|
125
153
|
} else {
|
|
126
|
-
attrs.push([`${
|
|
154
|
+
attrs.push([`${prop}="${value}"`])
|
|
127
155
|
}
|
|
128
156
|
}
|
|
129
157
|
if (attrs.length > 1) {
|
|
@@ -5,6 +5,7 @@ import AppLogo from './AppLogo.vue'
|
|
|
5
5
|
import { isDark, toggleDark } from '../../util/dark'
|
|
6
6
|
import { onKeyboardShortcut } from '../../util/keyboard'
|
|
7
7
|
import { makeTooltip } from '../../util/tooltip'
|
|
8
|
+
import { histoireConfig } from '../../util/config'
|
|
8
9
|
|
|
9
10
|
defineEmits({
|
|
10
11
|
search: () => true,
|
|
@@ -25,9 +26,15 @@ onKeyboardShortcut(['ctrl+shift+d', 'meta+shift+d'], (event) => {
|
|
|
25
26
|
class="htw-px-4 htw-h-16 htw-flex htw-items-center htw-gap-2"
|
|
26
27
|
>
|
|
27
28
|
<div class="htw-py-4 htw-flex-1 htw-h-full htw-flex htw-items-center htw-pr-2">
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
<a
|
|
30
|
+
:href="histoireConfig.theme?.logoHref"
|
|
31
|
+
target="_blank"
|
|
32
|
+
class="htw-block htw-w-full htw-h-full"
|
|
33
|
+
>
|
|
34
|
+
<AppLogo
|
|
35
|
+
class="htw-max-w-full htw-max-h-full"
|
|
36
|
+
/>
|
|
37
|
+
</a>
|
|
31
38
|
</div>
|
|
32
39
|
<div class="htw-ml-auto htw-flex-none htw-flex">
|
|
33
40
|
<a
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
|
|
7
|
+
props: {
|
|
8
|
+
exact: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
default: false,
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
matched: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
default: null,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<router-link
|
|
23
|
+
v-slot="{ isActive, isExactActive, href, navigate }"
|
|
24
|
+
v-bind="$attrs"
|
|
25
|
+
custom
|
|
26
|
+
>
|
|
27
|
+
<a
|
|
28
|
+
v-bind="$attrs"
|
|
29
|
+
:href="href"
|
|
30
|
+
class="htw-px-4 htw-h-full htw-inline-flex htw-items-center hover:htw-bg-primary-50 dark:hover:htw-bg-primary-900 htw-relative"
|
|
31
|
+
:class="{
|
|
32
|
+
'htw-text-primary-500 dark:htw-text-primary-400': matched != null ? matched : (exact && isExactActive) || (!exact && isActive),
|
|
33
|
+
}"
|
|
34
|
+
@click="navigate"
|
|
35
|
+
>
|
|
36
|
+
<slot />
|
|
37
|
+
|
|
38
|
+
<transition name="__histoire-scale-x">
|
|
39
|
+
<div
|
|
40
|
+
v-if="matched != null ? matched : (exact && isExactActive) || (!exact && isActive)"
|
|
41
|
+
class="htw-absolute htw-bottom-0 htw-left-0 htw-w-full htw-h-[2px] htw-bg-primary-500 dark:htw-bg-primary-400"
|
|
42
|
+
/>
|
|
43
|
+
</transition>
|
|
44
|
+
</a>
|
|
45
|
+
</router-link>
|
|
46
|
+
</template>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { computed, defineComponent, provide, useAttrs, VNode } from 'vue'
|
|
2
|
+
import { computed, defineComponent, provide, useAttrs, VNode, h, PropType } from 'vue'
|
|
3
3
|
import { Story } from '../../types.js'
|
|
4
|
+
import Variant from './Variant.vue'
|
|
4
5
|
|
|
5
6
|
export default defineComponent({
|
|
6
7
|
// eslint-disable-next-line vue/multi-word-component-names
|
|
@@ -9,6 +10,13 @@ export default defineComponent({
|
|
|
9
10
|
|
|
10
11
|
inheritAttrs: false,
|
|
11
12
|
|
|
13
|
+
props: {
|
|
14
|
+
initState: {
|
|
15
|
+
type: Function as PropType<() => any | Promise<any>>,
|
|
16
|
+
default: null,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
|
|
12
20
|
setup () {
|
|
13
21
|
const attrs = useAttrs() as {
|
|
14
22
|
story: Story
|
|
@@ -23,6 +31,15 @@ export default defineComponent({
|
|
|
23
31
|
},
|
|
24
32
|
|
|
25
33
|
render () {
|
|
34
|
+
const [firstVariant] = this.story.variants
|
|
35
|
+
if (firstVariant.id === '_default') {
|
|
36
|
+
return h(Variant, {
|
|
37
|
+
variant: firstVariant,
|
|
38
|
+
initState: this.initState,
|
|
39
|
+
...this.$attrs,
|
|
40
|
+
}, this.$slots)
|
|
41
|
+
}
|
|
42
|
+
|
|
26
43
|
// Apply variant as attribute to each child vnode (should be `<Variant>` components)
|
|
27
44
|
const vnodes: VNode[] = this.$slots.default()
|
|
28
45
|
// @ts-expect-error custom option
|
|
@@ -35,6 +52,9 @@ export default defineComponent({
|
|
|
35
52
|
vnode.props = {}
|
|
36
53
|
}
|
|
37
54
|
vnode.props.variant = this.story.variants[index]
|
|
55
|
+
if (!vnode.props.initState && !vnode.props['init-state']) {
|
|
56
|
+
vnode.props.initState = this.initState
|
|
57
|
+
}
|
|
38
58
|
}
|
|
39
59
|
return vnodes
|
|
40
60
|
},
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg fill="none">
|
|
3
|
+
<pattern
|
|
4
|
+
id="checkerboard"
|
|
5
|
+
width="64"
|
|
6
|
+
height="64"
|
|
7
|
+
patternUnits="userSpaceOnUse"
|
|
8
|
+
>
|
|
9
|
+
<rect
|
|
10
|
+
x="0"
|
|
11
|
+
y="0"
|
|
12
|
+
width="32"
|
|
13
|
+
height="32"
|
|
14
|
+
fill="currentColor"
|
|
15
|
+
/>
|
|
16
|
+
<rect
|
|
17
|
+
x="32"
|
|
18
|
+
y="32"
|
|
19
|
+
width="32"
|
|
20
|
+
height="32"
|
|
21
|
+
fill="currentColor"
|
|
22
|
+
/>
|
|
23
|
+
</pattern>
|
|
24
|
+
<rect
|
|
25
|
+
x="0"
|
|
26
|
+
y="0"
|
|
27
|
+
width="100%"
|
|
28
|
+
height="100%"
|
|
29
|
+
fill="url(#checkerboard)"
|
|
30
|
+
/>
|
|
31
|
+
</svg>
|
|
32
|
+
</template>
|
|
@@ -21,6 +21,10 @@ const props = defineProps({
|
|
|
21
21
|
},
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
+
const emit = defineEmits({
|
|
25
|
+
ready: () => true,
|
|
26
|
+
})
|
|
27
|
+
|
|
24
28
|
const sandbox = ref<HTMLDivElement>()
|
|
25
29
|
let app: App
|
|
26
30
|
let mounting = false
|
|
@@ -49,6 +53,8 @@ async function mountVariant () {
|
|
|
49
53
|
const target = document.createElement('div')
|
|
50
54
|
sandbox.value.appendChild(target)
|
|
51
55
|
app.mount(target)
|
|
56
|
+
|
|
57
|
+
emit('ready')
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
onMounted(async () => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import { PropType, ref, toRefs } from 'vue'
|
|
3
3
|
import { useRouter } from 'vue-router'
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
5
|
import { SearchResult } from '../../types'
|
|
6
6
|
import { onKeyboardShortcut } from '../../util/keyboard.js'
|
|
7
7
|
import BaseListItemLink from '../base/BaseListItemLink.vue'
|
|
8
|
+
import { useScrollOnActive } from '../../util/scroll'
|
|
8
9
|
|
|
9
10
|
const props = defineProps({
|
|
10
11
|
result: {
|
|
@@ -24,11 +25,8 @@ const emit = defineEmits({
|
|
|
24
25
|
|
|
25
26
|
const el = ref<HTMLDivElement>()
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
el.value.scrollIntoView()
|
|
30
|
-
}
|
|
31
|
-
})
|
|
28
|
+
const { selected } = toRefs(props)
|
|
29
|
+
useScrollOnActive(selected, el)
|
|
32
30
|
|
|
33
31
|
const router = useRouter()
|
|
34
32
|
|
|
@@ -43,8 +41,6 @@ const defaultIcons = {
|
|
|
43
41
|
variant: 'carbon:cube',
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
const iconColor = computed(() => props.result.iconColor)
|
|
47
|
-
|
|
48
44
|
const kindLabels = {
|
|
49
45
|
story: 'Story',
|
|
50
46
|
variant: 'Variant',
|
|
@@ -105,6 +101,6 @@ const kindLabels = {
|
|
|
105
101
|
|
|
106
102
|
<style scoped>
|
|
107
103
|
.bind-icon-color {
|
|
108
|
-
color: v-bind(iconColor);
|
|
104
|
+
color: v-bind('result.iconColor');
|
|
109
105
|
}
|
|
110
106
|
</style>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { PropType } from 'vue'
|
|
3
|
-
import { Story, Variant } from '
|
|
4
|
-
import SandboxVue3 from '
|
|
5
|
-
import BaseEmpty from '
|
|
3
|
+
import type { Story, Variant } from '../../types'
|
|
4
|
+
import SandboxVue3 from '../sandbox/SandboxVue3.vue'
|
|
5
|
+
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
6
6
|
|
|
7
7
|
defineProps({
|
|
8
8
|
variant: {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { PropType, ref, watchEffect } from 'vue'
|
|
3
|
+
import type { Story } from '../../types'
|
|
4
|
+
import BaseEmpty from '../base/BaseEmpty.vue'
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
story: {
|
|
8
|
+
type: Object as PropType<Story>,
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const renderedDoc = ref('')
|
|
14
|
+
|
|
15
|
+
watchEffect(async () => {
|
|
16
|
+
let comp = props.story.file?.component
|
|
17
|
+
if (comp.__asyncResolved) {
|
|
18
|
+
comp = comp.__asyncResolved
|
|
19
|
+
} else if (comp.__asyncLoader) {
|
|
20
|
+
comp = await comp.__asyncLoader()
|
|
21
|
+
}
|
|
22
|
+
renderedDoc.value = comp.doc
|
|
23
|
+
})
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<BaseEmpty
|
|
28
|
+
v-if="!renderedDoc"
|
|
29
|
+
>
|
|
30
|
+
No documentation available
|
|
31
|
+
</BaseEmpty>
|
|
32
|
+
<div
|
|
33
|
+
v-else
|
|
34
|
+
class="htw-prose dark:htw-prose-invert htw-p-4 htw-max-w-none"
|
|
35
|
+
v-html="renderedDoc"
|
|
36
|
+
/>
|
|
37
|
+
</template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { Story, Tree } from '
|
|
2
|
+
import type { Story, Tree, TreeFolder, TreeLeaf } from '../../types'
|
|
3
3
|
import StoryListItem from './StoryListItem.vue'
|
|
4
4
|
import StoryListFolder from './StoryListFolder.vue'
|
|
5
5
|
|
|
@@ -16,13 +16,13 @@ const props = defineProps<{
|
|
|
16
16
|
:key="element.title"
|
|
17
17
|
>
|
|
18
18
|
<StoryListFolder
|
|
19
|
-
v-if="element.children"
|
|
20
|
-
:folder="element"
|
|
19
|
+
v-if="(element as TreeFolder).children"
|
|
20
|
+
:folder="(element as TreeFolder)"
|
|
21
21
|
:stories="stories"
|
|
22
22
|
/>
|
|
23
23
|
<StoryListItem
|
|
24
24
|
v-else
|
|
25
|
-
:story="stories[element.index]"
|
|
25
|
+
:story="stories[(element as TreeLeaf).index]"
|
|
26
26
|
/>
|
|
27
27
|
</template>
|
|
28
28
|
</div>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { Story, TreeFolder } from '
|
|
2
|
+
import type { Story, TreeFolder, TreeLeaf } from '../../types'
|
|
3
3
|
import StoryListItem from './StoryListItem.vue'
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
|
-
import { computed,
|
|
6
|
-
import { useStoryStore } from '
|
|
5
|
+
import { computed, withDefaults } from 'vue'
|
|
6
|
+
import { useStoryStore } from '../../stores/story'
|
|
7
7
|
|
|
8
8
|
const props = withDefaults(defineProps<{
|
|
9
9
|
path?: Array<string>
|
|
@@ -64,7 +64,7 @@ const folderPadding = computed(() => {
|
|
|
64
64
|
:key="element.title"
|
|
65
65
|
>
|
|
66
66
|
<StoryListFolder
|
|
67
|
-
v-if="element.children"
|
|
67
|
+
v-if="(element as TreeFolder).children"
|
|
68
68
|
:path="folderPath"
|
|
69
69
|
:folder="element"
|
|
70
70
|
:stories="stories"
|
|
@@ -72,7 +72,7 @@ const folderPadding = computed(() => {
|
|
|
72
72
|
/>
|
|
73
73
|
<StoryListItem
|
|
74
74
|
v-else
|
|
75
|
-
:story="stories[element.index]"
|
|
75
|
+
:story="stories[(element as TreeLeaf).index]"
|
|
76
76
|
:depth="depth + 1"
|
|
77
77
|
/>
|
|
78
78
|
</template>
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { Story } from '
|
|
3
|
-
import BaseListItemLink from '
|
|
2
|
+
import type { Story } from '../../types'
|
|
3
|
+
import BaseListItemLink from '../base/BaseListItemLink.vue'
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
|
-
import { computed, withDefaults } from 'vue'
|
|
5
|
+
import { computed, ref, withDefaults } from 'vue'
|
|
6
|
+
import { useRoute } from 'vue-router'
|
|
7
|
+
import { useScrollOnActive } from '../../util/scroll.js'
|
|
6
8
|
|
|
7
9
|
const props = withDefaults(defineProps<{
|
|
8
10
|
story: Story
|
|
@@ -15,11 +17,14 @@ const filePadding = computed(() => {
|
|
|
15
17
|
return (props.depth * 16) + 'px'
|
|
16
18
|
})
|
|
17
19
|
|
|
18
|
-
const
|
|
20
|
+
const route = useRoute()
|
|
21
|
+
const active = computed(() => route.params.storyId === props.story.id)
|
|
22
|
+
const el = ref<HTMLDivElement>()
|
|
23
|
+
useScrollOnActive(active, el)
|
|
19
24
|
</script>
|
|
20
25
|
|
|
21
26
|
<template>
|
|
22
|
-
<div>
|
|
27
|
+
<div ref="el">
|
|
23
28
|
<BaseListItemLink
|
|
24
29
|
v-slot="{ active }"
|
|
25
30
|
:to="{
|
|
@@ -55,6 +60,6 @@ const iconColor = computed(() => props.story.iconColor)
|
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
.bind-icon-color {
|
|
58
|
-
color: v-bind(iconColor);
|
|
63
|
+
color: v-bind('story.iconColor');
|
|
59
64
|
}
|
|
60
65
|
</style>
|