histoire 0.0.2 → 0.0.5

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.
Files changed (119) hide show
  1. package/README.md +11 -0
  2. package/dist/client/app/App.vue +8 -8
  3. package/dist/client/app/codegen/vue3.js +28 -4
  4. package/dist/client/app/codegen/vue3.ts +32 -4
  5. package/dist/client/app/components/app/AppHeader.vue +10 -3
  6. package/dist/client/app/components/base/BaseTab.vue +46 -0
  7. package/dist/client/app/components/exposed/Story.vue +21 -1
  8. package/dist/client/app/components/exposed/Variant.vue +1 -0
  9. package/dist/client/app/components/misc/CheckerboardPattern.vue +32 -0
  10. package/dist/client/app/components/sandbox/SandboxVue3.vue +6 -0
  11. package/dist/client/app/components/search/SearchItem.vue +5 -9
  12. package/dist/client/app/components/{StoryControls.vue → story/StoryControls.vue} +3 -3
  13. package/dist/client/app/components/story/StoryDocs.vue +37 -0
  14. package/dist/client/app/components/{StoryList.vue → story/StoryList.vue} +4 -4
  15. package/{src/client/app/components → dist/client/app/components/story}/StoryListFolder.vue +5 -5
  16. package/{src/client/app/components → dist/client/app/components/story}/StoryListItem.vue +11 -6
  17. package/dist/client/app/components/story/StoryResponsivePreview.vue +214 -0
  18. package/dist/client/app/components/{StorySourceCode.vue → story/StorySourceCode.vue} +4 -8
  19. package/{src/client/app/components → dist/client/app/components/story}/StoryVariantGridItem.vue +14 -6
  20. package/dist/client/app/components/{StoryVariantListItem.vue → story/StoryVariantListItem.vue} +9 -8
  21. package/dist/client/app/components/story/StoryVariantSingleView.vue +182 -0
  22. package/dist/client/app/components/{StoryView.vue → story/StoryView.vue} +37 -10
  23. package/dist/client/app/global-components.js +2 -0
  24. package/dist/client/app/global-components.ts +3 -0
  25. package/dist/client/app/index.js +10 -0
  26. package/dist/client/app/index.ts +10 -0
  27. package/dist/client/app/router.js +1 -1
  28. package/dist/client/app/router.ts +1 -1
  29. package/dist/client/app/sandbox.js +37 -3
  30. package/dist/client/app/sandbox.ts +37 -3
  31. package/dist/client/app/stores/story.d.ts +15 -0
  32. package/dist/client/app/style/floating-vue.css +31 -0
  33. package/dist/client/app/style/main.css +17 -1
  34. package/dist/client/app/style/sandbox.css +5 -0
  35. package/dist/client/app/style/transitions.css +12 -0
  36. package/dist/client/app/types.d.ts +1 -0
  37. package/dist/client/app/types.ts +1 -0
  38. package/dist/client/app/util/const.d.ts +2 -0
  39. package/dist/client/app/util/const.js +2 -0
  40. package/dist/client/app/util/const.ts +2 -0
  41. package/dist/client/app/util/mapping.js +6 -0
  42. package/dist/client/app/util/mapping.ts +5 -0
  43. package/dist/client/app/util/preview-settings.d.ts +16 -0
  44. package/dist/client/app/util/preview-settings.js +15 -0
  45. package/dist/client/app/util/preview-settings.ts +26 -0
  46. package/dist/client/app/util/reactivity.d.ts +1 -0
  47. package/dist/client/app/util/reactivity.js +16 -0
  48. package/dist/client/app/util/reactivity.ts +22 -0
  49. package/dist/client/app/util/scroll.d.ts +2 -0
  50. package/dist/client/app/util/scroll.js +24 -0
  51. package/dist/client/app/util/scroll.ts +27 -0
  52. package/dist/client/app/{composable → util}/variant.d.ts +0 -0
  53. package/dist/client/app/{composable → util}/variant.js +0 -0
  54. package/dist/client/app/{composable → util}/variant.ts +0 -0
  55. package/dist/client/server/Story.server.vue +25 -2
  56. package/dist/client/server/index.js +2 -0
  57. package/dist/client/server/index.ts +3 -0
  58. package/dist/controls.d.ts +1 -0
  59. package/dist/controls.js +1 -0
  60. package/dist/node/build.js +36 -11
  61. package/dist/node/collect.js +12 -3
  62. package/dist/node/commands/dev.js +43 -5
  63. package/dist/node/config.d.ts +35 -0
  64. package/dist/node/config.js +75 -1
  65. package/dist/node/markdown.d.ts +2 -0
  66. package/dist/node/markdown.js +48 -0
  67. package/dist/node/plugin.js +35 -0
  68. package/dist/node/util/slugify.d.ts +1 -0
  69. package/dist/node/util/slugify.js +22 -0
  70. package/dist/style.css +869 -159
  71. package/package.json +15 -6
  72. package/src/client/app/App.vue +8 -8
  73. package/src/client/app/codegen/vue3.ts +32 -4
  74. package/src/client/app/components/app/AppHeader.vue +10 -3
  75. package/src/client/app/components/base/BaseTab.vue +46 -0
  76. package/src/client/app/components/exposed/Story.vue +21 -1
  77. package/src/client/app/components/exposed/Variant.vue +1 -0
  78. package/src/client/app/components/misc/CheckerboardPattern.vue +32 -0
  79. package/src/client/app/components/sandbox/SandboxVue3.vue +6 -0
  80. package/src/client/app/components/search/SearchItem.vue +5 -9
  81. package/src/client/app/components/{StoryControls.vue → story/StoryControls.vue} +3 -3
  82. package/src/client/app/components/story/StoryDocs.vue +37 -0
  83. package/src/client/app/components/{StoryList.vue → story/StoryList.vue} +4 -4
  84. package/{dist/client/app/components → src/client/app/components/story}/StoryListFolder.vue +5 -5
  85. package/{dist/client/app/components → src/client/app/components/story}/StoryListItem.vue +11 -6
  86. package/src/client/app/components/story/StoryResponsivePreview.vue +214 -0
  87. package/src/client/app/components/{StorySourceCode.vue → story/StorySourceCode.vue} +4 -8
  88. package/{dist/client/app/components → src/client/app/components/story}/StoryVariantGridItem.vue +14 -6
  89. package/src/client/app/components/{StoryVariantListItem.vue → story/StoryVariantListItem.vue} +9 -8
  90. package/src/client/app/components/story/StoryVariantSingleView.vue +182 -0
  91. package/src/client/app/components/{StoryView.vue → story/StoryView.vue} +37 -10
  92. package/src/client/app/global-components.ts +3 -0
  93. package/src/client/app/index.ts +10 -0
  94. package/src/client/app/router.ts +1 -1
  95. package/src/client/app/sandbox.ts +37 -3
  96. package/src/client/app/style/floating-vue.css +31 -0
  97. package/src/client/app/style/main.css +17 -1
  98. package/src/client/app/style/sandbox.css +5 -0
  99. package/src/client/app/style/transitions.css +12 -0
  100. package/src/client/app/types.ts +1 -0
  101. package/src/client/app/util/const.ts +2 -0
  102. package/src/client/app/util/mapping.ts +5 -0
  103. package/src/client/app/util/preview-settings.ts +26 -0
  104. package/src/client/app/util/reactivity.ts +22 -0
  105. package/src/client/app/util/scroll.ts +27 -0
  106. package/src/client/app/{composable → util}/variant.ts +0 -0
  107. package/src/client/server/Story.server.vue +25 -2
  108. package/src/client/server/index.ts +3 -0
  109. package/src/controls.ts +1 -0
  110. package/src/node/build.ts +43 -11
  111. package/src/node/collect.ts +12 -3
  112. package/src/node/commands/dev.ts +49 -5
  113. package/src/node/config.ts +112 -2
  114. package/src/node/markdown.ts +56 -0
  115. package/src/node/plugin.ts +38 -0
  116. package/src/node/util/slugify.ts +26 -0
  117. package/tailwind.config.cjs +79 -4
  118. package/dist/client/app/components/StoryVariantSingleView.vue +0 -145
  119. 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.2",
3
+ "version": "0.0.5",
4
4
  "description": "A fast story book powered by Vite",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -33,22 +33,30 @@
33
33
  "histoire": "./bin.mjs"
34
34
  },
35
35
  "dependencies": {
36
+ "@iconify/vue": "^3.1.3",
37
+ "@histoire/controls": "^0.0.5",
36
38
  "@vitejs/plugin-vue": "^2.2.0",
37
39
  "@vueuse/core": "^7.6.2",
38
40
  "case": "^1.6.3",
39
41
  "chokidar": "^3.5.3",
40
42
  "defu": "^5.0.1",
43
+ "diacritics": "^1.3.0",
41
44
  "floating-vue": "^2.0.0-beta.6",
42
45
  "fs-extra": "^10.0.0",
43
46
  "globby": "^13.1.1",
44
47
  "happy-dom": "^2.33.1",
48
+ "markdown-it": "^12.3.2",
49
+ "markdown-it-anchor": "^8.4.1",
50
+ "markdown-it-attrs": "^4.1.3",
51
+ "markdown-it-emoji": "^2.0.0",
45
52
  "mrmime": "^1.0.0",
46
53
  "pathe": "^0.2.0",
47
54
  "picocolors": "^1.0.0",
48
55
  "pinia": "^2.0.11",
49
56
  "sade": "^1.8.1",
57
+ "scroll-into-view-if-needed": "^2.2.29",
50
58
  "shiki": "^0.10.1",
51
- "vite-node": "^0.3.6",
59
+ "vite-node": "=0.6.1",
52
60
  "vue-router": "^4.0.12"
53
61
  },
54
62
  "peerDependencies": {
@@ -56,13 +64,13 @@
56
64
  "vue": "^3.2.31"
57
65
  },
58
66
  "devDependencies": {
59
- "@iconify/vue": "^3.1.3",
60
- "@peeky/test": "^0.13.2",
67
+ "@peeky/test": "^0.13.5",
68
+ "@tailwindcss/typography": "^0.5.2",
61
69
  "@types/fs-extra": "^9.0.13",
70
+ "@types/markdown-it": "^12.2.3",
62
71
  "@types/node": "^17.0.18",
63
72
  "autoprefixer": "^10.4.2",
64
73
  "concurrently": "^7.0.0",
65
- "globby": "^13.1.1",
66
74
  "postcss": "^8.4.6",
67
75
  "postcss-import": "^14.0.2",
68
76
  "tailwindcss": "^3.0.23",
@@ -76,5 +84,6 @@
76
84
  "watch": "concurrently \"tsc -d -w --sourceMap\" \"pnpm run build:css -- --watch\" \"node ./scripts/watchAndCopy.mjs\"",
77
85
  "test:open": "peeky open",
78
86
  "test": "peeky run"
79
- }
87
+ },
88
+ "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"
80
89
  }
@@ -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-slate-100">
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
- <SearchModal
110
- v-if="loadSearch"
111
- :shown="isSearchOpen"
112
- @close="isSearchOpen = false"
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, kebab } from 'case'
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}${modifiers}${arg}="`
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 = kebab(directive === '@' ? prop.slice(2) : prop)
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([`${kebab(prop)}="${value}"`])
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
- <AppLogo
29
- class="htw-max-w-full htw-max-h-full"
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
  },
@@ -37,6 +37,7 @@ export default defineComponent({
37
37
  source: props.source,
38
38
  })
39
39
  }
40
+ updateVariant()
40
41
 
41
42
  return {
42
43
  updateVariant,
@@ -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 { computed, PropType, ref, watch } from 'vue'
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
- watch(() => props.selected, value => {
28
- if (value) {
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 '../types'
4
- import SandboxVue3 from './sandbox/SandboxVue3.vue'
5
- import BaseEmpty from './base/BaseEmpty.vue'
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 '../types'
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 '../types'
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, ref, withDefaults } from 'vue'
6
- import { useStoryStore } from '../stores/story'
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 '../types'
3
- import BaseListItemLink from './base/BaseListItemLink.vue'
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 iconColor = computed(() => props.story.iconColor)
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>