histoire 0.1.4 → 0.2.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/client/app/App.vue +1 -1
- package/dist/client/app/components/app/AppHeader.vue +1 -0
- package/dist/client/app/components/base/BaseCheckbox.vue +76 -0
- package/dist/client/app/components/sandbox/lib.d.ts +2 -0
- package/dist/client/app/components/sandbox/lib.js +6 -0
- package/dist/client/app/components/sandbox/lib.ts +8 -0
- package/dist/client/app/components/search/SearchItem.vue +4 -1
- package/dist/client/app/components/search/SearchModal.vue +4 -4
- package/dist/client/app/components/story/StoryControls.vue +1 -1
- package/dist/client/app/components/story/StoryDocs.vue +1 -0
- package/dist/client/app/components/story/StoryListFolder.vue +1 -1
- package/dist/client/app/components/story/StoryListItem.vue +4 -1
- package/dist/client/app/components/story/StoryResponsivePreview.vue +3 -4
- package/dist/client/app/components/story/StorySidePanel.vue +1 -0
- package/dist/client/app/components/story/StorySourceCode.vue +4 -1
- package/dist/client/app/components/story/StoryVariantListItem.vue +4 -1
- package/dist/client/app/components/story/StoryVariantSingleView.vue +20 -160
- package/dist/client/app/components/story/StoryViewer.vue +19 -1
- package/dist/client/app/components/story/variant/StoryVariantBackground.vue +67 -0
- package/dist/client/app/components/story/variant/StoryVariantNewTab.vue +29 -0
- package/dist/client/app/components/story/variant/StoryVariantResponsiveSize.vue +82 -0
- package/dist/client/app/components/story/variant/StoryVariantTitle.vue +21 -0
- package/dist/client/app/stores/story.d.ts +6 -6
- package/dist/client/app/stores/story.js +2 -1
- package/dist/client/app/stores/story.ts +5 -1
- package/dist/client/app/style/main.pcss +5 -5
- package/dist/client/app/types.d.ts +1 -1
- package/dist/client/app/types.ts +1 -1
- package/dist/node/bin.js +7 -0
- package/dist/node/build.js +1 -1
- package/dist/node/{collect.d.ts → collect/index.d.ts} +2 -2
- package/dist/node/{collect.js → collect/index.js} +37 -27
- package/dist/node/collect/worker.d.ts +14 -0
- package/dist/node/collect/worker.js +36 -0
- package/dist/node/commands/preview.d.ts +4 -0
- package/dist/node/commands/preview.js +36 -0
- package/dist/node/server.js +1 -1
- package/dist/node/tree.js +24 -4
- package/dist/node/types.d.ts +1 -1
- package/dist/style.css +97 -53
- package/package.json +7 -3
- package/src/client/app/App.vue +1 -1
- package/src/client/app/components/app/AppHeader.vue +1 -0
- package/src/client/app/components/base/BaseCheckbox.vue +76 -0
- package/src/client/app/components/sandbox/lib.ts +8 -0
- package/src/client/app/components/search/SearchItem.vue +4 -1
- package/src/client/app/components/search/SearchModal.vue +4 -4
- package/src/client/app/components/story/StoryControls.vue +1 -1
- package/src/client/app/components/story/StoryDocs.vue +1 -0
- package/src/client/app/components/story/StoryListFolder.vue +1 -1
- package/src/client/app/components/story/StoryListItem.vue +4 -1
- package/src/client/app/components/story/StoryResponsivePreview.vue +3 -4
- package/src/client/app/components/story/StorySidePanel.vue +1 -0
- package/src/client/app/components/story/StorySourceCode.vue +4 -1
- package/src/client/app/components/story/StoryVariantListItem.vue +4 -1
- package/src/client/app/components/story/StoryVariantSingleView.vue +20 -160
- package/src/client/app/components/story/StoryViewer.vue +19 -1
- package/src/client/app/components/story/variant/StoryVariantBackground.vue +67 -0
- package/src/client/app/components/story/variant/StoryVariantNewTab.vue +29 -0
- package/src/client/app/components/story/variant/StoryVariantResponsiveSize.vue +82 -0
- package/src/client/app/components/story/variant/StoryVariantTitle.vue +21 -0
- package/src/client/app/stores/story.ts +5 -1
- package/src/client/app/style/main.pcss +5 -5
- package/src/client/app/types.ts +1 -1
- package/src/node/bin.ts +8 -0
- package/src/node/build.ts +1 -1
- package/src/node/{collect.ts → collect/index.ts} +48 -30
- package/src/node/collect/worker.ts +61 -0
- package/src/node/commands/preview.ts +50 -0
- package/src/node/server.ts +1 -1
- package/src/node/tree.spec.ts +61 -0
- package/src/node/tree.ts +29 -5
- package/src/node/types.ts +1 -1
package/dist/client/app/App.vue
CHANGED
|
@@ -80,7 +80,7 @@ onKeyboardShortcut(['ctrl+k', 'meta+k'], (event) => {
|
|
|
80
80
|
/>
|
|
81
81
|
</div>
|
|
82
82
|
|
|
83
|
-
<div class="htw-h-screen dark:htw-bg-gray-700 dark:htw-text-gray-100">
|
|
83
|
+
<div class="htw-h-screen htw-bg-white dark:htw-bg-gray-700 dark:htw-text-gray-100">
|
|
84
84
|
<div
|
|
85
85
|
v-if="isMobile"
|
|
86
86
|
class="htw-h-full htw-flex htw-flex-col htw-divide-y htw-divide-gray-100 dark:htw-divide-gray-800"
|
|
@@ -40,6 +40,7 @@ onKeyboardShortcut(['ctrl+shift+d', 'meta+shift+d'], (event) => {
|
|
|
40
40
|
<a
|
|
41
41
|
v-tooltip="makeTooltip('Search', ({ isMac }) => isMac ? 'meta+k' : 'ctrl+k')"
|
|
42
42
|
class="htw-p-2 sm:htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer"
|
|
43
|
+
data-test-id="search-btn"
|
|
43
44
|
@click="$emit('search')"
|
|
44
45
|
>
|
|
45
46
|
<Icon
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, ref, watch } from 'vue'
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
modelValue: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: false,
|
|
8
|
+
},
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
const emit = defineEmits({
|
|
12
|
+
'update:modelValue': (newValue: boolean) => true,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
function toggle () {
|
|
16
|
+
emit('update:modelValue', !props.modelValue)
|
|
17
|
+
animationEnabled.value = true
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// SVG check
|
|
21
|
+
|
|
22
|
+
const path = ref<SVGPathElement>()
|
|
23
|
+
const dasharray = ref(0)
|
|
24
|
+
const progress = computed(() => props.modelValue ? 1 : 0)
|
|
25
|
+
const dashoffset = computed(() => (1 - progress.value) * dasharray.value)
|
|
26
|
+
const animationEnabled = ref(false)
|
|
27
|
+
|
|
28
|
+
watch(path, value => {
|
|
29
|
+
dasharray.value = path.value.getTotalLength?.() ?? 21.21
|
|
30
|
+
})
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<div
|
|
35
|
+
role="checkbox"
|
|
36
|
+
tabindex="0"
|
|
37
|
+
class="htw-flex htw-items-center htw-gap-2 htw-select-none htw-px-4 htw-py-3 htw-cursor-pointer hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700"
|
|
38
|
+
@click="toggle()"
|
|
39
|
+
@keydown.enter.prevent="toggle()"
|
|
40
|
+
@keydown.space.prevent="toggle()"
|
|
41
|
+
>
|
|
42
|
+
<div class="htw-text-white htw-w-[16px] htw-h-[16px] htw-relative">
|
|
43
|
+
<div
|
|
44
|
+
class="htw-border group-active:htw-bg-gray-500/20 htw-rounded-sm htw-box-border htw-absolute htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out"
|
|
45
|
+
:class="[
|
|
46
|
+
modelValue
|
|
47
|
+
? 'htw-border-primary-500 htw-border-8'
|
|
48
|
+
: 'htw-border-black/25 dark:htw-border-white/25 htw-delay-150',
|
|
49
|
+
]"
|
|
50
|
+
/>
|
|
51
|
+
<svg
|
|
52
|
+
width="16"
|
|
53
|
+
height="16"
|
|
54
|
+
viewBox="0 0 24 24"
|
|
55
|
+
class="htw-relative htw-z-10"
|
|
56
|
+
>
|
|
57
|
+
<path
|
|
58
|
+
ref="path"
|
|
59
|
+
d="m 4 12 l 5 5 l 10 -10"
|
|
60
|
+
fill="none"
|
|
61
|
+
class="htw-stroke-white htw-stroke-2 htw-duration-200 htw-ease-in-out"
|
|
62
|
+
:class="[
|
|
63
|
+
animationEnabled ? 'htw-transition-all' : 'htw-transition-none',
|
|
64
|
+
{
|
|
65
|
+
'htw-delay-150': modelValue,
|
|
66
|
+
},
|
|
67
|
+
]"
|
|
68
|
+
:stroke-dasharray="dasharray"
|
|
69
|
+
:stroke-dashoffset="dashoffset"
|
|
70
|
+
/>
|
|
71
|
+
</svg>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<slot />
|
|
75
|
+
</div>
|
|
76
|
+
</template>
|
|
@@ -25,8 +25,7 @@ function close () {
|
|
|
25
25
|
// Autofocus
|
|
26
26
|
|
|
27
27
|
const input = ref<HTMLInputElement>()
|
|
28
|
-
const { focused } = useFocus({
|
|
29
|
-
target: input,
|
|
28
|
+
const { focused } = useFocus(input, {
|
|
30
29
|
initialValue: true,
|
|
31
30
|
})
|
|
32
31
|
|
|
@@ -132,6 +131,7 @@ function selectPrevious () {
|
|
|
132
131
|
<div
|
|
133
132
|
v-show="shown"
|
|
134
133
|
class="htw-fixed htw-inset-0 htw-bg-white/80 dark:htw-bg-gray-700/80 htw-z-20"
|
|
134
|
+
data-test-id="search-modal"
|
|
135
135
|
>
|
|
136
136
|
<div
|
|
137
137
|
class="htw-absolute htw-inset-0"
|
|
@@ -152,8 +152,8 @@ function selectPrevious () {
|
|
|
152
152
|
v-model="search"
|
|
153
153
|
placeholder="Search for stories, variants..."
|
|
154
154
|
class="htw-bg-transparent htw-w-full htw-flex-1 htw-pl-0 htw-pr-6 htw-py-4 htw-outline-none"
|
|
155
|
-
@keydown.down="selectNext()"
|
|
156
|
-
@keydown.up="selectPrevious()"
|
|
155
|
+
@keydown.down.prevent="selectNext()"
|
|
156
|
+
@keydown.up.prevent="selectPrevious()"
|
|
157
157
|
@keydown.escape="close()"
|
|
158
158
|
>
|
|
159
159
|
</div>
|
|
@@ -9,6 +9,7 @@ import HatchedPattern from '../misc/HatchedPattern.vue'
|
|
|
9
9
|
import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
|
|
10
10
|
import { toRawDeep } from '../../util/reactivity'
|
|
11
11
|
import { Settings } from 'http2'
|
|
12
|
+
import { getSandboxUrl } from '../sandbox/lib'
|
|
12
13
|
|
|
13
14
|
const props = defineProps<{
|
|
14
15
|
story: Story
|
|
@@ -61,10 +62,7 @@ useEventListener(window, 'message', (event) => {
|
|
|
61
62
|
})
|
|
62
63
|
|
|
63
64
|
const sandboxUrl = computed(() => {
|
|
64
|
-
|
|
65
|
-
url.append('storyId', props.story.id)
|
|
66
|
-
url.append('variantId', props.variant.id)
|
|
67
|
-
return '/__sandbox?' + url.toString()
|
|
65
|
+
return getSandboxUrl(props.story, props.variant)
|
|
68
66
|
})
|
|
69
67
|
|
|
70
68
|
const isIframeLoaded = ref(false)
|
|
@@ -255,6 +253,7 @@ const finalHeight = computed(() => props.settings.rotate ? props.settings.respon
|
|
|
255
253
|
'htw-invisible': !isIframeLoaded,
|
|
256
254
|
'htw-pointer-events-none': resizing,
|
|
257
255
|
}"
|
|
256
|
+
data-test-id="preview-iframe"
|
|
258
257
|
@load="onIframeLoad()"
|
|
259
258
|
/>
|
|
260
259
|
</div>
|
|
@@ -67,7 +67,10 @@ const copySourceCode = () => copy(sourceCode.value)
|
|
|
67
67
|
</script>
|
|
68
68
|
|
|
69
69
|
<template>
|
|
70
|
-
<div
|
|
70
|
+
<div
|
|
71
|
+
class="htw-bg-gray-100 dark:htw-bg-gray-800 htw-h-full htw-overflow-hidden htw-relative"
|
|
72
|
+
data-test-id="story-source-code"
|
|
73
|
+
>
|
|
71
74
|
<div
|
|
72
75
|
v-if="error"
|
|
73
76
|
class="htw-text-red-500 htw-h-full htw-p-2 htw-overflow-auto htw-font-mono htw-text-sm"
|
|
@@ -1,173 +1,39 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { PropType
|
|
3
|
-
import { Icon } from '@iconify/vue'
|
|
2
|
+
import { PropType } from 'vue'
|
|
4
3
|
import type { Story, Variant } from '../../types'
|
|
5
|
-
import { histoireConfig } from '../../util/config'
|
|
6
4
|
import { usePreviewSettings } from '../../util/preview-settings'
|
|
7
5
|
import StoryResponsivePreview from './StoryResponsivePreview.vue'
|
|
8
6
|
import { isMobile } from '../../util/responsive'
|
|
7
|
+
import StoryVariantTitle from './variant/StoryVariantTitle.vue'
|
|
8
|
+
import StoryVariantResponsiveSize from './variant/StoryVariantResponsiveSize.vue'
|
|
9
|
+
import StoryVariantBackground from './variant/StoryVariantBackground.vue'
|
|
10
|
+
import StoryVariantNewTab from './variant/StoryVariantNewTab.vue'
|
|
9
11
|
|
|
10
|
-
defineProps
|
|
11
|
-
variant:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
story: {
|
|
17
|
-
type: Object as PropType<Story>,
|
|
18
|
-
required: true,
|
|
19
|
-
},
|
|
20
|
-
})
|
|
12
|
+
defineProps<{
|
|
13
|
+
variant: Variant
|
|
14
|
+
story: Story
|
|
15
|
+
}>()
|
|
21
16
|
|
|
22
17
|
const settings = usePreviewSettings()
|
|
23
18
|
</script>
|
|
24
19
|
|
|
25
20
|
<template>
|
|
26
|
-
<div
|
|
21
|
+
<div
|
|
22
|
+
class="htw-h-full htw-flex htw-flex-col"
|
|
23
|
+
data-test-id="story-variant-single-view"
|
|
24
|
+
>
|
|
27
25
|
<!-- Toolbar -->
|
|
28
26
|
<div
|
|
29
27
|
v-if="!isMobile"
|
|
30
28
|
class="htw-flex-none htw-flex htw-items-center htw-h-8 -htw-mt-1"
|
|
31
29
|
>
|
|
32
|
-
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
]"
|
|
40
|
-
/>
|
|
41
|
-
<span>{{ variant.title }}</span>
|
|
42
|
-
</div>
|
|
43
|
-
|
|
44
|
-
<!-- Responsive size -->
|
|
45
|
-
<VDropdown
|
|
46
|
-
placement="bottom-end"
|
|
47
|
-
:skidding="6"
|
|
48
|
-
:disabled="!histoireConfig.responsivePresets?.length"
|
|
49
|
-
class="htw-h-full htw-flex-none"
|
|
50
|
-
>
|
|
51
|
-
<div
|
|
52
|
-
v-tooltip="'Responsive sizes'"
|
|
53
|
-
class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2"
|
|
54
|
-
:class="{
|
|
55
|
-
'htw-cursor-pointer hover:htw-text-primary-500': histoireConfig.responsivePresets?.length,
|
|
56
|
-
}"
|
|
57
|
-
>
|
|
58
|
-
<Icon
|
|
59
|
-
icon="ic:baseline-phone-android"
|
|
60
|
-
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
61
|
-
/>
|
|
62
|
-
<Icon
|
|
63
|
-
icon="carbon:caret-down"
|
|
64
|
-
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
65
|
-
/>
|
|
66
|
-
</div>
|
|
67
|
-
|
|
68
|
-
<template #popper="{ hide }">
|
|
69
|
-
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
70
|
-
<HstCheckbox
|
|
71
|
-
v-model="settings.rotate"
|
|
72
|
-
>
|
|
73
|
-
Rotate
|
|
74
|
-
</HstCheckbox>
|
|
75
|
-
|
|
76
|
-
<div class="htw-flex htw-gap-2 htw-px-4 htw-py-3">
|
|
77
|
-
<input
|
|
78
|
-
v-model.number="settings.responsiveWidth"
|
|
79
|
-
v-tooltip="'Responsive width (px)'"
|
|
80
|
-
type="number"
|
|
81
|
-
class="htw-bg-transparent htw-border htw-border-gray-200 dark:htw-border-gray-850 htw-rounded htw-w-20 htw-opacity-50 focus:htw-opacity-100 htw-flex-1 htw-min-w-0"
|
|
82
|
-
step="16"
|
|
83
|
-
placeholder="Auto"
|
|
84
|
-
>
|
|
85
|
-
<span class="htw-opacity-50">x</span>
|
|
86
|
-
<input
|
|
87
|
-
v-model.number="settings.responsiveHeight"
|
|
88
|
-
v-tooltip="'Responsive height (px)'"
|
|
89
|
-
type="number"
|
|
90
|
-
class="htw-bg-transparent htw-border htw-border-gray-200 dark:htw-border-gray-850 htw-rounded htw-w-20 htw-opacity-50 focus:htw-opacity-100 htw-flex-1 htw-min-w-0"
|
|
91
|
-
step="16"
|
|
92
|
-
placeholder="Auto"
|
|
93
|
-
>
|
|
94
|
-
</div>
|
|
95
|
-
|
|
96
|
-
<button
|
|
97
|
-
v-for="(preset, index) in histoireConfig.responsivePresets"
|
|
98
|
-
:key="index"
|
|
99
|
-
class="htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-4"
|
|
100
|
-
:class="[
|
|
101
|
-
settings.responsiveWidth === preset.width && settings.responsiveHeight === preset.height
|
|
102
|
-
? 'htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black'
|
|
103
|
-
: 'htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700',
|
|
104
|
-
]"
|
|
105
|
-
@click="settings.responsiveWidth = preset.width;settings.responsiveHeight = preset.height;hide()"
|
|
106
|
-
>
|
|
107
|
-
{{ preset.label }}
|
|
108
|
-
<span class="htw-ml-auto htw-opacity-70 htw-flex htw-gap-1">
|
|
109
|
-
<span v-if="preset.width">{{ preset.width }}<span v-if="!preset.height">px</span></span>
|
|
110
|
-
<span v-if="preset.width && preset.height">x</span>
|
|
111
|
-
<span v-if="preset.height">{{ preset.height }}<span v-if="!preset.width">px</span></span>
|
|
112
|
-
</span>
|
|
113
|
-
</button>
|
|
114
|
-
</div>
|
|
115
|
-
</template>
|
|
116
|
-
</VDropdown>
|
|
117
|
-
|
|
118
|
-
<!-- Background -->
|
|
119
|
-
<VDropdown
|
|
120
|
-
v-if="histoireConfig.backgroundPresets.length"
|
|
121
|
-
placement="bottom-end"
|
|
122
|
-
:skidding="6"
|
|
123
|
-
class="htw-h-full htw-flex-none"
|
|
124
|
-
>
|
|
125
|
-
<div
|
|
126
|
-
v-tooltip="'Background color'"
|
|
127
|
-
class="htw-cursor-pointer hover:htw-text-primary-500 htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2"
|
|
128
|
-
>
|
|
129
|
-
<div
|
|
130
|
-
class="bind-preview-bg htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/20 dark:htw-border-white/20"
|
|
131
|
-
/>
|
|
132
|
-
<Icon
|
|
133
|
-
icon="carbon:caret-down"
|
|
134
|
-
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
135
|
-
/>
|
|
136
|
-
</div>
|
|
137
|
-
|
|
138
|
-
<template #popper="{ hide }">
|
|
139
|
-
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
140
|
-
<HstCheckbox
|
|
141
|
-
v-model="settings.checkerboard"
|
|
142
|
-
>
|
|
143
|
-
Checkerboard
|
|
144
|
-
</HstCheckbox>
|
|
145
|
-
|
|
146
|
-
<button
|
|
147
|
-
v-for="(option, index) in histoireConfig.backgroundPresets"
|
|
148
|
-
:key="index"
|
|
149
|
-
class="htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-4"
|
|
150
|
-
:class="[
|
|
151
|
-
settings.backgroundColor === option.color
|
|
152
|
-
? 'htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black'
|
|
153
|
-
: 'htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700',
|
|
154
|
-
]"
|
|
155
|
-
@click="settings.backgroundColor = option.color;hide()"
|
|
156
|
-
>
|
|
157
|
-
<span class="htw-mr-auto">{{ option.label }}</span>
|
|
158
|
-
<template v-if="option.color !== '$checkerboard'">
|
|
159
|
-
<span class="htw-ml-auto htw-opacity-70">{{ option.color }}</span>
|
|
160
|
-
<div
|
|
161
|
-
class="htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/20 dark:htw-border-white/20"
|
|
162
|
-
:style="{
|
|
163
|
-
backgroundColor: option.color,
|
|
164
|
-
}"
|
|
165
|
-
/>
|
|
166
|
-
</template>
|
|
167
|
-
</button>
|
|
168
|
-
</div>
|
|
169
|
-
</template>
|
|
170
|
-
</VDropdown>
|
|
30
|
+
<StoryVariantTitle :variant="variant" />
|
|
31
|
+
<StoryVariantResponsiveSize />
|
|
32
|
+
<StoryVariantBackground />
|
|
33
|
+
<StoryVariantNewTab
|
|
34
|
+
:variant="variant"
|
|
35
|
+
:story="story"
|
|
36
|
+
/>
|
|
171
37
|
</div>
|
|
172
38
|
|
|
173
39
|
<!-- Preview -->
|
|
@@ -178,9 +44,3 @@ const settings = usePreviewSettings()
|
|
|
178
44
|
/>
|
|
179
45
|
</div>
|
|
180
46
|
</template>
|
|
181
|
-
|
|
182
|
-
<style scoped>
|
|
183
|
-
.bind-preview-bg {
|
|
184
|
-
background-color: v-bind('settings.backgroundColor');
|
|
185
|
-
}
|
|
186
|
-
</style>
|
|
@@ -33,6 +33,24 @@ function closeMenu () {
|
|
|
33
33
|
watch(variant, () => {
|
|
34
34
|
isMenuOpened.value = false
|
|
35
35
|
})
|
|
36
|
+
|
|
37
|
+
const templateWidth = computed(() => {
|
|
38
|
+
if (storyStore.currentStory.layout.type !== 'grid') {
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const layoutWidth = storyStore.currentStory.layout.width
|
|
43
|
+
|
|
44
|
+
if (!layoutWidth) {
|
|
45
|
+
return '200px'
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (typeof layoutWidth === 'number') {
|
|
49
|
+
return layoutWidth + 'px'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return layoutWidth
|
|
53
|
+
})
|
|
36
54
|
</script>
|
|
37
55
|
|
|
38
56
|
<template>
|
|
@@ -44,7 +62,7 @@ watch(variant, () => {
|
|
|
44
62
|
<div
|
|
45
63
|
class="htw-grid htw-gap-4 htw-m-4"
|
|
46
64
|
:style="{
|
|
47
|
-
gridTemplateColumns: `repeat(auto-fill, ${
|
|
65
|
+
gridTemplateColumns: `repeat(auto-fill, ${templateWidth})`,
|
|
48
66
|
}"
|
|
49
67
|
>
|
|
50
68
|
<StoryVariantGridItem
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { Icon } from '@iconify/vue'
|
|
3
|
+
import { histoireConfig } from '../../../util/config'
|
|
4
|
+
import { usePreviewSettings } from '../../../util/preview-settings'
|
|
5
|
+
import BaseCheckbox from '../../base/BaseCheckbox.vue'
|
|
6
|
+
|
|
7
|
+
const settings = usePreviewSettings()
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<VDropdown
|
|
12
|
+
v-if="histoireConfig.backgroundPresets.length"
|
|
13
|
+
placement="bottom-end"
|
|
14
|
+
:skidding="6"
|
|
15
|
+
class="htw-h-full htw-flex-none"
|
|
16
|
+
>
|
|
17
|
+
<div
|
|
18
|
+
v-tooltip="'Background color'"
|
|
19
|
+
class="htw-cursor-pointer hover:htw-text-primary-500 htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2"
|
|
20
|
+
>
|
|
21
|
+
<div
|
|
22
|
+
class="bind-preview-bg htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/50 dark:htw-border-white/50"
|
|
23
|
+
/>
|
|
24
|
+
<Icon
|
|
25
|
+
icon="carbon:caret-down"
|
|
26
|
+
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
27
|
+
/>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<template #popper="{ hide }">
|
|
31
|
+
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
32
|
+
<BaseCheckbox v-model="settings.checkerboard">
|
|
33
|
+
Checkerboard
|
|
34
|
+
</BaseCheckbox>
|
|
35
|
+
|
|
36
|
+
<button
|
|
37
|
+
v-for="(option, index) in histoireConfig.backgroundPresets"
|
|
38
|
+
:key="index"
|
|
39
|
+
class="htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-4"
|
|
40
|
+
:class="[
|
|
41
|
+
settings.backgroundColor === option.color
|
|
42
|
+
? 'htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black'
|
|
43
|
+
: 'htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700',
|
|
44
|
+
]"
|
|
45
|
+
@click="settings.backgroundColor = option.color;hide()"
|
|
46
|
+
>
|
|
47
|
+
<span class="htw-mr-auto">{{ option.label }}</span>
|
|
48
|
+
<template v-if="option.color !== '$checkerboard'">
|
|
49
|
+
<span class="htw-ml-auto htw-opacity-70">{{ option.color }}</span>
|
|
50
|
+
<div
|
|
51
|
+
class="htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/20 dark:htw-border-white/20"
|
|
52
|
+
:style="{
|
|
53
|
+
backgroundColor: option.color,
|
|
54
|
+
}"
|
|
55
|
+
/>
|
|
56
|
+
</template>
|
|
57
|
+
</button>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
</VDropdown>
|
|
61
|
+
</template>
|
|
62
|
+
|
|
63
|
+
<style scoped>
|
|
64
|
+
.bind-preview-bg {
|
|
65
|
+
background-color: v-bind('settings.backgroundColor');
|
|
66
|
+
}
|
|
67
|
+
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { Icon } from '@iconify/vue'
|
|
3
|
+
import type { Story, Variant } from '../../../types'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
import { getSandboxUrl } from '../../sandbox/lib'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
variant: Variant
|
|
9
|
+
story: Story
|
|
10
|
+
}>()
|
|
11
|
+
|
|
12
|
+
const sandboxUrl = computed(() => {
|
|
13
|
+
return getSandboxUrl(props.story, props.variant)
|
|
14
|
+
})
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<a
|
|
19
|
+
v-tooltip="'Open variant in new tab'"
|
|
20
|
+
:href="sandboxUrl"
|
|
21
|
+
target="_blank"
|
|
22
|
+
class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 hover:htw-text-primary-500"
|
|
23
|
+
>
|
|
24
|
+
<Icon
|
|
25
|
+
icon="carbon:launch"
|
|
26
|
+
class="base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50"
|
|
27
|
+
/>
|
|
28
|
+
</a>
|
|
29
|
+
</template>
|