histoire 0.2.1 → 0.2.4
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/codegen/vue3.js +11 -1
- package/dist/client/app/codegen/vue3.ts +9 -1
- package/dist/client/app/components/app/AppHeader.vue +3 -3
- package/dist/client/app/components/base/BaseListItemLink.vue +1 -1
- package/dist/client/app/components/base/BaseTab.vue +1 -1
- package/dist/client/app/components/exposed/Story.vue +25 -14
- package/dist/client/app/components/exposed/Variant.vue +7 -0
- package/dist/client/app/components/search/SearchModal.vue +7 -6
- package/dist/client/app/components/story/StoryResponsivePreview.vue +72 -77
- package/dist/client/app/components/story/StorySidePanel.vue +1 -1
- package/dist/client/app/components/story/StorySourceCode.vue +3 -17
- package/dist/client/app/components/story/StoryVariantGrid.vue +112 -0
- package/dist/client/app/components/story/StoryVariantGridItem.vue +36 -6
- package/dist/client/app/components/story/StoryVariantSingleView.vue +10 -11
- package/dist/client/app/components/story/StoryViewer.vue +7 -42
- package/dist/client/app/components/story/{variant → toolbar}/StoryVariantBackground.vue +4 -4
- package/{src/client/app/components/story/variant → dist/client/app/components/story/toolbar}/StoryVariantNewTab.vue +2 -2
- package/dist/client/app/components/story/{variant → toolbar}/StoryVariantResponsiveSize.vue +5 -5
- package/dist/client/app/components/story/{variant → toolbar}/StoryVariantTitle.vue +0 -0
- package/dist/client/app/stores/preview-settings.d.ts +8 -0
- package/dist/client/app/stores/preview-settings.js +14 -0
- package/dist/client/app/stores/preview-settings.ts +17 -0
- package/dist/client/app/stores/story.d.ts +45 -15
- package/dist/client/app/style/main.pcss +4 -0
- package/dist/client/app/types.d.ts +10 -1
- package/dist/client/app/types.ts +11 -1
- package/dist/client/app/util/mapping.js +10 -9
- package/dist/client/app/util/mapping.ts +10 -5
- package/dist/client/app/util/preview-settings.d.ts +1 -8
- package/dist/client/app/util/preview-settings.js +0 -10
- package/dist/client/app/util/preview-settings.ts +1 -19
- package/dist/client/app/util/scroll.d.ts +3 -1
- package/dist/client/app/util/scroll.js +3 -0
- package/dist/client/app/util/scroll.ts +4 -0
- package/dist/node/config.d.ts +2 -2
- package/dist/node/plugin.js +14 -6
- package/dist/style.css +67 -4
- package/package.json +21 -21
- package/src/client/app/App.vue +1 -1
- package/src/client/app/codegen/vue3.ts +9 -1
- package/src/client/app/components/app/AppHeader.vue +3 -3
- package/src/client/app/components/base/BaseListItemLink.vue +1 -1
- package/src/client/app/components/base/BaseTab.vue +1 -1
- package/src/client/app/components/exposed/Story.vue +25 -14
- package/src/client/app/components/exposed/Variant.vue +7 -0
- package/src/client/app/components/search/SearchModal.vue +7 -6
- package/src/client/app/components/story/StoryResponsivePreview.vue +72 -77
- package/src/client/app/components/story/StorySidePanel.vue +1 -1
- package/src/client/app/components/story/StorySourceCode.vue +3 -17
- package/src/client/app/components/story/StoryVariantGrid.vue +112 -0
- package/src/client/app/components/story/StoryVariantGridItem.vue +36 -6
- package/src/client/app/components/story/StoryVariantSingleView.vue +10 -11
- package/src/client/app/components/story/StoryViewer.vue +7 -42
- package/src/client/app/components/story/{variant → toolbar}/StoryVariantBackground.vue +4 -4
- package/{dist/client/app/components/story/variant → src/client/app/components/story/toolbar}/StoryVariantNewTab.vue +2 -2
- package/src/client/app/components/story/{variant → toolbar}/StoryVariantResponsiveSize.vue +5 -5
- package/src/client/app/components/story/{variant → toolbar}/StoryVariantTitle.vue +0 -0
- package/src/client/app/stores/preview-settings.ts +17 -0
- package/src/client/app/style/main.pcss +4 -0
- package/src/client/app/types.ts +11 -1
- package/src/client/app/util/mapping.ts +10 -5
- package/src/client/app/util/preview-settings.ts +1 -19
- package/src/client/app/util/scroll.ts +4 -0
- package/src/node/config.ts +2 -2
- package/src/node/plugin.ts +15 -6
- package/tsconfig.json +2 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { Icon } from '@iconify/vue'
|
|
3
|
+
import { usePreviewSettingsStore } from '../../../stores/preview-settings'
|
|
3
4
|
import { histoireConfig } from '../../../util/config'
|
|
4
|
-
import { usePreviewSettings } from '../../../util/preview-settings'
|
|
5
5
|
import BaseCheckbox from '../../base/BaseCheckbox.vue'
|
|
6
6
|
|
|
7
|
-
const settings =
|
|
7
|
+
const settings = usePreviewSettingsStore().currentSettings
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
10
|
<template>
|
|
@@ -17,18 +17,18 @@ const settings = usePreviewSettings()
|
|
|
17
17
|
>
|
|
18
18
|
<div
|
|
19
19
|
v-tooltip="'Responsive sizes'"
|
|
20
|
-
class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2"
|
|
20
|
+
class="htw-flex htw-items-center htw-gap-1 htw-h-full htw-px-2 htw-group"
|
|
21
21
|
:class="{
|
|
22
22
|
'htw-cursor-pointer hover:htw-text-primary-500': histoireConfig.responsivePresets?.length,
|
|
23
23
|
}"
|
|
24
24
|
>
|
|
25
25
|
<Icon
|
|
26
26
|
icon="carbon:devices"
|
|
27
|
-
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
27
|
+
class="htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
|
|
28
28
|
/>
|
|
29
29
|
<Icon
|
|
30
30
|
icon="carbon:caret-down"
|
|
31
|
-
class="htw-w-4 htw-h-4 htw-opacity-50"
|
|
31
|
+
class="htw-w-4 htw-h-4 htw-opacity-50 group-hover:htw-opacity-100"
|
|
32
32
|
/>
|
|
33
33
|
</div>
|
|
34
34
|
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { useStorage } from '@vueuse/core'
|
|
3
|
+
import type { PreviewSettings } from '../types'
|
|
4
|
+
|
|
5
|
+
export const usePreviewSettingsStore = defineStore('preview-settings', () => {
|
|
6
|
+
const currentSettings = useStorage<PreviewSettings>('_histoire-sandbox-settings-v2', {
|
|
7
|
+
responsiveWidth: 720,
|
|
8
|
+
responsiveHeight: null,
|
|
9
|
+
rotate: false,
|
|
10
|
+
backgroundColor: 'transparent',
|
|
11
|
+
checkerboard: false,
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
currentSettings,
|
|
16
|
+
}
|
|
17
|
+
})
|
package/src/client/app/types.ts
CHANGED
|
@@ -33,7 +33,9 @@ export interface Variant {
|
|
|
33
33
|
slots?: () => Readonly<any>
|
|
34
34
|
state?: any
|
|
35
35
|
source?: string
|
|
36
|
-
|
|
36
|
+
responsiveDisabled?: boolean
|
|
37
|
+
configReady?: boolean
|
|
38
|
+
previewReady?: boolean
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
export type TreeLeaf = {
|
|
@@ -58,3 +60,11 @@ export interface SearchResult {
|
|
|
58
60
|
icon?: string
|
|
59
61
|
iconColor?: string
|
|
60
62
|
}
|
|
63
|
+
|
|
64
|
+
export interface PreviewSettings {
|
|
65
|
+
responsiveWidth: number
|
|
66
|
+
responsiveHeight: number
|
|
67
|
+
rotate: boolean
|
|
68
|
+
backgroundColor: string
|
|
69
|
+
checkerboard: boolean
|
|
70
|
+
}
|
|
@@ -18,10 +18,15 @@ export function mapFile (file: StoryFile, existingFile?: StoryFile): StoryFile {
|
|
|
18
18
|
const variant = result.story.variants[index]
|
|
19
19
|
const existingVariant = existingFile.story.variants[index]
|
|
20
20
|
if (existingVariant) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
for (const key in existingVariant) {
|
|
22
|
+
if (typeof existingVariant[key] !== 'undefined') {
|
|
23
|
+
if (key === 'state') {
|
|
24
|
+
Object.assign(variant.state, existingVariant.state)
|
|
25
|
+
continue
|
|
26
|
+
}
|
|
27
|
+
variant[key] = existingVariant[key]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
if (existingFile.story.lastSelectedVariant) {
|
|
@@ -38,6 +43,6 @@ export function mapVariant (variant: Variant): Variant {
|
|
|
38
43
|
state: {},
|
|
39
44
|
initState: null,
|
|
40
45
|
slots: () => ({}),
|
|
41
|
-
|
|
46
|
+
previewReady: false,
|
|
42
47
|
}
|
|
43
48
|
}
|
|
@@ -1,23 +1,5 @@
|
|
|
1
|
-
import { useStorage } from '@vueuse/core'
|
|
2
1
|
import { reactive } from 'vue'
|
|
3
|
-
|
|
4
|
-
export interface PreviewSettings {
|
|
5
|
-
responsiveWidth: number
|
|
6
|
-
responsiveHeight: number
|
|
7
|
-
rotate: boolean
|
|
8
|
-
backgroundColor: string
|
|
9
|
-
checkerboard: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function usePreviewSettings () {
|
|
13
|
-
return useStorage<PreviewSettings>('_histoire-sandbox-settings-v1', {
|
|
14
|
-
responsiveWidth: 720,
|
|
15
|
-
responsiveHeight: null,
|
|
16
|
-
rotate: false,
|
|
17
|
-
backgroundColor: 'transparent',
|
|
18
|
-
checkerboard: false,
|
|
19
|
-
})
|
|
20
|
-
}
|
|
2
|
+
import type { PreviewSettings } from '../types'
|
|
21
3
|
|
|
22
4
|
export const receivedSettings = reactive<PreviewSettings>({} as PreviewSettings)
|
|
23
5
|
|
package/src/node/config.ts
CHANGED
|
@@ -77,7 +77,7 @@ export interface HistoireConfig {
|
|
|
77
77
|
dark?: string
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
|
-
* Href to the favicon file (**not** processed by Vite). Put the file in the public directory.
|
|
80
|
+
* Href to the favicon file (**not** processed by Vite). Put the file in the `public` directory.
|
|
81
81
|
*
|
|
82
82
|
* Example: `'/favicon.ico'`
|
|
83
83
|
*/
|
|
@@ -102,7 +102,7 @@ export interface HistoireConfig {
|
|
|
102
102
|
logoHref?: string
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
|
-
* Setup file
|
|
105
|
+
* Setup file exporting a default function executed when setting up each story preview.
|
|
106
106
|
*
|
|
107
107
|
* Import custom CSS files from this file.
|
|
108
108
|
*
|
package/src/node/plugin.ts
CHANGED
|
@@ -149,10 +149,10 @@ if (import.meta.hot) {
|
|
|
149
149
|
},
|
|
150
150
|
|
|
151
151
|
configureServer (server) {
|
|
152
|
-
server.middlewares.use((req, res, next) => {
|
|
152
|
+
server.middlewares.use(async (req, res, next) => {
|
|
153
153
|
if (req.url!.startsWith('/__sandbox')) {
|
|
154
154
|
res.statusCode = 200
|
|
155
|
-
|
|
155
|
+
let html = `
|
|
156
156
|
<!DOCTYPE html>
|
|
157
157
|
<html>
|
|
158
158
|
<head>
|
|
@@ -174,7 +174,11 @@ if (import.meta.hot) {
|
|
|
174
174
|
</script>
|
|
175
175
|
<script type="module" src="/@fs/${APP_PATH}/sandbox.js"></script>
|
|
176
176
|
</body>
|
|
177
|
-
</html>`
|
|
177
|
+
</html>`
|
|
178
|
+
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
179
|
+
// also applies HTML transforms from Vite plugins
|
|
180
|
+
html = await server.transformIndexHtml(req.url, html)
|
|
181
|
+
res.end(html)
|
|
178
182
|
return
|
|
179
183
|
}
|
|
180
184
|
next()
|
|
@@ -182,10 +186,11 @@ if (import.meta.hot) {
|
|
|
182
186
|
|
|
183
187
|
// serve our index.html after vite history fallback
|
|
184
188
|
return () => {
|
|
185
|
-
server.middlewares.use((req, res, next) => {
|
|
189
|
+
server.middlewares.use(async (req, res, next) => {
|
|
186
190
|
if (req.url!.endsWith('.html')) {
|
|
187
191
|
res.statusCode = 200
|
|
188
|
-
|
|
192
|
+
|
|
193
|
+
let html = `
|
|
189
194
|
<!DOCTYPE html>
|
|
190
195
|
<html>
|
|
191
196
|
<head>
|
|
@@ -200,7 +205,11 @@ if (import.meta.hot) {
|
|
|
200
205
|
<div id="app"></div>
|
|
201
206
|
<script type="module" src="/@fs/${APP_PATH}/index.js"></script>
|
|
202
207
|
</body>
|
|
203
|
-
</html>`
|
|
208
|
+
</html>`
|
|
209
|
+
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
210
|
+
// also applies HTML transforms from Vite plugins
|
|
211
|
+
html = await server.transformIndexHtml(req.url, html)
|
|
212
|
+
res.end(html)
|
|
204
213
|
return
|
|
205
214
|
}
|
|
206
215
|
next()
|