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
|
@@ -1,32 +1,51 @@
|
|
|
1
1
|
import './style/sandbox.css';
|
|
2
2
|
import { parseQuery } from 'vue-router';
|
|
3
|
-
import { computed, createApp, h,
|
|
3
|
+
import { computed, createApp, h, onMounted, ref, watch } from 'vue';
|
|
4
4
|
import { createPinia } from 'pinia';
|
|
5
5
|
import { registerGlobalComponents } from './global-components';
|
|
6
6
|
import SandboxVue3 from './components/sandbox/SandboxVue3.vue';
|
|
7
7
|
import { mapFile } from './util/mapping';
|
|
8
8
|
// @ts-expect-error virtual module
|
|
9
9
|
import { files } from '$histoire-stories';
|
|
10
|
-
import { STATE_SYNC } from './util/const.js';
|
|
10
|
+
import { PREVIEW_SETTINGS_SYNC, STATE_SYNC, SANDBOX_READY } from './util/const.js';
|
|
11
|
+
import { applyPreviewSettings } from './util/preview-settings.js';
|
|
12
|
+
import { isDark } from './util/dark.js';
|
|
13
|
+
import { histoireConfig } from './util/config.js';
|
|
14
|
+
import { toRawDeep } from './util/reactivity';
|
|
11
15
|
const query = parseQuery(window.location.search);
|
|
12
16
|
const file = ref(mapFile(files.find(f => f.id === query.storyId)));
|
|
13
17
|
const app = createApp({
|
|
14
18
|
setup() {
|
|
15
19
|
const story = computed(() => file.value.story);
|
|
16
20
|
const variant = computed(() => story.value?.variants.find(v => v.id === query.variantId));
|
|
21
|
+
let synced = false;
|
|
22
|
+
let mounted = false;
|
|
17
23
|
window.addEventListener('message', event => {
|
|
18
24
|
if (event.data?.type === STATE_SYNC) {
|
|
25
|
+
if (!mounted)
|
|
26
|
+
return;
|
|
27
|
+
synced = true;
|
|
19
28
|
Object.assign(variant.value.state, event.data.state);
|
|
20
29
|
}
|
|
30
|
+
else if (event.data?.type === PREVIEW_SETTINGS_SYNC) {
|
|
31
|
+
applyPreviewSettings(event.data.settings);
|
|
32
|
+
}
|
|
21
33
|
});
|
|
22
34
|
watch(() => variant.value.state, value => {
|
|
35
|
+
if (synced && mounted) {
|
|
36
|
+
synced = false;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
23
39
|
window.parent?.postMessage({
|
|
24
40
|
type: STATE_SYNC,
|
|
25
|
-
state:
|
|
41
|
+
state: toRawDeep(value),
|
|
26
42
|
});
|
|
27
43
|
}, {
|
|
28
44
|
deep: true,
|
|
29
45
|
});
|
|
46
|
+
onMounted(() => {
|
|
47
|
+
mounted = true;
|
|
48
|
+
});
|
|
30
49
|
return {
|
|
31
50
|
story,
|
|
32
51
|
variant,
|
|
@@ -43,6 +62,11 @@ const app = createApp({
|
|
|
43
62
|
? h(SandboxVue3, {
|
|
44
63
|
story: this.story,
|
|
45
64
|
variant: this.variant,
|
|
65
|
+
onReady: () => {
|
|
66
|
+
window.parent?.postMessage({
|
|
67
|
+
type: SANDBOX_READY,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
46
70
|
})
|
|
47
71
|
: null,
|
|
48
72
|
];
|
|
@@ -51,4 +75,13 @@ const app = createApp({
|
|
|
51
75
|
app.use(createPinia());
|
|
52
76
|
registerGlobalComponents(app);
|
|
53
77
|
app.mount('#app');
|
|
54
|
-
|
|
78
|
+
watch(isDark, value => {
|
|
79
|
+
if (value) {
|
|
80
|
+
document.documentElement.classList.add(histoireConfig.sandboxDarkClass);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
document.documentElement.classList.remove(histoireConfig.sandboxDarkClass);
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
immediate: true,
|
|
87
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './style/sandbox.css'
|
|
2
2
|
import { parseQuery } from 'vue-router'
|
|
3
|
-
import { computed, createApp, h,
|
|
3
|
+
import { computed, createApp, h, onMounted, ref, watch } from 'vue'
|
|
4
4
|
import { createPinia } from 'pinia'
|
|
5
5
|
import { registerGlobalComponents } from './global-components'
|
|
6
6
|
import SandboxVue3 from './components/sandbox/SandboxVue3.vue'
|
|
@@ -8,7 +8,11 @@ import type { StoryFile } from './types'
|
|
|
8
8
|
import { mapFile } from './util/mapping'
|
|
9
9
|
// @ts-expect-error virtual module
|
|
10
10
|
import { files } from '$histoire-stories'
|
|
11
|
-
import { STATE_SYNC } from './util/const.js'
|
|
11
|
+
import { PREVIEW_SETTINGS_SYNC, STATE_SYNC, SANDBOX_READY } from './util/const.js'
|
|
12
|
+
import { applyPreviewSettings } from './util/preview-settings.js'
|
|
13
|
+
import { isDark } from './util/dark.js'
|
|
14
|
+
import { histoireConfig } from './util/config.js'
|
|
15
|
+
import { toRawDeep } from './util/reactivity'
|
|
12
16
|
|
|
13
17
|
const query = parseQuery(window.location.search)
|
|
14
18
|
const file = ref<StoryFile>(mapFile(files.find(f => f.id === query.storyId)))
|
|
@@ -18,21 +22,36 @@ const app = createApp({
|
|
|
18
22
|
const story = computed(() => file.value.story)
|
|
19
23
|
const variant = computed(() => story.value?.variants.find(v => v.id === query.variantId))
|
|
20
24
|
|
|
25
|
+
let synced = false
|
|
26
|
+
let mounted = false
|
|
27
|
+
|
|
21
28
|
window.addEventListener('message', event => {
|
|
22
29
|
if (event.data?.type === STATE_SYNC) {
|
|
30
|
+
if (!mounted) return
|
|
31
|
+
synced = true
|
|
23
32
|
Object.assign(variant.value.state, event.data.state)
|
|
33
|
+
} else if (event.data?.type === PREVIEW_SETTINGS_SYNC) {
|
|
34
|
+
applyPreviewSettings(event.data.settings)
|
|
24
35
|
}
|
|
25
36
|
})
|
|
26
37
|
|
|
27
38
|
watch(() => variant.value.state, value => {
|
|
39
|
+
if (synced && mounted) {
|
|
40
|
+
synced = false
|
|
41
|
+
return
|
|
42
|
+
}
|
|
28
43
|
window.parent?.postMessage({
|
|
29
44
|
type: STATE_SYNC,
|
|
30
|
-
state:
|
|
45
|
+
state: toRawDeep(value),
|
|
31
46
|
})
|
|
32
47
|
}, {
|
|
33
48
|
deep: true,
|
|
34
49
|
})
|
|
35
50
|
|
|
51
|
+
onMounted(() => {
|
|
52
|
+
mounted = true
|
|
53
|
+
})
|
|
54
|
+
|
|
36
55
|
return {
|
|
37
56
|
story,
|
|
38
57
|
variant,
|
|
@@ -50,6 +69,11 @@ const app = createApp({
|
|
|
50
69
|
? h(SandboxVue3, {
|
|
51
70
|
story: this.story,
|
|
52
71
|
variant: this.variant,
|
|
72
|
+
onReady: () => {
|
|
73
|
+
window.parent?.postMessage({
|
|
74
|
+
type: SANDBOX_READY,
|
|
75
|
+
})
|
|
76
|
+
},
|
|
53
77
|
})
|
|
54
78
|
: null,
|
|
55
79
|
]
|
|
@@ -58,3 +82,13 @@ const app = createApp({
|
|
|
58
82
|
app.use(createPinia())
|
|
59
83
|
registerGlobalComponents(app)
|
|
60
84
|
app.mount('#app')
|
|
85
|
+
|
|
86
|
+
watch(isDark, value => {
|
|
87
|
+
if (value) {
|
|
88
|
+
document.documentElement.classList.add(histoireConfig.sandboxDarkClass)
|
|
89
|
+
} else {
|
|
90
|
+
document.documentElement.classList.remove(histoireConfig.sandboxDarkClass)
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
immediate: true,
|
|
94
|
+
})
|
|
@@ -12,6 +12,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
12
12
|
slots?: () => Readonly<any>;
|
|
13
13
|
state?: any;
|
|
14
14
|
source?: string;
|
|
15
|
+
ready?: boolean;
|
|
15
16
|
}[];
|
|
16
17
|
layout?: {
|
|
17
18
|
type: "single";
|
|
@@ -37,6 +38,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
37
38
|
slots?: () => Readonly<any>;
|
|
38
39
|
state?: any;
|
|
39
40
|
source?: string;
|
|
41
|
+
ready?: boolean;
|
|
40
42
|
};
|
|
41
43
|
}[]>;
|
|
42
44
|
setStories: (value: Story[]) => void;
|
|
@@ -52,6 +54,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
52
54
|
slots?: () => Readonly<any>;
|
|
53
55
|
state?: any;
|
|
54
56
|
source?: string;
|
|
57
|
+
ready?: boolean;
|
|
55
58
|
}[];
|
|
56
59
|
layout?: {
|
|
57
60
|
type: "single";
|
|
@@ -77,6 +80,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
77
80
|
slots?: () => Readonly<any>;
|
|
78
81
|
state?: any;
|
|
79
82
|
source?: string;
|
|
83
|
+
ready?: boolean;
|
|
80
84
|
};
|
|
81
85
|
}>;
|
|
82
86
|
currentVariant: import("vue").ComputedRef<{
|
|
@@ -88,7 +92,10 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
88
92
|
slots?: () => Readonly<any>;
|
|
89
93
|
state?: any;
|
|
90
94
|
source?: string;
|
|
95
|
+
ready?: boolean;
|
|
91
96
|
}>;
|
|
97
|
+
isFolderOpened: (path: Array<string>) => boolean;
|
|
98
|
+
toggleFolder: (path: Array<string>, force?: boolean) => void;
|
|
92
99
|
}, "stories">>, import("pinia")._UnwrapAll<Pick<{
|
|
93
100
|
stories: import("vue").Ref<{
|
|
94
101
|
id: string;
|
|
@@ -102,6 +109,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
102
109
|
slots?: () => Readonly<any>;
|
|
103
110
|
state?: any;
|
|
104
111
|
source?: string;
|
|
112
|
+
ready?: boolean;
|
|
105
113
|
}[];
|
|
106
114
|
layout?: {
|
|
107
115
|
type: "single";
|
|
@@ -127,6 +135,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
127
135
|
slots?: () => Readonly<any>;
|
|
128
136
|
state?: any;
|
|
129
137
|
source?: string;
|
|
138
|
+
ready?: boolean;
|
|
130
139
|
};
|
|
131
140
|
}[]>;
|
|
132
141
|
setStories: (value: Story[]) => void;
|
|
@@ -142,6 +151,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
142
151
|
slots?: () => Readonly<any>;
|
|
143
152
|
state?: any;
|
|
144
153
|
source?: string;
|
|
154
|
+
ready?: boolean;
|
|
145
155
|
}[];
|
|
146
156
|
layout?: {
|
|
147
157
|
type: "single";
|
|
@@ -167,6 +177,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
167
177
|
slots?: () => Readonly<any>;
|
|
168
178
|
state?: any;
|
|
169
179
|
source?: string;
|
|
180
|
+
ready?: boolean;
|
|
170
181
|
};
|
|
171
182
|
}>;
|
|
172
183
|
currentVariant: import("vue").ComputedRef<{
|
|
@@ -178,7 +189,10 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
178
189
|
slots?: () => Readonly<any>;
|
|
179
190
|
state?: any;
|
|
180
191
|
source?: string;
|
|
192
|
+
ready?: boolean;
|
|
181
193
|
}>;
|
|
194
|
+
isFolderOpened: (path: Array<string>) => boolean;
|
|
195
|
+
toggleFolder: (path: Array<string>, force?: boolean) => void;
|
|
182
196
|
}, "currentStory" | "currentVariant">>, Pick<{
|
|
183
197
|
stories: import("vue").Ref<{
|
|
184
198
|
id: string;
|
|
@@ -192,6 +206,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
192
206
|
slots?: () => Readonly<any>;
|
|
193
207
|
state?: any;
|
|
194
208
|
source?: string;
|
|
209
|
+
ready?: boolean;
|
|
195
210
|
}[];
|
|
196
211
|
layout?: {
|
|
197
212
|
type: "single";
|
|
@@ -217,6 +232,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
217
232
|
slots?: () => Readonly<any>;
|
|
218
233
|
state?: any;
|
|
219
234
|
source?: string;
|
|
235
|
+
ready?: boolean;
|
|
220
236
|
};
|
|
221
237
|
}[]>;
|
|
222
238
|
setStories: (value: Story[]) => void;
|
|
@@ -232,6 +248,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
232
248
|
slots?: () => Readonly<any>;
|
|
233
249
|
state?: any;
|
|
234
250
|
source?: string;
|
|
251
|
+
ready?: boolean;
|
|
235
252
|
}[];
|
|
236
253
|
layout?: {
|
|
237
254
|
type: "single";
|
|
@@ -257,6 +274,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
257
274
|
slots?: () => Readonly<any>;
|
|
258
275
|
state?: any;
|
|
259
276
|
source?: string;
|
|
277
|
+
ready?: boolean;
|
|
260
278
|
};
|
|
261
279
|
}>;
|
|
262
280
|
currentVariant: import("vue").ComputedRef<{
|
|
@@ -268,5 +286,8 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
268
286
|
slots?: () => Readonly<any>;
|
|
269
287
|
state?: any;
|
|
270
288
|
source?: string;
|
|
289
|
+
ready?: boolean;
|
|
271
290
|
}>;
|
|
272
|
-
|
|
291
|
+
isFolderOpened: (path: Array<string>) => boolean;
|
|
292
|
+
toggleFolder: (path: Array<string>, force?: boolean) => void;
|
|
293
|
+
}, "setStories" | "isFolderOpened" | "toggleFolder">>;
|
|
@@ -1,5 +1,5 @@
|
|
|
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([]);
|
|
@@ -8,11 +8,39 @@ export const useStoryStore = defineStore('story', () => {
|
|
|
8
8
|
}
|
|
9
9
|
const currentStory = computed(() => stories.value.find(s => s.id === router.currentRoute.value.params.storyId));
|
|
10
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);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
openedFolders.value.delete(stringPath);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function isFolderOpened(path) {
|
|
28
|
+
return openedFolders.value.get(getStringPath(path));
|
|
29
|
+
}
|
|
30
|
+
function openFileFolders(path) {
|
|
31
|
+
for (let pathLength = 1; pathLength < path.length; pathLength++) {
|
|
32
|
+
toggleFolder(path.slice(0, pathLength), true);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
watch(currentStory, () => {
|
|
36
|
+
openFileFolders(currentStory.value.file.path);
|
|
37
|
+
});
|
|
11
38
|
return {
|
|
12
39
|
stories,
|
|
13
40
|
setStories,
|
|
14
41
|
currentStory,
|
|
15
42
|
currentVariant,
|
|
43
|
+
isFolderOpened,
|
|
44
|
+
toggleFolder,
|
|
16
45
|
};
|
|
17
46
|
});
|
|
18
|
-
//# sourceMappingURL=story.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineStore } from 'pinia'
|
|
2
|
-
import { computed, ref } from 'vue'
|
|
2
|
+
import { computed, reactive, ref, watch } from 'vue'
|
|
3
3
|
import { router } from '../router'
|
|
4
4
|
import { Story } from '../types'
|
|
5
5
|
|
|
@@ -13,10 +13,46 @@ export const useStoryStore = defineStore('story', () => {
|
|
|
13
13
|
|
|
14
14
|
const currentVariant = computed(() => currentStory.value?.variants.find(v => v.id === router.currentRoute.value.query.variantId))
|
|
15
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
|
+
|
|
16
50
|
return {
|
|
17
51
|
stories,
|
|
18
52
|
setStories,
|
|
19
53
|
currentStory,
|
|
20
54
|
currentVariant,
|
|
55
|
+
isFolderOpened,
|
|
56
|
+
toggleFolder,
|
|
21
57
|
}
|
|
22
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
|
+
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
@import url('https://fonts.googleapis.com/css2?family=Lato&display=swap');
|
|
2
2
|
@import 'floating-vue/dist/style.css';
|
|
3
3
|
@import 'floating-vue.css';
|
|
4
|
+
@import 'transitions.css';
|
|
4
5
|
|
|
5
6
|
*,
|
|
6
7
|
::before,
|
|
@@ -12,7 +13,8 @@
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
a,
|
|
15
|
-
input
|
|
16
|
+
input,
|
|
17
|
+
button {
|
|
16
18
|
color: inherit;
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -49,3 +51,17 @@ body,
|
|
|
49
51
|
.__histoire-sandbox {
|
|
50
52
|
contain: content;
|
|
51
53
|
}
|
|
54
|
+
|
|
55
|
+
.__histoire-code .shiki {
|
|
56
|
+
background: transparent !important;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.htw-prose {
|
|
60
|
+
h1, h2, h3, h4 {
|
|
61
|
+
&:not(:hover) {
|
|
62
|
+
.header-anchor[aria-hidden="true"] {
|
|
63
|
+
visibility: hidden;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
package/dist/client/app/types.js
CHANGED
package/dist/client/app/types.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { RouteLocationRaw } from 'vue-router'
|
|
2
|
+
|
|
1
3
|
export interface StoryFile {
|
|
2
4
|
id: string
|
|
3
5
|
framework: string
|
|
4
6
|
component: any
|
|
5
7
|
story: Story
|
|
8
|
+
path: string[]
|
|
6
9
|
}
|
|
7
10
|
|
|
8
11
|
export interface Story {
|
|
@@ -30,6 +33,7 @@ export interface Variant {
|
|
|
30
33
|
slots?: () => Readonly<any>
|
|
31
34
|
state?: any
|
|
32
35
|
source?: string
|
|
36
|
+
ready?: boolean
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
export type TreeLeaf = {
|
|
@@ -43,3 +47,14 @@ export type TreeFolder = {
|
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
export type Tree = (TreeFolder | TreeLeaf)[]
|
|
50
|
+
|
|
51
|
+
export interface SearchResult {
|
|
52
|
+
kind: 'story' | 'variant'
|
|
53
|
+
rank: number
|
|
54
|
+
id: string
|
|
55
|
+
title: string
|
|
56
|
+
route: RouteLocationRaw
|
|
57
|
+
path?: string[]
|
|
58
|
+
icon?: string
|
|
59
|
+
iconColor?: string
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isMac = navigator.platform.toLowerCase().includes('mac')
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
}
|