histoire 0.2.0 → 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/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/story/StoryResponsivePreview.vue +2 -4
- package/dist/client/app/components/story/StoryVariantSingleView.vue +16 -156
- 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/node/tree.js +24 -4
- package/dist/style.css +8 -0
- package/package.json +2 -2
- package/src/client/app/components/sandbox/lib.ts +8 -0
- package/src/client/app/components/story/StoryResponsivePreview.vue +2 -4
- package/src/client/app/components/story/StoryVariantSingleView.vue +16 -156
- 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/node/tree.spec.ts +61 -0
- package/src/node/tree.ts +29 -5
|
@@ -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)
|
|
@@ -1,24 +1,18 @@
|
|
|
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
|
-
import BaseCheckbox from '../base/BaseCheckbox.vue'
|
|
9
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'
|
|
10
11
|
|
|
11
|
-
defineProps
|
|
12
|
-
variant:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
story: {
|
|
18
|
-
type: Object as PropType<Story>,
|
|
19
|
-
required: true,
|
|
20
|
-
},
|
|
21
|
-
})
|
|
12
|
+
defineProps<{
|
|
13
|
+
variant: Variant
|
|
14
|
+
story: Story
|
|
15
|
+
}>()
|
|
22
16
|
|
|
23
17
|
const settings = usePreviewSettings()
|
|
24
18
|
</script>
|
|
@@ -33,141 +27,13 @@ const settings = usePreviewSettings()
|
|
|
33
27
|
v-if="!isMobile"
|
|
34
28
|
class="htw-flex-none htw-flex htw-items-center htw-h-8 -htw-mt-1"
|
|
35
29
|
>
|
|
36
|
-
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
]"
|
|
44
|
-
/>
|
|
45
|
-
<span>{{ variant.title }}</span>
|
|
46
|
-
</div>
|
|
47
|
-
|
|
48
|
-
<!-- Responsive size -->
|
|
49
|
-
<VDropdown
|
|
50
|
-
placement="bottom-end"
|
|
51
|
-
:skidding="6"
|
|
52
|
-
:disabled="!histoireConfig.responsivePresets?.length"
|
|
53
|
-
class="htw-h-full htw-flex-none"
|
|
54
|
-
>
|
|
55
|
-
<div
|
|
56
|
-
v-tooltip="'Responsive sizes'"
|
|
57
|
-
class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2"
|
|
58
|
-
:class="{
|
|
59
|
-
'htw-cursor-pointer hover:htw-text-primary-500': histoireConfig.responsivePresets?.length,
|
|
60
|
-
}"
|
|
61
|
-
>
|
|
62
|
-
<Icon
|
|
63
|
-
icon="ic:baseline-phone-android"
|
|
64
|
-
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
65
|
-
/>
|
|
66
|
-
<Icon
|
|
67
|
-
icon="carbon:caret-down"
|
|
68
|
-
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
69
|
-
/>
|
|
70
|
-
</div>
|
|
71
|
-
|
|
72
|
-
<template #popper="{ hide }">
|
|
73
|
-
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
74
|
-
<BaseCheckbox v-model="settings.rotate">
|
|
75
|
-
Rotate
|
|
76
|
-
</BaseCheckbox>
|
|
77
|
-
|
|
78
|
-
<div class="htw-flex htw-gap-2 htw-px-4 htw-py-3">
|
|
79
|
-
<input
|
|
80
|
-
v-model.number="settings.responsiveWidth"
|
|
81
|
-
v-tooltip="'Responsive width (px)'"
|
|
82
|
-
type="number"
|
|
83
|
-
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"
|
|
84
|
-
step="16"
|
|
85
|
-
placeholder="Auto"
|
|
86
|
-
>
|
|
87
|
-
<span class="htw-opacity-50">x</span>
|
|
88
|
-
<input
|
|
89
|
-
v-model.number="settings.responsiveHeight"
|
|
90
|
-
v-tooltip="'Responsive height (px)'"
|
|
91
|
-
type="number"
|
|
92
|
-
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"
|
|
93
|
-
step="16"
|
|
94
|
-
placeholder="Auto"
|
|
95
|
-
>
|
|
96
|
-
</div>
|
|
97
|
-
|
|
98
|
-
<button
|
|
99
|
-
v-for="(preset, index) in histoireConfig.responsivePresets"
|
|
100
|
-
:key="index"
|
|
101
|
-
class="htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-4"
|
|
102
|
-
:class="[
|
|
103
|
-
settings.responsiveWidth === preset.width && settings.responsiveHeight === preset.height
|
|
104
|
-
? 'htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black'
|
|
105
|
-
: 'htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700',
|
|
106
|
-
]"
|
|
107
|
-
@click="settings.responsiveWidth = preset.width;settings.responsiveHeight = preset.height;hide()"
|
|
108
|
-
>
|
|
109
|
-
{{ preset.label }}
|
|
110
|
-
<span class="htw-ml-auto htw-opacity-70 htw-flex htw-gap-1">
|
|
111
|
-
<span v-if="preset.width">{{ preset.width }}<span v-if="!preset.height">px</span></span>
|
|
112
|
-
<span v-if="preset.width && preset.height">x</span>
|
|
113
|
-
<span v-if="preset.height">{{ preset.height }}<span v-if="!preset.width">px</span></span>
|
|
114
|
-
</span>
|
|
115
|
-
</button>
|
|
116
|
-
</div>
|
|
117
|
-
</template>
|
|
118
|
-
</VDropdown>
|
|
119
|
-
|
|
120
|
-
<!-- Background -->
|
|
121
|
-
<VDropdown
|
|
122
|
-
v-if="histoireConfig.backgroundPresets.length"
|
|
123
|
-
placement="bottom-end"
|
|
124
|
-
:skidding="6"
|
|
125
|
-
class="htw-h-full htw-flex-none"
|
|
126
|
-
>
|
|
127
|
-
<div
|
|
128
|
-
v-tooltip="'Background color'"
|
|
129
|
-
class="htw-cursor-pointer hover:htw-text-primary-500 htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2"
|
|
130
|
-
>
|
|
131
|
-
<div
|
|
132
|
-
class="bind-preview-bg htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/20 dark:htw-border-white/20"
|
|
133
|
-
/>
|
|
134
|
-
<Icon
|
|
135
|
-
icon="carbon:caret-down"
|
|
136
|
-
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
137
|
-
/>
|
|
138
|
-
</div>
|
|
139
|
-
|
|
140
|
-
<template #popper="{ hide }">
|
|
141
|
-
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
142
|
-
<BaseCheckbox v-model="settings.checkerboard">
|
|
143
|
-
Checkerboard
|
|
144
|
-
</BaseCheckbox>
|
|
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>
|
|
@@ -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>
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
<!-- Responsive size -->
|
|
12
|
+
<VDropdown
|
|
13
|
+
placement="bottom-end"
|
|
14
|
+
:skidding="6"
|
|
15
|
+
:disabled="!histoireConfig.responsivePresets?.length"
|
|
16
|
+
class="htw-h-full htw-flex-none"
|
|
17
|
+
>
|
|
18
|
+
<div
|
|
19
|
+
v-tooltip="'Responsive sizes'"
|
|
20
|
+
class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2"
|
|
21
|
+
:class="{
|
|
22
|
+
'htw-cursor-pointer hover:htw-text-primary-500': histoireConfig.responsivePresets?.length,
|
|
23
|
+
}"
|
|
24
|
+
>
|
|
25
|
+
<Icon
|
|
26
|
+
icon="carbon:devices"
|
|
27
|
+
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
28
|
+
/>
|
|
29
|
+
<Icon
|
|
30
|
+
icon="carbon:caret-down"
|
|
31
|
+
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<template #popper="{ hide }">
|
|
36
|
+
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
37
|
+
<BaseCheckbox v-model="settings.rotate">
|
|
38
|
+
Rotate
|
|
39
|
+
</BaseCheckbox>
|
|
40
|
+
|
|
41
|
+
<div class="htw-flex htw-gap-2 htw-px-4 htw-py-3">
|
|
42
|
+
<input
|
|
43
|
+
v-model.number="settings.responsiveWidth"
|
|
44
|
+
v-tooltip="'Responsive width (px)'"
|
|
45
|
+
type="number"
|
|
46
|
+
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"
|
|
47
|
+
step="16"
|
|
48
|
+
placeholder="Auto"
|
|
49
|
+
>
|
|
50
|
+
<span class="htw-opacity-50">x</span>
|
|
51
|
+
<input
|
|
52
|
+
v-model.number="settings.responsiveHeight"
|
|
53
|
+
v-tooltip="'Responsive height (px)'"
|
|
54
|
+
type="number"
|
|
55
|
+
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"
|
|
56
|
+
step="16"
|
|
57
|
+
placeholder="Auto"
|
|
58
|
+
>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<button
|
|
62
|
+
v-for="(preset, index) in histoireConfig.responsivePresets"
|
|
63
|
+
:key="index"
|
|
64
|
+
class="htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-4"
|
|
65
|
+
:class="[
|
|
66
|
+
settings.responsiveWidth === preset.width && settings.responsiveHeight === preset.height
|
|
67
|
+
? 'htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black'
|
|
68
|
+
: 'htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700',
|
|
69
|
+
]"
|
|
70
|
+
@click="settings.responsiveWidth = preset.width;settings.responsiveHeight = preset.height;hide()"
|
|
71
|
+
>
|
|
72
|
+
{{ preset.label }}
|
|
73
|
+
<span class="htw-ml-auto htw-opacity-70 htw-flex htw-gap-1">
|
|
74
|
+
<span v-if="preset.width">{{ preset.width }}<span v-if="!preset.height">px</span></span>
|
|
75
|
+
<span v-if="preset.width && preset.height">x</span>
|
|
76
|
+
<span v-if="preset.height">{{ preset.height }}<span v-if="!preset.width">px</span></span>
|
|
77
|
+
</span>
|
|
78
|
+
</button>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
81
|
+
</VDropdown>
|
|
82
|
+
</template>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { Icon } from '@iconify/vue'
|
|
3
|
+
import type { Variant } from '../../../types'
|
|
4
|
+
|
|
5
|
+
defineProps<{
|
|
6
|
+
variant: Variant
|
|
7
|
+
}>()
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div class="htw-flex htw-items-center htw-gap-1 htw-text-gray-500 htw-flex-1 htw-truncate htw-min-w-0">
|
|
12
|
+
<Icon
|
|
13
|
+
:icon="variant.icon ?? 'carbon:cube'"
|
|
14
|
+
class="base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50"
|
|
15
|
+
:class="[
|
|
16
|
+
variant.iconColor ? 'bind-icon-color' : 'htw-text-gray-500',
|
|
17
|
+
]"
|
|
18
|
+
/>
|
|
19
|
+
<span>{{ variant.title }}</span>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
package/dist/node/tree.js
CHANGED
|
@@ -20,17 +20,37 @@ export function makeTree(config, files) {
|
|
|
20
20
|
sortingFunction = config.tree.order;
|
|
21
21
|
}
|
|
22
22
|
return buildTree(treeObject);
|
|
23
|
-
// Undefined behavior for folder and file that share the same name under the same directory
|
|
24
23
|
function setPath(path, value, tree) {
|
|
25
24
|
path.reduce((subtree, key, i) => {
|
|
26
|
-
if (
|
|
25
|
+
if (i === path.length - 1) {
|
|
26
|
+
setKey(subtree, key, value);
|
|
27
|
+
}
|
|
28
|
+
else if (isLeaf(subtree[key])) {
|
|
29
|
+
setKey(subtree, key, subtree[key]);
|
|
27
30
|
subtree[key] = {};
|
|
28
31
|
}
|
|
29
|
-
if (
|
|
30
|
-
subtree[key] =
|
|
32
|
+
else if (!subtree[key]) {
|
|
33
|
+
subtree[key] = {};
|
|
31
34
|
}
|
|
32
35
|
return subtree[key];
|
|
33
36
|
}, tree);
|
|
37
|
+
function isLeaf(element) {
|
|
38
|
+
return !isNaN(element);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function setKey(tree, key, value) {
|
|
42
|
+
if (isUndefined(tree[key])) {
|
|
43
|
+
tree[key] = value;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
let copyNumber = 1;
|
|
47
|
+
while (!isUndefined(tree[`${key}-${copyNumber}`])) {
|
|
48
|
+
copyNumber++;
|
|
49
|
+
}
|
|
50
|
+
tree[`${key}-${copyNumber}`] = value;
|
|
51
|
+
function isUndefined(element) {
|
|
52
|
+
return element === undefined;
|
|
53
|
+
}
|
|
34
54
|
}
|
|
35
55
|
function buildTree(treeObject) {
|
|
36
56
|
const tree = [];
|
package/dist/style.css
CHANGED
|
@@ -1330,6 +1330,10 @@ button {
|
|
|
1330
1330
|
border-color:rgb(var(--_histoire-color-primary-200) / var(--tw-border-opacity))
|
|
1331
1331
|
}
|
|
1332
1332
|
|
|
1333
|
+
.htw-border-black\/50{
|
|
1334
|
+
border-color:rgb(0 0 0 / 0.5)
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1333
1337
|
.htw-border-black\/20{
|
|
1334
1338
|
border-color:rgb(0 0 0 / 0.2)
|
|
1335
1339
|
}
|
|
@@ -1807,6 +1811,10 @@ body {
|
|
|
1807
1811
|
border-color:rgb(var(--_histoire-color-primary-900) / var(--tw-border-opacity))
|
|
1808
1812
|
}
|
|
1809
1813
|
|
|
1814
|
+
.htw-dark .dark\:htw-border-white\/50{
|
|
1815
|
+
border-color:rgb(255 255 255 / 0.5)
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1810
1818
|
.htw-dark .dark\:htw-border-white\/20{
|
|
1811
1819
|
border-color:rgb(255 255 255 / 0.2)
|
|
1812
1820
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "histoire",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A fast story book powered by Vite",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@iconify/vue": "^3.1.3",
|
|
37
|
-
"@histoire/controls": "^0.2.
|
|
37
|
+
"@histoire/controls": "^0.2.1",
|
|
38
38
|
"@vitejs/plugin-vue": "^2.2.0",
|
|
39
39
|
"@vueuse/core": "^8.1.1",
|
|
40
40
|
"birpc": "^0.1.0",
|
|
@@ -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)
|
|
@@ -1,24 +1,18 @@
|
|
|
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
|
-
import BaseCheckbox from '../base/BaseCheckbox.vue'
|
|
9
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'
|
|
10
11
|
|
|
11
|
-
defineProps
|
|
12
|
-
variant:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
story: {
|
|
18
|
-
type: Object as PropType<Story>,
|
|
19
|
-
required: true,
|
|
20
|
-
},
|
|
21
|
-
})
|
|
12
|
+
defineProps<{
|
|
13
|
+
variant: Variant
|
|
14
|
+
story: Story
|
|
15
|
+
}>()
|
|
22
16
|
|
|
23
17
|
const settings = usePreviewSettings()
|
|
24
18
|
</script>
|
|
@@ -33,141 +27,13 @@ const settings = usePreviewSettings()
|
|
|
33
27
|
v-if="!isMobile"
|
|
34
28
|
class="htw-flex-none htw-flex htw-items-center htw-h-8 -htw-mt-1"
|
|
35
29
|
>
|
|
36
|
-
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
]"
|
|
44
|
-
/>
|
|
45
|
-
<span>{{ variant.title }}</span>
|
|
46
|
-
</div>
|
|
47
|
-
|
|
48
|
-
<!-- Responsive size -->
|
|
49
|
-
<VDropdown
|
|
50
|
-
placement="bottom-end"
|
|
51
|
-
:skidding="6"
|
|
52
|
-
:disabled="!histoireConfig.responsivePresets?.length"
|
|
53
|
-
class="htw-h-full htw-flex-none"
|
|
54
|
-
>
|
|
55
|
-
<div
|
|
56
|
-
v-tooltip="'Responsive sizes'"
|
|
57
|
-
class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2"
|
|
58
|
-
:class="{
|
|
59
|
-
'htw-cursor-pointer hover:htw-text-primary-500': histoireConfig.responsivePresets?.length,
|
|
60
|
-
}"
|
|
61
|
-
>
|
|
62
|
-
<Icon
|
|
63
|
-
icon="ic:baseline-phone-android"
|
|
64
|
-
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
65
|
-
/>
|
|
66
|
-
<Icon
|
|
67
|
-
icon="carbon:caret-down"
|
|
68
|
-
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
69
|
-
/>
|
|
70
|
-
</div>
|
|
71
|
-
|
|
72
|
-
<template #popper="{ hide }">
|
|
73
|
-
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
74
|
-
<BaseCheckbox v-model="settings.rotate">
|
|
75
|
-
Rotate
|
|
76
|
-
</BaseCheckbox>
|
|
77
|
-
|
|
78
|
-
<div class="htw-flex htw-gap-2 htw-px-4 htw-py-3">
|
|
79
|
-
<input
|
|
80
|
-
v-model.number="settings.responsiveWidth"
|
|
81
|
-
v-tooltip="'Responsive width (px)'"
|
|
82
|
-
type="number"
|
|
83
|
-
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"
|
|
84
|
-
step="16"
|
|
85
|
-
placeholder="Auto"
|
|
86
|
-
>
|
|
87
|
-
<span class="htw-opacity-50">x</span>
|
|
88
|
-
<input
|
|
89
|
-
v-model.number="settings.responsiveHeight"
|
|
90
|
-
v-tooltip="'Responsive height (px)'"
|
|
91
|
-
type="number"
|
|
92
|
-
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"
|
|
93
|
-
step="16"
|
|
94
|
-
placeholder="Auto"
|
|
95
|
-
>
|
|
96
|
-
</div>
|
|
97
|
-
|
|
98
|
-
<button
|
|
99
|
-
v-for="(preset, index) in histoireConfig.responsivePresets"
|
|
100
|
-
:key="index"
|
|
101
|
-
class="htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-4"
|
|
102
|
-
:class="[
|
|
103
|
-
settings.responsiveWidth === preset.width && settings.responsiveHeight === preset.height
|
|
104
|
-
? 'htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black'
|
|
105
|
-
: 'htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700',
|
|
106
|
-
]"
|
|
107
|
-
@click="settings.responsiveWidth = preset.width;settings.responsiveHeight = preset.height;hide()"
|
|
108
|
-
>
|
|
109
|
-
{{ preset.label }}
|
|
110
|
-
<span class="htw-ml-auto htw-opacity-70 htw-flex htw-gap-1">
|
|
111
|
-
<span v-if="preset.width">{{ preset.width }}<span v-if="!preset.height">px</span></span>
|
|
112
|
-
<span v-if="preset.width && preset.height">x</span>
|
|
113
|
-
<span v-if="preset.height">{{ preset.height }}<span v-if="!preset.width">px</span></span>
|
|
114
|
-
</span>
|
|
115
|
-
</button>
|
|
116
|
-
</div>
|
|
117
|
-
</template>
|
|
118
|
-
</VDropdown>
|
|
119
|
-
|
|
120
|
-
<!-- Background -->
|
|
121
|
-
<VDropdown
|
|
122
|
-
v-if="histoireConfig.backgroundPresets.length"
|
|
123
|
-
placement="bottom-end"
|
|
124
|
-
:skidding="6"
|
|
125
|
-
class="htw-h-full htw-flex-none"
|
|
126
|
-
>
|
|
127
|
-
<div
|
|
128
|
-
v-tooltip="'Background color'"
|
|
129
|
-
class="htw-cursor-pointer hover:htw-text-primary-500 htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2"
|
|
130
|
-
>
|
|
131
|
-
<div
|
|
132
|
-
class="bind-preview-bg htw-w-4 htw-h-4 htw-rounded-full htw-border htw-border-black/20 dark:htw-border-white/20"
|
|
133
|
-
/>
|
|
134
|
-
<Icon
|
|
135
|
-
icon="carbon:caret-down"
|
|
136
|
-
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
137
|
-
/>
|
|
138
|
-
</div>
|
|
139
|
-
|
|
140
|
-
<template #popper="{ hide }">
|
|
141
|
-
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
142
|
-
<BaseCheckbox v-model="settings.checkerboard">
|
|
143
|
-
Checkerboard
|
|
144
|
-
</BaseCheckbox>
|
|
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>
|
|
@@ -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>
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
<!-- Responsive size -->
|
|
12
|
+
<VDropdown
|
|
13
|
+
placement="bottom-end"
|
|
14
|
+
:skidding="6"
|
|
15
|
+
:disabled="!histoireConfig.responsivePresets?.length"
|
|
16
|
+
class="htw-h-full htw-flex-none"
|
|
17
|
+
>
|
|
18
|
+
<div
|
|
19
|
+
v-tooltip="'Responsive sizes'"
|
|
20
|
+
class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2"
|
|
21
|
+
:class="{
|
|
22
|
+
'htw-cursor-pointer hover:htw-text-primary-500': histoireConfig.responsivePresets?.length,
|
|
23
|
+
}"
|
|
24
|
+
>
|
|
25
|
+
<Icon
|
|
26
|
+
icon="carbon:devices"
|
|
27
|
+
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
28
|
+
/>
|
|
29
|
+
<Icon
|
|
30
|
+
icon="carbon:caret-down"
|
|
31
|
+
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<template #popper="{ hide }">
|
|
36
|
+
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
37
|
+
<BaseCheckbox v-model="settings.rotate">
|
|
38
|
+
Rotate
|
|
39
|
+
</BaseCheckbox>
|
|
40
|
+
|
|
41
|
+
<div class="htw-flex htw-gap-2 htw-px-4 htw-py-3">
|
|
42
|
+
<input
|
|
43
|
+
v-model.number="settings.responsiveWidth"
|
|
44
|
+
v-tooltip="'Responsive width (px)'"
|
|
45
|
+
type="number"
|
|
46
|
+
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"
|
|
47
|
+
step="16"
|
|
48
|
+
placeholder="Auto"
|
|
49
|
+
>
|
|
50
|
+
<span class="htw-opacity-50">x</span>
|
|
51
|
+
<input
|
|
52
|
+
v-model.number="settings.responsiveHeight"
|
|
53
|
+
v-tooltip="'Responsive height (px)'"
|
|
54
|
+
type="number"
|
|
55
|
+
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"
|
|
56
|
+
step="16"
|
|
57
|
+
placeholder="Auto"
|
|
58
|
+
>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<button
|
|
62
|
+
v-for="(preset, index) in histoireConfig.responsivePresets"
|
|
63
|
+
:key="index"
|
|
64
|
+
class="htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-4"
|
|
65
|
+
:class="[
|
|
66
|
+
settings.responsiveWidth === preset.width && settings.responsiveHeight === preset.height
|
|
67
|
+
? 'htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black'
|
|
68
|
+
: 'htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700',
|
|
69
|
+
]"
|
|
70
|
+
@click="settings.responsiveWidth = preset.width;settings.responsiveHeight = preset.height;hide()"
|
|
71
|
+
>
|
|
72
|
+
{{ preset.label }}
|
|
73
|
+
<span class="htw-ml-auto htw-opacity-70 htw-flex htw-gap-1">
|
|
74
|
+
<span v-if="preset.width">{{ preset.width }}<span v-if="!preset.height">px</span></span>
|
|
75
|
+
<span v-if="preset.width && preset.height">x</span>
|
|
76
|
+
<span v-if="preset.height">{{ preset.height }}<span v-if="!preset.width">px</span></span>
|
|
77
|
+
</span>
|
|
78
|
+
</button>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
81
|
+
</VDropdown>
|
|
82
|
+
</template>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { Icon } from '@iconify/vue'
|
|
3
|
+
import type { Variant } from '../../../types'
|
|
4
|
+
|
|
5
|
+
defineProps<{
|
|
6
|
+
variant: Variant
|
|
7
|
+
}>()
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div class="htw-flex htw-items-center htw-gap-1 htw-text-gray-500 htw-flex-1 htw-truncate htw-min-w-0">
|
|
12
|
+
<Icon
|
|
13
|
+
:icon="variant.icon ?? 'carbon:cube'"
|
|
14
|
+
class="base-list-item-link-icon htw-w-4 htw-h-4 htw-opacity-50"
|
|
15
|
+
:class="[
|
|
16
|
+
variant.iconColor ? 'bind-icon-color' : 'htw-text-gray-500',
|
|
17
|
+
]"
|
|
18
|
+
/>
|
|
19
|
+
<span>{{ variant.title }}</span>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
package/src/node/tree.spec.ts
CHANGED
|
@@ -25,4 +25,65 @@ describe('makeTree', () => {
|
|
|
25
25
|
{ title: 'hi', index: 0 },
|
|
26
26
|
])
|
|
27
27
|
})
|
|
28
|
+
|
|
29
|
+
test('should handle title conflict', () => {
|
|
30
|
+
const config = getDefaultConfig()
|
|
31
|
+
const files = [
|
|
32
|
+
{ index: 0, path: ['hi'] },
|
|
33
|
+
{ index: 1, path: ['hi'] },
|
|
34
|
+
{ index: 2, path: ['hi'] },
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
const tree = makeTree(config, files)
|
|
38
|
+
|
|
39
|
+
expect(tree).toEqual([
|
|
40
|
+
{ title: 'hi', index: 0 },
|
|
41
|
+
{ title: 'hi-1', index: 1 },
|
|
42
|
+
{ title: 'hi-2', index: 2 },
|
|
43
|
+
])
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('should handle file-folder conflict when folder in first', () => {
|
|
47
|
+
const config = getDefaultConfig()
|
|
48
|
+
const files = [
|
|
49
|
+
{ index: 0, path: ['hi', 'dad'] },
|
|
50
|
+
{ index: 1, path: ['hi'] },
|
|
51
|
+
{ index: 2, path: ['hi', 'mom'] },
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
const tree = makeTree(config, files)
|
|
55
|
+
|
|
56
|
+
expect(tree).toEqual([
|
|
57
|
+
{
|
|
58
|
+
title: 'hi',
|
|
59
|
+
children: [
|
|
60
|
+
{ title: 'dad', index: 0 },
|
|
61
|
+
{ title: 'mom', index: 2 },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
{ title: 'hi-1', index: 1 },
|
|
65
|
+
])
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test('should handle file-folder conflict when file in first', () => {
|
|
69
|
+
const config = getDefaultConfig()
|
|
70
|
+
const files = [
|
|
71
|
+
{ index: 0, path: ['hi'] },
|
|
72
|
+
{ index: 1, path: ['hi', 'dad'] },
|
|
73
|
+
{ index: 2, path: ['hi', 'mom'] },
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
const tree = makeTree(config, files)
|
|
77
|
+
|
|
78
|
+
expect(tree).toEqual([
|
|
79
|
+
{
|
|
80
|
+
title: 'hi',
|
|
81
|
+
children: [
|
|
82
|
+
{ title: 'dad', index: 1 },
|
|
83
|
+
{ title: 'mom', index: 2 },
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
{ title: 'hi-1', index: 0 },
|
|
87
|
+
])
|
|
88
|
+
})
|
|
28
89
|
})
|
package/src/node/tree.ts
CHANGED
|
@@ -51,17 +51,41 @@ export function makeTree (config: HistoireConfig, files: { path: string[], index
|
|
|
51
51
|
|
|
52
52
|
return buildTree(treeObject)
|
|
53
53
|
|
|
54
|
-
// Undefined behavior for folder and file that share the same name under the same directory
|
|
55
54
|
function setPath (path: string[], value: unknown, tree: unknown) {
|
|
56
55
|
path.reduce((subtree, key, i) => {
|
|
57
|
-
if (!subtree[key]) {
|
|
58
|
-
subtree[key] = {}
|
|
59
|
-
}
|
|
60
56
|
if (i === path.length - 1) {
|
|
61
|
-
subtree
|
|
57
|
+
setKey(subtree, key, value)
|
|
58
|
+
} else if (isLeaf(subtree[key])) {
|
|
59
|
+
setKey(subtree, key, subtree[key])
|
|
60
|
+
subtree[key] = {}
|
|
61
|
+
} else if (!subtree[key]) {
|
|
62
|
+
subtree[key] = {}
|
|
62
63
|
}
|
|
63
64
|
return subtree[key]
|
|
64
65
|
}, tree)
|
|
66
|
+
|
|
67
|
+
function isLeaf (element) {
|
|
68
|
+
return !isNaN(element)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function setKey (tree, key, value) {
|
|
73
|
+
if (isUndefined(tree[key])) {
|
|
74
|
+
tree[key] = value
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let copyNumber = 1
|
|
79
|
+
|
|
80
|
+
while (!isUndefined(tree[`${key}-${copyNumber}`])) {
|
|
81
|
+
copyNumber++
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
tree[`${key}-${copyNumber}`] = value
|
|
85
|
+
|
|
86
|
+
function isUndefined (element) {
|
|
87
|
+
return element === undefined
|
|
88
|
+
}
|
|
65
89
|
}
|
|
66
90
|
|
|
67
91
|
function buildTree (treeObject: ITreeObject): Tree {
|