histoire 0.0.1 → 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 +8 -8
- package/dist/client/app/codegen/serialize-js.js +0 -1
- package/dist/client/app/codegen/util.js +0 -1
- package/dist/client/app/codegen/vue3.js +28 -5
- 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/{src/client/app/components → dist/client/app/components/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/dist/client/app/components/{StoryListFolder.vue → story/StoryListFolder.vue} +13 -6
- package/dist/client/app/components/{StoryListItem.vue → story/StoryListItem.vue} +11 -6
- package/dist/client/app/components/story/StoryResponsivePreview.vue +214 -0
- package/{src/client/app/components → dist/client/app/components/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 -1
- package/dist/client/app/global-components.ts +3 -0
- package/dist/client/app/index.js +10 -1
- package/dist/client/app/index.ts +10 -0
- package/dist/client/app/router.js +1 -2
- package/dist/client/app/router.ts +1 -1
- package/dist/client/app/sandbox.js +37 -4
- package/dist/client/app/sandbox.ts +37 -3
- package/dist/client/app/stores/story.d.ts +22 -1
- package/dist/client/app/stores/story.js +30 -2
- package/dist/client/app/stores/story.ts +37 -1
- package/dist/client/app/style/floating-vue.css +31 -0
- package/dist/client/app/style/main.css +17 -1
- 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.js +0 -1
- package/dist/client/app/types.ts +15 -0
- package/dist/client/app/util/config.js +0 -1
- package/dist/client/app/util/const.d.ts +2 -0
- package/dist/client/app/util/const.js +2 -1
- package/dist/client/app/util/const.ts +2 -0
- package/dist/client/app/util/dark.js +0 -1
- package/dist/client/app/util/env.js +0 -1
- package/dist/client/app/util/env.ts +1 -0
- package/dist/client/app/util/keyboard.js +0 -1
- package/dist/client/app/util/keyboard.ts +99 -0
- package/dist/client/app/util/mapping.js +6 -1
- package/dist/client/app/util/mapping.ts +5 -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/util/tooltip.js +0 -1
- package/dist/client/app/util/tooltip.ts +13 -0
- package/dist/client/app/{composable → util}/variant.d.ts +0 -0
- package/dist/client/app/{composable → util}/variant.js +0 -1
- package/dist/client/app/{composable → util}/variant.ts +0 -0
- package/dist/client/index.js +0 -1
- package/dist/client/server/Story.server.vue +25 -2
- package/dist/client/server/index.js +2 -1
- package/dist/client/server/index.ts +3 -0
- package/dist/controls.d.ts +1 -0
- package/dist/controls.js +1 -0
- package/dist/node/alias.js +0 -1
- package/dist/node/bin.js +0 -1
- package/dist/node/build.js +13 -9
- package/dist/node/collect.js +12 -4
- package/dist/node/colors.d.ts +12 -0
- package/dist/node/colors.js +12 -1
- package/dist/node/commands/build.js +0 -1
- package/dist/node/commands/dev.js +43 -6
- package/dist/node/config.d.ts +35 -0
- package/dist/node/config.js +75 -2
- package/dist/node/context.js +0 -1
- package/dist/node/dom/dom-keys.js +0 -1
- package/dist/node/dom/env.js +0 -1
- package/dist/node/index.js +0 -1
- package/dist/node/markdown.d.ts +2 -0
- package/dist/node/markdown.js +48 -0
- package/dist/node/plugin.js +35 -1
- package/dist/node/server.js +0 -1
- package/dist/node/stories.js +0 -1
- package/dist/node/tree.js +0 -1
- package/dist/node/types.js +0 -1
- package/dist/node/util/slugify.d.ts +1 -0
- package/dist/node/util/slugify.js +22 -0
- package/dist/style.css +863 -157
- package/package.json +17 -4
- package/src/client/app/App.vue +8 -8
- 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/{dist/client/app/components → src/client/app/components/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/src/client/app/components/{StoryListFolder.vue → story/StoryListFolder.vue} +13 -6
- package/src/client/app/components/{StoryListItem.vue → story/StoryListItem.vue} +11 -6
- package/src/client/app/components/story/StoryResponsivePreview.vue +214 -0
- package/{dist/client/app/components → src/client/app/components/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 +10 -0
- package/src/client/app/router.ts +1 -1
- package/src/client/app/sandbox.ts +37 -3
- package/src/client/app/stores/story.ts +37 -1
- package/src/client/app/style/floating-vue.css +31 -0
- package/src/client/app/style/main.css +17 -1
- 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 +5 -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/colors.ts +12 -0
- package/src/node/commands/dev.ts +49 -5
- package/src/node/config.ts +112 -2
- package/src/node/markdown.ts +56 -0
- package/src/node/plugin.ts +38 -0
- package/src/node/tree.spec.ts +28 -0
- package/src/node/util/slugify.ts +26 -0
- package/tailwind.config.cjs +79 -4
- package/tsconfig.json +2 -1
- package/dist/client/app/codegen/serialize-js.js.map +0 -1
- package/dist/client/app/codegen/util.js.map +0 -1
- package/dist/client/app/codegen/vue3.js.map +0 -1
- package/dist/client/app/components/StoryVariantSingleView.vue +0 -145
- 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/sandbox.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/client/app/util/config.js.map +0 -1
- package/dist/client/app/util/const.js.map +0 -1
- package/dist/client/app/util/dark.js.map +0 -1
- package/dist/client/app/util/env.js.map +0 -1
- package/dist/client/app/util/keyboard.js.map +0 -1
- package/dist/client/app/util/mapping.js.map +0 -1
- package/dist/client/app/util/tooltip.js.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/client/server/index.js.map +0 -1
- package/dist/node/alias.js.map +0 -1
- package/dist/node/bin.js.map +0 -1
- package/dist/node/build.js.map +0 -1
- package/dist/node/collect.js.map +0 -1
- package/dist/node/colors.js.map +0 -1
- package/dist/node/commands/build.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/dom/dom-keys.js.map +0 -1
- package/dist/node/dom/env.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/dist/node/tree.js.map +0 -1
- package/dist/node/types.js.map +0 -1
- package/src/client/app/components/StoryVariantSingleView.vue +0 -145
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "histoire",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "A fast story book powered by Vite",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -33,22 +33,29 @@
|
|
|
33
33
|
"histoire": "./bin.mjs"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@histoire/controls": "^0.0.4",
|
|
36
37
|
"@vitejs/plugin-vue": "^2.2.0",
|
|
37
38
|
"@vueuse/core": "^7.6.2",
|
|
38
39
|
"case": "^1.6.3",
|
|
39
40
|
"chokidar": "^3.5.3",
|
|
40
41
|
"defu": "^5.0.1",
|
|
42
|
+
"diacritics": "^1.3.0",
|
|
41
43
|
"floating-vue": "^2.0.0-beta.6",
|
|
42
44
|
"fs-extra": "^10.0.0",
|
|
43
45
|
"globby": "^13.1.1",
|
|
44
46
|
"happy-dom": "^2.33.1",
|
|
47
|
+
"markdown-it": "^12.3.2",
|
|
48
|
+
"markdown-it-anchor": "^8.4.1",
|
|
49
|
+
"markdown-it-attrs": "^4.1.3",
|
|
50
|
+
"markdown-it-emoji": "^2.0.0",
|
|
45
51
|
"mrmime": "^1.0.0",
|
|
46
52
|
"pathe": "^0.2.0",
|
|
47
53
|
"picocolors": "^1.0.0",
|
|
48
54
|
"pinia": "^2.0.11",
|
|
49
55
|
"sade": "^1.8.1",
|
|
56
|
+
"scroll-into-view-if-needed": "^2.2.29",
|
|
50
57
|
"shiki": "^0.10.1",
|
|
51
|
-
"vite-node": "
|
|
58
|
+
"vite-node": "=0.6.1",
|
|
52
59
|
"vue-router": "^4.0.12"
|
|
53
60
|
},
|
|
54
61
|
"peerDependencies": {
|
|
@@ -57,7 +64,10 @@
|
|
|
57
64
|
},
|
|
58
65
|
"devDependencies": {
|
|
59
66
|
"@iconify/vue": "^3.1.3",
|
|
67
|
+
"@peeky/test": "^0.13.5",
|
|
68
|
+
"@tailwindcss/typography": "^0.5.2",
|
|
60
69
|
"@types/fs-extra": "^9.0.13",
|
|
70
|
+
"@types/markdown-it": "^12.2.3",
|
|
61
71
|
"@types/node": "^17.0.18",
|
|
62
72
|
"autoprefixer": "^10.4.2",
|
|
63
73
|
"concurrently": "^7.0.0",
|
|
@@ -72,6 +82,9 @@
|
|
|
72
82
|
"scripts": {
|
|
73
83
|
"build": "rimraf dist && tsc -d && pnpm run build:css && node ./scripts/copy.mjs",
|
|
74
84
|
"build:css": "tailwindcss -i src/client/app/style/main.css -o ./dist/style.css -c tailwind.config.cjs --postcss postcss.config.cjs",
|
|
75
|
-
"watch": "concurrently \"tsc -d -w --sourceMap\" \"pnpm run build:css -- --watch\" \"node ./scripts/watchAndCopy.mjs\""
|
|
76
|
-
|
|
85
|
+
"watch": "concurrently \"tsc -d -w --sourceMap\" \"pnpm run build:css -- --watch\" \"node ./scripts/watchAndCopy.mjs\"",
|
|
86
|
+
"test:open": "peeky open",
|
|
87
|
+
"test": "peeky run"
|
|
88
|
+
},
|
|
89
|
+
"readme": "# Histoire\n\n> Fast and beautiful interactive component playgrounds\n\n[Learn more](https://github.com/Akryum/histoire)\n\n```\npnpm add histoire -D\npnpm exec histoire dev\npnpm exec histoire build\n```\n"
|
|
77
90
|
}
|
package/src/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'
|
|
@@ -78,7 +78,7 @@ onKeyboardShortcut(['ctrl+k', 'meta+k'], (event) => {
|
|
|
78
78
|
/>
|
|
79
79
|
</div>
|
|
80
80
|
|
|
81
|
-
<div class="htw-h-screen dark:htw-bg-gray-700 dark:htw-text-
|
|
81
|
+
<div class="htw-h-screen dark:htw-bg-gray-700 dark:htw-text-gray-100">
|
|
82
82
|
<BaseSplitPane
|
|
83
83
|
save-id="main-horiz"
|
|
84
84
|
:min="5"
|
|
@@ -104,11 +104,11 @@ onKeyboardShortcut(['ctrl+k', 'meta+k'], (event) => {
|
|
|
104
104
|
<RouterView />
|
|
105
105
|
</template>
|
|
106
106
|
</BaseSplitPane>
|
|
107
|
-
</div>
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
<SearchModal
|
|
109
|
+
v-if="loadSearch"
|
|
110
|
+
:shown="isSearchOpen"
|
|
111
|
+
@close="isSearchOpen = false"
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
114
|
</template>
|
|
@@ -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,21 +1,27 @@
|
|
|
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,
|
|
5
|
+
import { computed, withDefaults } from 'vue'
|
|
6
|
+
import { useStoryStore } from '../../stores/story'
|
|
6
7
|
|
|
7
8
|
const props = withDefaults(defineProps<{
|
|
9
|
+
path?: Array<string>
|
|
8
10
|
folder: TreeFolder
|
|
9
11
|
stories: Story[]
|
|
10
12
|
depth?: number
|
|
11
13
|
}>(), {
|
|
12
14
|
depth: 0,
|
|
15
|
+
path: () => [],
|
|
13
16
|
})
|
|
14
17
|
|
|
15
|
-
const
|
|
18
|
+
const storyStore = useStoryStore()
|
|
19
|
+
|
|
20
|
+
const folderPath = computed(() => [...props.path, props.folder.title])
|
|
21
|
+
const isFolderOpen = computed(() => storyStore.isFolderOpened(folderPath.value))
|
|
16
22
|
|
|
17
23
|
function toggleOpen () {
|
|
18
|
-
|
|
24
|
+
storyStore.toggleFolder(folderPath.value)
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
const folderPadding = computed(() => {
|
|
@@ -58,14 +64,15 @@ const folderPadding = computed(() => {
|
|
|
58
64
|
:key="element.title"
|
|
59
65
|
>
|
|
60
66
|
<StoryListFolder
|
|
61
|
-
v-if="element.children"
|
|
67
|
+
v-if="(element as TreeFolder).children"
|
|
68
|
+
:path="folderPath"
|
|
62
69
|
:folder="element"
|
|
63
70
|
:stories="stories"
|
|
64
71
|
:depth="depth + 1"
|
|
65
72
|
/>
|
|
66
73
|
<StoryListItem
|
|
67
74
|
v-else
|
|
68
|
-
:story="stories[element.index]"
|
|
75
|
+
:story="stories[(element as TreeLeaf).index]"
|
|
69
76
|
:depth="depth + 1"
|
|
70
77
|
/>
|
|
71
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>
|