histoire 0.3.1 → 0.4.0
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/dist/bundled/BaseEmpty.js +13 -0
- package/dist/bundled/HomeView.js +23 -0
- package/dist/bundled/MobileOverlay.js +303 -0
- package/dist/bundled/SearchPane.js +504 -0
- package/dist/bundled/StoryView.js +2330 -0
- package/dist/bundled/api.js +32 -0
- package/dist/bundled/config.js +4 -0
- package/dist/bundled/const.js +5 -0
- package/dist/bundled/dark.js +4 -0
- package/dist/bundled/events.js +29 -0
- package/dist/bundled/global-components.js +203 -0
- package/dist/bundled/index.js +7 -0
- package/dist/bundled/index2.js +762 -0
- package/dist/bundled/reactivity.js +96 -0
- package/dist/bundled/sandbox.js +97 -0
- package/dist/bundled/search-docs-data.js +7 -0
- package/dist/bundled/story.js +59 -0
- package/dist/bundled/style.css +102 -0
- package/dist/client/app/App.vue +2 -2
- package/dist/client/app/api.d.ts +1 -0
- package/dist/client/app/api.js +1 -0
- package/dist/client/app/codegen/vue3.js +1 -2
- package/dist/client/app/components/HomeView.vue +1 -1
- package/dist/client/app/components/app/AppLogo.vue +1 -1
- package/dist/client/app/components/app/MobileOverlay.vue +0 -1
- package/dist/client/app/components/base/BaseEmpty.vue +1 -1
- package/dist/client/app/components/base/BaseOverflowMenu.vue +118 -0
- package/dist/client/app/components/base/BaseOverflowTab.vue +46 -0
- package/dist/client/app/components/exposed/Story.vue +13 -2
- package/dist/client/app/components/exposed/Variant.vue +6 -0
- package/dist/client/app/components/panel/PaneTabs.vue +64 -0
- package/{src/client/app/components/story → dist/client/app/components/panel}/StoryControls.vue +1 -1
- package/dist/client/app/components/{story → panel}/StoryDocs.vue +0 -0
- package/dist/client/app/components/{story → panel}/StoryEvent.vue +1 -0
- package/dist/client/app/components/{story → panel}/StoryEvents.vue +0 -0
- package/dist/client/app/components/{story → panel}/StorySidePanel.vue +3 -31
- package/dist/client/app/components/{story → panel}/StorySourceCode.vue +0 -0
- package/dist/client/app/components/sandbox/SandboxVue3.vue +10 -0
- package/dist/client/app/components/search/SearchItem.vue +1 -1
- package/dist/client/app/components/search/SearchPane.vue +108 -25
- package/dist/client/app/components/search/search-docs-data.d.ts +3 -0
- package/dist/client/app/components/search/{search-data.js → search-docs-data.js} +1 -1
- package/dist/client/app/components/search/search-title-data.d.ts +3 -0
- package/dist/client/app/components/search/search-title-data.js +7 -0
- package/dist/client/app/components/search/types.d.ts +7 -0
- package/dist/client/app/components/search/types.js +1 -0
- package/dist/client/app/components/story/StoryResponsivePreview.vue +9 -131
- package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/dist/client/app/components/story/StoryVariantListItem.vue +1 -1
- package/dist/client/app/components/story/StoryVariantSingle.vue +109 -0
- package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +42 -0
- package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
- package/dist/client/app/components/story/StoryVariantSingleView.vue +13 -6
- package/dist/client/app/components/story/StoryView.vue +2 -2
- package/dist/client/app/components/story/StoryViewer.vue +2 -92
- package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantBackground.vue +3 -3
- package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantNewTab.vue +2 -2
- package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantResponsiveSize.vue +3 -3
- package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantTitle.vue +1 -1
- package/dist/client/app/components/tree/StoryListItem.vue +1 -1
- package/dist/client/app/index.d.ts +1 -1
- package/dist/client/app/index.js +21 -18
- package/dist/client/app/sandbox.d.ts +1 -1
- package/dist/client/app/sandbox.js +0 -1
- package/dist/client/app/stores/events.js +1 -1
- package/dist/client/app/stores/story.d.ts +27 -0
- package/dist/client/app/style/transitions.pcss +13 -0
- package/dist/client/app/types.d.ts +3 -0
- package/dist/client/app/util/events.d.ts +1 -1
- package/dist/client/app/util/events.js +2 -2
- package/dist/client/app/util/mapping.js +2 -0
- package/dist/client/bundle-index.js +5 -0
- package/dist/client/bundle-main.js +5 -0
- package/dist/client/bundle-sandbox.js +3 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/server/vue3/Story.vue +1 -1
- package/dist/client/server/vue3/run.js +8 -0
- package/dist/node/alias.js +1 -1
- package/dist/node/build.js +4 -4
- package/dist/node/builtin-plugins/tailwind-tokens.js +1 -1
- package/dist/node/search.d.ts +15 -1
- package/dist/node/search.js +78 -32
- package/dist/node/server.js +2 -2
- package/dist/node/types.d.ts +1 -0
- package/dist/node/vite.d.ts +4 -2
- package/dist/node/vite.js +24 -28
- package/dist/style.css +93 -69
- package/package.json +10 -10
- package/src/client/app/App.vue +2 -2
- package/src/client/app/api.ts +1 -0
- package/src/client/app/codegen/vue3.ts +1 -2
- package/src/client/app/components/HomeView.vue +1 -1
- package/src/client/app/components/app/AppLogo.vue +1 -1
- package/src/client/app/components/app/MobileOverlay.vue +0 -1
- package/src/client/app/components/base/BaseEmpty.vue +1 -1
- package/src/client/app/components/base/BaseOverflowMenu.vue +118 -0
- package/src/client/app/components/base/BaseOverflowTab.vue +46 -0
- package/src/client/app/components/exposed/Story.vue +13 -2
- package/src/client/app/components/exposed/Variant.vue +6 -0
- package/src/client/app/components/panel/PaneTabs.vue +64 -0
- package/{dist/client/app/components/story → src/client/app/components/panel}/StoryControls.vue +1 -1
- package/src/client/app/components/{story → panel}/StoryDocs.vue +0 -0
- package/src/client/app/components/{story → panel}/StoryEvent.vue +1 -0
- package/src/client/app/components/{story → panel}/StoryEvents.vue +0 -0
- package/src/client/app/components/{story → panel}/StorySidePanel.vue +3 -31
- package/src/client/app/components/{story → panel}/StorySourceCode.vue +0 -0
- package/src/client/app/components/sandbox/SandboxVue3.vue +10 -0
- package/src/client/app/components/search/SearchItem.vue +1 -1
- package/src/client/app/components/search/SearchPane.vue +108 -25
- package/src/client/app/components/search/search-docs-data.ts +10 -0
- package/src/client/app/components/search/search-title-data.ts +10 -0
- package/src/client/app/components/search/types.ts +4 -0
- package/src/client/app/components/story/StoryResponsivePreview.vue +9 -131
- package/src/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/src/client/app/components/story/StoryVariantListItem.vue +1 -1
- package/src/client/app/components/story/StoryVariantSingle.vue +109 -0
- package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +42 -0
- package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
- package/src/client/app/components/story/StoryVariantSingleView.vue +13 -6
- package/src/client/app/components/story/StoryView.vue +2 -2
- package/src/client/app/components/story/StoryViewer.vue +2 -92
- package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantBackground.vue +3 -3
- package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantNewTab.vue +2 -2
- package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantResponsiveSize.vue +3 -3
- package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantTitle.vue +1 -1
- package/src/client/app/components/tree/StoryListItem.vue +1 -1
- package/src/client/app/index.ts +23 -19
- package/src/client/app/sandbox.ts +1 -2
- package/src/client/app/stores/events.ts +1 -1
- package/src/client/app/style/transitions.pcss +13 -0
- package/src/client/app/types.ts +4 -0
- package/src/client/app/util/events.ts +2 -2
- package/src/client/app/util/mapping.ts +2 -0
- package/src/client/bundle-index.js +5 -0
- package/src/client/bundle-main.js +5 -0
- package/src/client/bundle-sandbox.js +3 -0
- package/src/client/index.ts +1 -1
- package/src/client/server/vue3/Story.vue +1 -1
- package/src/client/server/vue3/run.ts +11 -0
- package/src/node/alias.ts +1 -1
- package/src/node/build.ts +4 -4
- package/src/node/builtin-plugins/tailwind-tokens.ts +1 -1
- package/src/node/search.ts +87 -32
- package/src/node/server.ts +2 -2
- package/src/node/types.ts +1 -0
- package/src/node/vite.ts +24 -29
- package/vite.config.ts +46 -0
- package/dist/client/app/components/search/search-data.d.ts +0 -2
- package/src/client/app/components/search/search-data.ts +0 -9
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { defineComponent, ref, createApp, onMounted, watch, onUnmounted, openBlock, createElementBlock, isRef, unref } from "vue";
|
|
2
|
+
import * as setup from "$histoire-setup";
|
|
3
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4
|
+
props: {
|
|
5
|
+
variant: {
|
|
6
|
+
type: Object,
|
|
7
|
+
required: true
|
|
8
|
+
},
|
|
9
|
+
story: {
|
|
10
|
+
type: Object,
|
|
11
|
+
required: true
|
|
12
|
+
},
|
|
13
|
+
slotName: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: "default"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
emits: {
|
|
19
|
+
ready: () => true
|
|
20
|
+
},
|
|
21
|
+
setup(__props, { emit }) {
|
|
22
|
+
const props = __props;
|
|
23
|
+
const sandbox = ref();
|
|
24
|
+
let app;
|
|
25
|
+
let mounting = false;
|
|
26
|
+
async function mountVariant() {
|
|
27
|
+
mounting = true;
|
|
28
|
+
await props.variant.initState();
|
|
29
|
+
app = createApp({
|
|
30
|
+
name: "SandboxVue3",
|
|
31
|
+
render: () => {
|
|
32
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
33
|
+
return (_g = (_c = (_a = props.variant.slots()) == null ? void 0 : _a[props.slotName]) == null ? void 0 : _c.call(_a, {
|
|
34
|
+
state: (_b = props.variant.state) != null ? _b : {}
|
|
35
|
+
})) != null ? _g : (_f = (_d = props.story.slots()) == null ? void 0 : _d[props.slotName]) == null ? void 0 : _f.call(_d, {
|
|
36
|
+
state: (_e = props.variant.state) != null ? _e : {}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
if (typeof (setup == null ? void 0 : setup.setupVue3) === "function") {
|
|
41
|
+
await setup.setupVue3({
|
|
42
|
+
app,
|
|
43
|
+
story: props.story,
|
|
44
|
+
variant: props.variant
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (typeof props.variant.setupApp === "function") {
|
|
48
|
+
await props.variant.setupApp({
|
|
49
|
+
app,
|
|
50
|
+
story: props.story,
|
|
51
|
+
variant: props.variant
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const target = document.createElement("div");
|
|
55
|
+
sandbox.value.appendChild(target);
|
|
56
|
+
app.mount(target);
|
|
57
|
+
emit("ready");
|
|
58
|
+
}
|
|
59
|
+
onMounted(async () => {
|
|
60
|
+
if (props.variant.initState) {
|
|
61
|
+
await mountVariant();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
watch(() => props.variant.initState, (value) => {
|
|
65
|
+
if (value && !mounting) {
|
|
66
|
+
mountVariant();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
onUnmounted(() => {
|
|
70
|
+
app == null ? void 0 : app.unmount();
|
|
71
|
+
});
|
|
72
|
+
return (_ctx, _cache) => {
|
|
73
|
+
return openBlock(), createElementBlock("div", {
|
|
74
|
+
ref_key: "sandbox",
|
|
75
|
+
ref: sandbox,
|
|
76
|
+
class: "__histoire-sandbox htw-overflow-auto"
|
|
77
|
+
}, null, 512);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
82
|
+
function toRawDeep(val) {
|
|
83
|
+
const unwrappedValue = isRef(val) ? unref(val) : val;
|
|
84
|
+
if (!isObject(unwrappedValue)) {
|
|
85
|
+
return unwrappedValue;
|
|
86
|
+
}
|
|
87
|
+
if (Array.isArray(unwrappedValue)) {
|
|
88
|
+
return unwrappedValue.map(toRawDeep);
|
|
89
|
+
}
|
|
90
|
+
return toRawObject(unwrappedValue);
|
|
91
|
+
}
|
|
92
|
+
const toRawObject = (obj) => Object.keys(obj).reduce((raw, key) => {
|
|
93
|
+
raw[key] = toRawDeep(obj[key]);
|
|
94
|
+
return raw;
|
|
95
|
+
}, {});
|
|
96
|
+
export { _sfc_main as _, toRawDeep as t };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { parseQuery } from "vue-router";
|
|
2
|
+
import { reactive, ref, createApp, computed, watch, onMounted, h } from "vue";
|
|
3
|
+
import { createPinia } from "pinia";
|
|
4
|
+
import { m as mapFile, r as registerGlobalComponents } from "./global-components.js";
|
|
5
|
+
import { t as toRawDeep, _ as _sfc_main } from "./reactivity.js";
|
|
6
|
+
import { files } from "$histoire-stories";
|
|
7
|
+
import { S as STATE_SYNC, P as PREVIEW_SETTINGS_SYNC, a as SANDBOX_READY } from "./const.js";
|
|
8
|
+
import { i as isDark } from "./dark.js";
|
|
9
|
+
import { h as histoireConfig } from "./config.js";
|
|
10
|
+
const receivedSettings = reactive({});
|
|
11
|
+
function applyPreviewSettings(settings) {
|
|
12
|
+
Object.assign(receivedSettings, settings);
|
|
13
|
+
}
|
|
14
|
+
const query = parseQuery(window.location.search);
|
|
15
|
+
const file = ref(mapFile(files.find((f) => f.id === query.storyId)));
|
|
16
|
+
const app = createApp({
|
|
17
|
+
name: "SandboxApp",
|
|
18
|
+
setup() {
|
|
19
|
+
const story = computed(() => file.value.story);
|
|
20
|
+
const variant = computed(() => {
|
|
21
|
+
var _a;
|
|
22
|
+
return (_a = story.value) == null ? void 0 : _a.variants.find((v) => v.id === query.variantId);
|
|
23
|
+
});
|
|
24
|
+
let synced = false;
|
|
25
|
+
let mounted = false;
|
|
26
|
+
window.addEventListener("message", (event) => {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
if (((_a = event.data) == null ? void 0 : _a.type) === STATE_SYNC) {
|
|
29
|
+
if (!mounted)
|
|
30
|
+
return;
|
|
31
|
+
synced = true;
|
|
32
|
+
if (variant.value.state) {
|
|
33
|
+
for (const key in event.data.state) {
|
|
34
|
+
if (typeof variant.value.state[key] === "object") {
|
|
35
|
+
Object.assign(variant.value.state[key], event.data.state[key]);
|
|
36
|
+
} else {
|
|
37
|
+
variant.value.state[key] = event.data.state[key];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} else if (((_b = event.data) == null ? void 0 : _b.type) === PREVIEW_SETTINGS_SYNC) {
|
|
42
|
+
applyPreviewSettings(event.data.settings);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
watch(() => variant.value.state, (value) => {
|
|
46
|
+
var _a;
|
|
47
|
+
if (synced && mounted) {
|
|
48
|
+
synced = false;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
52
|
+
type: STATE_SYNC,
|
|
53
|
+
state: toRawDeep(value)
|
|
54
|
+
});
|
|
55
|
+
}, {
|
|
56
|
+
deep: true
|
|
57
|
+
});
|
|
58
|
+
onMounted(() => {
|
|
59
|
+
mounted = true;
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
story,
|
|
63
|
+
variant
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
render() {
|
|
67
|
+
return [
|
|
68
|
+
h("div", { class: "htw-sandbox-hidden" }, [
|
|
69
|
+
h(file.value.component, {
|
|
70
|
+
story: file.value.story
|
|
71
|
+
})
|
|
72
|
+
]),
|
|
73
|
+
this.story && this.variant ? h(_sfc_main, {
|
|
74
|
+
story: this.story,
|
|
75
|
+
variant: this.variant,
|
|
76
|
+
onReady: () => {
|
|
77
|
+
var _a;
|
|
78
|
+
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
79
|
+
type: SANDBOX_READY
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}) : null
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
app.use(createPinia());
|
|
87
|
+
registerGlobalComponents(app);
|
|
88
|
+
app.mount("#app");
|
|
89
|
+
watch(isDark, (value) => {
|
|
90
|
+
if (value) {
|
|
91
|
+
document.documentElement.classList.add(histoireConfig.sandboxDarkClass);
|
|
92
|
+
} else {
|
|
93
|
+
document.documentElement.classList.remove(histoireConfig.sandboxDarkClass);
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
immediate: true
|
|
97
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { ref, computed } from "vue";
|
|
3
|
+
import { createRouter, createWebHistory } from "vue-router";
|
|
4
|
+
const base = "/";
|
|
5
|
+
const router = createRouter({
|
|
6
|
+
history: createWebHistory(base),
|
|
7
|
+
routes: [
|
|
8
|
+
{
|
|
9
|
+
path: "/",
|
|
10
|
+
name: "home",
|
|
11
|
+
component: () => import("./HomeView.js")
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
path: "/story/:storyId",
|
|
15
|
+
name: "story",
|
|
16
|
+
component: () => import("./StoryView.js")
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
const useStoryStore = defineStore("story", () => {
|
|
21
|
+
const stories = ref([]);
|
|
22
|
+
function setStories(value) {
|
|
23
|
+
stories.value = value;
|
|
24
|
+
}
|
|
25
|
+
const currentStory = computed(() => stories.value.find((s) => s.id === router.currentRoute.value.params.storyId));
|
|
26
|
+
const currentVariant = computed(() => {
|
|
27
|
+
var _a;
|
|
28
|
+
return (_a = currentStory.value) == null ? void 0 : _a.variants.find((v) => v.id === router.currentRoute.value.query.variantId);
|
|
29
|
+
});
|
|
30
|
+
const maps = computed(() => {
|
|
31
|
+
const storyMap = /* @__PURE__ */ new Map();
|
|
32
|
+
const variantMap = /* @__PURE__ */ new Map();
|
|
33
|
+
for (const story of stories.value) {
|
|
34
|
+
storyMap.set(story.id, story);
|
|
35
|
+
for (const variant of story.variants) {
|
|
36
|
+
variantMap.set(`${story.id}:${variant.id}`, variant);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
stories: storyMap,
|
|
41
|
+
variants: variantMap
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
function getStoryById(id) {
|
|
45
|
+
return maps.value.stories.get(id);
|
|
46
|
+
}
|
|
47
|
+
function getVariantById(idWithStoryId) {
|
|
48
|
+
return maps.value.variants.get(idWithStoryId);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
stories,
|
|
52
|
+
setStories,
|
|
53
|
+
currentStory,
|
|
54
|
+
currentVariant,
|
|
55
|
+
getStoryById,
|
|
56
|
+
getVariantById
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
export { base as b, router as r, useStoryStore as u };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
|
|
2
|
+
.bind-tree-margin[data-v-3bb05a26] {
|
|
3
|
+
margin-left: var(--335c8a9c);
|
|
4
|
+
}
|
|
5
|
+
.bind-icon-color[data-v-3bb05a26] {
|
|
6
|
+
color: var(--10044424);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.bind-tree-padding[data-v-1a78012e] {
|
|
10
|
+
padding-left: var(--27f98670);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.bind-icon-color[data-v-5fe505b0] {
|
|
14
|
+
color: var(--7fa476a0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.landscape > div > .dragger[data-v-4de97f66] {
|
|
18
|
+
width: 10px;
|
|
19
|
+
}
|
|
20
|
+
.portrait > div > .dragger[data-v-4de97f66] {
|
|
21
|
+
height: 10px;
|
|
22
|
+
}
|
|
23
|
+
.landscape > div > .dragger.dragger-offset-before[data-v-4de97f66] {
|
|
24
|
+
right: 0;
|
|
25
|
+
}
|
|
26
|
+
.portrait > div > .dragger.dragger-offset-before[data-v-4de97f66] {
|
|
27
|
+
bottom: 0;
|
|
28
|
+
}
|
|
29
|
+
.landscape > div > .dragger.dragger-offset-center[data-v-4de97f66] {
|
|
30
|
+
right: -5px;
|
|
31
|
+
}
|
|
32
|
+
.portrait > div > .dragger.dragger-offset-center[data-v-4de97f66] {
|
|
33
|
+
bottom: -5px;
|
|
34
|
+
}
|
|
35
|
+
.landscape > div > .dragger.dragger-offset-after[data-v-4de97f66] {
|
|
36
|
+
right: -10px;
|
|
37
|
+
}
|
|
38
|
+
.portrait > div > .dragger.dragger-offset-after[data-v-4de97f66] {
|
|
39
|
+
bottom: -10px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.bind-icon-color[data-v-2cdc2ac0] {
|
|
43
|
+
color: var(--3c4190ff);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.bind-icon-color[data-v-5c057bcc] {
|
|
47
|
+
color: var(--4b330766);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.bind-preview-bg[data-v-bde73868] {
|
|
51
|
+
background-color: var(--b797c7ca);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.__histoire-hatched-pattern[data-v-250960ac] {
|
|
55
|
+
background: repeating-linear-gradient(135deg,
|
|
56
|
+
transparent 0px,
|
|
57
|
+
transparent 32px,
|
|
58
|
+
currentColor 32px,
|
|
59
|
+
currentColor 64px);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.bind-preview-bg[data-v-769a585e] {
|
|
63
|
+
background-color: var(--700caecc);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.bind-icon-color[data-v-a52efa6c] {
|
|
67
|
+
color: var(--ffdba94a);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.bind-icon-color[data-v-141c6b20] {
|
|
71
|
+
color: var(--4ecaabeb);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.__histoire-code-placeholder[data-v-32cb8d14] {
|
|
75
|
+
color: inherit;
|
|
76
|
+
font-size: inherit;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.htw-base-empty[data-v-552cc113]:not(.no-animation) {
|
|
80
|
+
-webkit-animation: htw-base-empty-552cc113 .3s 1s both;
|
|
81
|
+
animation: htw-base-empty-552cc113 .3s 1s both;
|
|
82
|
+
}
|
|
83
|
+
@-webkit-keyframes htw-base-empty-552cc113 {
|
|
84
|
+
0% {
|
|
85
|
+
opacity: 0;
|
|
86
|
+
}
|
|
87
|
+
100% {
|
|
88
|
+
opacity: 1;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
@keyframes htw-base-empty-552cc113 {
|
|
92
|
+
0% {
|
|
93
|
+
opacity: 0;
|
|
94
|
+
}
|
|
95
|
+
100% {
|
|
96
|
+
opacity: 1;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.bind-icon-color[data-v-7856c5b0] {
|
|
101
|
+
color: var(--0e1c785e);
|
|
102
|
+
}
|
package/dist/client/app/App.vue
CHANGED
|
@@ -15,8 +15,8 @@ import type { StoryFile, Tree } from './types'
|
|
|
15
15
|
import { useStoryStore } from './stores/story'
|
|
16
16
|
import { mapFile } from './util/mapping'
|
|
17
17
|
import { useTitle } from '@vueuse/core'
|
|
18
|
-
import { histoireConfig } from './util/config
|
|
19
|
-
import { onKeyboardShortcut } from './util/keyboard
|
|
18
|
+
import { histoireConfig } from './util/config'
|
|
19
|
+
import { onKeyboardShortcut } from './util/keyboard'
|
|
20
20
|
import { isMobile } from './util/responsive'
|
|
21
21
|
import Breadcrumb from './components/app/Breadcrumb.vue'
|
|
22
22
|
import SearchModal from './components/search/SearchModal.vue'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { hstEvent } from './util/events.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { hstEvent } from './util/events.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// @TODO remove no-check and fix vnode type errors
|
|
3
|
-
import { vModelText, vModelCheckbox, vModelSelect, vModelRadio, vModelDynamic } from 'vue';
|
|
4
|
-
import { Text } from '@vue/runtime-core';
|
|
3
|
+
import { vModelText, vModelCheckbox, vModelSelect, vModelRadio, vModelDynamic, Text } from 'vue';
|
|
5
4
|
import { pascal } from 'case';
|
|
6
5
|
import { createAutoBuildingObject, indent } from './util';
|
|
7
6
|
import { serializeJs } from './serialize-js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { computed } from 'vue'
|
|
3
|
-
import { histoireConfig, customLogos } from '../util/config
|
|
3
|
+
import { histoireConfig, customLogos } from '../util/config'
|
|
4
4
|
import HistoireLogo from '../assets/histoire.svg'
|
|
5
5
|
|
|
6
6
|
const logoUrl = computed(() => histoireConfig.theme?.logo?.square ? customLogos.square : HistoireLogo)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { isDark } from '../../util/dark'
|
|
3
3
|
import { computed } from 'vue'
|
|
4
|
-
import { histoireConfig, customLogos } from '../../util/config
|
|
4
|
+
import { histoireConfig, customLogos } from '../../util/config'
|
|
5
5
|
|
|
6
6
|
import HistoireLogoDark from '../../assets/histoire-text-dark.svg'
|
|
7
7
|
import HistoireLogoLight from '../../assets/histoire-text.svg'
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { ref, h, onBeforeUnmount, reactive, computed } from 'vue'
|
|
3
|
+
import { useResizeObserver } from '@vueuse/core'
|
|
4
|
+
import { Icon } from '@iconify/vue'
|
|
5
|
+
|
|
6
|
+
// Container
|
|
7
|
+
|
|
8
|
+
const overflowButtonWidth = 32
|
|
9
|
+
|
|
10
|
+
const el = ref<HTMLDivElement>()
|
|
11
|
+
|
|
12
|
+
const availableWidth = ref(0)
|
|
13
|
+
|
|
14
|
+
useResizeObserver(el, (entries) => {
|
|
15
|
+
const containerWidth = entries[0].contentRect.width
|
|
16
|
+
availableWidth.value = containerWidth - overflowButtonWidth
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
// Children
|
|
20
|
+
|
|
21
|
+
interface ChildState {
|
|
22
|
+
width: number
|
|
23
|
+
index: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const children = ref(new Map<HTMLElement, ChildState>())
|
|
27
|
+
|
|
28
|
+
const visibleChildrenCount = computed(() => {
|
|
29
|
+
let width = 0
|
|
30
|
+
const c = [...children.value.values()].sort((a, b) => a.index - b.index)
|
|
31
|
+
for (let i = 0; i < c.length; i++) {
|
|
32
|
+
width += c[i].width
|
|
33
|
+
if (width > availableWidth.value) {
|
|
34
|
+
return i
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return c.length
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Watches for the size of each child and automatically hide them
|
|
42
|
+
*/
|
|
43
|
+
const ChildWrapper = {
|
|
44
|
+
props: ['index'],
|
|
45
|
+
setup (props, { slots }) {
|
|
46
|
+
const el = ref<HTMLDivElement>()
|
|
47
|
+
|
|
48
|
+
const state = reactive({ width: 0, index: props.index })
|
|
49
|
+
|
|
50
|
+
useResizeObserver(el, (entries) => {
|
|
51
|
+
const width = entries[0].contentRect.width
|
|
52
|
+
if (!children.value.has(el.value)) {
|
|
53
|
+
children.value.set(el.value, state)
|
|
54
|
+
}
|
|
55
|
+
state.width = width
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
onBeforeUnmount(() => {
|
|
59
|
+
children.value.delete(el.value)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const visible = computed(() => visibleChildrenCount.value > state.index)
|
|
63
|
+
|
|
64
|
+
return () => h('div', { ref: el, style: { visibility: visible.value ? 'visible' : 'hidden' } }, slots.default())
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Wraps each child with a <ChildWrapper>
|
|
70
|
+
*/
|
|
71
|
+
const ChildrenRender = (props, { slots }) => {
|
|
72
|
+
const [fragment] = slots.default()
|
|
73
|
+
return fragment.children.map((vnode, index) => h(ChildWrapper, { index }, () => [vnode]))
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Only renders a part of a children list
|
|
78
|
+
*/
|
|
79
|
+
const ChildrenSlice = (props, { slots }) => {
|
|
80
|
+
const [fragment] = slots.default()
|
|
81
|
+
return fragment.children.slice(props.start, props.end)
|
|
82
|
+
}
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<template>
|
|
86
|
+
<div
|
|
87
|
+
ref="el"
|
|
88
|
+
class="htw-flex htw-overflow-hidden htw-relative"
|
|
89
|
+
>
|
|
90
|
+
<ChildrenRender>
|
|
91
|
+
<slot />
|
|
92
|
+
</ChildrenRender>
|
|
93
|
+
|
|
94
|
+
<VDropdown
|
|
95
|
+
v-if="visibleChildrenCount < children.size"
|
|
96
|
+
>
|
|
97
|
+
<div
|
|
98
|
+
role="button"
|
|
99
|
+
class="htw-cursor-pointer hover:htw-bg-primary-50 dark:hover:htw-bg-primary-900 htw-w-8 htw-h-full htw-flex htw-items-center htw-justify-center htw-absolute htw-top-0 htw-right-0"
|
|
100
|
+
>
|
|
101
|
+
<Icon
|
|
102
|
+
icon="carbon:caret-down"
|
|
103
|
+
class="htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
|
|
104
|
+
/>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<template #popper>
|
|
108
|
+
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
109
|
+
<ChildrenSlice
|
|
110
|
+
:start="visibleChildrenCount"
|
|
111
|
+
>
|
|
112
|
+
<slot name="overflow" />
|
|
113
|
+
</ChildrenSlice>
|
|
114
|
+
</div>
|
|
115
|
+
</template>
|
|
116
|
+
</VDropdown>
|
|
117
|
+
</div>
|
|
118
|
+
</template>
|
|
@@ -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-10 htw-min-w-[150px] htw-inline-flex htw-items-center hover:htw-bg-primary-50 dark:hover:htw-bg-primary-900 htw-relative htw-text-gray-900 dark:htw-text-gray-100"
|
|
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-y">
|
|
39
|
+
<div
|
|
40
|
+
v-if="matched != null ? matched : (exact && isExactActive) || (!exact && isActive)"
|
|
41
|
+
class="htw-absolute htw-top-0 htw-left-0 htw-h-full htw-w-[2px] htw-bg-primary-500 dark:htw-bg-primary-400"
|
|
42
|
+
/>
|
|
43
|
+
</transition>
|
|
44
|
+
</a>
|
|
45
|
+
</router-link>
|
|
46
|
+
</template>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { computed, defineComponent, provide, useAttrs, VNode, h, PropType, getCurrentInstance } from 'vue'
|
|
3
|
-
import { Story } from '../../types.js'
|
|
3
|
+
import type { Story } from '../../types.js'
|
|
4
4
|
import Variant from './Variant.vue'
|
|
5
5
|
|
|
6
6
|
export default defineComponent({
|
|
@@ -18,6 +18,8 @@ export default defineComponent({
|
|
|
18
18
|
},
|
|
19
19
|
|
|
20
20
|
setup () {
|
|
21
|
+
const vm = getCurrentInstance()
|
|
22
|
+
|
|
21
23
|
const attrs = useAttrs() as {
|
|
22
24
|
story: Story
|
|
23
25
|
}
|
|
@@ -25,7 +27,7 @@ export default defineComponent({
|
|
|
25
27
|
const story = computed(() => attrs.story)
|
|
26
28
|
provide('story', story)
|
|
27
29
|
|
|
28
|
-
const storyComponent: any =
|
|
30
|
+
const storyComponent: any = vm.parent
|
|
29
31
|
// Allows tracking reactivity with watchers to sync state
|
|
30
32
|
const implicitState = {
|
|
31
33
|
$data: storyComponent.data,
|
|
@@ -46,12 +48,21 @@ export default defineComponent({
|
|
|
46
48
|
}
|
|
47
49
|
provide('implicitState', () => implicitState)
|
|
48
50
|
|
|
51
|
+
function updateStory () {
|
|
52
|
+
Object.assign(attrs.story, {
|
|
53
|
+
slots: () => vm.proxy.$slots,
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
49
57
|
return {
|
|
50
58
|
story,
|
|
59
|
+
updateStory,
|
|
51
60
|
}
|
|
52
61
|
},
|
|
53
62
|
|
|
54
63
|
render () {
|
|
64
|
+
this.updateStory()
|
|
65
|
+
|
|
55
66
|
const [firstVariant] = this.story.variants
|
|
56
67
|
if (firstVariant.id === '_default') {
|
|
57
68
|
return h(Variant, {
|
|
@@ -24,6 +24,11 @@ export default defineComponent({
|
|
|
24
24
|
type: Boolean,
|
|
25
25
|
default: false,
|
|
26
26
|
},
|
|
27
|
+
|
|
28
|
+
setupApp: {
|
|
29
|
+
type: Function,
|
|
30
|
+
default: null,
|
|
31
|
+
},
|
|
27
32
|
},
|
|
28
33
|
|
|
29
34
|
setup (props) {
|
|
@@ -53,6 +58,7 @@ export default defineComponent({
|
|
|
53
58
|
slots: () => vm.proxy.$slots,
|
|
54
59
|
source: props.source,
|
|
55
60
|
responsiveDisabled: props.responsiveDisabled,
|
|
61
|
+
setupApp: props.setupApp,
|
|
56
62
|
configReady: true,
|
|
57
63
|
})
|
|
58
64
|
}
|