histoire 0.0.0 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/client.d.ts +2 -0
- package/dist/client/app/App.vue +84 -21
- package/dist/client/app/assets/histoire-text-dark.svg +89 -0
- package/dist/client/app/assets/histoire-text.svg +89 -0
- package/dist/client/app/assets/histoire.svg +51 -0
- package/dist/client/app/codegen/serialize-js.d.ts +1 -0
- package/dist/client/app/codegen/serialize-js.js +113 -0
- package/dist/client/app/codegen/serialize-js.ts +119 -0
- package/dist/client/app/codegen/util.d.ts +10 -0
- package/dist/client/app/codegen/util.js +70 -0
- package/dist/client/app/codegen/util.ts +79 -0
- package/dist/client/app/codegen/vue3.d.ts +2 -0
- package/dist/client/app/codegen/vue3.js +238 -0
- package/dist/client/app/codegen/vue3.ts +240 -0
- package/dist/client/app/components/HomeView.vue +15 -1
- package/dist/client/app/components/StoryControls.vue +7 -2
- package/dist/client/app/components/StoryList.vue +20 -13
- package/dist/client/app/components/StoryListFolder.vue +87 -0
- package/dist/client/app/components/StoryListItem.vue +38 -12
- package/dist/client/app/components/StorySourceCode.vue +121 -0
- package/dist/client/app/components/StoryVariantGridItem.vue +32 -17
- package/dist/client/app/components/StoryVariantListItem.vue +46 -0
- package/dist/client/app/components/StoryVariantSingleView.vue +145 -15
- package/dist/client/app/components/StoryView.vue +88 -54
- package/dist/client/app/components/app/AppHeader.vue +56 -0
- package/dist/client/app/components/app/AppLogo.vue +24 -0
- package/dist/client/app/components/base/BaseEmpty.vue +1 -1
- package/dist/client/app/components/base/BaseListItemLink.vue +55 -0
- package/dist/client/app/components/base/BaseSplitPane.vue +57 -21
- package/dist/client/app/components/exposed/Story.vue +23 -58
- package/dist/client/app/components/exposed/Variant.vue +24 -47
- package/dist/client/app/components/misc/HatchedPattern.vue +25 -0
- package/dist/client/app/components/{SandboxVue.vue → sandbox/SandboxVue3.vue} +31 -12
- package/dist/client/app/components/search/SearchItem.vue +110 -0
- package/dist/client/app/components/search/SearchModal.vue +179 -0
- package/dist/client/app/composable/variant.js +0 -1
- package/dist/client/app/composable/variant.ts +20 -0
- package/dist/client/app/global-components.js +0 -1
- package/dist/client/app/global-components.ts +10 -0
- package/dist/client/app/index.d.ts +1 -0
- package/dist/client/app/index.js +10 -2
- package/dist/client/app/index.ts +24 -0
- package/dist/client/app/router.js +0 -1
- package/dist/client/app/router.ts +17 -0
- package/dist/client/app/sandbox.d.ts +1 -0
- package/dist/client/app/sandbox.js +53 -0
- package/dist/client/app/sandbox.ts +60 -0
- package/dist/client/app/stores/story.d.ts +167 -50
- package/dist/client/app/stores/story.js +33 -16
- package/dist/client/app/stores/story.ts +58 -0
- package/dist/client/app/style/floating-vue.css +31 -0
- package/dist/client/app/style/main.css +17 -2
- package/dist/client/app/style/sandbox.css +14 -0
- package/dist/client/app/types.d.ts +36 -4
- package/dist/client/app/types.js +0 -1
- package/dist/client/app/types.ts +59 -0
- package/dist/client/app/util/config.d.ts +3 -0
- package/dist/client/app/util/config.js +4 -0
- package/dist/client/app/util/config.ts +6 -0
- package/dist/client/app/util/const.d.ts +1 -0
- package/dist/client/app/util/const.js +1 -0
- package/dist/client/app/util/const.ts +1 -0
- package/dist/client/app/util/dark.d.ts +2 -0
- package/dist/client/app/util/dark.js +3 -0
- package/dist/client/app/util/dark.ts +4 -0
- package/dist/client/app/util/env.d.ts +1 -0
- package/dist/client/app/util/env.js +1 -0
- package/dist/client/app/util/env.ts +1 -0
- package/dist/client/app/util/keyboard.d.ts +8 -0
- package/dist/client/app/util/keyboard.js +82 -0
- package/dist/client/app/util/keyboard.ts +99 -0
- package/dist/client/app/util/mapping.d.ts +3 -0
- package/dist/client/app/util/mapping.js +39 -0
- package/dist/client/app/util/mapping.ts +41 -0
- package/dist/client/app/util/tooltip.d.ts +6 -0
- package/dist/client/app/util/tooltip.js +11 -0
- package/dist/client/app/util/tooltip.ts +13 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.ts +12 -0
- package/dist/client/server/Story.server.vue +65 -0
- package/dist/client/server/Variant.server.vue +50 -0
- package/dist/client/server/index.d.ts +2 -0
- package/dist/client/server/index.js +25 -0
- package/dist/client/server/index.ts +29 -0
- package/dist/client/shim.d.ts +5 -0
- package/dist/node/alias.js +0 -1
- package/dist/node/bin.js +8 -3
- package/dist/node/build.d.ts +2 -0
- package/dist/node/build.js +71 -0
- package/dist/node/collect.d.ts +12 -0
- package/dist/node/collect.js +65 -0
- package/dist/node/colors.d.ts +286 -0
- package/dist/node/colors.js +324 -0
- package/dist/node/commands/build.d.ts +1 -0
- package/dist/node/commands/build.js +10 -0
- package/dist/node/commands/dev.d.ts +1 -1
- package/dist/node/commands/dev.js +45 -13
- package/dist/node/config.d.ts +112 -1
- package/dist/node/config.js +124 -2
- package/dist/node/context.d.ts +13 -0
- package/dist/node/context.js +12 -2
- package/dist/node/dom/dom-keys.d.ts +4 -0
- package/dist/node/dom/dom-keys.js +223 -0
- package/dist/node/dom/env.d.ts +5 -0
- package/dist/node/dom/env.js +22 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +2 -2
- package/dist/node/plugin.d.ts +8 -2
- package/dist/node/plugin.js +150 -22
- package/dist/node/server.d.ts +4 -1
- package/dist/node/server.js +80 -21
- package/dist/node/stories.d.ts +8 -9
- package/dist/node/stories.js +42 -23
- package/dist/node/tree.d.ts +19 -0
- package/dist/node/tree.js +54 -0
- package/dist/node/types.d.ts +38 -0
- package/dist/node/types.js +1 -0
- package/dist/style.css +610 -53
- package/package.json +45 -25
- package/scripts/copy.mjs +11 -0
- package/src/client/app/App.vue +84 -21
- package/src/client/app/assets/histoire-text-dark.svg +89 -0
- package/src/client/app/assets/histoire-text.svg +89 -0
- package/src/client/app/assets/histoire.svg +51 -0
- package/src/client/app/codegen/serialize-js.ts +119 -0
- package/src/client/app/codegen/util.ts +79 -0
- package/src/client/app/codegen/vue3.ts +240 -0
- package/src/client/app/components/HomeView.vue +15 -1
- package/src/client/app/components/StoryControls.vue +7 -2
- package/src/client/app/components/StoryList.vue +20 -13
- package/src/client/app/components/StoryListFolder.vue +87 -0
- package/src/client/app/components/StoryListItem.vue +38 -12
- package/src/client/app/components/StorySourceCode.vue +121 -0
- package/src/client/app/components/StoryVariantGridItem.vue +32 -17
- package/src/client/app/components/StoryVariantListItem.vue +46 -0
- package/src/client/app/components/StoryVariantSingleView.vue +145 -15
- package/src/client/app/components/StoryView.vue +88 -54
- package/src/client/app/components/app/AppHeader.vue +56 -0
- package/src/client/app/components/app/AppLogo.vue +24 -0
- package/src/client/app/components/base/BaseEmpty.vue +1 -1
- package/src/client/app/components/base/BaseListItemLink.vue +55 -0
- package/src/client/app/components/base/BaseSplitPane.vue +57 -21
- package/src/client/app/components/exposed/Story.vue +23 -58
- package/src/client/app/components/exposed/Variant.vue +24 -47
- package/src/client/app/components/misc/HatchedPattern.vue +25 -0
- package/src/client/app/components/{SandboxVue.vue → sandbox/SandboxVue3.vue} +31 -12
- package/src/client/app/components/search/SearchItem.vue +110 -0
- package/src/client/app/components/search/SearchModal.vue +179 -0
- package/src/client/app/index.ts +10 -1
- package/src/client/app/sandbox.ts +60 -0
- package/src/client/app/stores/story.ts +39 -15
- package/src/client/app/style/floating-vue.css +31 -0
- package/src/client/app/style/main.css +17 -2
- package/src/client/app/style/sandbox.css +14 -0
- package/src/client/app/types.ts +42 -4
- package/src/client/app/util/config.ts +6 -0
- package/src/client/app/util/const.ts +1 -0
- package/src/client/app/util/dark.ts +4 -0
- package/src/client/app/util/env.ts +1 -0
- package/src/client/app/util/keyboard.ts +99 -0
- package/src/client/app/util/mapping.ts +41 -0
- package/src/client/app/util/tooltip.ts +13 -0
- package/src/client/index.ts +12 -0
- package/src/client/server/Story.server.vue +65 -0
- package/src/client/server/Variant.server.vue +50 -0
- package/src/client/server/index.ts +29 -0
- package/src/node/bin.ts +9 -2
- package/src/node/build.ts +80 -0
- package/src/node/collect.ts +78 -0
- package/src/node/colors.ts +340 -0
- package/src/node/commands/build.ts +12 -0
- package/src/node/commands/dev.ts +49 -12
- package/src/node/config.ts +240 -1
- package/src/node/context.ts +21 -1
- package/src/node/dom/dom-keys.ts +227 -0
- package/src/node/dom/env.ts +26 -0
- package/src/node/index.ts +2 -0
- package/src/node/plugin.ts +155 -22
- package/src/node/server.ts +95 -20
- package/src/node/stories.ts +53 -31
- package/src/node/tree.spec.ts +28 -0
- package/src/node/tree.ts +88 -0
- package/src/node/types.ts +40 -0
- package/tailwind.config.cjs +41 -1
- package/tsconfig.json +2 -1
- package/dist/client/app/components/StoryVariantItem.vue +0 -29
- 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/stores/story.js.map +0 -1
- package/dist/client/app/types.js.map +0 -1
- package/dist/node/alias.js.map +0 -1
- package/dist/node/bin.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/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/src/client/app/components/StoryVariantItem.vue +0 -29
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import './style/sandbox.css'
|
|
2
|
+
import { parseQuery } from 'vue-router'
|
|
3
|
+
import { computed, createApp, h, ref, toRaw, watch } from 'vue'
|
|
4
|
+
import { createPinia } from 'pinia'
|
|
5
|
+
import { registerGlobalComponents } from './global-components'
|
|
6
|
+
import SandboxVue3 from './components/sandbox/SandboxVue3.vue'
|
|
7
|
+
import type { StoryFile } from './types'
|
|
8
|
+
import { mapFile } from './util/mapping'
|
|
9
|
+
// @ts-expect-error virtual module
|
|
10
|
+
import { files } from '$histoire-stories'
|
|
11
|
+
import { STATE_SYNC } from './util/const.js'
|
|
12
|
+
|
|
13
|
+
const query = parseQuery(window.location.search)
|
|
14
|
+
const file = ref<StoryFile>(mapFile(files.find(f => f.id === query.storyId)))
|
|
15
|
+
|
|
16
|
+
const app = createApp({
|
|
17
|
+
setup () {
|
|
18
|
+
const story = computed(() => file.value.story)
|
|
19
|
+
const variant = computed(() => story.value?.variants.find(v => v.id === query.variantId))
|
|
20
|
+
|
|
21
|
+
window.addEventListener('message', event => {
|
|
22
|
+
if (event.data?.type === STATE_SYNC) {
|
|
23
|
+
Object.assign(variant.value.state, event.data.state)
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
watch(() => variant.value.state, value => {
|
|
28
|
+
window.parent?.postMessage({
|
|
29
|
+
type: STATE_SYNC,
|
|
30
|
+
state: toRaw(value),
|
|
31
|
+
})
|
|
32
|
+
}, {
|
|
33
|
+
deep: true,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
story,
|
|
38
|
+
variant,
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
render () {
|
|
43
|
+
return [
|
|
44
|
+
h('div', { class: 'htw-sandbox-hidden' }, [
|
|
45
|
+
h(file.value.component, {
|
|
46
|
+
story: file.value.story,
|
|
47
|
+
}),
|
|
48
|
+
]),
|
|
49
|
+
this.story && this.variant
|
|
50
|
+
? h(SandboxVue3, {
|
|
51
|
+
story: this.story,
|
|
52
|
+
variant: this.variant,
|
|
53
|
+
})
|
|
54
|
+
: null,
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
app.use(createPinia())
|
|
59
|
+
registerGlobalComponents(app)
|
|
60
|
+
app.mount('#app')
|
|
@@ -6,9 +6,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
6
6
|
variants: {
|
|
7
7
|
id: string;
|
|
8
8
|
title: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
icon?: string;
|
|
10
|
+
iconColor?: string;
|
|
11
|
+
initState?: () => any;
|
|
12
|
+
slots?: () => Readonly<any>;
|
|
13
|
+
state?: any;
|
|
14
|
+
source?: string;
|
|
12
15
|
}[];
|
|
13
16
|
layout?: {
|
|
14
17
|
type: "single";
|
|
@@ -16,26 +19,39 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
16
19
|
type: "grid";
|
|
17
20
|
width: number;
|
|
18
21
|
};
|
|
22
|
+
icon?: string;
|
|
23
|
+
iconColor?: string;
|
|
24
|
+
file?: {
|
|
25
|
+
id: string;
|
|
26
|
+
framework: string;
|
|
27
|
+
component: any;
|
|
28
|
+
story: any;
|
|
29
|
+
path: string[];
|
|
30
|
+
};
|
|
19
31
|
lastSelectedVariant?: {
|
|
20
32
|
id: string;
|
|
21
33
|
title: string;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
icon?: string;
|
|
35
|
+
iconColor?: string;
|
|
36
|
+
initState?: () => any;
|
|
37
|
+
slots?: () => Readonly<any>;
|
|
38
|
+
state?: any;
|
|
39
|
+
source?: string;
|
|
25
40
|
};
|
|
26
|
-
mountTime: number;
|
|
27
41
|
}[]>;
|
|
28
|
-
|
|
29
|
-
removeStory: (story: Story) => void;
|
|
42
|
+
setStories: (value: Story[]) => void;
|
|
30
43
|
currentStory: import("vue").ComputedRef<{
|
|
31
44
|
id: string;
|
|
32
45
|
title: string;
|
|
33
46
|
variants: {
|
|
34
47
|
id: string;
|
|
35
48
|
title: string;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
49
|
+
icon?: string;
|
|
50
|
+
iconColor?: string;
|
|
51
|
+
initState?: () => any;
|
|
52
|
+
slots?: () => Readonly<any>;
|
|
53
|
+
state?: any;
|
|
54
|
+
source?: string;
|
|
39
55
|
}[];
|
|
40
56
|
layout?: {
|
|
41
57
|
type: "single";
|
|
@@ -43,15 +59,38 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
43
59
|
type: "grid";
|
|
44
60
|
width: number;
|
|
45
61
|
};
|
|
62
|
+
icon?: string;
|
|
63
|
+
iconColor?: string;
|
|
64
|
+
file?: {
|
|
65
|
+
id: string;
|
|
66
|
+
framework: string;
|
|
67
|
+
component: any;
|
|
68
|
+
story: any;
|
|
69
|
+
path: string[];
|
|
70
|
+
};
|
|
46
71
|
lastSelectedVariant?: {
|
|
47
72
|
id: string;
|
|
48
73
|
title: string;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
74
|
+
icon?: string;
|
|
75
|
+
iconColor?: string;
|
|
76
|
+
initState?: () => any;
|
|
77
|
+
slots?: () => Readonly<any>;
|
|
78
|
+
state?: any;
|
|
79
|
+
source?: string;
|
|
52
80
|
};
|
|
53
|
-
mountTime: number;
|
|
54
81
|
}>;
|
|
82
|
+
currentVariant: import("vue").ComputedRef<{
|
|
83
|
+
id: string;
|
|
84
|
+
title: string;
|
|
85
|
+
icon?: string;
|
|
86
|
+
iconColor?: string;
|
|
87
|
+
initState?: () => any;
|
|
88
|
+
slots?: () => Readonly<any>;
|
|
89
|
+
state?: any;
|
|
90
|
+
source?: string;
|
|
91
|
+
}>;
|
|
92
|
+
isFolderOpened: (path: Array<string>) => boolean;
|
|
93
|
+
toggleFolder: (path: Array<string>, force?: boolean) => void;
|
|
55
94
|
}, "stories">>, import("pinia")._UnwrapAll<Pick<{
|
|
56
95
|
stories: import("vue").Ref<{
|
|
57
96
|
id: string;
|
|
@@ -59,9 +98,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
59
98
|
variants: {
|
|
60
99
|
id: string;
|
|
61
100
|
title: string;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
101
|
+
icon?: string;
|
|
102
|
+
iconColor?: string;
|
|
103
|
+
initState?: () => any;
|
|
104
|
+
slots?: () => Readonly<any>;
|
|
105
|
+
state?: any;
|
|
106
|
+
source?: string;
|
|
65
107
|
}[];
|
|
66
108
|
layout?: {
|
|
67
109
|
type: "single";
|
|
@@ -69,26 +111,39 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
69
111
|
type: "grid";
|
|
70
112
|
width: number;
|
|
71
113
|
};
|
|
114
|
+
icon?: string;
|
|
115
|
+
iconColor?: string;
|
|
116
|
+
file?: {
|
|
117
|
+
id: string;
|
|
118
|
+
framework: string;
|
|
119
|
+
component: any;
|
|
120
|
+
story: any;
|
|
121
|
+
path: string[];
|
|
122
|
+
};
|
|
72
123
|
lastSelectedVariant?: {
|
|
73
124
|
id: string;
|
|
74
125
|
title: string;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
126
|
+
icon?: string;
|
|
127
|
+
iconColor?: string;
|
|
128
|
+
initState?: () => any;
|
|
129
|
+
slots?: () => Readonly<any>;
|
|
130
|
+
state?: any;
|
|
131
|
+
source?: string;
|
|
78
132
|
};
|
|
79
|
-
mountTime: number;
|
|
80
133
|
}[]>;
|
|
81
|
-
|
|
82
|
-
removeStory: (story: Story) => void;
|
|
134
|
+
setStories: (value: Story[]) => void;
|
|
83
135
|
currentStory: import("vue").ComputedRef<{
|
|
84
136
|
id: string;
|
|
85
137
|
title: string;
|
|
86
138
|
variants: {
|
|
87
139
|
id: string;
|
|
88
140
|
title: string;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
141
|
+
icon?: string;
|
|
142
|
+
iconColor?: string;
|
|
143
|
+
initState?: () => any;
|
|
144
|
+
slots?: () => Readonly<any>;
|
|
145
|
+
state?: any;
|
|
146
|
+
source?: string;
|
|
92
147
|
}[];
|
|
93
148
|
layout?: {
|
|
94
149
|
type: "single";
|
|
@@ -96,25 +151,51 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
96
151
|
type: "grid";
|
|
97
152
|
width: number;
|
|
98
153
|
};
|
|
154
|
+
icon?: string;
|
|
155
|
+
iconColor?: string;
|
|
156
|
+
file?: {
|
|
157
|
+
id: string;
|
|
158
|
+
framework: string;
|
|
159
|
+
component: any;
|
|
160
|
+
story: any;
|
|
161
|
+
path: string[];
|
|
162
|
+
};
|
|
99
163
|
lastSelectedVariant?: {
|
|
100
164
|
id: string;
|
|
101
165
|
title: string;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
166
|
+
icon?: string;
|
|
167
|
+
iconColor?: string;
|
|
168
|
+
initState?: () => any;
|
|
169
|
+
slots?: () => Readonly<any>;
|
|
170
|
+
state?: any;
|
|
171
|
+
source?: string;
|
|
105
172
|
};
|
|
106
|
-
mountTime: number;
|
|
107
173
|
}>;
|
|
108
|
-
|
|
174
|
+
currentVariant: import("vue").ComputedRef<{
|
|
175
|
+
id: string;
|
|
176
|
+
title: string;
|
|
177
|
+
icon?: string;
|
|
178
|
+
iconColor?: string;
|
|
179
|
+
initState?: () => any;
|
|
180
|
+
slots?: () => Readonly<any>;
|
|
181
|
+
state?: any;
|
|
182
|
+
source?: string;
|
|
183
|
+
}>;
|
|
184
|
+
isFolderOpened: (path: Array<string>) => boolean;
|
|
185
|
+
toggleFolder: (path: Array<string>, force?: boolean) => void;
|
|
186
|
+
}, "currentStory" | "currentVariant">>, Pick<{
|
|
109
187
|
stories: import("vue").Ref<{
|
|
110
188
|
id: string;
|
|
111
189
|
title: string;
|
|
112
190
|
variants: {
|
|
113
191
|
id: string;
|
|
114
192
|
title: string;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
193
|
+
icon?: string;
|
|
194
|
+
iconColor?: string;
|
|
195
|
+
initState?: () => any;
|
|
196
|
+
slots?: () => Readonly<any>;
|
|
197
|
+
state?: any;
|
|
198
|
+
source?: string;
|
|
118
199
|
}[];
|
|
119
200
|
layout?: {
|
|
120
201
|
type: "single";
|
|
@@ -122,26 +203,39 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
122
203
|
type: "grid";
|
|
123
204
|
width: number;
|
|
124
205
|
};
|
|
206
|
+
icon?: string;
|
|
207
|
+
iconColor?: string;
|
|
208
|
+
file?: {
|
|
209
|
+
id: string;
|
|
210
|
+
framework: string;
|
|
211
|
+
component: any;
|
|
212
|
+
story: any;
|
|
213
|
+
path: string[];
|
|
214
|
+
};
|
|
125
215
|
lastSelectedVariant?: {
|
|
126
216
|
id: string;
|
|
127
217
|
title: string;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
218
|
+
icon?: string;
|
|
219
|
+
iconColor?: string;
|
|
220
|
+
initState?: () => any;
|
|
221
|
+
slots?: () => Readonly<any>;
|
|
222
|
+
state?: any;
|
|
223
|
+
source?: string;
|
|
131
224
|
};
|
|
132
|
-
mountTime: number;
|
|
133
225
|
}[]>;
|
|
134
|
-
|
|
135
|
-
removeStory: (story: Story) => void;
|
|
226
|
+
setStories: (value: Story[]) => void;
|
|
136
227
|
currentStory: import("vue").ComputedRef<{
|
|
137
228
|
id: string;
|
|
138
229
|
title: string;
|
|
139
230
|
variants: {
|
|
140
231
|
id: string;
|
|
141
232
|
title: string;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
233
|
+
icon?: string;
|
|
234
|
+
iconColor?: string;
|
|
235
|
+
initState?: () => any;
|
|
236
|
+
slots?: () => Readonly<any>;
|
|
237
|
+
state?: any;
|
|
238
|
+
source?: string;
|
|
145
239
|
}[];
|
|
146
240
|
layout?: {
|
|
147
241
|
type: "single";
|
|
@@ -149,13 +243,36 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
149
243
|
type: "grid";
|
|
150
244
|
width: number;
|
|
151
245
|
};
|
|
246
|
+
icon?: string;
|
|
247
|
+
iconColor?: string;
|
|
248
|
+
file?: {
|
|
249
|
+
id: string;
|
|
250
|
+
framework: string;
|
|
251
|
+
component: any;
|
|
252
|
+
story: any;
|
|
253
|
+
path: string[];
|
|
254
|
+
};
|
|
152
255
|
lastSelectedVariant?: {
|
|
153
256
|
id: string;
|
|
154
257
|
title: string;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
258
|
+
icon?: string;
|
|
259
|
+
iconColor?: string;
|
|
260
|
+
initState?: () => any;
|
|
261
|
+
slots?: () => Readonly<any>;
|
|
262
|
+
state?: any;
|
|
263
|
+
source?: string;
|
|
158
264
|
};
|
|
159
|
-
mountTime: number;
|
|
160
265
|
}>;
|
|
161
|
-
|
|
266
|
+
currentVariant: import("vue").ComputedRef<{
|
|
267
|
+
id: string;
|
|
268
|
+
title: string;
|
|
269
|
+
icon?: string;
|
|
270
|
+
iconColor?: string;
|
|
271
|
+
initState?: () => any;
|
|
272
|
+
slots?: () => Readonly<any>;
|
|
273
|
+
state?: any;
|
|
274
|
+
source?: string;
|
|
275
|
+
}>;
|
|
276
|
+
isFolderOpened: (path: Array<string>) => boolean;
|
|
277
|
+
toggleFolder: (path: Array<string>, force?: boolean) => void;
|
|
278
|
+
}, "setStories" | "isFolderOpened" | "toggleFolder">>;
|
|
@@ -1,29 +1,46 @@
|
|
|
1
1
|
import { defineStore } from 'pinia';
|
|
2
|
-
import { computed, ref } from 'vue';
|
|
2
|
+
import { computed, ref, watch } from 'vue';
|
|
3
3
|
import { router } from '../router';
|
|
4
4
|
export const useStoryStore = defineStore('story', () => {
|
|
5
5
|
const stories = ref([]);
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
function setStories(value) {
|
|
7
|
+
stories.value = value;
|
|
8
|
+
}
|
|
9
|
+
const currentStory = computed(() => stories.value.find(s => s.id === router.currentRoute.value.params.storyId));
|
|
10
|
+
const currentVariant = computed(() => currentStory.value?.variants.find(v => v.id === router.currentRoute.value.query.variantId));
|
|
11
|
+
const openedFolders = ref(new Map());
|
|
12
|
+
function getStringPath(path) {
|
|
13
|
+
return path.join('␜');
|
|
14
|
+
}
|
|
15
|
+
function toggleFolder(path, force) {
|
|
16
|
+
const stringPath = getStringPath(path);
|
|
17
|
+
if (force === undefined) {
|
|
18
|
+
force = !openedFolders.value.get(stringPath);
|
|
19
|
+
}
|
|
20
|
+
if (force) {
|
|
21
|
+
openedFolders.value.set(stringPath, true);
|
|
11
22
|
}
|
|
12
|
-
|
|
13
|
-
|
|
23
|
+
else {
|
|
24
|
+
openedFolders.value.delete(stringPath);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function isFolderOpened(path) {
|
|
28
|
+
return openedFolders.value.get(getStringPath(path));
|
|
14
29
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
stories.value.splice(index, 1);
|
|
30
|
+
function openFileFolders(path) {
|
|
31
|
+
for (let pathLength = 1; pathLength < path.length; pathLength++) {
|
|
32
|
+
toggleFolder(path.slice(0, pathLength), true);
|
|
19
33
|
}
|
|
20
34
|
}
|
|
21
|
-
|
|
35
|
+
watch(currentStory, () => {
|
|
36
|
+
openFileFolders(currentStory.value.file.path);
|
|
37
|
+
});
|
|
22
38
|
return {
|
|
23
39
|
stories,
|
|
24
|
-
|
|
25
|
-
removeStory,
|
|
40
|
+
setStories,
|
|
26
41
|
currentStory,
|
|
42
|
+
currentVariant,
|
|
43
|
+
isFolderOpened,
|
|
44
|
+
toggleFolder,
|
|
27
45
|
};
|
|
28
46
|
});
|
|
29
|
-
//# sourceMappingURL=story.js.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { computed, reactive, ref, watch } from 'vue'
|
|
3
|
+
import { router } from '../router'
|
|
4
|
+
import { Story } from '../types'
|
|
5
|
+
|
|
6
|
+
export const useStoryStore = defineStore('story', () => {
|
|
7
|
+
const stories = ref<Story[]>([])
|
|
8
|
+
function setStories (value: Story[]) {
|
|
9
|
+
stories.value = value
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const currentStory = computed(() => stories.value.find(s => s.id === router.currentRoute.value.params.storyId))
|
|
13
|
+
|
|
14
|
+
const currentVariant = computed(() => currentStory.value?.variants.find(v => v.id === router.currentRoute.value.query.variantId))
|
|
15
|
+
|
|
16
|
+
const openedFolders = ref(new Map() as Map<string, boolean>)
|
|
17
|
+
|
|
18
|
+
function getStringPath (path: Array<string>) {
|
|
19
|
+
return path.join('␜')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function toggleFolder (path: Array<string>, force?: boolean) {
|
|
23
|
+
const stringPath = getStringPath(path)
|
|
24
|
+
|
|
25
|
+
if (force === undefined) {
|
|
26
|
+
force = !openedFolders.value.get(stringPath)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (force) {
|
|
30
|
+
openedFolders.value.set(stringPath, true)
|
|
31
|
+
} else {
|
|
32
|
+
openedFolders.value.delete(stringPath)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function isFolderOpened (path: Array<string>) {
|
|
37
|
+
return openedFolders.value.get(getStringPath(path))
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function openFileFolders (path: Array<string>) {
|
|
41
|
+
for (let pathLength = 1; pathLength < path.length; pathLength++) {
|
|
42
|
+
toggleFolder(path.slice(0, pathLength), true)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
watch(currentStory, () => {
|
|
47
|
+
openFileFolders(currentStory.value.file.path)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
stories,
|
|
52
|
+
setStories,
|
|
53
|
+
currentStory,
|
|
54
|
+
currentVariant,
|
|
55
|
+
isFolderOpened,
|
|
56
|
+
toggleFolder,
|
|
57
|
+
}
|
|
58
|
+
})
|
|
@@ -1 +1,32 @@
|
|
|
1
1
|
/* @TODO custom themes */
|
|
2
|
+
|
|
3
|
+
.v-popper {
|
|
4
|
+
line-height: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.v-popper--theme-dropdown {
|
|
8
|
+
.htw-dark & {
|
|
9
|
+
.v-popper__inner {
|
|
10
|
+
@apply htw-bg-gray-700 htw-border-gray-850 htw-text-gray-100;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.v-popper__arrow-inner {
|
|
14
|
+
@apply htw-border-gray-700;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.v-popper__arrow-outer {
|
|
18
|
+
@apply htw-border-gray-850;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.v-popper__popper--show-from .v-popper__wrapper {
|
|
23
|
+
transform: scale(.75);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.v-popper__popper--show-to .v-popper__wrapper {
|
|
27
|
+
transform: none;
|
|
28
|
+
transition: transform .15s cubic-bezier(0, 1, .5, 1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
@@ -11,16 +11,31 @@
|
|
|
11
11
|
border-color: #e5e7eb;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
a
|
|
14
|
+
a,
|
|
15
|
+
input,
|
|
16
|
+
button {
|
|
15
17
|
color: inherit;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
a {
|
|
16
21
|
text-decoration: inherit;
|
|
17
22
|
}
|
|
18
23
|
|
|
24
|
+
input {
|
|
25
|
+
font-family: inherit;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
a,
|
|
29
|
+
button {
|
|
30
|
+
user-select: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
@tailwind base;
|
|
20
34
|
@tailwind components;
|
|
21
35
|
@tailwind utilities;
|
|
22
36
|
|
|
23
|
-
body
|
|
37
|
+
body,
|
|
38
|
+
pre {
|
|
24
39
|
margin: 0;
|
|
25
40
|
}
|
|
26
41
|
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import type { RouteLocationRaw } from 'vue-router';
|
|
2
|
+
export interface StoryFile {
|
|
3
|
+
id: string;
|
|
4
|
+
framework: string;
|
|
5
|
+
component: any;
|
|
6
|
+
story: Story;
|
|
7
|
+
path: string[];
|
|
8
|
+
}
|
|
1
9
|
export interface Story {
|
|
2
10
|
id: string;
|
|
3
11
|
title: string;
|
|
@@ -8,13 +16,37 @@ export interface Story {
|
|
|
8
16
|
type: 'grid';
|
|
9
17
|
width: number;
|
|
10
18
|
};
|
|
19
|
+
icon?: string;
|
|
20
|
+
iconColor?: string;
|
|
21
|
+
file?: StoryFile;
|
|
11
22
|
lastSelectedVariant?: Variant;
|
|
12
|
-
mountTime: number;
|
|
13
23
|
}
|
|
14
24
|
export interface Variant {
|
|
15
25
|
id: string;
|
|
16
26
|
title: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
icon?: string;
|
|
28
|
+
iconColor?: string;
|
|
29
|
+
initState?: () => any;
|
|
30
|
+
slots?: () => Readonly<any>;
|
|
31
|
+
state?: any;
|
|
32
|
+
source?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare type TreeLeaf = {
|
|
35
|
+
title: string;
|
|
36
|
+
index: number;
|
|
37
|
+
};
|
|
38
|
+
export declare type TreeFolder = {
|
|
39
|
+
title: string;
|
|
40
|
+
children: (TreeFolder | TreeLeaf)[];
|
|
41
|
+
};
|
|
42
|
+
export declare type Tree = (TreeFolder | TreeLeaf)[];
|
|
43
|
+
export interface SearchResult {
|
|
44
|
+
kind: 'story' | 'variant';
|
|
45
|
+
rank: number;
|
|
46
|
+
id: string;
|
|
47
|
+
title: string;
|
|
48
|
+
route: RouteLocationRaw;
|
|
49
|
+
path?: string[];
|
|
50
|
+
icon?: string;
|
|
51
|
+
iconColor?: string;
|
|
20
52
|
}
|
package/dist/client/app/types.js
CHANGED