@histoire/app 0.10.7 → 0.11.1
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/app/style/main.pcss +12 -1
- package/dist/bundled/App.js +4 -148
- package/dist/bundled/App.vue_vue_type_script_setup_true_lang.js +156 -0
- package/dist/bundled/_virtual/{plugin-vue_export-helper.js → _plugin-vue_export-helper.js} +4 -2
- package/dist/bundled/api.js +4 -1
- package/dist/bundled/assets/histoire-text-dark.js +4 -2
- package/dist/bundled/assets/histoire-text.js +4 -2
- package/dist/bundled/assets/histoire.js +4 -2
- package/dist/bundled/components/HomeView.js +5 -24
- package/dist/bundled/components/HomeView.vue_vue_type_script_setup_true_lang.js +26 -0
- package/dist/bundled/components/app/AppHeader.js +5 -67
- package/dist/bundled/components/app/AppHeader.vue_vue_type_script_setup_true_lang.js +70 -0
- package/dist/bundled/components/app/AppLogo.js +5 -26
- package/dist/bundled/components/app/AppLogo.vue_vue_type_script_setup_true_lang.js +28 -0
- package/dist/bundled/components/app/Breadcrumb.js +7 -95
- package/dist/bundled/components/app/Breadcrumb.vue_vue_type_script_setup_true_lang.js +95 -0
- package/dist/bundled/components/app/Breadcrumb.vue_vue_type_style_index_0_scoped_afeba72b_lang.js +4 -0
- package/dist/bundled/components/app/InitialLoading.js +5 -48
- package/dist/bundled/components/app/InitialLoading.vue_vue_type_script_setup_true_lang.js +50 -0
- package/dist/bundled/components/app/MobileOverlay.js +4 -40
- package/dist/bundled/components/app/MobileOverlay.vue_vue_type_script_setup_true_lang.js +43 -0
- package/dist/bundled/components/base/BaseCheckbox.js +4 -74
- package/dist/bundled/components/base/BaseCheckbox.vue_vue_type_script_setup_true_lang.js +77 -0
- package/dist/bundled/components/base/BaseEmpty.js +7 -5
- package/dist/bundled/components/base/BaseEmpty.vue_vue_type_style_index_0_scoped_af3328a6_lang.js +4 -0
- package/dist/bundled/components/base/BaseListItemLink.js +7 -25
- package/dist/bundled/components/base/BaseListItemLink.vue_vue_type_script_lang.js +25 -0
- package/dist/bundled/components/base/BaseOverflowMenu.js +4 -96
- package/dist/bundled/components/base/BaseOverflowMenu.vue_vue_type_script_setup_true_lang.js +99 -0
- package/dist/bundled/components/base/BaseOverflowTab.js +7 -17
- package/dist/bundled/components/base/BaseOverflowTab.vue_vue_type_script_lang.js +17 -0
- package/dist/bundled/components/base/BaseSelect.js +5 -69
- package/dist/bundled/components/base/BaseSelect.vue_vue_type_script_setup_true_lang.js +71 -0
- package/dist/bundled/components/base/BaseSplitPane.js +7 -184
- package/dist/bundled/components/base/BaseSplitPane.vue_vue_type_script_setup_true_lang.js +183 -0
- package/dist/bundled/components/base/BaseSplitPane.vue_vue_type_style_index_0_scoped_bb6c600c_lang.js +4 -0
- package/dist/bundled/components/base/BaseTab.js +7 -17
- package/dist/bundled/components/base/BaseTab.vue_vue_type_script_lang.js +17 -0
- package/dist/bundled/components/misc/CheckerboardPattern.js +5 -3
- package/dist/bundled/components/misc/HatchedPattern.js +7 -5
- package/dist/bundled/components/misc/HatchedPattern.vue_vue_type_style_index_0_scoped_91561117_lang.js +4 -0
- package/dist/bundled/components/panel/ControlsComponentPropItem.js +5 -98
- package/dist/bundled/components/panel/ControlsComponentPropItem.vue_vue_type_script_setup_true_lang.js +100 -0
- package/dist/bundled/components/panel/ControlsComponentProps.js +5 -42
- package/dist/bundled/components/panel/ControlsComponentProps.vue_vue_type_script_setup_true_lang.js +45 -0
- package/dist/bundled/components/panel/PaneTabs.js +4 -111
- package/dist/bundled/components/panel/PaneTabs.vue_vue_type_script_setup_true_lang.js +110 -0
- package/dist/bundled/components/panel/StatePresets.js +4 -189
- package/dist/bundled/components/panel/StatePresets.vue_vue_type_script_setup_true_lang.js +193 -0
- package/dist/bundled/components/panel/StoryControls.js +4 -72
- package/dist/bundled/components/panel/StoryControls.vue_vue_type_script_setup_true_lang.js +79 -0
- package/dist/bundled/components/panel/StoryDocs.js +6 -72
- package/dist/bundled/components/panel/StoryDocs.vue_vue_type_script_setup_true_lang.js +74 -0
- package/dist/bundled/components/panel/StoryEvent.js +4 -55
- package/dist/bundled/components/panel/StoryEvent.vue_vue_type_script_setup_true_lang.js +58 -0
- package/dist/bundled/components/panel/StoryEvents.js +5 -49
- package/dist/bundled/components/panel/StoryEvents.vue_vue_type_script_setup_true_lang.js +51 -0
- package/dist/bundled/components/panel/StorySidePanel.js +5 -72
- package/dist/bundled/components/panel/StorySidePanel.vue_vue_type_script_setup_true_lang.js +78 -0
- package/dist/bundled/components/panel/StorySourceCode.js +6 -130
- package/dist/bundled/components/panel/StorySourceCode.vue_vue_type_script_setup_true_lang.js +218 -0
- package/dist/bundled/components/panel/StorySourceCode.vue_vue_type_style_index_0_scoped_0d096b10_lang.js +4 -0
- package/dist/bundled/components/search/SearchItem.js +6 -112
- package/dist/bundled/components/search/SearchItem.vue_vue_type_script_setup_true_lang.js +112 -0
- package/dist/bundled/components/search/SearchItem.vue_vue_type_style_index_0_scoped_b819ed97_lang.js +4 -0
- package/dist/bundled/components/search/SearchLoading.js +5 -19
- package/dist/bundled/components/search/SearchLoading.vue_vue_type_script_setup_true_lang.js +20 -0
- package/dist/bundled/components/search/SearchModal.js +4 -45
- package/dist/bundled/components/search/SearchModal.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/bundled/components/search/SearchPane.js +4 -268
- package/dist/bundled/components/search/SearchPane.vue_vue_type_script_setup_true_lang.js +270 -0
- package/dist/bundled/components/search/search-docs-data.js +5 -2
- package/dist/bundled/components/search/search-title-data.js +5 -2
- package/dist/bundled/components/story/GenericMountStory.js +4 -30
- package/dist/bundled/components/story/GenericMountStory.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/bundled/components/story/GenericRenderStory.js +4 -30
- package/dist/bundled/components/story/GenericRenderStory.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/bundled/components/story/StoryResponsivePreview.js +6 -180
- package/dist/bundled/components/story/StoryResponsivePreview.vue_vue_type_script_setup_true_lang.js +183 -0
- package/dist/bundled/components/story/StoryResponsivePreview.vue_vue_type_style_index_0_scoped_1375d05a_lang.js +4 -0
- package/dist/bundled/components/story/StoryVariantGrid.js +5 -94
- package/dist/bundled/components/story/StoryVariantGrid.vue_vue_type_script_setup_true_lang.js +130 -0
- package/dist/bundled/components/story/StoryVariantGridItem.js +7 -108
- package/dist/bundled/components/story/StoryVariantGridItem.vue_vue_type_script_setup_true_lang.js +134 -0
- package/dist/bundled/components/story/StoryVariantGridItem.vue_vue_type_style_index_0_scoped_5ded7495_lang.js +4 -0
- package/dist/bundled/components/story/StoryVariantListItem.js +7 -58
- package/dist/bundled/components/story/StoryVariantListItem.vue_vue_type_script_setup_true_lang.js +57 -0
- package/dist/bundled/components/story/StoryVariantListItem.vue_vue_type_style_index_0_scoped_cc25ec8b_lang.js +4 -0
- package/dist/bundled/components/story/StoryVariantSingle.js +6 -114
- package/dist/bundled/components/story/StoryVariantSingle.vue_vue_type_script_setup_true_lang.js +114 -0
- package/dist/bundled/components/story/StoryVariantSingle.vue_vue_type_style_index_0_scoped_afe0bbc2_lang.js +4 -0
- package/dist/bundled/components/story/StoryVariantSinglePreviewNative.js +5 -45
- package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.js +5 -122
- package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue_vue_type_script_setup_true_lang.js +124 -0
- package/dist/bundled/components/story/StoryVariantSingleView.js +4 -48
- package/dist/bundled/components/story/StoryVariantSingleView.vue_vue_type_script_setup_true_lang.js +56 -0
- package/dist/bundled/components/story/StoryView.js +4 -89
- package/dist/bundled/components/story/StoryView.vue_vue_type_script_setup_true_lang.js +94 -0
- package/dist/bundled/components/story/StoryViewer.js +7 -57
- package/dist/bundled/components/story/StoryViewer.vue_vue_type_script_setup_true_lang.js +58 -0
- package/dist/bundled/components/story/StoryViewer.vue_vue_type_style_index_0_scoped_54d5a557_lang.js +4 -0
- package/dist/bundled/components/toolbar/StoryVariantBackground.js +7 -85
- package/dist/bundled/components/toolbar/StoryVariantBackground.vue_vue_type_script_setup_true_lang.js +84 -0
- package/dist/bundled/components/toolbar/StoryVariantBackground.vue_vue_type_style_index_0_scoped_8dc02d19_lang.js +4 -0
- package/dist/bundled/components/toolbar/StoryVariantNewTab.js +5 -33
- package/dist/bundled/components/toolbar/StoryVariantNewTab.vue_vue_type_script_setup_true_lang.js +35 -0
- package/dist/bundled/components/toolbar/StoryVariantResponsiveSize.js +5 -129
- package/dist/bundled/components/toolbar/StoryVariantResponsiveSize.vue_vue_type_script_setup_true_lang.js +131 -0
- package/dist/bundled/components/toolbar/StoryVariantTitle.js +5 -24
- package/dist/bundled/components/toolbar/StoryVariantTitle.vue_vue_type_script_setup_true_lang.js +26 -0
- package/dist/bundled/components/tree/StoryGroup.js +4 -73
- package/dist/bundled/components/tree/StoryGroup.vue_vue_type_script_setup_true_lang.js +76 -0
- package/dist/bundled/components/tree/StoryList.js +5 -37
- package/dist/bundled/components/tree/StoryList.vue_vue_type_script_setup_true_lang.js +40 -0
- package/dist/bundled/components/tree/StoryListFolder.js +7 -89
- package/dist/bundled/components/tree/StoryListFolder.vue_vue_type_script_setup_true_lang.js +88 -0
- package/dist/bundled/components/tree/StoryListFolder.vue_vue_type_style_index_0_scoped_41fb5f7e_lang.js +4 -0
- package/dist/bundled/components/tree/StoryListItem.js +6 -71
- package/dist/bundled/components/tree/StoryListItem.vue_vue_type_script_setup_true_lang.js +71 -0
- package/dist/bundled/components/tree/StoryListItem.vue_vue_type_style_index_0_scoped_313a2f42_lang.js +4 -0
- package/dist/bundled/index.js +6 -3
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/common.js +13 -1
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/en.js +7 -2
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/advanced.js +7 -2
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/balance.js +7 -2
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/simple.js +7 -2
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang.js +11 -1
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/type.js +4 -1
- package/dist/bundled/router.js +4 -1
- package/dist/bundled/sandbox.js +5 -3
- package/dist/bundled/stores/events.js +3 -1
- package/dist/bundled/stores/folder.js +6 -2
- package/dist/bundled/stores/preview-settings.js +3 -1
- package/dist/bundled/stores/story.js +3 -1
- package/dist/bundled/style.css +40 -46
- package/dist/bundled/util/config.js +5 -2
- package/dist/bundled/util/const.js +6 -1
- package/dist/bundled/util/dark.js +4 -1
- package/dist/bundled/util/env.js +3 -1
- package/dist/bundled/util/events.js +4 -2
- package/dist/bundled/util/keyboard.js +4 -1
- package/dist/bundled/util/mapping.js +4 -1
- package/dist/bundled/util/preview-settings.js +4 -1
- package/dist/bundled/util/responsive.js +3 -1
- package/dist/bundled/util/sandbox.js +3 -1
- package/dist/bundled/util/scroll.js +3 -1
- package/dist/bundled/util/state.js +3 -1
- package/dist/bundled/util/tooltip.js +3 -1
- package/dist/bundled/util/variant.js +3 -1
- package/dist/style.css +203 -122
- package/package.json +6 -6
- package/src/app/App.vue +2 -2
- package/src/app/api.ts +1 -1
- package/src/app/components/base/BaseSplitPane.vue +2 -2
- package/src/app/components/panel/StoryControls.vue +5 -3
- package/src/app/components/panel/StorySourceCode.vue +134 -26
- package/src/app/components/search/search-docs-data.ts +1 -1
- package/src/app/components/search/search-title-data.ts +1 -1
- package/src/app/components/story/StoryResponsivePreview.vue +55 -54
- package/src/app/components/story/StoryVariantGrid.vue +57 -18
- package/src/app/components/story/StoryVariantGridItem.vue +37 -10
- package/src/app/components/story/StoryVariantSingle.vue +2 -2
- package/src/app/index.ts +1 -1
- package/src/app/sandbox.ts +1 -1
- package/src/app/stores/folder.ts +3 -1
- package/src/app/style/main.pcss +12 -1
- package/src/app/util/config.ts +1 -1
- package/src/app/util/events.ts +1 -1
- package/tailwind.config.cjs +12 -0
- package/tsconfig.json +0 -1
- package/dist/bundled/components/app/Breadcrumb.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
- package/dist/bundled/components/base/BaseEmpty.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
- package/dist/bundled/components/base/BaseSplitPane.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
- package/dist/bundled/components/misc/HatchedPattern.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
- package/dist/bundled/components/panel/StorySourceCode.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
- package/dist/bundled/components/search/SearchItem.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
- package/dist/bundled/components/story/StoryResponsivePreview.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
- package/dist/bundled/components/story/StoryVariantGridItem.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
- package/dist/bundled/components/story/StoryVariantListItem.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
- package/dist/bundled/components/story/StoryVariantSingle.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
- package/dist/bundled/components/story/StoryViewer.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
- package/dist/bundled/components/toolbar/StoryVariantBackground.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
- package/dist/bundled/components/tree/StoryListFolder.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
- package/dist/bundled/components/tree/StoryListItem.vue_vue_type_style_index_0_scoped_true_lang.js +0 -2
package/dist/bundled/components/story/StoryResponsivePreview.vue_vue_type_script_setup_true_lang.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { defineComponent, useCssVars, unref, ref, onUnmounted, computed, openBlock, createElementBlock, createVNode, createCommentVNode, createElementVNode, normalizeClass, createBlock, renderSlot, Fragment, pushScopeId, popScopeId, createStaticVNode } from "@histoire/vendors/vue";
|
|
2
|
+
import { useEventListener } from "@histoire/vendors/vue-use";
|
|
3
|
+
import { Icon } from "@histoire/vendors/iconify";
|
|
4
|
+
import HatchedPattern from "../misc/HatchedPattern.js";
|
|
5
|
+
import CheckerboardPattern from "../misc/CheckerboardPattern.js";
|
|
6
|
+
import { usePreviewSettingsStore } from "../../stores/preview-settings.js";
|
|
7
|
+
const _withScopeId = (n) => (pushScopeId("data-v-1375d05a"), n = n(), popScopeId(), n);
|
|
8
|
+
const _hoisted_1 = { class: "htw-w-full htw-h-full htw-flex-1 htw-rounded-lg htw-relative htw-overflow-hidden" };
|
|
9
|
+
const _hoisted_2 = {
|
|
10
|
+
key: 0,
|
|
11
|
+
class: "htw-absolute htw-inset-0 htw-w-full htw-h-full htw-bg-gray-100 dark:htw-bg-gray-750 htw-rounded-r-lg htw-border-l-2 htw-border-gray-500/10 dark:htw-border-gray-700/30 htw-overflow-hidden"
|
|
12
|
+
};
|
|
13
|
+
const _hoisted_3 = { class: "bind-preview-bg htw-rounded-lg htw-h-full" };
|
|
14
|
+
const _hoisted_4 = { class: "htw-p-8 htw-h-full htw-relative" };
|
|
15
|
+
const _hoisted_5 = { class: "htw-w-full htw-h-full htw-relative" };
|
|
16
|
+
const _hoisted_6 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "htw-absolute htw-inset-0" }, null, -1));
|
|
17
|
+
const _hoisted_7 = /* @__PURE__ */ createStaticVNode('<div class="htw-absolute htw-top-5 htw-left-8 htw-h-2 htw-w-px htw-bg-gray-400/25" data-v-1375d05a></div><div class="htw-absolute htw-top-5 htw-right-8 htw-h-2 htw-w-px htw-bg-gray-400/25" data-v-1375d05a></div><div class="htw-absolute htw-bottom-5 htw-left-8 htw-h-2 htw-w-px htw-bg-gray-400/25" data-v-1375d05a></div><div class="htw-absolute htw-bottom-5 htw-right-8 htw-h-2 htw-w-px htw-bg-gray-400/25" data-v-1375d05a></div><div class="htw-absolute htw-left-5 htw-top-8 htw-w-2 htw-h-px htw-bg-gray-400/25" data-v-1375d05a></div><div class="htw-absolute htw-left-5 htw-bottom-8 htw-w-2 htw-h-px htw-bg-gray-400/25" data-v-1375d05a></div><div class="htw-absolute htw-right-5 htw-top-8 htw-w-2 htw-h-px htw-bg-gray-400/25" data-v-1375d05a></div><div class="htw-absolute htw-right-5 htw-bottom-8 htw-w-2 htw-h-px htw-bg-gray-400/25" data-v-1375d05a></div>', 8);
|
|
18
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
19
|
+
__name: "StoryResponsivePreview",
|
|
20
|
+
props: {
|
|
21
|
+
variant: null
|
|
22
|
+
},
|
|
23
|
+
setup(__props) {
|
|
24
|
+
const props = __props;
|
|
25
|
+
useCssVars((_ctx) => ({
|
|
26
|
+
"cfc058d0": unref(settings).backgroundColor
|
|
27
|
+
}));
|
|
28
|
+
const settings = usePreviewSettingsStore().currentSettings;
|
|
29
|
+
const resizing = ref(false);
|
|
30
|
+
const onUnmountedCleanupFns = [];
|
|
31
|
+
onUnmounted(() => {
|
|
32
|
+
onUnmountedCleanupFns.forEach((fn) => fn());
|
|
33
|
+
});
|
|
34
|
+
function addWindowListener(event, listener) {
|
|
35
|
+
window.addEventListener(event, listener);
|
|
36
|
+
const removeListener = () => window.removeEventListener(event, listener);
|
|
37
|
+
onUnmountedCleanupFns.push(removeListener);
|
|
38
|
+
return () => {
|
|
39
|
+
removeListener();
|
|
40
|
+
onUnmountedCleanupFns.splice(onUnmountedCleanupFns.indexOf(removeListener), 1);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function useDragger(el, value, min, max, axis) {
|
|
44
|
+
function onMouseDown(event) {
|
|
45
|
+
var _a;
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
event.stopPropagation();
|
|
48
|
+
const start = axis === "x" ? event.clientX : event.clientY;
|
|
49
|
+
const startValue = (_a = value.value) != null ? _a : axis === "x" ? previewWrapper.value.clientWidth - 67 : previewWrapper.value.clientHeight - 70;
|
|
50
|
+
resizing.value = true;
|
|
51
|
+
const removeListeners = [
|
|
52
|
+
addWindowListener("mousemove", onMouseMove),
|
|
53
|
+
addWindowListener("mouseup", onMouseUp)
|
|
54
|
+
];
|
|
55
|
+
function onMouseMove(event2) {
|
|
56
|
+
const snapTarget = axis === "x" ? previewWrapper.value.clientWidth : previewWrapper.value.clientHeight;
|
|
57
|
+
const delta = (axis === "x" ? event2.clientX : event2.clientY) - start;
|
|
58
|
+
value.value = Math.max(min, Math.min(max, startValue + delta));
|
|
59
|
+
if (Math.abs(value.value - (snapTarget - 67)) < 16) {
|
|
60
|
+
value.value = null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function onMouseUp() {
|
|
64
|
+
removeListeners.forEach((fn) => fn());
|
|
65
|
+
resizing.value = false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
useEventListener(el, "mousedown", onMouseDown);
|
|
69
|
+
function onTouchStart(event) {
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
event.stopPropagation();
|
|
72
|
+
const start = axis === "x" ? event.touches[0].clientX : event.touches[0].clientY;
|
|
73
|
+
const startValue = value.value;
|
|
74
|
+
resizing.value = true;
|
|
75
|
+
const removeListeners = [
|
|
76
|
+
addWindowListener("touchmove", onTouchMove),
|
|
77
|
+
addWindowListener("touchend", onTouchEnd),
|
|
78
|
+
addWindowListener("touchcancel", onTouchEnd)
|
|
79
|
+
];
|
|
80
|
+
function onTouchMove(event2) {
|
|
81
|
+
const delta = (axis === "x" ? event2.touches[0].clientX : event2.touches[0].clientY) - start;
|
|
82
|
+
value.value = Math.max(min, Math.min(max, startValue + delta));
|
|
83
|
+
}
|
|
84
|
+
function onTouchEnd() {
|
|
85
|
+
removeListeners.forEach((fn) => fn());
|
|
86
|
+
resizing.value = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
useEventListener(el, "touchstart", onTouchStart);
|
|
90
|
+
}
|
|
91
|
+
const responsiveWidth = computed({
|
|
92
|
+
get: () => settings[settings.rotate ? "responsiveHeight" : "responsiveWidth"],
|
|
93
|
+
set: (value) => {
|
|
94
|
+
settings[settings.rotate ? "responsiveHeight" : "responsiveWidth"] = value;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
const responsiveHeight = computed({
|
|
98
|
+
get: () => settings[settings.rotate ? "responsiveWidth" : "responsiveHeight"],
|
|
99
|
+
set: (value) => {
|
|
100
|
+
settings[settings.rotate ? "responsiveWidth" : "responsiveHeight"] = value;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const horizontalDragger = ref();
|
|
104
|
+
const verticalDragger = ref();
|
|
105
|
+
const cornerDragger = ref();
|
|
106
|
+
const previewWrapper = ref();
|
|
107
|
+
useDragger(horizontalDragger, responsiveWidth, 32, 2e4, "x");
|
|
108
|
+
useDragger(verticalDragger, responsiveHeight, 32, 2e4, "y");
|
|
109
|
+
useDragger(cornerDragger, responsiveWidth, 32, 2e4, "x");
|
|
110
|
+
useDragger(cornerDragger, responsiveHeight, 32, 2e4, "y");
|
|
111
|
+
const finalWidth = computed(() => settings.rotate ? settings.responsiveHeight : settings.responsiveWidth);
|
|
112
|
+
const finalHeight = computed(() => settings.rotate ? settings.responsiveWidth : settings.responsiveHeight);
|
|
113
|
+
const isResponsiveEnabled = computed(() => !props.variant.responsiveDisabled);
|
|
114
|
+
return (_ctx, _cache) => {
|
|
115
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
116
|
+
unref(isResponsiveEnabled) ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
117
|
+
createVNode(HatchedPattern, { class: "htw-w-full htw-h-full htw-text-black/[1%] dark:htw-text-white/[1%]" })
|
|
118
|
+
])) : createCommentVNode("", true),
|
|
119
|
+
createElementVNode("div", {
|
|
120
|
+
ref_key: "previewWrapper",
|
|
121
|
+
ref: previewWrapper,
|
|
122
|
+
class: "htw-h-full htw-overflow-auto htw-relative"
|
|
123
|
+
}, [
|
|
124
|
+
createElementVNode("div", {
|
|
125
|
+
class: normalizeClass(["htw-h-full htw-overflow-hidden htw-bg-white dark:htw-bg-gray-700 htw-rounded-lg htw-relative", unref(isResponsiveEnabled) ? {
|
|
126
|
+
"htw-w-fit": !!unref(finalWidth),
|
|
127
|
+
"htw-h-fit": !!unref(finalHeight)
|
|
128
|
+
} : void 0])
|
|
129
|
+
}, [
|
|
130
|
+
createElementVNode("div", _hoisted_3, [
|
|
131
|
+
unref(settings).checkerboard ? (openBlock(), createBlock(CheckerboardPattern, {
|
|
132
|
+
key: 0,
|
|
133
|
+
class: "htw-absolute htw-inset-0 htw-w-full htw-h-full htw-text-gray-500/20"
|
|
134
|
+
})) : createCommentVNode("", true),
|
|
135
|
+
createElementVNode("div", _hoisted_4, [
|
|
136
|
+
createElementVNode("div", _hoisted_5, [
|
|
137
|
+
_hoisted_6,
|
|
138
|
+
renderSlot(_ctx.$slots, "default", {
|
|
139
|
+
isResponsiveEnabled: unref(isResponsiveEnabled),
|
|
140
|
+
finalWidth: unref(finalWidth),
|
|
141
|
+
finalHeight: unref(finalHeight),
|
|
142
|
+
resizing: resizing.value
|
|
143
|
+
}, void 0, true)
|
|
144
|
+
]),
|
|
145
|
+
_hoisted_7
|
|
146
|
+
]),
|
|
147
|
+
unref(isResponsiveEnabled) ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
148
|
+
createElementVNode("div", {
|
|
149
|
+
ref_key: "horizontalDragger",
|
|
150
|
+
ref: horizontalDragger,
|
|
151
|
+
class: "htw-absolute htw-w-4 htw-top-0 htw-bottom-4 htw-right-0 hover:htw-bg-primary-500/30 htw-flex htw-items-center htw-justify-center htw-cursor-ew-resize htw-group hover:htw-text-primary-500"
|
|
152
|
+
}, [
|
|
153
|
+
createVNode(unref(Icon), {
|
|
154
|
+
icon: "mdi:drag-vertical-variant",
|
|
155
|
+
class: "htw-w-4 htw-h-4 htw-opacity-20 group-hover:htw-opacity-90"
|
|
156
|
+
})
|
|
157
|
+
], 512),
|
|
158
|
+
createElementVNode("div", {
|
|
159
|
+
ref_key: "verticalDragger",
|
|
160
|
+
ref: verticalDragger,
|
|
161
|
+
class: "htw-absolute htw-h-4 htw-left-0 htw-right-4 htw-bottom-0 hover:htw-bg-primary-500/30 htw-flex htw-items-center htw-justify-center htw-cursor-ns-resize htw-group hover:htw-text-primary-500"
|
|
162
|
+
}, [
|
|
163
|
+
createVNode(unref(Icon), {
|
|
164
|
+
icon: "mdi:drag-horizontal-variant",
|
|
165
|
+
class: "htw-w-4 htw-h-4 htw-opacity-20 group-hover:htw-opacity-90"
|
|
166
|
+
})
|
|
167
|
+
], 512),
|
|
168
|
+
createElementVNode("div", {
|
|
169
|
+
ref_key: "cornerDragger",
|
|
170
|
+
ref: cornerDragger,
|
|
171
|
+
class: "htw-absolute htw-w-4 htw-h-4 htw-right-0 htw-bottom-0 hover:htw-bg-primary-500/30 htw-flex htw-items-center htw-justify-center htw-cursor-nwse-resize htw-group hover:htw-text-primary-500"
|
|
172
|
+
}, null, 512)
|
|
173
|
+
], 64)) : createCommentVNode("", true)
|
|
174
|
+
])
|
|
175
|
+
], 2)
|
|
176
|
+
], 512)
|
|
177
|
+
]);
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
export {
|
|
182
|
+
_sfc_main as default
|
|
183
|
+
};
|
|
@@ -1,94 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
__name: "StoryVariantGrid",
|
|
7
|
-
setup(__props) {
|
|
8
|
-
const storyStore = useStoryStore();
|
|
9
|
-
const gridTemplateWidth = computed(() => {
|
|
10
|
-
if (storyStore.currentStory.layout.type !== "grid") {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const layoutWidth = storyStore.currentStory.layout.width;
|
|
14
|
-
if (!layoutWidth) {
|
|
15
|
-
return "200px";
|
|
16
|
-
}
|
|
17
|
-
if (typeof layoutWidth === "number") {
|
|
18
|
-
return layoutWidth + "px";
|
|
19
|
-
}
|
|
20
|
-
return layoutWidth;
|
|
21
|
-
});
|
|
22
|
-
const margin = 16;
|
|
23
|
-
const gap = 16;
|
|
24
|
-
const itemWidth = ref(16);
|
|
25
|
-
const maxItemHeight = ref(0);
|
|
26
|
-
const maxCount = ref(10);
|
|
27
|
-
const countPerRow = ref(0);
|
|
28
|
-
const visibleRows = ref(0);
|
|
29
|
-
const el = ref(null);
|
|
30
|
-
useResizeObserver(el, () => {
|
|
31
|
-
updateMaxCount();
|
|
32
|
-
});
|
|
33
|
-
function updateMaxCount() {
|
|
34
|
-
if (!maxItemHeight.value)
|
|
35
|
-
return;
|
|
36
|
-
const width = el.value.clientWidth - margin * 2;
|
|
37
|
-
const height = el.value.clientHeight;
|
|
38
|
-
const scrollTop = el.value.scrollTop;
|
|
39
|
-
countPerRow.value = Math.floor((width + gap) / (itemWidth.value + gap));
|
|
40
|
-
visibleRows.value = Math.ceil((height + scrollTop + gap) / (maxItemHeight.value + gap));
|
|
41
|
-
const newMaxCount = countPerRow.value * visibleRows.value;
|
|
42
|
-
if (maxCount.value < newMaxCount) {
|
|
43
|
-
maxCount.value = newMaxCount;
|
|
44
|
-
}
|
|
45
|
-
if (storyStore.currentVariant) {
|
|
46
|
-
const index = storyStore.currentStory.variants.indexOf(storyStore.currentVariant);
|
|
47
|
-
if (index + 1 > maxCount.value) {
|
|
48
|
-
maxCount.value = index + 1;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function onItemResize(w, h) {
|
|
53
|
-
itemWidth.value = w;
|
|
54
|
-
if (maxItemHeight.value < h) {
|
|
55
|
-
maxItemHeight.value = h;
|
|
56
|
-
updateMaxCount();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
watch(() => storyStore.currentVariant, () => {
|
|
60
|
-
updateMaxCount();
|
|
61
|
-
});
|
|
62
|
-
return (_ctx, _cache) => {
|
|
63
|
-
return openBlock(), createElementBlock("div", {
|
|
64
|
-
ref_key: "el",
|
|
65
|
-
ref: el,
|
|
66
|
-
class: "htw-h-full htw-overflow-y-auto",
|
|
67
|
-
onScroll: _cache[0] || (_cache[0] = ($event) => updateMaxCount())
|
|
68
|
-
}, [
|
|
69
|
-
createElementVNode("div", {
|
|
70
|
-
style: normalizeStyle({
|
|
71
|
-
minHeight: `${unref(storyStore).currentStory.variants.length / countPerRow.value * (maxItemHeight.value + gap) - gap}px`
|
|
72
|
-
})
|
|
73
|
-
}, [
|
|
74
|
-
createElementVNode("div", {
|
|
75
|
-
class: "htw-grid htw-gap-4 htw-m-4",
|
|
76
|
-
style: normalizeStyle({
|
|
77
|
-
gridTemplateColumns: `repeat(auto-fill, ${unref(gridTemplateWidth)})`
|
|
78
|
-
})
|
|
79
|
-
}, [
|
|
80
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(storyStore).currentStory.variants.slice(0, maxCount.value), (variant, index) => {
|
|
81
|
-
return openBlock(), createBlock(StoryVariantGridItem, {
|
|
82
|
-
key: index,
|
|
83
|
-
variant,
|
|
84
|
-
story: unref(storyStore).currentStory,
|
|
85
|
-
onResize: onItemResize
|
|
86
|
-
}, null, 8, ["variant", "story"]);
|
|
87
|
-
}), 128))
|
|
88
|
-
], 4)
|
|
89
|
-
], 4)
|
|
90
|
-
], 544);
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
export { _sfc_main as default };
|
|
1
|
+
import _sfc_main from "./StoryVariantGrid.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
import { default as default2 } from "./StoryVariantGrid.vue_vue_type_script_setup_true_lang.js";
|
|
3
|
+
export {
|
|
4
|
+
default2 as default
|
|
5
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { defineComponent, computed, ref, watch, onMounted, openBlock, createElementBlock, unref, createVNode, createCommentVNode, createElementVNode, normalizeStyle, Fragment, renderList, createBlock } from "@histoire/vendors/vue";
|
|
2
|
+
import { useResizeObserver } from "@histoire/vendors/vue-use";
|
|
3
|
+
import { useStoryStore } from "../../stores/story.js";
|
|
4
|
+
import { isMobile } from "../../util/responsive.js";
|
|
5
|
+
import StoryVariantGridItem from "./StoryVariantGridItem.js";
|
|
6
|
+
import StoryVariantBackground from "../toolbar/StoryVariantBackground.js";
|
|
7
|
+
const _hoisted_1 = { class: "htw-flex htw-flex-col htw-items-stretch htw-h-full" };
|
|
8
|
+
const _hoisted_2 = {
|
|
9
|
+
key: 0,
|
|
10
|
+
class: "htw-flex-none htw-flex htw-items-center htw-justify-end htw-h-8 htw-mx-2 htw-mt-1"
|
|
11
|
+
};
|
|
12
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
13
|
+
__name: "StoryVariantGrid",
|
|
14
|
+
setup(__props) {
|
|
15
|
+
const storyStore = useStoryStore();
|
|
16
|
+
const gridTemplateWidth = computed(() => {
|
|
17
|
+
if (storyStore.currentStory.layout.type !== "grid") {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const layoutWidth = storyStore.currentStory.layout.width;
|
|
21
|
+
if (!layoutWidth) {
|
|
22
|
+
return "200px";
|
|
23
|
+
}
|
|
24
|
+
if (typeof layoutWidth === "number") {
|
|
25
|
+
return layoutWidth + "px";
|
|
26
|
+
}
|
|
27
|
+
return layoutWidth;
|
|
28
|
+
});
|
|
29
|
+
const margin = 16;
|
|
30
|
+
const gap = 16;
|
|
31
|
+
const itemWidth = ref(16);
|
|
32
|
+
const maxItemHeight = ref(0);
|
|
33
|
+
const maxCount = ref(10);
|
|
34
|
+
const countPerRow = ref(0);
|
|
35
|
+
const visibleRows = ref(0);
|
|
36
|
+
const el = ref(null);
|
|
37
|
+
useResizeObserver(el, () => {
|
|
38
|
+
updateMaxCount();
|
|
39
|
+
updateSize();
|
|
40
|
+
});
|
|
41
|
+
function updateMaxCount() {
|
|
42
|
+
if (!maxItemHeight.value)
|
|
43
|
+
return;
|
|
44
|
+
const width = el.value.clientWidth - margin * 2;
|
|
45
|
+
const height = el.value.clientHeight;
|
|
46
|
+
const scrollTop = el.value.scrollTop;
|
|
47
|
+
countPerRow.value = Math.floor((width + gap) / (itemWidth.value + gap));
|
|
48
|
+
visibleRows.value = Math.ceil((height + scrollTop + gap) / (maxItemHeight.value + gap));
|
|
49
|
+
const newMaxCount = countPerRow.value * visibleRows.value;
|
|
50
|
+
if (maxCount.value < newMaxCount) {
|
|
51
|
+
maxCount.value = newMaxCount;
|
|
52
|
+
}
|
|
53
|
+
if (storyStore.currentVariant) {
|
|
54
|
+
const index = storyStore.currentStory.variants.indexOf(storyStore.currentVariant);
|
|
55
|
+
if (index + 1 > maxCount.value) {
|
|
56
|
+
maxCount.value = index + 1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function onItemResize(w, h) {
|
|
61
|
+
itemWidth.value = w;
|
|
62
|
+
if (maxItemHeight.value < h) {
|
|
63
|
+
maxItemHeight.value = h;
|
|
64
|
+
updateMaxCount();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
watch(() => storyStore.currentVariant, () => {
|
|
68
|
+
updateMaxCount();
|
|
69
|
+
});
|
|
70
|
+
const gridEl = ref(null);
|
|
71
|
+
const gridColumnWidth = ref(1);
|
|
72
|
+
const viewWidth = ref(1);
|
|
73
|
+
function updateSize() {
|
|
74
|
+
if (!el.value)
|
|
75
|
+
return;
|
|
76
|
+
viewWidth.value = el.value.clientWidth;
|
|
77
|
+
if (!gridEl.value)
|
|
78
|
+
return;
|
|
79
|
+
const firstCellEl = gridEl.value.children[0];
|
|
80
|
+
if (!firstCellEl)
|
|
81
|
+
return;
|
|
82
|
+
gridColumnWidth.value = firstCellEl.clientWidth;
|
|
83
|
+
}
|
|
84
|
+
onMounted(() => {
|
|
85
|
+
updateSize();
|
|
86
|
+
});
|
|
87
|
+
const columnCount = computed(() => Math.min(storyStore.currentStory.variants.length, Math.floor((viewWidth.value + gap) / (gridColumnWidth.value + gap))));
|
|
88
|
+
return (_ctx, _cache) => {
|
|
89
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
90
|
+
!unref(isMobile) ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
91
|
+
createVNode(StoryVariantBackground)
|
|
92
|
+
])) : createCommentVNode("", true),
|
|
93
|
+
createElementVNode("div", {
|
|
94
|
+
ref_key: "el",
|
|
95
|
+
ref: el,
|
|
96
|
+
class: "htw-overflow-y-auto __histoire-pane-shadow-from-right htw-flex htw-flex-1",
|
|
97
|
+
onScroll: _cache[0] || (_cache[0] = ($event) => updateMaxCount())
|
|
98
|
+
}, [
|
|
99
|
+
createElementVNode("div", {
|
|
100
|
+
class: "htw-m-auto",
|
|
101
|
+
style: normalizeStyle({
|
|
102
|
+
minHeight: `${unref(storyStore).currentStory.variants.length / countPerRow.value * (maxItemHeight.value + gap) - gap}px`
|
|
103
|
+
})
|
|
104
|
+
}, [
|
|
105
|
+
createElementVNode("div", {
|
|
106
|
+
ref_key: "gridEl",
|
|
107
|
+
ref: gridEl,
|
|
108
|
+
class: "htw-grid htw-gap-4 htw-m-4",
|
|
109
|
+
style: normalizeStyle({
|
|
110
|
+
gridTemplateColumns: `repeat(${unref(columnCount)}, ${unref(gridTemplateWidth)})`
|
|
111
|
+
})
|
|
112
|
+
}, [
|
|
113
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(storyStore).currentStory.variants.slice(0, maxCount.value), (variant, index) => {
|
|
114
|
+
return openBlock(), createBlock(StoryVariantGridItem, {
|
|
115
|
+
key: index,
|
|
116
|
+
variant,
|
|
117
|
+
story: unref(storyStore).currentStory,
|
|
118
|
+
onResize: onItemResize
|
|
119
|
+
}, null, 8, ["variant", "story"]);
|
|
120
|
+
}), 128))
|
|
121
|
+
], 4)
|
|
122
|
+
], 4)
|
|
123
|
+
], 544)
|
|
124
|
+
]);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
export {
|
|
129
|
+
_sfc_main as default
|
|
130
|
+
};
|
|
@@ -1,108 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import "./StoryVariantGridItem.vue_vue_type_style_index_0_scoped_true_lang.js";
|
|
9
|
-
import _export_sfc from "../../_virtual/plugin-vue_export-helper.js";
|
|
10
|
-
const _withScopeId = (n) => (pushScopeId("data-v-2db4d3d2"), n = n(), popScopeId(), n);
|
|
11
|
-
const _hoisted_1 = { class: "htw-flex-none htw-flex htw-items-center" };
|
|
12
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
13
|
-
__name: "StoryVariantGridItem",
|
|
14
|
-
props: {
|
|
15
|
-
variant: {
|
|
16
|
-
type: Object,
|
|
17
|
-
required: true
|
|
18
|
-
},
|
|
19
|
-
story: {
|
|
20
|
-
type: Object,
|
|
21
|
-
required: true
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
emits: {
|
|
25
|
-
resize: (width, height) => true
|
|
26
|
-
},
|
|
27
|
-
setup(__props, { emit }) {
|
|
28
|
-
const props = __props;
|
|
29
|
-
useCssVars((_ctx) => ({
|
|
30
|
-
"1eec3e4a": unref(variant).iconColor
|
|
31
|
-
}));
|
|
32
|
-
const { variant } = toRefs(props);
|
|
33
|
-
const { isActive, targetRoute } = useCurrentVariantRoute(variant);
|
|
34
|
-
Object.assign(props.variant, {
|
|
35
|
-
previewReady: false
|
|
36
|
-
});
|
|
37
|
-
function onReady() {
|
|
38
|
-
Object.assign(props.variant, {
|
|
39
|
-
previewReady: true
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
const router = useRouter();
|
|
43
|
-
function selectVariant() {
|
|
44
|
-
router.push(targetRoute.value);
|
|
45
|
-
}
|
|
46
|
-
const el = ref();
|
|
47
|
-
const { autoScroll } = useScrollOnActive(isActive, el);
|
|
48
|
-
useResizeObserver(el, () => {
|
|
49
|
-
if (props.variant.previewReady) {
|
|
50
|
-
emit("resize", el.value.clientWidth, el.value.clientHeight);
|
|
51
|
-
if (isActive.value) {
|
|
52
|
-
autoScroll();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return (_ctx, _cache) => {
|
|
57
|
-
const _component_RouterLink = resolveComponent("RouterLink");
|
|
58
|
-
return openBlock(), createElementBlock("div", {
|
|
59
|
-
ref_key: "el",
|
|
60
|
-
ref: el,
|
|
61
|
-
class: "htw-cursor-default htw-flex htw-flex-col htw-gap-y-1"
|
|
62
|
-
}, [
|
|
63
|
-
createElementVNode("div", _hoisted_1, [
|
|
64
|
-
createVNode(_component_RouterLink, {
|
|
65
|
-
to: unref(targetRoute),
|
|
66
|
-
class: normalizeClass(["htw-rounded htw-w-max htw-px-2 htw-py-0.5 htw-min-w-16 htw-cursor-pointer htw-flex htw-items-center htw-gap-1", {
|
|
67
|
-
"hover:htw-bg-gray-200 htw-text-gray-500 dark:hover:htw-bg-gray-800": !unref(isActive),
|
|
68
|
-
"htw-bg-primary-200 hover:htw-bg-primary-300 htw-text-primary-800 dark:htw-bg-primary-700 dark:hover:htw-bg-primary-800 dark:htw-text-primary-200": unref(isActive)
|
|
69
|
-
}])
|
|
70
|
-
}, {
|
|
71
|
-
default: withCtx(() => {
|
|
72
|
-
var _a;
|
|
73
|
-
return [
|
|
74
|
-
createVNode(unref(Icon), {
|
|
75
|
-
icon: (_a = unref(variant).icon) != null ? _a : "carbon:cube",
|
|
76
|
-
class: normalizeClass(["base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50", {
|
|
77
|
-
"htw-text-gray-500": !unref(isActive) && !unref(variant).iconColor,
|
|
78
|
-
"bind-icon-color": !unref(isActive) && unref(variant).iconColor
|
|
79
|
-
}])
|
|
80
|
-
}, null, 8, ["icon", "class"]),
|
|
81
|
-
createElementVNode("span", null, toDisplayString(unref(variant).title), 1)
|
|
82
|
-
];
|
|
83
|
-
}),
|
|
84
|
-
_: 1
|
|
85
|
-
}, 8, ["to", "class"])
|
|
86
|
-
]),
|
|
87
|
-
createElementVNode("div", {
|
|
88
|
-
class: normalizeClass(["htw-border htw-bg-white dark:htw-bg-gray-700 htw-rounded-lg htw-flex-1 htw-p-4", {
|
|
89
|
-
"htw-border-gray-100 dark:htw-border-gray-800": !unref(isActive),
|
|
90
|
-
"htw-border-primary-200 dark:htw-border-primary-900": unref(isActive)
|
|
91
|
-
}]),
|
|
92
|
-
"data-test-id": "sandbox-render",
|
|
93
|
-
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => selectVariant(), ["stop"])),
|
|
94
|
-
onKeyup: _cache[1] || (_cache[1] = ($event) => selectVariant())
|
|
95
|
-
}, [
|
|
96
|
-
(openBlock(), createBlock(_sfc_main$1, {
|
|
97
|
-
key: `${__props.story.id}-${unref(variant).id}`,
|
|
98
|
-
variant: unref(variant),
|
|
99
|
-
story: __props.story,
|
|
100
|
-
onReady
|
|
101
|
-
}, null, 8, ["variant", "story"]))
|
|
102
|
-
], 34)
|
|
103
|
-
], 512);
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
var StoryVariantGridItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2db4d3d2"]]);
|
|
108
|
-
export { StoryVariantGridItem as default };
|
|
1
|
+
import _sfc_main from "./StoryVariantGridItem.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
import "./StoryVariantGridItem.vue_vue_type_style_index_0_scoped_5ded7495_lang.js";
|
|
3
|
+
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const StoryVariantGridItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5ded7495"]]);
|
|
5
|
+
export {
|
|
6
|
+
StoryVariantGridItem as default
|
|
7
|
+
};
|
package/dist/bundled/components/story/StoryVariantGridItem.vue_vue_type_script_setup_true_lang.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { defineComponent, useCssVars, unref, toRefs, ref, resolveComponent, resolveDirective, openBlock, createElementBlock, createElementVNode, withDirectives, createBlock, normalizeClass, withCtx, createVNode, toDisplayString, withModifiers, createCommentVNode, pushScopeId, popScopeId } from "@histoire/vendors/vue";
|
|
2
|
+
import { Icon } from "@histoire/vendors/iconify";
|
|
3
|
+
import { useRouter } from "@histoire/vendors/vue-router";
|
|
4
|
+
import { useResizeObserver } from "@histoire/vendors/vue-use";
|
|
5
|
+
import { useCurrentVariantRoute } from "../../util/variant.js";
|
|
6
|
+
import { useScrollOnActive } from "../../util/scroll.js";
|
|
7
|
+
import { usePreviewSettingsStore } from "../../stores/preview-settings.js";
|
|
8
|
+
import "./GenericRenderStory.js";
|
|
9
|
+
import "../toolbar/StoryVariantNewTab.js";
|
|
10
|
+
import CheckerboardPattern from "../misc/CheckerboardPattern.js";
|
|
11
|
+
import _sfc_main$1 from "../toolbar/StoryVariantNewTab.vue_vue_type_script_setup_true_lang.js";
|
|
12
|
+
import _sfc_main$2 from "./GenericRenderStory.vue_vue_type_script_setup_true_lang.js";
|
|
13
|
+
const _withScopeId = (n) => (pushScopeId("data-v-5ded7495"), n = n(), popScopeId(), n);
|
|
14
|
+
const _hoisted_1 = { class: "htw-flex-none htw-flex htw-items-center" };
|
|
15
|
+
const _hoisted_2 = { class: "htw-truncate htw-flex-1" };
|
|
16
|
+
const _hoisted_3 = { class: "htw-flex-none htw-ml-auto htw-hidden group-hover:htw-flex htw-items-center" };
|
|
17
|
+
const _hoisted_4 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "htw-absolute htw-inset-0 htw-rounded bind-preview-bg" }, null, -1));
|
|
18
|
+
const _hoisted_5 = { class: "htw-relative htw-h-full" };
|
|
19
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
20
|
+
__name: "StoryVariantGridItem",
|
|
21
|
+
props: {
|
|
22
|
+
variant: {
|
|
23
|
+
type: Object,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
story: {
|
|
27
|
+
type: Object,
|
|
28
|
+
required: true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
emits: {
|
|
32
|
+
resize: (width, height) => true
|
|
33
|
+
},
|
|
34
|
+
setup(__props, { emit }) {
|
|
35
|
+
const props = __props;
|
|
36
|
+
useCssVars((_ctx) => ({
|
|
37
|
+
"35fad884": unref(variant).iconColor,
|
|
38
|
+
"4dbef967": unref(settings).backgroundColor
|
|
39
|
+
}));
|
|
40
|
+
const { variant } = toRefs(props);
|
|
41
|
+
const { isActive, targetRoute } = useCurrentVariantRoute(variant);
|
|
42
|
+
Object.assign(props.variant, {
|
|
43
|
+
previewReady: false
|
|
44
|
+
});
|
|
45
|
+
function onReady() {
|
|
46
|
+
Object.assign(props.variant, {
|
|
47
|
+
previewReady: true
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const router = useRouter();
|
|
51
|
+
function selectVariant() {
|
|
52
|
+
router.push(targetRoute.value);
|
|
53
|
+
}
|
|
54
|
+
const el = ref();
|
|
55
|
+
const { autoScroll } = useScrollOnActive(isActive, el);
|
|
56
|
+
useResizeObserver(el, () => {
|
|
57
|
+
if (props.variant.previewReady) {
|
|
58
|
+
emit("resize", el.value.clientWidth, el.value.clientHeight);
|
|
59
|
+
if (isActive.value) {
|
|
60
|
+
autoScroll();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const settings = usePreviewSettingsStore().currentSettings;
|
|
65
|
+
return (_ctx, _cache) => {
|
|
66
|
+
const _component_RouterLink = resolveComponent("RouterLink");
|
|
67
|
+
const _directive_tooltip = resolveDirective("tooltip");
|
|
68
|
+
return openBlock(), createElementBlock("div", {
|
|
69
|
+
ref_key: "el",
|
|
70
|
+
ref: el,
|
|
71
|
+
class: "htw-cursor-default htw-flex htw-flex-col htw-gap-y-1 htw-group"
|
|
72
|
+
}, [
|
|
73
|
+
createElementVNode("div", _hoisted_1, [
|
|
74
|
+
withDirectives((openBlock(), createBlock(_component_RouterLink, {
|
|
75
|
+
to: unref(targetRoute),
|
|
76
|
+
class: normalizeClass(["htw-rounded htw-w-max htw-px-2 htw-py-0.5 htw-min-w-16 htw-cursor-pointer htw-flex htw-items-center htw-gap-1 htw-flex-shrink", {
|
|
77
|
+
"hover:htw-bg-gray-200 htw-text-gray-500 dark:hover:htw-bg-gray-800": !unref(isActive),
|
|
78
|
+
"htw-bg-primary-200 hover:htw-bg-primary-300 htw-text-primary-800 dark:htw-bg-primary-700 dark:hover:htw-bg-primary-800 dark:htw-text-primary-200": unref(isActive)
|
|
79
|
+
}])
|
|
80
|
+
}, {
|
|
81
|
+
default: withCtx(() => {
|
|
82
|
+
var _a;
|
|
83
|
+
return [
|
|
84
|
+
createVNode(unref(Icon), {
|
|
85
|
+
icon: (_a = unref(variant).icon) != null ? _a : "carbon:cube",
|
|
86
|
+
class: normalizeClass(["base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50", {
|
|
87
|
+
"htw-text-gray-500": !unref(isActive) && !unref(variant).iconColor,
|
|
88
|
+
"bind-icon-color": !unref(isActive) && unref(variant).iconColor
|
|
89
|
+
}])
|
|
90
|
+
}, null, 8, ["icon", "class"]),
|
|
91
|
+
createElementVNode("span", _hoisted_2, toDisplayString(unref(variant).title), 1)
|
|
92
|
+
];
|
|
93
|
+
}),
|
|
94
|
+
_: 1
|
|
95
|
+
}, 8, ["to", "class"])), [
|
|
96
|
+
[_directive_tooltip, unref(variant).title]
|
|
97
|
+
]),
|
|
98
|
+
createElementVNode("div", _hoisted_3, [
|
|
99
|
+
createVNode(_sfc_main$1, {
|
|
100
|
+
variant: unref(variant),
|
|
101
|
+
story: __props.story
|
|
102
|
+
}, null, 8, ["variant", "story"])
|
|
103
|
+
])
|
|
104
|
+
]),
|
|
105
|
+
createElementVNode("div", {
|
|
106
|
+
class: normalizeClass(["htw-border htw-bg-white dark:htw-bg-gray-700 htw-rounded htw-flex-1 htw-p-4 htw-relative", {
|
|
107
|
+
"htw-border-gray-100 dark:htw-border-gray-800": !unref(isActive),
|
|
108
|
+
"htw-border-primary-200 dark:htw-border-primary-900": unref(isActive)
|
|
109
|
+
}]),
|
|
110
|
+
"data-test-id": "sandbox-render",
|
|
111
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => selectVariant(), ["stop"])),
|
|
112
|
+
onKeyup: _cache[1] || (_cache[1] = ($event) => selectVariant())
|
|
113
|
+
}, [
|
|
114
|
+
_hoisted_4,
|
|
115
|
+
unref(settings).checkerboard ? (openBlock(), createBlock(CheckerboardPattern, {
|
|
116
|
+
key: 0,
|
|
117
|
+
class: "htw-absolute htw-inset-0 htw-w-full htw-h-full htw-text-gray-500/20"
|
|
118
|
+
})) : createCommentVNode("", true),
|
|
119
|
+
createElementVNode("div", _hoisted_5, [
|
|
120
|
+
(openBlock(), createBlock(_sfc_main$2, {
|
|
121
|
+
key: `${__props.story.id}-${unref(variant).id}`,
|
|
122
|
+
variant: unref(variant),
|
|
123
|
+
story: __props.story,
|
|
124
|
+
onReady
|
|
125
|
+
}, null, 8, ["variant", "story"]))
|
|
126
|
+
])
|
|
127
|
+
], 34)
|
|
128
|
+
], 512);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
export {
|
|
133
|
+
_sfc_main as default
|
|
134
|
+
};
|