histoire 0.0.0 → 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/LICENSE +21 -0
- package/client.d.ts +2 -0
- package/dist/client/app/App.vue +84 -21
- package/dist/client/app/assets/histoire-text-dark.svg +89 -0
- package/dist/client/app/assets/histoire-text.svg +89 -0
- package/dist/client/app/assets/histoire.svg +51 -0
- package/dist/client/app/codegen/serialize-js.d.ts +1 -0
- package/dist/client/app/codegen/serialize-js.js +113 -0
- package/dist/client/app/codegen/serialize-js.ts +119 -0
- package/dist/client/app/codegen/util.d.ts +10 -0
- package/dist/client/app/codegen/util.js +70 -0
- package/dist/client/app/codegen/util.ts +79 -0
- package/dist/client/app/codegen/vue3.d.ts +2 -0
- package/dist/client/app/codegen/vue3.js +238 -0
- package/dist/client/app/codegen/vue3.ts +240 -0
- package/dist/client/app/components/HomeView.vue +15 -1
- package/dist/client/app/components/StoryControls.vue +7 -2
- package/dist/client/app/components/StoryList.vue +20 -13
- package/dist/client/app/components/StoryListFolder.vue +87 -0
- package/dist/client/app/components/StoryListItem.vue +38 -12
- package/dist/client/app/components/StorySourceCode.vue +121 -0
- package/dist/client/app/components/StoryVariantGridItem.vue +32 -17
- package/dist/client/app/components/StoryVariantListItem.vue +46 -0
- package/dist/client/app/components/StoryVariantSingleView.vue +145 -15
- package/dist/client/app/components/StoryView.vue +88 -54
- package/dist/client/app/components/app/AppHeader.vue +56 -0
- package/dist/client/app/components/app/AppLogo.vue +24 -0
- package/dist/client/app/components/base/BaseEmpty.vue +1 -1
- package/dist/client/app/components/base/BaseListItemLink.vue +55 -0
- package/dist/client/app/components/base/BaseSplitPane.vue +57 -21
- package/dist/client/app/components/exposed/Story.vue +23 -58
- package/dist/client/app/components/exposed/Variant.vue +24 -47
- package/dist/client/app/components/misc/HatchedPattern.vue +25 -0
- package/dist/client/app/components/{SandboxVue.vue → sandbox/SandboxVue3.vue} +31 -12
- package/dist/client/app/components/search/SearchItem.vue +110 -0
- package/dist/client/app/components/search/SearchModal.vue +179 -0
- package/dist/client/app/composable/variant.js +0 -1
- package/dist/client/app/composable/variant.ts +20 -0
- package/dist/client/app/global-components.js +0 -1
- package/dist/client/app/global-components.ts +10 -0
- package/dist/client/app/index.d.ts +1 -0
- package/dist/client/app/index.js +10 -2
- package/dist/client/app/index.ts +24 -0
- package/dist/client/app/router.js +0 -1
- package/dist/client/app/router.ts +17 -0
- package/dist/client/app/sandbox.d.ts +1 -0
- package/dist/client/app/sandbox.js +53 -0
- package/dist/client/app/sandbox.ts +60 -0
- package/dist/client/app/stores/story.d.ts +167 -50
- package/dist/client/app/stores/story.js +33 -16
- package/dist/client/app/stores/story.ts +58 -0
- package/dist/client/app/style/floating-vue.css +31 -0
- package/dist/client/app/style/main.css +17 -2
- package/dist/client/app/style/sandbox.css +14 -0
- package/dist/client/app/types.d.ts +36 -4
- package/dist/client/app/types.js +0 -1
- package/dist/client/app/types.ts +59 -0
- package/dist/client/app/util/config.d.ts +3 -0
- package/dist/client/app/util/config.js +4 -0
- package/dist/client/app/util/config.ts +6 -0
- package/dist/client/app/util/const.d.ts +1 -0
- package/dist/client/app/util/const.js +1 -0
- package/dist/client/app/util/const.ts +1 -0
- package/dist/client/app/util/dark.d.ts +2 -0
- package/dist/client/app/util/dark.js +3 -0
- package/dist/client/app/util/dark.ts +4 -0
- package/dist/client/app/util/env.d.ts +1 -0
- package/dist/client/app/util/env.js +1 -0
- package/dist/client/app/util/env.ts +1 -0
- package/dist/client/app/util/keyboard.d.ts +8 -0
- package/dist/client/app/util/keyboard.js +82 -0
- package/dist/client/app/util/keyboard.ts +99 -0
- package/dist/client/app/util/mapping.d.ts +3 -0
- package/dist/client/app/util/mapping.js +39 -0
- package/dist/client/app/util/mapping.ts +41 -0
- package/dist/client/app/util/tooltip.d.ts +6 -0
- package/dist/client/app/util/tooltip.js +11 -0
- package/dist/client/app/util/tooltip.ts +13 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.ts +12 -0
- package/dist/client/server/Story.server.vue +65 -0
- package/dist/client/server/Variant.server.vue +50 -0
- package/dist/client/server/index.d.ts +2 -0
- package/dist/client/server/index.js +25 -0
- package/dist/client/server/index.ts +29 -0
- package/dist/client/shim.d.ts +5 -0
- package/dist/node/alias.js +0 -1
- package/dist/node/bin.js +8 -3
- package/dist/node/build.d.ts +2 -0
- package/dist/node/build.js +71 -0
- package/dist/node/collect.d.ts +12 -0
- package/dist/node/collect.js +65 -0
- package/dist/node/colors.d.ts +286 -0
- package/dist/node/colors.js +324 -0
- package/dist/node/commands/build.d.ts +1 -0
- package/dist/node/commands/build.js +10 -0
- package/dist/node/commands/dev.d.ts +1 -1
- package/dist/node/commands/dev.js +45 -13
- package/dist/node/config.d.ts +112 -1
- package/dist/node/config.js +124 -2
- package/dist/node/context.d.ts +13 -0
- package/dist/node/context.js +12 -2
- package/dist/node/dom/dom-keys.d.ts +4 -0
- package/dist/node/dom/dom-keys.js +223 -0
- package/dist/node/dom/env.d.ts +5 -0
- package/dist/node/dom/env.js +22 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +2 -2
- package/dist/node/plugin.d.ts +8 -2
- package/dist/node/plugin.js +150 -22
- package/dist/node/server.d.ts +4 -1
- package/dist/node/server.js +80 -21
- package/dist/node/stories.d.ts +8 -9
- package/dist/node/stories.js +42 -23
- package/dist/node/tree.d.ts +19 -0
- package/dist/node/tree.js +54 -0
- package/dist/node/types.d.ts +38 -0
- package/dist/node/types.js +1 -0
- package/dist/style.css +610 -53
- package/package.json +45 -25
- package/scripts/copy.mjs +11 -0
- package/src/client/app/App.vue +84 -21
- package/src/client/app/assets/histoire-text-dark.svg +89 -0
- package/src/client/app/assets/histoire-text.svg +89 -0
- package/src/client/app/assets/histoire.svg +51 -0
- package/src/client/app/codegen/serialize-js.ts +119 -0
- package/src/client/app/codegen/util.ts +79 -0
- package/src/client/app/codegen/vue3.ts +240 -0
- package/src/client/app/components/HomeView.vue +15 -1
- package/src/client/app/components/StoryControls.vue +7 -2
- package/src/client/app/components/StoryList.vue +20 -13
- package/src/client/app/components/StoryListFolder.vue +87 -0
- package/src/client/app/components/StoryListItem.vue +38 -12
- package/src/client/app/components/StorySourceCode.vue +121 -0
- package/src/client/app/components/StoryVariantGridItem.vue +32 -17
- package/src/client/app/components/StoryVariantListItem.vue +46 -0
- package/src/client/app/components/StoryVariantSingleView.vue +145 -15
- package/src/client/app/components/StoryView.vue +88 -54
- package/src/client/app/components/app/AppHeader.vue +56 -0
- package/src/client/app/components/app/AppLogo.vue +24 -0
- package/src/client/app/components/base/BaseEmpty.vue +1 -1
- package/src/client/app/components/base/BaseListItemLink.vue +55 -0
- package/src/client/app/components/base/BaseSplitPane.vue +57 -21
- package/src/client/app/components/exposed/Story.vue +23 -58
- package/src/client/app/components/exposed/Variant.vue +24 -47
- package/src/client/app/components/misc/HatchedPattern.vue +25 -0
- package/src/client/app/components/{SandboxVue.vue → sandbox/SandboxVue3.vue} +31 -12
- package/src/client/app/components/search/SearchItem.vue +110 -0
- package/src/client/app/components/search/SearchModal.vue +179 -0
- package/src/client/app/index.ts +10 -1
- package/src/client/app/sandbox.ts +60 -0
- package/src/client/app/stores/story.ts +39 -15
- package/src/client/app/style/floating-vue.css +31 -0
- package/src/client/app/style/main.css +17 -2
- package/src/client/app/style/sandbox.css +14 -0
- package/src/client/app/types.ts +42 -4
- package/src/client/app/util/config.ts +6 -0
- package/src/client/app/util/const.ts +1 -0
- package/src/client/app/util/dark.ts +4 -0
- package/src/client/app/util/env.ts +1 -0
- package/src/client/app/util/keyboard.ts +99 -0
- package/src/client/app/util/mapping.ts +41 -0
- package/src/client/app/util/tooltip.ts +13 -0
- package/src/client/index.ts +12 -0
- package/src/client/server/Story.server.vue +65 -0
- package/src/client/server/Variant.server.vue +50 -0
- package/src/client/server/index.ts +29 -0
- package/src/node/bin.ts +9 -2
- package/src/node/build.ts +80 -0
- package/src/node/collect.ts +78 -0
- package/src/node/colors.ts +340 -0
- package/src/node/commands/build.ts +12 -0
- package/src/node/commands/dev.ts +49 -12
- package/src/node/config.ts +240 -1
- package/src/node/context.ts +21 -1
- package/src/node/dom/dom-keys.ts +227 -0
- package/src/node/dom/env.ts +26 -0
- package/src/node/index.ts +2 -0
- package/src/node/plugin.ts +155 -22
- package/src/node/server.ts +95 -20
- package/src/node/stories.ts +53 -31
- package/src/node/tree.spec.ts +28 -0
- package/src/node/tree.ts +88 -0
- package/src/node/types.ts +40 -0
- package/tailwind.config.cjs +41 -1
- package/tsconfig.json +2 -1
- package/dist/client/app/components/StoryVariantItem.vue +0 -29
- package/dist/client/app/composable/variant.js.map +0 -1
- package/dist/client/app/global-components.js.map +0 -1
- package/dist/client/app/index.js.map +0 -1
- package/dist/client/app/router.js.map +0 -1
- package/dist/client/app/stores/story.js.map +0 -1
- package/dist/client/app/types.js.map +0 -1
- package/dist/node/alias.js.map +0 -1
- package/dist/node/bin.js.map +0 -1
- package/dist/node/commands/dev.js.map +0 -1
- package/dist/node/config.js.map +0 -1
- package/dist/node/context.js.map +0 -1
- package/dist/node/index.js.map +0 -1
- package/dist/node/plugin.js.map +0 -1
- package/dist/node/server.js.map +0 -1
- package/dist/node/stories.js.map +0 -1
- package/src/client/app/components/StoryVariantItem.vue +0 -29
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
export const defaultColors = {
|
|
2
|
+
slate: {
|
|
3
|
+
50: '#f8fafc',
|
|
4
|
+
100: '#f1f5f9',
|
|
5
|
+
200: '#e2e8f0',
|
|
6
|
+
300: '#cbd5e1',
|
|
7
|
+
400: '#94a3b8',
|
|
8
|
+
500: '#64748b',
|
|
9
|
+
600: '#475569',
|
|
10
|
+
700: '#334155',
|
|
11
|
+
750: '#283548',
|
|
12
|
+
800: '#1e293b',
|
|
13
|
+
850: '#151f32',
|
|
14
|
+
900: '#0f172a',
|
|
15
|
+
950: '#09101f',
|
|
16
|
+
},
|
|
17
|
+
gray: {
|
|
18
|
+
50: '#f9fafb',
|
|
19
|
+
100: '#f3f4f6',
|
|
20
|
+
200: '#e5e7eb',
|
|
21
|
+
300: '#d1d5db',
|
|
22
|
+
400: '#9ca3af',
|
|
23
|
+
500: '#6b7280',
|
|
24
|
+
600: '#4b5563',
|
|
25
|
+
700: '#374151',
|
|
26
|
+
750: '#2b3546',
|
|
27
|
+
800: '#1f2937',
|
|
28
|
+
850: '#18212f',
|
|
29
|
+
900: '#111827',
|
|
30
|
+
950: '#0c101d',
|
|
31
|
+
},
|
|
32
|
+
zinc: {
|
|
33
|
+
50: '#fafafa',
|
|
34
|
+
100: '#f4f4f5',
|
|
35
|
+
200: '#e4e4e7',
|
|
36
|
+
300: '#d4d4d8',
|
|
37
|
+
400: '#a1a1aa',
|
|
38
|
+
500: '#71717a',
|
|
39
|
+
600: '#52525b',
|
|
40
|
+
700: '#3f3f46',
|
|
41
|
+
750: '#323238',
|
|
42
|
+
800: '#27272a',
|
|
43
|
+
850: '#1f1f21',
|
|
44
|
+
900: '#18181b',
|
|
45
|
+
950: '#101012',
|
|
46
|
+
},
|
|
47
|
+
neutral: {
|
|
48
|
+
50: '#fafafa',
|
|
49
|
+
100: '#f5f5f5',
|
|
50
|
+
200: '#e5e5e5',
|
|
51
|
+
300: '#d4d4d4',
|
|
52
|
+
400: '#a3a3a3',
|
|
53
|
+
500: '#737373',
|
|
54
|
+
600: '#525252',
|
|
55
|
+
700: '#404040',
|
|
56
|
+
750: '#333333',
|
|
57
|
+
800: '#262626',
|
|
58
|
+
850: '#1f1f1f',
|
|
59
|
+
900: '#171717',
|
|
60
|
+
950: '#0f0f0f',
|
|
61
|
+
},
|
|
62
|
+
stone: {
|
|
63
|
+
50: '#fafaf9',
|
|
64
|
+
100: '#f5f5f4',
|
|
65
|
+
200: '#e7e5e4',
|
|
66
|
+
300: '#d6d3d1',
|
|
67
|
+
400: '#a8a29e',
|
|
68
|
+
500: '#78716c',
|
|
69
|
+
600: '#57534e',
|
|
70
|
+
700: '#44403c',
|
|
71
|
+
750: '#363230',
|
|
72
|
+
800: '#292524',
|
|
73
|
+
850: '#211e1c',
|
|
74
|
+
900: '#1c1917',
|
|
75
|
+
950: '#171412',
|
|
76
|
+
},
|
|
77
|
+
red: {
|
|
78
|
+
50: '#fef2f2',
|
|
79
|
+
100: '#fee2e2',
|
|
80
|
+
200: '#fecaca',
|
|
81
|
+
300: '#fca5a5',
|
|
82
|
+
400: '#f87171',
|
|
83
|
+
500: '#ef4444',
|
|
84
|
+
600: '#dc2626',
|
|
85
|
+
700: '#b91c1c',
|
|
86
|
+
800: '#991b1b',
|
|
87
|
+
900: '#7f1d1d',
|
|
88
|
+
},
|
|
89
|
+
orange: {
|
|
90
|
+
50: '#fff7ed',
|
|
91
|
+
100: '#ffedd5',
|
|
92
|
+
200: '#fed7aa',
|
|
93
|
+
300: '#fdba74',
|
|
94
|
+
400: '#fb923c',
|
|
95
|
+
500: '#f97316',
|
|
96
|
+
600: '#ea580c',
|
|
97
|
+
700: '#c2410c',
|
|
98
|
+
800: '#9a3412',
|
|
99
|
+
900: '#7c2d12',
|
|
100
|
+
},
|
|
101
|
+
amber: {
|
|
102
|
+
50: '#fffbeb',
|
|
103
|
+
100: '#fef3c7',
|
|
104
|
+
200: '#fde68a',
|
|
105
|
+
300: '#fcd34d',
|
|
106
|
+
400: '#fbbf24',
|
|
107
|
+
500: '#f59e0b',
|
|
108
|
+
600: '#d97706',
|
|
109
|
+
700: '#b45309',
|
|
110
|
+
800: '#92400e',
|
|
111
|
+
900: '#78350f',
|
|
112
|
+
},
|
|
113
|
+
yellow: {
|
|
114
|
+
50: '#fefce8',
|
|
115
|
+
100: '#fef9c3',
|
|
116
|
+
200: '#fef08a',
|
|
117
|
+
300: '#fde047',
|
|
118
|
+
400: '#facc15',
|
|
119
|
+
500: '#eab308',
|
|
120
|
+
600: '#ca8a04',
|
|
121
|
+
700: '#a16207',
|
|
122
|
+
800: '#854d0e',
|
|
123
|
+
900: '#713f12',
|
|
124
|
+
},
|
|
125
|
+
lime: {
|
|
126
|
+
50: '#f7fee7',
|
|
127
|
+
100: '#ecfccb',
|
|
128
|
+
200: '#d9f99d',
|
|
129
|
+
300: '#bef264',
|
|
130
|
+
400: '#a3e635',
|
|
131
|
+
500: '#84cc16',
|
|
132
|
+
600: '#65a30d',
|
|
133
|
+
700: '#4d7c0f',
|
|
134
|
+
800: '#3f6212',
|
|
135
|
+
900: '#365314',
|
|
136
|
+
},
|
|
137
|
+
green: {
|
|
138
|
+
50: '#f0fdf4',
|
|
139
|
+
100: '#dcfce7',
|
|
140
|
+
200: '#bbf7d0',
|
|
141
|
+
300: '#86efac',
|
|
142
|
+
400: '#4ade80',
|
|
143
|
+
500: '#22c55e',
|
|
144
|
+
600: '#16a34a',
|
|
145
|
+
700: '#15803d',
|
|
146
|
+
800: '#166534',
|
|
147
|
+
900: '#14532d',
|
|
148
|
+
},
|
|
149
|
+
emerald: {
|
|
150
|
+
50: '#ecfdf5',
|
|
151
|
+
100: '#d1fae5',
|
|
152
|
+
200: '#a7f3d0',
|
|
153
|
+
300: '#6ee7b7',
|
|
154
|
+
400: '#34d399',
|
|
155
|
+
500: '#10b981',
|
|
156
|
+
600: '#059669',
|
|
157
|
+
700: '#047857',
|
|
158
|
+
800: '#065f46',
|
|
159
|
+
900: '#064e3b',
|
|
160
|
+
},
|
|
161
|
+
teal: {
|
|
162
|
+
50: '#f0fdfa',
|
|
163
|
+
100: '#ccfbf1',
|
|
164
|
+
200: '#99f6e4',
|
|
165
|
+
300: '#5eead4',
|
|
166
|
+
400: '#2dd4bf',
|
|
167
|
+
500: '#14b8a6',
|
|
168
|
+
600: '#0d9488',
|
|
169
|
+
700: '#0f766e',
|
|
170
|
+
800: '#115e59',
|
|
171
|
+
900: '#134e4a',
|
|
172
|
+
},
|
|
173
|
+
cyan: {
|
|
174
|
+
50: '#ecfeff',
|
|
175
|
+
100: '#cffafe',
|
|
176
|
+
200: '#a5f3fc',
|
|
177
|
+
300: '#67e8f9',
|
|
178
|
+
400: '#22d3ee',
|
|
179
|
+
500: '#06b6d4',
|
|
180
|
+
600: '#0891b2',
|
|
181
|
+
700: '#0e7490',
|
|
182
|
+
800: '#155e75',
|
|
183
|
+
900: '#164e63',
|
|
184
|
+
},
|
|
185
|
+
sky: {
|
|
186
|
+
50: '#f0f9ff',
|
|
187
|
+
100: '#e0f2fe',
|
|
188
|
+
200: '#bae6fd',
|
|
189
|
+
300: '#7dd3fc',
|
|
190
|
+
400: '#38bdf8',
|
|
191
|
+
500: '#0ea5e9',
|
|
192
|
+
600: '#0284c7',
|
|
193
|
+
700: '#0369a1',
|
|
194
|
+
800: '#075985',
|
|
195
|
+
900: '#0c4a6e',
|
|
196
|
+
},
|
|
197
|
+
blue: {
|
|
198
|
+
50: '#eff6ff',
|
|
199
|
+
100: '#dbeafe',
|
|
200
|
+
200: '#bfdbfe',
|
|
201
|
+
300: '#93c5fd',
|
|
202
|
+
400: '#60a5fa',
|
|
203
|
+
500: '#3b82f6',
|
|
204
|
+
600: '#2563eb',
|
|
205
|
+
700: '#1d4ed8',
|
|
206
|
+
800: '#1e40af',
|
|
207
|
+
900: '#1e3a8a',
|
|
208
|
+
},
|
|
209
|
+
indigo: {
|
|
210
|
+
50: '#eef2ff',
|
|
211
|
+
100: '#e0e7ff',
|
|
212
|
+
200: '#c7d2fe',
|
|
213
|
+
300: '#a5b4fc',
|
|
214
|
+
400: '#818cf8',
|
|
215
|
+
500: '#6366f1',
|
|
216
|
+
600: '#4f46e5',
|
|
217
|
+
700: '#4338ca',
|
|
218
|
+
800: '#3730a3',
|
|
219
|
+
900: '#312e81',
|
|
220
|
+
},
|
|
221
|
+
violet: {
|
|
222
|
+
50: '#f5f3ff',
|
|
223
|
+
100: '#ede9fe',
|
|
224
|
+
200: '#ddd6fe',
|
|
225
|
+
300: '#c4b5fd',
|
|
226
|
+
400: '#a78bfa',
|
|
227
|
+
500: '#8b5cf6',
|
|
228
|
+
600: '#7c3aed',
|
|
229
|
+
700: '#6d28d9',
|
|
230
|
+
800: '#5b21b6',
|
|
231
|
+
900: '#4c1d95',
|
|
232
|
+
},
|
|
233
|
+
purple: {
|
|
234
|
+
50: '#faf5ff',
|
|
235
|
+
100: '#f3e8ff',
|
|
236
|
+
200: '#e9d5ff',
|
|
237
|
+
300: '#d8b4fe',
|
|
238
|
+
400: '#c084fc',
|
|
239
|
+
500: '#a855f7',
|
|
240
|
+
600: '#9333ea',
|
|
241
|
+
700: '#7e22ce',
|
|
242
|
+
800: '#6b21a8',
|
|
243
|
+
900: '#581c87',
|
|
244
|
+
},
|
|
245
|
+
fuchsia: {
|
|
246
|
+
50: '#fdf4ff',
|
|
247
|
+
100: '#fae8ff',
|
|
248
|
+
200: '#f5d0fe',
|
|
249
|
+
300: '#f0abfc',
|
|
250
|
+
400: '#e879f9',
|
|
251
|
+
500: '#d946ef',
|
|
252
|
+
600: '#c026d3',
|
|
253
|
+
700: '#a21caf',
|
|
254
|
+
800: '#86198f',
|
|
255
|
+
900: '#701a75',
|
|
256
|
+
},
|
|
257
|
+
pink: {
|
|
258
|
+
50: '#fdf2f8',
|
|
259
|
+
100: '#fce7f3',
|
|
260
|
+
200: '#fbcfe8',
|
|
261
|
+
300: '#f9a8d4',
|
|
262
|
+
400: '#f472b6',
|
|
263
|
+
500: '#ec4899',
|
|
264
|
+
600: '#db2777',
|
|
265
|
+
700: '#be185d',
|
|
266
|
+
800: '#9d174d',
|
|
267
|
+
900: '#831843',
|
|
268
|
+
},
|
|
269
|
+
rose: {
|
|
270
|
+
50: '#fff1f2',
|
|
271
|
+
100: '#ffe4e6',
|
|
272
|
+
200: '#fecdd3',
|
|
273
|
+
300: '#fda4af',
|
|
274
|
+
400: '#fb7185',
|
|
275
|
+
500: '#f43f5e',
|
|
276
|
+
600: '#e11d48',
|
|
277
|
+
700: '#be123c',
|
|
278
|
+
800: '#9f1239',
|
|
279
|
+
900: '#881337',
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
const HEX = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i;
|
|
283
|
+
const SHORT_HEX = /^#([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i;
|
|
284
|
+
const VALUE = `(?:\\d+|\\d*\\.\\d+)%?`;
|
|
285
|
+
const SEP = `(?:\\s*,\\s*|\\s+)`;
|
|
286
|
+
const ALPHA_SEP = `\\s*[,/]\\s*`;
|
|
287
|
+
const RGB = new RegExp(`^rgba?\\(\\s*(${VALUE})${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`);
|
|
288
|
+
const HSL = new RegExp(`^hsla?\\(\\s*((?:${VALUE})(?:deg|rad|grad|turn)?)${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`);
|
|
289
|
+
export function parseColor(value) {
|
|
290
|
+
if (typeof value !== 'string') {
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
value = value.trim();
|
|
294
|
+
if (value === 'transparent') {
|
|
295
|
+
return { mode: 'rgb', color: ['0', '0', '0'], alpha: '0' };
|
|
296
|
+
}
|
|
297
|
+
const hex = value
|
|
298
|
+
.replace(SHORT_HEX, (_, r, g, b, a) => ['#', r, r, g, g, b, b, a ? a + a : ''].join(''))
|
|
299
|
+
.match(HEX);
|
|
300
|
+
if (hex !== null) {
|
|
301
|
+
return {
|
|
302
|
+
mode: 'rgb',
|
|
303
|
+
color: [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)].map((v) => v.toString()),
|
|
304
|
+
alpha: hex[4] ? (parseInt(hex[4], 16) / 255).toString() : undefined,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
const rgbMatch = value.match(RGB);
|
|
308
|
+
if (rgbMatch !== null) {
|
|
309
|
+
return {
|
|
310
|
+
mode: 'rgb',
|
|
311
|
+
color: [rgbMatch[1], rgbMatch[2], rgbMatch[3]].map((v) => v.toString()),
|
|
312
|
+
alpha: rgbMatch[4]?.toString?.(),
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
const hslMatch = value.match(HSL);
|
|
316
|
+
if (hslMatch !== null) {
|
|
317
|
+
return {
|
|
318
|
+
mode: 'hsl',
|
|
319
|
+
color: [hslMatch[1], hslMatch[2], hslMatch[3]].map((v) => v.toString()),
|
|
320
|
+
alpha: hslMatch[4]?.toString?.(),
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildCommand(): Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { build } from '../build.js';
|
|
2
|
+
import { createContext } from '../context.js';
|
|
3
|
+
export async function buildCommand() {
|
|
4
|
+
const ctx = await createContext({
|
|
5
|
+
mode: 'build',
|
|
6
|
+
});
|
|
7
|
+
await build(ctx);
|
|
8
|
+
// @TODO remove when https://github.com/vitejs/vite/issues/6815 is fixed
|
|
9
|
+
process.exit(0);
|
|
10
|
+
}
|
|
@@ -1,15 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveConfigFile } from '../config.js';
|
|
2
|
+
import { createContext } from '../context.js';
|
|
2
3
|
import { createServer } from '../server.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
import chokidar from 'chokidar';
|
|
5
|
+
import pc from 'picocolors';
|
|
6
|
+
export async function devCommand(options) {
|
|
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
|
+
}
|
|
14
47
|
}
|
|
15
|
-
//# sourceMappingURL=dev.js.map
|
package/dist/node/config.d.ts
CHANGED
|
@@ -1,4 +1,115 @@
|
|
|
1
|
+
import { UserConfig as ViteConfig } from 'vite';
|
|
2
|
+
import { TreeFile } from './tree.js';
|
|
3
|
+
declare type CustomizableColors = 'primary' | 'gray';
|
|
4
|
+
declare type ColorKeys = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
|
|
5
|
+
declare type GrayColorKeys = ColorKeys | '750' | '850' | '950';
|
|
6
|
+
interface ResponsivePreset {
|
|
7
|
+
label: string;
|
|
8
|
+
width: number;
|
|
9
|
+
}
|
|
1
10
|
export interface HistoireConfig {
|
|
2
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Output directory.
|
|
13
|
+
*/
|
|
14
|
+
outDir: string;
|
|
15
|
+
/**
|
|
16
|
+
* Glob patterns for story files to include.
|
|
17
|
+
*/
|
|
3
18
|
storyMatch: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Glob patterns to ignore files while searching for story files.
|
|
21
|
+
*/
|
|
22
|
+
storyIgnored: string[];
|
|
23
|
+
/**
|
|
24
|
+
* How to generate the story tree.
|
|
25
|
+
*/
|
|
26
|
+
tree: {
|
|
27
|
+
/**
|
|
28
|
+
* Use `'title'` to create the path from the title of the story, using `/` as the separator.
|
|
29
|
+
*
|
|
30
|
+
* Use `'path'` use the real folder structure on your computer.
|
|
31
|
+
*/
|
|
32
|
+
file?: 'title' | 'path' | ((file: TreeFile) => string[]);
|
|
33
|
+
order?: 'asc' | ((a: string, b: string) => number);
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Customize the look of the histoire book.
|
|
37
|
+
*/
|
|
38
|
+
theme: {
|
|
39
|
+
/**
|
|
40
|
+
* Main page title. For example: 'Acme Inc.'
|
|
41
|
+
*/
|
|
42
|
+
title?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Custom logo files. Should be import paths (processed by Vite).
|
|
45
|
+
*
|
|
46
|
+
* Example: `'/src/assets/my-logo.svg'`
|
|
47
|
+
*/
|
|
48
|
+
logo?: {
|
|
49
|
+
/**
|
|
50
|
+
* Square logo without text.
|
|
51
|
+
*/
|
|
52
|
+
square?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Full logo for light theme.
|
|
55
|
+
*/
|
|
56
|
+
light?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Full logo for dark theme.
|
|
59
|
+
*/
|
|
60
|
+
dark?: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Href to the favicon file (**not** processed by Vite). Put the file in the public directory.
|
|
64
|
+
*
|
|
65
|
+
* Example: `'/favicon.ico'`
|
|
66
|
+
*/
|
|
67
|
+
favicon?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Customize the colors. Each color should be an object with shades as keys.
|
|
70
|
+
*
|
|
71
|
+
* Example: ```{ primary: { 50: '#eef2ff', 100: '#e0e7ff', ..., 900: '#312e81' } }```
|
|
72
|
+
*
|
|
73
|
+
* You can import `defaultColors` from `'histoire'` to use predefined colors or you can create your own colors from scratch.
|
|
74
|
+
*/
|
|
75
|
+
colors?: {
|
|
76
|
+
[key in CustomizableColors]?: key extends 'gray' ? {
|
|
77
|
+
[key in GrayColorKeys]?: string;
|
|
78
|
+
} : {
|
|
79
|
+
[key in ColorKeys]?: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Setup file exposting a default function executed when setting up each story preview.
|
|
85
|
+
*
|
|
86
|
+
* Import custom CSS files from this file.
|
|
87
|
+
*
|
|
88
|
+
* Example: `'/src/histoire-setup.ts'`
|
|
89
|
+
*/
|
|
90
|
+
setupFile?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Predefined responsive sizes for story playgrounds.
|
|
93
|
+
*/
|
|
94
|
+
responsivePresets?: ResponsivePreset[];
|
|
95
|
+
/**
|
|
96
|
+
* Vite config override
|
|
97
|
+
*/
|
|
98
|
+
vite?: ViteConfig;
|
|
99
|
+
}
|
|
100
|
+
export declare function getDefaultConfig(): HistoireConfig;
|
|
101
|
+
export declare const configFileNames: string[];
|
|
102
|
+
export declare function resolveConfigFile(cwd?: string): string;
|
|
103
|
+
export declare function loadConfigFile(configFile: string): Promise<Partial<HistoireConfig>>;
|
|
104
|
+
export declare function resolveConfig(cwd?: string): Promise<HistoireConfig>;
|
|
105
|
+
export declare function processConfig(config: HistoireConfig): HistoireConfig;
|
|
106
|
+
export declare function defineConfig(config: Partial<HistoireConfig>): Partial<HistoireConfig>;
|
|
107
|
+
declare module 'vite' {
|
|
108
|
+
interface UserConfig {
|
|
109
|
+
/**
|
|
110
|
+
* Histoire configuration
|
|
111
|
+
*/
|
|
112
|
+
histoire?: Partial<HistoireConfig>;
|
|
113
|
+
}
|
|
4
114
|
}
|
|
115
|
+
export {};
|
package/dist/node/config.js
CHANGED
|
@@ -1,2 +1,124 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from 'pathe';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import defu from 'defu';
|
|
4
|
+
import { createServer, resolveConfig as resolveViteConfig } from 'vite';
|
|
5
|
+
import { ViteNodeServer } from 'vite-node/server';
|
|
6
|
+
import { ViteNodeRunner } from 'vite-node/client';
|
|
7
|
+
import pc from 'picocolors';
|
|
8
|
+
import { defaultColors } from './colors.js';
|
|
9
|
+
export function getDefaultConfig() {
|
|
10
|
+
return {
|
|
11
|
+
outDir: 'histoire-dist',
|
|
12
|
+
storyMatch: ['**/*.story.vue'],
|
|
13
|
+
storyIgnored: ['**/node_modules/**'],
|
|
14
|
+
tree: {
|
|
15
|
+
file: 'title',
|
|
16
|
+
order: 'asc',
|
|
17
|
+
},
|
|
18
|
+
theme: {
|
|
19
|
+
title: 'Histoire',
|
|
20
|
+
colors: {
|
|
21
|
+
primary: defaultColors.emerald,
|
|
22
|
+
gray: defaultColors.zinc,
|
|
23
|
+
},
|
|
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
|
+
],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export const configFileNames = [
|
|
62
|
+
'histoire.config.ts',
|
|
63
|
+
'histoire.config.js',
|
|
64
|
+
'.histoire.ts',
|
|
65
|
+
'.histoire.js',
|
|
66
|
+
];
|
|
67
|
+
export function resolveConfigFile(cwd = process.cwd()) {
|
|
68
|
+
let { root } = path.parse(cwd);
|
|
69
|
+
let dir = cwd;
|
|
70
|
+
// Fix for windows, waiting for pathe to fix this: https://github.com/unjs/pathe/issues/5
|
|
71
|
+
if (root === '' && dir[1] === ':') {
|
|
72
|
+
root = dir.substring(0, 2);
|
|
73
|
+
}
|
|
74
|
+
while (dir !== root) {
|
|
75
|
+
for (const fileName of configFileNames) {
|
|
76
|
+
const searchPath = path.join(dir, fileName);
|
|
77
|
+
if (fs.existsSync(searchPath)) {
|
|
78
|
+
return searchPath;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
dir = path.dirname(dir);
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
export async function loadConfigFile(configFile) {
|
|
86
|
+
try {
|
|
87
|
+
const server = await createServer();
|
|
88
|
+
await server.pluginContainer.buildStart({});
|
|
89
|
+
const node = new ViteNodeServer(server);
|
|
90
|
+
const runner = new ViteNodeRunner({
|
|
91
|
+
root: path.dirname(configFile),
|
|
92
|
+
fetchModule(id) {
|
|
93
|
+
return node.fetchModule(id);
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
const result = await runner.executeFile(configFile);
|
|
97
|
+
await server.close();
|
|
98
|
+
if (!result.default) {
|
|
99
|
+
throw new Error(`Expected default export in ${configFile}`);
|
|
100
|
+
}
|
|
101
|
+
return result.default;
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
console.error(pc.red(`Error while loading ${configFile}`));
|
|
105
|
+
throw e;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export async function resolveConfig(cwd = process.cwd()) {
|
|
109
|
+
let result;
|
|
110
|
+
const configFile = resolveConfigFile(cwd);
|
|
111
|
+
if (configFile) {
|
|
112
|
+
result = await loadConfigFile(configFile);
|
|
113
|
+
}
|
|
114
|
+
const viteConfig = await resolveViteConfig({}, 'serve');
|
|
115
|
+
const viteHistoireConfig = (viteConfig.histoire ?? {});
|
|
116
|
+
return processConfig(defu(result, viteHistoireConfig, getDefaultConfig()));
|
|
117
|
+
}
|
|
118
|
+
export function processConfig(config) {
|
|
119
|
+
config.outDir = path.resolve(process.cwd(), config.outDir);
|
|
120
|
+
return config;
|
|
121
|
+
}
|
|
122
|
+
export function defineConfig(config) {
|
|
123
|
+
return config;
|
|
124
|
+
}
|
package/dist/node/context.d.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { HistoireConfig } from './config.js';
|
|
2
|
+
import type { StoryFile } from './types.js';
|
|
2
3
|
export interface Context {
|
|
4
|
+
root: string;
|
|
3
5
|
config: HistoireConfig;
|
|
6
|
+
mode: 'dev' | 'build';
|
|
7
|
+
storyFiles: StoryFile[];
|
|
4
8
|
}
|
|
9
|
+
export interface CreateContextOptions {
|
|
10
|
+
mode: Context['mode'];
|
|
11
|
+
}
|
|
12
|
+
export declare function createContext(options: CreateContextOptions): Promise<{
|
|
13
|
+
root: string;
|
|
14
|
+
config: HistoireConfig;
|
|
15
|
+
mode: "build" | "dev";
|
|
16
|
+
storyFiles: any[];
|
|
17
|
+
}>;
|
package/dist/node/context.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { resolveConfig as resolveViteConfig } from 'vite';
|
|
2
|
+
import { resolveConfig } from './config.js';
|
|
3
|
+
export async function createContext(options) {
|
|
4
|
+
const config = await resolveConfig();
|
|
5
|
+
const viteConfig = await resolveViteConfig({}, 'build');
|
|
6
|
+
return {
|
|
7
|
+
root: viteConfig.root,
|
|
8
|
+
config,
|
|
9
|
+
mode: options.mode,
|
|
10
|
+
storyFiles: [],
|
|
11
|
+
};
|
|
12
|
+
}
|