histoire 0.2.5 → 0.3.2

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 (219) hide show
  1. package/dist/client/app/App.vue +8 -3
  2. package/dist/client/app/codegen/const.d.ts +1 -0
  3. package/dist/client/app/codegen/const.js +3 -0
  4. package/dist/client/app/codegen/vue3.js +83 -21
  5. package/dist/client/app/codegen/vue3.js.map +1 -0
  6. package/dist/client/app/components/base/BaseEmpty.vue +17 -1
  7. package/dist/client/app/components/base/BaseOverflowMenu.vue +118 -0
  8. package/dist/client/app/components/base/BaseOverflowTab.vue +46 -0
  9. package/dist/client/app/components/exposed/Story.vue +33 -1
  10. package/dist/client/app/components/exposed/Variant.vue +19 -1
  11. package/dist/client/app/components/panel/PaneTabs.vue +64 -0
  12. package/dist/client/app/components/{story → panel}/StoryControls.vue +6 -1
  13. package/dist/client/app/components/{story → panel}/StoryDocs.vue +18 -11
  14. package/dist/client/app/components/panel/StoryEvent.vue +53 -0
  15. package/dist/client/app/components/panel/StoryEvents.vue +45 -0
  16. package/{src/client/app/components/story → dist/client/app/components/panel}/StorySidePanel.vue +17 -20
  17. package/{src/client/app/components/story → dist/client/app/components/panel}/StorySourceCode.vue +24 -14
  18. package/dist/client/app/components/sandbox/SandboxVue3.vue +16 -4
  19. package/dist/client/app/components/sandbox/lib.js +2 -1
  20. package/dist/client/app/components/search/SearchLoading.vue +16 -0
  21. package/dist/client/app/components/search/SearchModal.vue +12 -149
  22. package/dist/client/app/components/search/SearchPane.vue +210 -0
  23. package/dist/client/app/components/search/search-data.d.ts +2 -0
  24. package/dist/client/app/components/search/search-data.js +8 -0
  25. package/dist/client/app/components/search/search-data.js.map +1 -0
  26. package/dist/client/app/components/story/StoryResponsivePreview.vue +9 -98
  27. package/dist/client/app/components/story/StoryVariantSingle.vue +109 -0
  28. package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +39 -0
  29. package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
  30. package/dist/client/app/components/story/StoryVariantSingleView.vue +13 -6
  31. package/dist/client/app/components/story/StoryView.vue +17 -3
  32. package/dist/client/app/components/story/StoryViewer.vue +2 -92
  33. package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantBackground.vue +3 -3
  34. package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantNewTab.vue +2 -2
  35. package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantResponsiveSize.vue +3 -3
  36. package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantTitle.vue +1 -1
  37. package/dist/client/app/components/tree/StoryGroup.vue +4 -4
  38. package/dist/client/app/components/tree/StoryListFolder.vue +4 -4
  39. package/dist/client/app/components/tree/StoryListItem.vue +4 -1
  40. package/dist/client/app/global-components.js +1 -0
  41. package/dist/client/app/global-components.js.map +1 -0
  42. package/dist/client/app/index.js +1 -0
  43. package/dist/client/app/index.js.map +1 -0
  44. package/dist/client/app/router.d.ts +1 -0
  45. package/dist/client/app/router.js +3 -1
  46. package/dist/client/app/sandbox.js +12 -1
  47. package/dist/client/app/sandbox.js.map +1 -0
  48. package/dist/client/app/stores/events.d.ts +29 -0
  49. package/dist/client/app/stores/events.js +26 -0
  50. package/dist/client/app/stores/events.js.map +1 -0
  51. package/dist/client/app/stores/folder.d.ts +10 -0
  52. package/dist/client/app/stores/folder.js +48 -0
  53. package/dist/client/app/stores/folder.js.map +1 -0
  54. package/dist/client/app/stores/story.d.ts +41 -8
  55. package/dist/client/app/stores/story.js +21 -33
  56. package/dist/client/app/stores/story.js.map +1 -0
  57. package/dist/client/app/style/main.pcss +5 -0
  58. package/dist/client/app/style/sandbox.css +2 -0
  59. package/dist/client/app/style/transitions.pcss +13 -0
  60. package/dist/client/app/types.d.ts +4 -0
  61. package/dist/client/app/types.js +1 -0
  62. package/dist/client/app/types.js.map +1 -0
  63. package/dist/client/app/util/const.d.ts +1 -0
  64. package/dist/client/app/util/const.js +1 -0
  65. package/dist/client/app/util/events.d.ts +1 -0
  66. package/dist/client/app/util/events.js +32 -0
  67. package/dist/client/app/util/events.js.map +1 -0
  68. package/dist/client/app/util/keyboard.js +1 -0
  69. package/dist/client/app/util/keyboard.js.map +1 -0
  70. package/dist/client/app/util/mapping.js +5 -2
  71. package/dist/client/app/util/mapping.js.map +1 -0
  72. package/dist/client/app/util/preview-settings.js +1 -0
  73. package/dist/client/app/util/preview-settings.js.map +1 -0
  74. package/dist/client/app/util/reactivity.js +1 -0
  75. package/dist/client/app/util/reactivity.js.map +1 -0
  76. package/dist/client/app/util/scroll.js +1 -0
  77. package/dist/client/app/util/scroll.js.map +1 -0
  78. package/dist/client/app/util/variant.js +1 -0
  79. package/dist/client/app/util/variant.js.map +1 -0
  80. package/dist/client/index.d.ts +4 -3
  81. package/dist/client/index.js +3 -1
  82. package/dist/client/index.js.map +1 -0
  83. package/dist/client/server/index.d.ts +7 -2
  84. package/dist/client/server/index.js +8 -26
  85. package/{src/client/server/Story.server.vue → dist/client/server/vue3/Story.vue} +14 -3
  86. package/dist/client/server/{Variant.server.vue → vue3/Variant.vue} +0 -0
  87. package/dist/client/server/vue3/run.d.ts +2 -0
  88. package/dist/client/server/vue3/run.js +33 -0
  89. package/dist/client/server/vue3/run.js.map +1 -0
  90. package/dist/controls.js +1 -0
  91. package/dist/controls.js.map +1 -0
  92. package/dist/node/alias.d.ts +2 -1
  93. package/dist/node/alias.js +3 -2
  94. package/dist/node/build.js +74 -21
  95. package/dist/node/builtin-plugins/tailwind-tokens.d.ts +5 -0
  96. package/dist/node/builtin-plugins/tailwind-tokens.js +510 -0
  97. package/dist/node/collect/index.js +3 -1
  98. package/dist/node/collect/worker.js +6 -2
  99. package/dist/node/commands/preview.js +4 -25
  100. package/dist/node/config.d.ts +103 -3
  101. package/dist/node/config.js +40 -23
  102. package/dist/node/context.d.ts +3 -3
  103. package/dist/node/context.js +1 -1
  104. package/dist/node/index.d.ts +1 -0
  105. package/dist/node/index.js +1 -0
  106. package/dist/node/load.d.ts +12 -0
  107. package/dist/node/load.js +42 -0
  108. package/dist/node/plugin.d.ts +67 -11
  109. package/dist/node/plugin.js +42 -245
  110. package/dist/node/preview.d.ts +8 -0
  111. package/dist/node/preview.js +41 -0
  112. package/dist/node/search.d.ts +2 -0
  113. package/dist/node/search.js +68 -0
  114. package/dist/node/server.js +43 -21
  115. package/dist/node/stories.d.ts +2 -0
  116. package/dist/node/stories.js +4 -4
  117. package/dist/node/types.d.ts +1 -0
  118. package/dist/node/util/find-up.d.ts +1 -0
  119. package/dist/node/util/find-up.js +20 -0
  120. package/dist/node/vite.d.ts +13 -0
  121. package/dist/node/vite.js +278 -0
  122. package/dist/style.css +174 -86
  123. package/package.json +7 -6
  124. package/scripts/copy.mjs +2 -1
  125. package/src/client/app/App.vue +8 -3
  126. package/src/client/app/codegen/const.ts +3 -0
  127. package/src/client/app/codegen/vue3.ts +80 -22
  128. package/src/client/app/components/base/BaseEmpty.vue +17 -1
  129. package/src/client/app/components/base/BaseOverflowMenu.vue +118 -0
  130. package/src/client/app/components/base/BaseOverflowTab.vue +46 -0
  131. package/src/client/app/components/exposed/Story.vue +33 -1
  132. package/src/client/app/components/exposed/Variant.vue +19 -1
  133. package/src/client/app/components/panel/PaneTabs.vue +64 -0
  134. package/src/client/app/components/{story → panel}/StoryControls.vue +6 -1
  135. package/src/client/app/components/{story → panel}/StoryDocs.vue +18 -11
  136. package/src/client/app/components/panel/StoryEvent.vue +53 -0
  137. package/src/client/app/components/panel/StoryEvents.vue +45 -0
  138. package/{dist/client/app/components/story → src/client/app/components/panel}/StorySidePanel.vue +17 -20
  139. package/{dist/client/app/components/story → src/client/app/components/panel}/StorySourceCode.vue +24 -14
  140. package/src/client/app/components/sandbox/SandboxVue3.vue +16 -4
  141. package/src/client/app/components/sandbox/lib.ts +3 -1
  142. package/src/client/app/components/search/SearchLoading.vue +16 -0
  143. package/src/client/app/components/search/SearchModal.vue +12 -149
  144. package/src/client/app/components/search/SearchPane.vue +210 -0
  145. package/src/client/app/components/search/search-data.ts +9 -0
  146. package/src/client/app/components/story/StoryResponsivePreview.vue +9 -98
  147. package/src/client/app/components/story/StoryVariantSingle.vue +109 -0
  148. package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +39 -0
  149. package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
  150. package/src/client/app/components/story/StoryVariantSingleView.vue +13 -6
  151. package/src/client/app/components/story/StoryView.vue +17 -3
  152. package/src/client/app/components/story/StoryViewer.vue +2 -92
  153. package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantBackground.vue +3 -3
  154. package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantNewTab.vue +2 -2
  155. package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantResponsiveSize.vue +3 -3
  156. package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantTitle.vue +1 -1
  157. package/src/client/app/components/tree/StoryGroup.vue +4 -4
  158. package/src/client/app/components/tree/StoryListFolder.vue +4 -4
  159. package/src/client/app/components/tree/StoryListItem.vue +4 -1
  160. package/src/client/app/router.ts +4 -1
  161. package/src/client/app/sandbox.ts +11 -1
  162. package/src/client/app/stores/events.ts +36 -0
  163. package/{dist/client/app/stores/story.ts → src/client/app/stores/folder.ts} +16 -23
  164. package/src/client/app/stores/story.ts +21 -40
  165. package/src/client/app/style/main.pcss +5 -0
  166. package/src/client/app/style/sandbox.css +2 -0
  167. package/src/client/app/style/transitions.pcss +13 -0
  168. package/src/client/app/types.ts +5 -0
  169. package/src/client/app/util/const.ts +1 -0
  170. package/src/client/app/util/events.ts +30 -0
  171. package/src/client/app/util/mapping.ts +4 -2
  172. package/src/client/index.ts +4 -3
  173. package/src/client/server/index.ts +14 -27
  174. package/{dist/client/server/Story.server.vue → src/client/server/vue3/Story.vue} +14 -3
  175. package/src/client/server/{Variant.server.vue → vue3/Variant.vue} +0 -0
  176. package/{dist/client/server/index.ts → src/client/server/vue3/run.ts} +10 -4
  177. package/src/node/alias.ts +4 -2
  178. package/src/node/build.ts +86 -21
  179. package/src/node/builtin-plugins/tailwind-tokens.ts +521 -0
  180. package/src/node/collect/index.ts +3 -1
  181. package/src/node/collect/worker.ts +7 -2
  182. package/src/node/commands/preview.ts +4 -33
  183. package/src/node/config.ts +53 -27
  184. package/src/node/context.ts +3 -3
  185. package/src/node/index.ts +1 -0
  186. package/src/node/load.ts +63 -0
  187. package/src/node/plugin.ts +75 -252
  188. package/src/node/preview.ts +56 -0
  189. package/src/node/search.ts +75 -0
  190. package/src/node/server.ts +49 -23
  191. package/src/node/stories.ts +4 -4
  192. package/src/node/types.ts +1 -0
  193. package/src/node/util/find-up.ts +24 -0
  194. package/src/node/vite.ts +296 -0
  195. package/tailwind.config.cjs +1 -0
  196. package/dist/client/app/codegen/serialize-js.ts +0 -119
  197. package/dist/client/app/codegen/util.ts +0 -79
  198. package/dist/client/app/codegen/vue3.ts +0 -276
  199. package/dist/client/app/components/sandbox/lib.ts +0 -8
  200. package/dist/client/app/global-components.ts +0 -13
  201. package/dist/client/app/index.ts +0 -28
  202. package/dist/client/app/router.ts +0 -17
  203. package/dist/client/app/sandbox.ts +0 -94
  204. package/dist/client/app/stores/preview-settings.ts +0 -17
  205. package/dist/client/app/types.ts +0 -78
  206. package/dist/client/app/util/config.ts +0 -6
  207. package/dist/client/app/util/const.ts +0 -3
  208. package/dist/client/app/util/dark.ts +0 -4
  209. package/dist/client/app/util/env.ts +0 -1
  210. package/dist/client/app/util/keyboard.ts +0 -99
  211. package/dist/client/app/util/mapping.ts +0 -48
  212. package/dist/client/app/util/preview-settings.ts +0 -8
  213. package/dist/client/app/util/reactivity.ts +0 -22
  214. package/dist/client/app/util/responsive.ts +0 -3
  215. package/dist/client/app/util/scroll.ts +0 -31
  216. package/dist/client/app/util/tooltip.ts +0 -13
  217. package/dist/client/app/util/variant.ts +0 -20
  218. package/dist/client/index.ts +0 -12
  219. package/dist/client/shim.d.ts +0 -5
@@ -1,78 +0,0 @@
1
- import type { RouteLocationRaw } from 'vue-router'
2
-
3
- export interface StoryFile {
4
- id: string
5
- framework: string
6
- component: any
7
- story: Story
8
- path: string[]
9
- }
10
-
11
- export interface Story {
12
- id: string
13
- title: string
14
- group?: string
15
- variants: Variant[]
16
- layout?: {
17
- type: 'single'
18
- } | {
19
- type: 'grid'
20
- width?: number | string
21
- }
22
- icon?: string
23
- iconColor?: string
24
- file?: StoryFile
25
- lastSelectedVariant?: Variant
26
- }
27
-
28
- export interface Variant {
29
- id: string
30
- title: string
31
- icon?: string
32
- iconColor?: string
33
- initState?: () => any
34
- slots?: () => Readonly<any>
35
- state?: any
36
- source?: string
37
- responsiveDisabled?: boolean
38
- configReady?: boolean
39
- previewReady?: boolean
40
- }
41
-
42
- export type TreeLeaf = {
43
- title: string
44
- index: number
45
- }
46
-
47
- export type TreeFolder = {
48
- title: string
49
- children: (TreeFolder | TreeLeaf)[]
50
- }
51
-
52
- export interface TreeGroup {
53
- group: true
54
- id: string
55
- title: string
56
- children: (TreeFolder | TreeLeaf)[]
57
- }
58
-
59
- export type Tree = (TreeGroup | TreeFolder | TreeLeaf)[]
60
-
61
- export interface SearchResult {
62
- kind: 'story' | 'variant'
63
- rank: number
64
- id: string
65
- title: string
66
- route: RouteLocationRaw
67
- path?: string[]
68
- icon?: string
69
- iconColor?: string
70
- }
71
-
72
- export interface PreviewSettings {
73
- responsiveWidth: number
74
- responsiveHeight: number
75
- rotate: boolean
76
- backgroundColor: string
77
- checkerboard: boolean
78
- }
@@ -1,6 +0,0 @@
1
- import type { HistoireConfig } from '../../../node/config'
2
- // @ts-expect-error virtual module
3
- import { config as configRaw, logos as logosRaw } from '$histoire-config'
4
-
5
- export const histoireConfig: HistoireConfig = configRaw
6
- export const customLogos: HistoireConfig['theme']['logo'] = logosRaw
@@ -1,3 +0,0 @@
1
- export const STATE_SYNC = '__histoire:state-sync'
2
- export const SANDBOX_READY = '__histoire:sandbox-ready'
3
- export const PREVIEW_SETTINGS_SYNC = '__histoire:preview-settings-sync'
@@ -1,4 +0,0 @@
1
- import { useDark, useToggle } from '@vueuse/core'
2
-
3
- export const isDark = useDark({ valueDark: 'htw-dark' })
4
- export const toggleDark = useToggle(isDark)
@@ -1 +0,0 @@
1
- export const isMac = navigator.platform.toLowerCase().includes('mac')
@@ -1,99 +0,0 @@
1
- import { useEventListener } from '@vueuse/core'
2
- import { isRef, Ref } from 'vue'
3
- import { isMac } from './env.js'
4
-
5
- export type KeyboardShortcut = string[]
6
-
7
- export type KeyboardHandler = (event: KeyboardEvent) => unknown
8
-
9
- export interface KeyboardShortcutOptions {
10
- event?: 'keyup' | 'keydown' | 'keypress'
11
- }
12
-
13
- export function onKeyboardShortcut (shortcut: KeyboardShortcut | Ref<KeyboardShortcut>, handler: KeyboardHandler, options: KeyboardShortcutOptions = {}) {
14
- useEventListener(options.event ?? 'keydown', event => {
15
- if (isMatchingShortcut(isRef(shortcut) ? shortcut.value : shortcut)) {
16
- handler(event)
17
- }
18
- })
19
- }
20
-
21
- const modifiers: { [i: string]: { key: string, pressed: boolean } } = {
22
- ctrl: { key: 'Control', pressed: false },
23
- alt: { key: 'Alt', pressed: false },
24
- shift: { key: 'Shift', pressed: false },
25
- meta: { key: 'Meta', pressed: false },
26
- }
27
-
28
- const pressedKeys = new Set<string>()
29
-
30
- window.addEventListener('keydown', event => {
31
- for (const i in modifiers) {
32
- const mod = modifiers[i]
33
- if (mod.key === event.key) {
34
- mod.pressed = true
35
- return
36
- }
37
- }
38
- pressedKeys.add(event.key.toLocaleLowerCase())
39
- })
40
-
41
- window.addEventListener('keyup', event => {
42
- requestAnimationFrame(() => {
43
- pressedKeys.clear()
44
- for (const i in modifiers) {
45
- const mod = modifiers[i]
46
- if (mod.key === event.key) {
47
- mod.pressed = false
48
- break
49
- }
50
- }
51
- })
52
- })
53
-
54
- window.addEventListener('blur', () => {
55
- pressedKeys.clear()
56
- for (const i in modifiers) {
57
- const mod = modifiers[i]
58
- mod.pressed = false
59
- }
60
- })
61
-
62
- function isMatchingShortcut (shortcut: KeyboardShortcut): boolean {
63
- for (const combination of shortcut) {
64
- if (isMatchingCombination(combination.toLowerCase())) {
65
- return true
66
- }
67
- }
68
- return false
69
- }
70
-
71
- function isMatchingCombination (combination: string): boolean {
72
- const splitted = combination.split('+').map(key => key.trim())
73
- const targetKey = splitted.pop()
74
- for (const mod in modifiers) {
75
- const containsMod = splitted.includes(mod)
76
- const isPressed = modifiers[mod].pressed
77
- if (containsMod !== isPressed) {
78
- return false
79
- }
80
- }
81
- return pressedKeys.has(targetKey)
82
- }
83
-
84
- export function formatKey (key: string) {
85
- key = key.toLowerCase()
86
- if (key === 'ctrl') {
87
- return isMac ? '^' : 'Ctrl'
88
- }
89
- if (key === 'alt') {
90
- return isMac ? '⎇' : 'Alt'
91
- }
92
- if (key === 'shift') {
93
- return '⇧'
94
- }
95
- if (key === 'meta') {
96
- return '⌘'
97
- }
98
- return key.charAt(0).toUpperCase() + key.substring(1).toLowerCase()
99
- }
@@ -1,48 +0,0 @@
1
- import { markRaw } from 'vue'
2
- import type { StoryFile, Variant } from '../types'
3
-
4
- export function mapFile (file: StoryFile, existingFile?: StoryFile): StoryFile {
5
- const result: StoryFile = {
6
- ...file,
7
- component: markRaw(file.component),
8
- story: {
9
- ...file.story,
10
- title: file.story.title,
11
- file: markRaw(file),
12
- variants: file.story.variants.map(v => mapVariant(v)),
13
- },
14
- }
15
-
16
- if (existingFile) {
17
- for (const index in result.story.variants) {
18
- const variant = result.story.variants[index]
19
- const existingVariant = existingFile.story.variants[index]
20
- if (existingVariant) {
21
- for (const key in existingVariant) {
22
- if (typeof existingVariant[key] !== 'undefined') {
23
- if (key === 'state') {
24
- Object.assign(variant.state, existingVariant.state)
25
- continue
26
- }
27
- variant[key] = existingVariant[key]
28
- }
29
- }
30
- }
31
- }
32
- if (existingFile.story.lastSelectedVariant) {
33
- result.story.lastSelectedVariant = result.story.variants.find(v => v.id === existingFile.story.lastSelectedVariant.id)
34
- }
35
- }
36
-
37
- return result
38
- }
39
-
40
- export function mapVariant (variant: Variant): Variant {
41
- return {
42
- ...variant,
43
- state: {},
44
- initState: null,
45
- slots: () => ({}),
46
- previewReady: false,
47
- }
48
- }
@@ -1,8 +0,0 @@
1
- import { reactive } from 'vue'
2
- import type { PreviewSettings } from '../types'
3
-
4
- export const receivedSettings = reactive<PreviewSettings>({} as PreviewSettings)
5
-
6
- export function applyPreviewSettings (settings: PreviewSettings) {
7
- Object.assign(receivedSettings, settings)
8
- }
@@ -1,22 +0,0 @@
1
- import { unref, isRef } from 'vue'
2
-
3
- const isObject = (val) => val !== null && typeof val === 'object'
4
-
5
- export function toRawDeep (val) {
6
- const unwrappedValue = isRef(val) ? unref(val) : val
7
-
8
- if (!isObject(unwrappedValue)) {
9
- return unwrappedValue
10
- }
11
-
12
- if (Array.isArray(unwrappedValue)) {
13
- return unwrappedValue.map(toRawDeep)
14
- }
15
-
16
- return toRawObject(unwrappedValue)
17
- }
18
-
19
- const toRawObject = (obj: Record<any, any>) => Object.keys(obj).reduce((raw, key) => {
20
- raw[key] = toRawDeep(obj[key])
21
- return raw
22
- }, {})
@@ -1,3 +0,0 @@
1
- import { useMediaQuery } from '@vueuse/core'
2
-
3
- export const isMobile = useMediaQuery('(max-width: 640px)')
@@ -1,31 +0,0 @@
1
- import { watch, onMounted, Ref } from 'vue'
2
- import scrollIntoView from 'scroll-into-view-if-needed'
3
-
4
- export function useScrollOnActive (active: Ref<boolean>, el: Ref<HTMLElement>) {
5
- watch(active, value => {
6
- if (value) {
7
- autoScroll()
8
- }
9
- })
10
-
11
- function autoScroll () {
12
- if (el.value) {
13
- scrollIntoView(el.value, {
14
- scrollMode: 'if-needed',
15
- block: 'center',
16
- inline: 'nearest',
17
- behavior: 'smooth',
18
- })
19
- }
20
- }
21
-
22
- onMounted(() => {
23
- if (active.value) {
24
- autoScroll()
25
- }
26
- })
27
-
28
- return {
29
- autoScroll,
30
- }
31
- }
@@ -1,13 +0,0 @@
1
- import { isMac } from './env.js'
2
- import { formatKey } from './keyboard.js'
3
-
4
- export function makeTooltip (descriptionHtml: string, keyboardShortcut: ({ isMac: boolean }) => string) {
5
- return {
6
- content: `<div>${descriptionHtml}</div><div class="htw-flex htw-items-center htw-gap-1 htw-mt-2 htw-text-sm">${genKeyboardShortcutHtml(keyboardShortcut({ isMac }))}</div>`,
7
- html: true,
8
- }
9
- }
10
-
11
- function genKeyboardShortcutHtml (shortcut: string) {
12
- return shortcut.split('+').map(k => k.trim()).map(key => `<span class="htw-bg-gray-500 htw-border-b-2 htw-border-gray-600 htw-px-1 htw-rounded-sm">${formatKey(key)}</span>`).join('')
13
- }
@@ -1,20 +0,0 @@
1
- import { computed, Ref } from 'vue'
2
- import { useRoute } from 'vue-router'
3
- import { Variant } from '../types'
4
-
5
- export function useCurrentVariantRoute (variant: Ref<Variant>) {
6
- const route = useRoute()
7
- const isActive = computed(() => route.query.variantId === variant.value.id)
8
- const targetRoute = computed(() => ({
9
- ...route,
10
- query: {
11
- ...route.query,
12
- variantId: variant.value.id,
13
- },
14
- }))
15
-
16
- return {
17
- isActive,
18
- targetRoute,
19
- }
20
- }
@@ -1,12 +0,0 @@
1
- import type { App } from 'vue'
2
- import type { Story, Variant } from './app/types.js'
3
-
4
- export type Vue3StorySetupHandler = (payload: {
5
- app: App
6
- story: Story
7
- variant: Variant
8
- }) => Promise<void> | void
9
-
10
- export function defineVue3StorySetup (handler: Vue3StorySetupHandler): Vue3StorySetupHandler {
11
- return handler
12
- }
@@ -1,5 +0,0 @@
1
- declare module '*.vue' {
2
- import { ComponentOptions } from 'vue'
3
- const comp: ComponentOptions
4
- export default comp
5
- }