histoire 0.0.2 → 0.0.3
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 +7 -7
- package/dist/client/app/components/StoryVariantSingleView.vue +32 -4
- package/dist/client/app/index.js +6 -0
- package/dist/client/app/index.ts +6 -0
- package/dist/client/app/style/floating-vue.css +31 -0
- package/dist/client/app/style/main.css +2 -1
- package/dist/client/app/util/mapping.js +3 -0
- package/dist/client/app/util/mapping.ts +3 -0
- package/dist/node/commands/dev.js +43 -5
- package/dist/node/config.d.ts +13 -0
- package/dist/node/config.js +34 -0
- package/dist/node/plugin.js +8 -0
- package/dist/style.css +81 -26
- package/package.json +1 -1
- package/src/client/app/App.vue +7 -7
- package/src/client/app/components/StoryVariantSingleView.vue +32 -4
- package/src/client/app/index.ts +6 -0
- package/src/client/app/style/floating-vue.css +31 -0
- package/src/client/app/style/main.css +2 -1
- package/src/client/app/util/mapping.ts +3 -0
- package/src/node/commands/dev.ts +49 -5
- package/src/node/config.ts +48 -1
- package/src/node/plugin.ts +9 -0
package/dist/client/app/App.vue
CHANGED
|
@@ -78,7 +78,7 @@ onKeyboardShortcut(['ctrl+k', 'meta+k'], (event) => {
|
|
|
78
78
|
/>
|
|
79
79
|
</div>
|
|
80
80
|
|
|
81
|
-
<div class="htw-h-screen dark:htw-bg-gray-700 dark:htw-text-
|
|
81
|
+
<div class="htw-h-screen dark:htw-bg-gray-700 dark:htw-text-gray-100">
|
|
82
82
|
<BaseSplitPane
|
|
83
83
|
save-id="main-horiz"
|
|
84
84
|
:min="5"
|
|
@@ -104,11 +104,11 @@ onKeyboardShortcut(['ctrl+k', 'meta+k'], (event) => {
|
|
|
104
104
|
<RouterView />
|
|
105
105
|
</template>
|
|
106
106
|
</BaseSplitPane>
|
|
107
|
-
</div>
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
<SearchModal
|
|
109
|
+
v-if="loadSearch"
|
|
110
|
+
:shown="isSearchOpen"
|
|
111
|
+
@close="isSearchOpen = false"
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
114
|
</template>
|
|
@@ -4,6 +4,7 @@ import { PropType, ref, watch, toRaw, computed } from 'vue'
|
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
5
|
import { Story, Variant } from '../types'
|
|
6
6
|
import { STATE_SYNC } from '../util/const.js'
|
|
7
|
+
import { histoireConfig } from '../util/config.js'
|
|
7
8
|
import BaseSplitPane from './base/BaseSplitPane.vue'
|
|
8
9
|
import HatchedPattern from './misc/HatchedPattern.vue'
|
|
9
10
|
|
|
@@ -85,10 +86,37 @@ const responsiveWidth = ref<number>(undefined)
|
|
|
85
86
|
|
|
86
87
|
<!-- Responsive size -->
|
|
87
88
|
<div class="htw-flex-none htw-flex htw-gap-1 htw-items-center">
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
<VDropdown
|
|
90
|
+
placement="bottom-end"
|
|
91
|
+
:distance="10"
|
|
92
|
+
:skidding="6"
|
|
93
|
+
:disabled="!histoireConfig.responsivePresets?.length"
|
|
94
|
+
>
|
|
95
|
+
<Icon
|
|
96
|
+
icon="ic:baseline-phone-android"
|
|
97
|
+
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
98
|
+
:class="{
|
|
99
|
+
'htw-cursor-pointer hover:htw-text-primary-500': histoireConfig.responsivePresets?.length,
|
|
100
|
+
}"
|
|
101
|
+
/>
|
|
102
|
+
|
|
103
|
+
<template #popper="{ hide }">
|
|
104
|
+
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
105
|
+
<button
|
|
106
|
+
v-for="(preset, index) in histoireConfig.responsivePresets"
|
|
107
|
+
:key="index"
|
|
108
|
+
class="htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700 htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-2"
|
|
109
|
+
:class="{
|
|
110
|
+
'htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black': responsiveWidth === preset.width,
|
|
111
|
+
}"
|
|
112
|
+
@click="responsiveWidth = preset.width;hide()"
|
|
113
|
+
>
|
|
114
|
+
{{ preset.label }}
|
|
115
|
+
<span class="htw-ml-auto htw-opacity-70">{{ preset.width }}px</span>
|
|
116
|
+
</button>
|
|
117
|
+
</div>
|
|
118
|
+
</template>
|
|
119
|
+
</VDropdown>
|
|
92
120
|
|
|
93
121
|
<input
|
|
94
122
|
v-model.number="responsiveWidth"
|
package/dist/client/app/index.js
CHANGED
|
@@ -10,6 +10,12 @@ const app = createApp(App);
|
|
|
10
10
|
app.use(createPinia());
|
|
11
11
|
app.use(FloatingVue, {
|
|
12
12
|
overflowPadding: 4,
|
|
13
|
+
arrowPadding: 8,
|
|
14
|
+
themes: {
|
|
15
|
+
dropdown: {
|
|
16
|
+
computeTransformOrigin: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
13
19
|
});
|
|
14
20
|
app.use(router);
|
|
15
21
|
registerGlobalComponents(app);
|
package/dist/client/app/index.ts
CHANGED
|
@@ -12,6 +12,12 @@ const app = createApp(App)
|
|
|
12
12
|
app.use(createPinia())
|
|
13
13
|
app.use(FloatingVue, {
|
|
14
14
|
overflowPadding: 4,
|
|
15
|
+
arrowPadding: 8,
|
|
16
|
+
themes: {
|
|
17
|
+
dropdown: {
|
|
18
|
+
computeTransformOrigin: true,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
15
21
|
})
|
|
16
22
|
app.use(router)
|
|
17
23
|
registerGlobalComponents(app)
|
|
@@ -1 +1,32 @@
|
|
|
1
1
|
/* @TODO custom themes */
|
|
2
|
+
|
|
3
|
+
.v-popper {
|
|
4
|
+
line-height: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.v-popper--theme-dropdown {
|
|
8
|
+
.htw-dark & {
|
|
9
|
+
.v-popper__inner {
|
|
10
|
+
@apply htw-bg-gray-700 htw-border-gray-850 htw-text-gray-100;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.v-popper__arrow-inner {
|
|
14
|
+
@apply htw-border-gray-700;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.v-popper__arrow-outer {
|
|
18
|
+
@apply htw-border-gray-850;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.v-popper__popper--show-from .v-popper__wrapper {
|
|
23
|
+
transform: scale(.75);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.v-popper__popper--show-to .v-popper__wrapper {
|
|
27
|
+
transform: none;
|
|
28
|
+
transition: transform .15s cubic-bezier(0, 1, .5, 1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
@@ -23,6 +23,9 @@ export function mapFile(file, existingFile) {
|
|
|
23
23
|
variant.slots = existingVariant.slots;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
if (existingFile.story.lastSelectedVariant) {
|
|
27
|
+
result.story.lastSelectedVariant = result.story.variants.find(v => v.id === existingFile.story.lastSelectedVariant.id);
|
|
28
|
+
}
|
|
26
29
|
}
|
|
27
30
|
return result;
|
|
28
31
|
}
|
|
@@ -23,6 +23,9 @@ export function mapFile (file: StoryFile, existingFile?: StoryFile): StoryFile {
|
|
|
23
23
|
if (existingVariant.slots) variant.slots = existingVariant.slots
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
if (existingFile.story.lastSelectedVariant) {
|
|
27
|
+
result.story.lastSelectedVariant = result.story.variants.find(v => v.id === existingFile.story.lastSelectedVariant.id)
|
|
28
|
+
}
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
return result
|
|
@@ -1,9 +1,47 @@
|
|
|
1
|
+
import { resolveConfigFile } from '../config.js';
|
|
1
2
|
import { createContext } from '../context.js';
|
|
2
3
|
import { createServer } from '../server.js';
|
|
4
|
+
import chokidar from 'chokidar';
|
|
5
|
+
import pc from 'picocolors';
|
|
3
6
|
export async function devCommand(options) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
let stop;
|
|
8
|
+
async function start() {
|
|
9
|
+
const ctx = await createContext({
|
|
10
|
+
mode: 'dev',
|
|
11
|
+
});
|
|
12
|
+
const { server, close } = await createServer(ctx, options.port);
|
|
13
|
+
server.printUrls();
|
|
14
|
+
// Histoire config watcher
|
|
15
|
+
let watcher;
|
|
16
|
+
if (server.config.configFile) {
|
|
17
|
+
watcher = chokidar.watch(server.config.configFile, {
|
|
18
|
+
ignoreInitial: true,
|
|
19
|
+
});
|
|
20
|
+
watcher.on('change', () => {
|
|
21
|
+
restart('Vite');
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return async () => {
|
|
25
|
+
await watcher?.close();
|
|
26
|
+
await close();
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async function restart(source) {
|
|
30
|
+
if (stop) {
|
|
31
|
+
console.log(pc.blue(`${source} config changed, restarting...`));
|
|
32
|
+
stop();
|
|
33
|
+
stop = null; // Don't call stop again until new start() is done
|
|
34
|
+
stop = await start();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
stop = await start();
|
|
38
|
+
const configFile = await resolveConfigFile();
|
|
39
|
+
if (configFile) {
|
|
40
|
+
const watcher = chokidar.watch(configFile, {
|
|
41
|
+
ignoreInitial: true,
|
|
42
|
+
});
|
|
43
|
+
watcher.on('change', () => {
|
|
44
|
+
restart('Histoire');
|
|
45
|
+
});
|
|
46
|
+
}
|
|
9
47
|
}
|
package/dist/node/config.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { UserConfig as ViteConfig } from 'vite';
|
|
1
2
|
import { TreeFile } from './tree.js';
|
|
2
3
|
declare type CustomizableColors = 'primary' | 'gray';
|
|
3
4
|
declare type ColorKeys = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
|
|
4
5
|
declare type GrayColorKeys = ColorKeys | '750' | '850' | '950';
|
|
6
|
+
interface ResponsivePreset {
|
|
7
|
+
label: string;
|
|
8
|
+
width: number;
|
|
9
|
+
}
|
|
5
10
|
export interface HistoireConfig {
|
|
6
11
|
/**
|
|
7
12
|
* Output directory.
|
|
@@ -83,6 +88,14 @@ export interface HistoireConfig {
|
|
|
83
88
|
* Example: `'/src/histoire-setup.ts'`
|
|
84
89
|
*/
|
|
85
90
|
setupFile?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Predefined responsive sizes for story playgrounds.
|
|
93
|
+
*/
|
|
94
|
+
responsivePresets?: ResponsivePreset[];
|
|
95
|
+
/**
|
|
96
|
+
* Vite config override
|
|
97
|
+
*/
|
|
98
|
+
vite?: ViteConfig;
|
|
86
99
|
}
|
|
87
100
|
export declare function getDefaultConfig(): HistoireConfig;
|
|
88
101
|
export declare const configFileNames: string[];
|
package/dist/node/config.js
CHANGED
|
@@ -22,6 +22,40 @@ export function getDefaultConfig() {
|
|
|
22
22
|
gray: defaultColors.zinc,
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
|
+
responsivePresets: [
|
|
26
|
+
{
|
|
27
|
+
label: 'Mobile (Small)',
|
|
28
|
+
width: 320,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: 'Mobile (Medium)',
|
|
32
|
+
width: 375,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: 'Mobile (Large)',
|
|
36
|
+
width: 425,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: 'Tablet',
|
|
40
|
+
width: 768,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: 'Laptop (Small)',
|
|
44
|
+
width: 1024,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: 'Laptop (Large)',
|
|
48
|
+
width: 1440,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: 'Desktop',
|
|
52
|
+
width: 1920,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: '4K',
|
|
56
|
+
width: 3840,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
25
59
|
};
|
|
26
60
|
}
|
|
27
61
|
export const configFileNames = [
|
package/dist/node/plugin.js
CHANGED
|
@@ -20,6 +20,14 @@ export async function createVitePlugins(ctx) {
|
|
|
20
20
|
if (!hasVuePlugin) {
|
|
21
21
|
plugins.push((await import('@vitejs/plugin-vue')).default());
|
|
22
22
|
}
|
|
23
|
+
if (ctx.config.vite) {
|
|
24
|
+
plugins.push({
|
|
25
|
+
name: 'histoire-vite-config-override',
|
|
26
|
+
config() {
|
|
27
|
+
return ctx.config.vite;
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
23
31
|
plugins.push({
|
|
24
32
|
name: 'histoire-vite-plugin',
|
|
25
33
|
config() {
|
package/dist/style.css
CHANGED
|
@@ -212,6 +212,38 @@
|
|
|
212
212
|
|
|
213
213
|
/* @TODO custom themes */
|
|
214
214
|
|
|
215
|
+
.v-popper {
|
|
216
|
+
line-height: 0;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.htw-dark .v-popper--theme-dropdown .v-popper__inner{
|
|
220
|
+
--tw-border-opacity:1;
|
|
221
|
+
border-color:rgb(var(--_histoire-color-gray-850) / var(--tw-border-opacity));
|
|
222
|
+
--tw-bg-opacity:1;
|
|
223
|
+
background-color:rgb(var(--_histoire-color-gray-700) / var(--tw-bg-opacity));
|
|
224
|
+
--tw-text-opacity:1;
|
|
225
|
+
color:rgb(var(--_histoire-color-gray-100) / var(--tw-text-opacity))
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.htw-dark .v-popper--theme-dropdown .v-popper__arrow-inner{
|
|
229
|
+
--tw-border-opacity:1;
|
|
230
|
+
border-color:rgb(var(--_histoire-color-gray-700) / var(--tw-border-opacity))
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.htw-dark .v-popper--theme-dropdown .v-popper__arrow-outer{
|
|
234
|
+
--tw-border-opacity:1;
|
|
235
|
+
border-color:rgb(var(--_histoire-color-gray-850) / var(--tw-border-opacity))
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.v-popper--theme-dropdown.v-popper__popper--show-from .v-popper__wrapper {
|
|
239
|
+
transform: scale(.75);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.v-popper--theme-dropdown.v-popper__popper--show-to .v-popper__wrapper {
|
|
243
|
+
transform: none;
|
|
244
|
+
transition: transform .15s cubic-bezier(0, 1, .5, 1);
|
|
245
|
+
}
|
|
246
|
+
|
|
215
247
|
*,
|
|
216
248
|
::before,
|
|
217
249
|
::after {
|
|
@@ -222,7 +254,8 @@
|
|
|
222
254
|
}
|
|
223
255
|
|
|
224
256
|
a,
|
|
225
|
-
input
|
|
257
|
+
input,
|
|
258
|
+
button {
|
|
226
259
|
color: inherit;
|
|
227
260
|
}
|
|
228
261
|
|
|
@@ -390,14 +423,14 @@ button {
|
|
|
390
423
|
margin:1rem
|
|
391
424
|
}
|
|
392
425
|
|
|
393
|
-
.htw-mt-2{
|
|
394
|
-
margin-top:0.5rem
|
|
395
|
-
}
|
|
396
|
-
|
|
397
426
|
.htw-ml-auto{
|
|
398
427
|
margin-left:auto
|
|
399
428
|
}
|
|
400
429
|
|
|
430
|
+
.htw-mt-2{
|
|
431
|
+
margin-top:0.5rem
|
|
432
|
+
}
|
|
433
|
+
|
|
401
434
|
.htw-mt-0\.5{
|
|
402
435
|
margin-top:0.125rem
|
|
403
436
|
}
|
|
@@ -560,6 +593,10 @@ button {
|
|
|
560
593
|
align-items:center
|
|
561
594
|
}
|
|
562
595
|
|
|
596
|
+
.htw-items-stretch{
|
|
597
|
+
align-items:stretch
|
|
598
|
+
}
|
|
599
|
+
|
|
563
600
|
.htw-justify-center{
|
|
564
601
|
justify-content:center
|
|
565
602
|
}
|
|
@@ -717,6 +754,11 @@ button {
|
|
|
717
754
|
background-color:rgb(255 255 255 / var(--tw-bg-opacity))
|
|
718
755
|
}
|
|
719
756
|
|
|
757
|
+
.htw-bg-primary-500{
|
|
758
|
+
--tw-bg-opacity:1;
|
|
759
|
+
background-color:rgb(var(--_histoire-color-primary-500) / var(--tw-bg-opacity))
|
|
760
|
+
}
|
|
761
|
+
|
|
720
762
|
.htw-bg-gray-200{
|
|
721
763
|
--tw-bg-opacity:1;
|
|
722
764
|
background-color:rgb(var(--_histoire-color-gray-200) / var(--tw-bg-opacity))
|
|
@@ -732,11 +774,6 @@ button {
|
|
|
732
774
|
background-color:rgb(var(--_histoire-color-gray-500) / var(--tw-bg-opacity))
|
|
733
775
|
}
|
|
734
776
|
|
|
735
|
-
.htw-bg-primary-500{
|
|
736
|
-
--tw-bg-opacity:1;
|
|
737
|
-
background-color:rgb(var(--_histoire-color-primary-500) / var(--tw-bg-opacity))
|
|
738
|
-
}
|
|
739
|
-
|
|
740
777
|
.htw-bg-primary-500\/25{
|
|
741
778
|
background-color:rgb(var(--_histoire-color-primary-500) / 0.25)
|
|
742
779
|
}
|
|
@@ -796,16 +833,21 @@ button {
|
|
|
796
833
|
padding-bottom:0px
|
|
797
834
|
}
|
|
798
835
|
|
|
799
|
-
.htw-px-1{
|
|
800
|
-
padding-left:0.25rem;
|
|
801
|
-
padding-right:0.25rem
|
|
802
|
-
}
|
|
803
|
-
|
|
804
836
|
.htw-px-4{
|
|
805
837
|
padding-left:1rem;
|
|
806
838
|
padding-right:1rem
|
|
807
839
|
}
|
|
808
840
|
|
|
841
|
+
.htw-py-3{
|
|
842
|
+
padding-top:0.75rem;
|
|
843
|
+
padding-bottom:0.75rem
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
.htw-px-1{
|
|
847
|
+
padding-left:0.25rem;
|
|
848
|
+
padding-right:0.25rem
|
|
849
|
+
}
|
|
850
|
+
|
|
809
851
|
.htw-py-4{
|
|
810
852
|
padding-top:1rem;
|
|
811
853
|
padding-bottom:1rem
|
|
@@ -845,6 +887,10 @@ button {
|
|
|
845
887
|
padding-right:1.5rem
|
|
846
888
|
}
|
|
847
889
|
|
|
890
|
+
.htw-text-left{
|
|
891
|
+
text-align:left
|
|
892
|
+
}
|
|
893
|
+
|
|
848
894
|
.htw-text-center{
|
|
849
895
|
text-align:center
|
|
850
896
|
}
|
|
@@ -883,6 +929,11 @@ button {
|
|
|
883
929
|
color:rgb(var(--_histoire-color-primary-800) / var(--tw-text-opacity))
|
|
884
930
|
}
|
|
885
931
|
|
|
932
|
+
.htw-text-white{
|
|
933
|
+
--tw-text-opacity:1;
|
|
934
|
+
color:rgb(255 255 255 / var(--tw-text-opacity))
|
|
935
|
+
}
|
|
936
|
+
|
|
886
937
|
.htw-text-black\/\[2\%\]{
|
|
887
938
|
color:rgb(0 0 0 / 2%)
|
|
888
939
|
}
|
|
@@ -892,11 +943,6 @@ button {
|
|
|
892
943
|
color:rgb(var(--_histoire-color-gray-400) / var(--tw-text-opacity))
|
|
893
944
|
}
|
|
894
945
|
|
|
895
|
-
.htw-text-white{
|
|
896
|
-
--tw-text-opacity:1;
|
|
897
|
-
color:rgb(255 255 255 / var(--tw-text-opacity))
|
|
898
|
-
}
|
|
899
|
-
|
|
900
946
|
.htw-opacity-25{
|
|
901
947
|
opacity:0.25
|
|
902
948
|
}
|
|
@@ -913,6 +959,10 @@ button {
|
|
|
913
959
|
opacity:0.5
|
|
914
960
|
}
|
|
915
961
|
|
|
962
|
+
.htw-opacity-70{
|
|
963
|
+
opacity:0.7
|
|
964
|
+
}
|
|
965
|
+
|
|
916
966
|
.htw-opacity-60{
|
|
917
967
|
opacity:0.6
|
|
918
968
|
}
|
|
@@ -1058,9 +1108,9 @@ body,
|
|
|
1058
1108
|
background-color:rgb(var(--_histoire-color-gray-700) / 0.8)
|
|
1059
1109
|
}
|
|
1060
1110
|
|
|
1061
|
-
.htw-dark .dark\:htw-text-
|
|
1111
|
+
.htw-dark .dark\:htw-text-gray-100{
|
|
1062
1112
|
--tw-text-opacity:1;
|
|
1063
|
-
color:rgb(
|
|
1113
|
+
color:rgb(var(--_histoire-color-gray-100) / var(--tw-text-opacity))
|
|
1064
1114
|
}
|
|
1065
1115
|
|
|
1066
1116
|
.htw-dark .dark\:htw-text-primary-200{
|
|
@@ -1068,15 +1118,15 @@ body,
|
|
|
1068
1118
|
color:rgb(var(--_histoire-color-primary-200) / var(--tw-text-opacity))
|
|
1069
1119
|
}
|
|
1070
1120
|
|
|
1071
|
-
.htw-dark .dark\:htw-text-white\/\[2\%\]{
|
|
1072
|
-
color:rgb(255 255 255 / 2%)
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
1121
|
.htw-dark .dark\:htw-text-black{
|
|
1076
1122
|
--tw-text-opacity:1;
|
|
1077
1123
|
color:rgb(0 0 0 / var(--tw-text-opacity))
|
|
1078
1124
|
}
|
|
1079
1125
|
|
|
1126
|
+
.htw-dark .dark\:htw-text-white\/\[2\%\]{
|
|
1127
|
+
color:rgb(255 255 255 / 2%)
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1080
1130
|
.htw-dark .dark\:hover\:htw-bg-primary-900:hover{
|
|
1081
1131
|
--tw-bg-opacity:1;
|
|
1082
1132
|
background-color:rgb(var(--_histoire-color-primary-900) / var(--tw-bg-opacity))
|
|
@@ -1092,6 +1142,11 @@ body,
|
|
|
1092
1142
|
background-color:rgb(var(--_histoire-color-primary-800) / var(--tw-bg-opacity))
|
|
1093
1143
|
}
|
|
1094
1144
|
|
|
1145
|
+
.htw-dark .dark\:hover\:htw-bg-primary-700:hover{
|
|
1146
|
+
--tw-bg-opacity:1;
|
|
1147
|
+
background-color:rgb(var(--_histoire-color-primary-700) / var(--tw-bg-opacity))
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1095
1150
|
.htw-dark .dark\:hover\:htw-text-primary-400:hover{
|
|
1096
1151
|
--tw-text-opacity:1;
|
|
1097
1152
|
color:rgb(var(--_histoire-color-primary-400) / var(--tw-text-opacity))
|
package/package.json
CHANGED
package/src/client/app/App.vue
CHANGED
|
@@ -78,7 +78,7 @@ onKeyboardShortcut(['ctrl+k', 'meta+k'], (event) => {
|
|
|
78
78
|
/>
|
|
79
79
|
</div>
|
|
80
80
|
|
|
81
|
-
<div class="htw-h-screen dark:htw-bg-gray-700 dark:htw-text-
|
|
81
|
+
<div class="htw-h-screen dark:htw-bg-gray-700 dark:htw-text-gray-100">
|
|
82
82
|
<BaseSplitPane
|
|
83
83
|
save-id="main-horiz"
|
|
84
84
|
:min="5"
|
|
@@ -104,11 +104,11 @@ onKeyboardShortcut(['ctrl+k', 'meta+k'], (event) => {
|
|
|
104
104
|
<RouterView />
|
|
105
105
|
</template>
|
|
106
106
|
</BaseSplitPane>
|
|
107
|
-
</div>
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
<SearchModal
|
|
109
|
+
v-if="loadSearch"
|
|
110
|
+
:shown="isSearchOpen"
|
|
111
|
+
@close="isSearchOpen = false"
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
114
|
</template>
|
|
@@ -4,6 +4,7 @@ import { PropType, ref, watch, toRaw, computed } from 'vue'
|
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
5
|
import { Story, Variant } from '../types'
|
|
6
6
|
import { STATE_SYNC } from '../util/const.js'
|
|
7
|
+
import { histoireConfig } from '../util/config.js'
|
|
7
8
|
import BaseSplitPane from './base/BaseSplitPane.vue'
|
|
8
9
|
import HatchedPattern from './misc/HatchedPattern.vue'
|
|
9
10
|
|
|
@@ -85,10 +86,37 @@ const responsiveWidth = ref<number>(undefined)
|
|
|
85
86
|
|
|
86
87
|
<!-- Responsive size -->
|
|
87
88
|
<div class="htw-flex-none htw-flex htw-gap-1 htw-items-center">
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
<VDropdown
|
|
90
|
+
placement="bottom-end"
|
|
91
|
+
:distance="10"
|
|
92
|
+
:skidding="6"
|
|
93
|
+
:disabled="!histoireConfig.responsivePresets?.length"
|
|
94
|
+
>
|
|
95
|
+
<Icon
|
|
96
|
+
icon="ic:baseline-phone-android"
|
|
97
|
+
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
98
|
+
:class="{
|
|
99
|
+
'htw-cursor-pointer hover:htw-text-primary-500': histoireConfig.responsivePresets?.length,
|
|
100
|
+
}"
|
|
101
|
+
/>
|
|
102
|
+
|
|
103
|
+
<template #popper="{ hide }">
|
|
104
|
+
<div class="htw-flex htw-flex-col htw-items-stretch">
|
|
105
|
+
<button
|
|
106
|
+
v-for="(preset, index) in histoireConfig.responsivePresets"
|
|
107
|
+
:key="index"
|
|
108
|
+
class="htw-bg-transparent hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700 htw-px-4 htw-py-3 htw-cursor-pointer htw-text-left htw-flex htw-gap-2"
|
|
109
|
+
:class="{
|
|
110
|
+
'htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black': responsiveWidth === preset.width,
|
|
111
|
+
}"
|
|
112
|
+
@click="responsiveWidth = preset.width;hide()"
|
|
113
|
+
>
|
|
114
|
+
{{ preset.label }}
|
|
115
|
+
<span class="htw-ml-auto htw-opacity-70">{{ preset.width }}px</span>
|
|
116
|
+
</button>
|
|
117
|
+
</div>
|
|
118
|
+
</template>
|
|
119
|
+
</VDropdown>
|
|
92
120
|
|
|
93
121
|
<input
|
|
94
122
|
v-model.number="responsiveWidth"
|
package/src/client/app/index.ts
CHANGED
|
@@ -12,6 +12,12 @@ const app = createApp(App)
|
|
|
12
12
|
app.use(createPinia())
|
|
13
13
|
app.use(FloatingVue, {
|
|
14
14
|
overflowPadding: 4,
|
|
15
|
+
arrowPadding: 8,
|
|
16
|
+
themes: {
|
|
17
|
+
dropdown: {
|
|
18
|
+
computeTransformOrigin: true,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
15
21
|
})
|
|
16
22
|
app.use(router)
|
|
17
23
|
registerGlobalComponents(app)
|
|
@@ -1 +1,32 @@
|
|
|
1
1
|
/* @TODO custom themes */
|
|
2
|
+
|
|
3
|
+
.v-popper {
|
|
4
|
+
line-height: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.v-popper--theme-dropdown {
|
|
8
|
+
.htw-dark & {
|
|
9
|
+
.v-popper__inner {
|
|
10
|
+
@apply htw-bg-gray-700 htw-border-gray-850 htw-text-gray-100;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.v-popper__arrow-inner {
|
|
14
|
+
@apply htw-border-gray-700;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.v-popper__arrow-outer {
|
|
18
|
+
@apply htw-border-gray-850;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.v-popper__popper--show-from .v-popper__wrapper {
|
|
23
|
+
transform: scale(.75);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.v-popper__popper--show-to .v-popper__wrapper {
|
|
27
|
+
transform: none;
|
|
28
|
+
transition: transform .15s cubic-bezier(0, 1, .5, 1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
@@ -23,6 +23,9 @@ export function mapFile (file: StoryFile, existingFile?: StoryFile): StoryFile {
|
|
|
23
23
|
if (existingVariant.slots) variant.slots = existingVariant.slots
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
if (existingFile.story.lastSelectedVariant) {
|
|
27
|
+
result.story.lastSelectedVariant = result.story.variants.find(v => v.id === existingFile.story.lastSelectedVariant.id)
|
|
28
|
+
}
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
return result
|
package/src/node/commands/dev.ts
CHANGED
|
@@ -1,14 +1,58 @@
|
|
|
1
|
+
import { resolveConfigFile } from '../config.js'
|
|
1
2
|
import { createContext } from '../context.js'
|
|
2
3
|
import { createServer } from '../server.js'
|
|
4
|
+
import chokidar from 'chokidar'
|
|
5
|
+
import pc from 'picocolors'
|
|
3
6
|
|
|
4
7
|
export interface DevOptions {
|
|
5
8
|
port: number
|
|
6
9
|
}
|
|
7
10
|
|
|
8
11
|
export async function devCommand (options: DevOptions) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
let stop: () => Promise<void>
|
|
13
|
+
|
|
14
|
+
async function start () {
|
|
15
|
+
const ctx = await createContext({
|
|
16
|
+
mode: 'dev',
|
|
17
|
+
})
|
|
18
|
+
const { server, close } = await createServer(ctx, options.port)
|
|
19
|
+
server.printUrls()
|
|
20
|
+
|
|
21
|
+
// Histoire config watcher
|
|
22
|
+
let watcher: chokidar.FSWatcher
|
|
23
|
+
if (server.config.configFile) {
|
|
24
|
+
watcher = chokidar.watch(server.config.configFile, {
|
|
25
|
+
ignoreInitial: true,
|
|
26
|
+
})
|
|
27
|
+
watcher.on('change', () => {
|
|
28
|
+
restart('Vite')
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return async () => {
|
|
33
|
+
await watcher?.close()
|
|
34
|
+
await close()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function restart (source: string) {
|
|
39
|
+
if (stop) {
|
|
40
|
+
console.log(pc.blue(`${source} config changed, restarting...`))
|
|
41
|
+
stop()
|
|
42
|
+
stop = null // Don't call stop again until new start() is done
|
|
43
|
+
stop = await start()
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
stop = await start()
|
|
48
|
+
|
|
49
|
+
const configFile = await resolveConfigFile()
|
|
50
|
+
if (configFile) {
|
|
51
|
+
const watcher = chokidar.watch(configFile, {
|
|
52
|
+
ignoreInitial: true,
|
|
53
|
+
})
|
|
54
|
+
watcher.on('change', () => {
|
|
55
|
+
restart('Histoire')
|
|
56
|
+
})
|
|
57
|
+
}
|
|
14
58
|
}
|
package/src/node/config.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'pathe'
|
|
2
2
|
import fs from 'fs'
|
|
3
3
|
import defu from 'defu'
|
|
4
|
-
import { createServer, resolveConfig as resolveViteConfig } from 'vite'
|
|
4
|
+
import { createServer, resolveConfig as resolveViteConfig, UserConfig as ViteConfig } from 'vite'
|
|
5
5
|
import { ViteNodeServer } from 'vite-node/server'
|
|
6
6
|
import { ViteNodeRunner } from 'vite-node/client'
|
|
7
7
|
import pc from 'picocolors'
|
|
@@ -12,6 +12,11 @@ type CustomizableColors = 'primary' | 'gray'
|
|
|
12
12
|
type ColorKeys = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'
|
|
13
13
|
type GrayColorKeys = ColorKeys | '750' | '850' | '950'
|
|
14
14
|
|
|
15
|
+
interface ResponsivePreset {
|
|
16
|
+
label: string
|
|
17
|
+
width: number
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
export interface HistoireConfig {
|
|
16
21
|
/**
|
|
17
22
|
* Output directory.
|
|
@@ -93,6 +98,14 @@ export interface HistoireConfig {
|
|
|
93
98
|
* Example: `'/src/histoire-setup.ts'`
|
|
94
99
|
*/
|
|
95
100
|
setupFile?: string
|
|
101
|
+
/**
|
|
102
|
+
* Predefined responsive sizes for story playgrounds.
|
|
103
|
+
*/
|
|
104
|
+
responsivePresets?: ResponsivePreset[]
|
|
105
|
+
/**
|
|
106
|
+
* Vite config override
|
|
107
|
+
*/
|
|
108
|
+
vite?: ViteConfig
|
|
96
109
|
}
|
|
97
110
|
|
|
98
111
|
export function getDefaultConfig (): HistoireConfig {
|
|
@@ -111,6 +124,40 @@ export function getDefaultConfig (): HistoireConfig {
|
|
|
111
124
|
gray: defaultColors.zinc,
|
|
112
125
|
},
|
|
113
126
|
},
|
|
127
|
+
responsivePresets: [
|
|
128
|
+
{
|
|
129
|
+
label: 'Mobile (Small)',
|
|
130
|
+
width: 320,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
label: 'Mobile (Medium)',
|
|
134
|
+
width: 375,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
label: 'Mobile (Large)',
|
|
138
|
+
width: 425,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
label: 'Tablet',
|
|
142
|
+
width: 768,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
label: 'Laptop (Small)',
|
|
146
|
+
width: 1024,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
label: 'Laptop (Large)',
|
|
150
|
+
width: 1440,
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
label: 'Desktop',
|
|
154
|
+
width: 1920,
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
label: '4K',
|
|
158
|
+
width: 3840,
|
|
159
|
+
},
|
|
160
|
+
],
|
|
114
161
|
}
|
|
115
162
|
}
|
|
116
163
|
|
package/src/node/plugin.ts
CHANGED
|
@@ -26,6 +26,15 @@ export async function createVitePlugins (ctx: Context): Promise<VitePlugin[]> {
|
|
|
26
26
|
plugins.push((await import('@vitejs/plugin-vue')).default())
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
if (ctx.config.vite) {
|
|
30
|
+
plugins.push({
|
|
31
|
+
name: 'histoire-vite-config-override',
|
|
32
|
+
config () {
|
|
33
|
+
return ctx.config.vite
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
29
38
|
plugins.push({
|
|
30
39
|
name: 'histoire-vite-plugin',
|
|
31
40
|
|