histoire 0.0.1 → 0.0.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/README.md +11 -0
- package/dist/client/app/App.vue +8 -8
- package/dist/client/app/codegen/serialize-js.js +0 -1
- package/dist/client/app/codegen/util.js +0 -1
- package/dist/client/app/codegen/vue3.js +28 -5
- package/dist/client/app/codegen/vue3.ts +32 -4
- package/dist/client/app/components/app/AppHeader.vue +10 -3
- package/dist/client/app/components/base/BaseTab.vue +46 -0
- package/dist/client/app/components/exposed/Story.vue +21 -1
- package/dist/client/app/components/exposed/Variant.vue +1 -0
- package/dist/client/app/components/misc/CheckerboardPattern.vue +32 -0
- package/dist/client/app/components/sandbox/SandboxVue3.vue +6 -0
- package/dist/client/app/components/search/SearchItem.vue +5 -9
- package/{src/client/app/components → dist/client/app/components/story}/StoryControls.vue +3 -3
- package/dist/client/app/components/story/StoryDocs.vue +37 -0
- package/dist/client/app/components/{StoryList.vue → story/StoryList.vue} +4 -4
- package/dist/client/app/components/{StoryListFolder.vue → story/StoryListFolder.vue} +13 -6
- package/dist/client/app/components/{StoryListItem.vue → story/StoryListItem.vue} +11 -6
- package/dist/client/app/components/story/StoryResponsivePreview.vue +214 -0
- package/{src/client/app/components → dist/client/app/components/story}/StorySourceCode.vue +4 -8
- package/{src/client/app/components → dist/client/app/components/story}/StoryVariantGridItem.vue +14 -6
- package/dist/client/app/components/{StoryVariantListItem.vue → story/StoryVariantListItem.vue} +9 -8
- package/dist/client/app/components/story/StoryVariantSingleView.vue +182 -0
- package/dist/client/app/components/{StoryView.vue → story/StoryView.vue} +37 -10
- package/dist/client/app/global-components.js +2 -1
- package/dist/client/app/global-components.ts +3 -0
- package/dist/client/app/index.js +10 -1
- package/dist/client/app/index.ts +10 -0
- package/dist/client/app/router.js +1 -2
- package/dist/client/app/router.ts +1 -1
- package/dist/client/app/sandbox.js +37 -4
- package/dist/client/app/sandbox.ts +37 -3
- package/dist/client/app/stores/story.d.ts +22 -1
- package/dist/client/app/stores/story.js +30 -2
- package/dist/client/app/stores/story.ts +37 -1
- package/dist/client/app/style/floating-vue.css +31 -0
- package/dist/client/app/style/main.css +17 -1
- package/dist/client/app/style/sandbox.css +5 -0
- package/dist/client/app/style/transitions.css +12 -0
- package/dist/client/app/types.d.ts +1 -0
- package/dist/client/app/types.js +0 -1
- package/dist/client/app/types.ts +15 -0
- package/dist/client/app/util/config.js +0 -1
- package/dist/client/app/util/const.d.ts +2 -0
- package/dist/client/app/util/const.js +2 -1
- package/dist/client/app/util/const.ts +2 -0
- package/dist/client/app/util/dark.js +0 -1
- package/dist/client/app/util/env.js +0 -1
- package/dist/client/app/util/env.ts +1 -0
- package/dist/client/app/util/keyboard.js +0 -1
- package/dist/client/app/util/keyboard.ts +99 -0
- package/dist/client/app/util/mapping.js +6 -1
- package/dist/client/app/util/mapping.ts +5 -0
- package/dist/client/app/util/preview-settings.d.ts +16 -0
- package/dist/client/app/util/preview-settings.js +15 -0
- package/dist/client/app/util/preview-settings.ts +26 -0
- package/dist/client/app/util/reactivity.d.ts +1 -0
- package/dist/client/app/util/reactivity.js +16 -0
- package/dist/client/app/util/reactivity.ts +22 -0
- package/dist/client/app/util/scroll.d.ts +2 -0
- package/dist/client/app/util/scroll.js +24 -0
- package/dist/client/app/util/scroll.ts +27 -0
- package/dist/client/app/util/tooltip.js +0 -1
- package/dist/client/app/util/tooltip.ts +13 -0
- package/dist/client/app/{composable → util}/variant.d.ts +0 -0
- package/dist/client/app/{composable → util}/variant.js +0 -1
- package/dist/client/app/{composable → util}/variant.ts +0 -0
- package/dist/client/index.js +0 -1
- package/dist/client/server/Story.server.vue +25 -2
- package/dist/client/server/index.js +2 -1
- package/dist/client/server/index.ts +3 -0
- package/dist/controls.d.ts +1 -0
- package/dist/controls.js +1 -0
- package/dist/node/alias.js +0 -1
- package/dist/node/bin.js +0 -1
- package/dist/node/build.js +13 -9
- package/dist/node/collect.js +12 -4
- package/dist/node/colors.d.ts +12 -0
- package/dist/node/colors.js +12 -1
- package/dist/node/commands/build.js +0 -1
- package/dist/node/commands/dev.js +43 -6
- package/dist/node/config.d.ts +35 -0
- package/dist/node/config.js +75 -2
- package/dist/node/context.js +0 -1
- package/dist/node/dom/dom-keys.js +0 -1
- package/dist/node/dom/env.js +0 -1
- package/dist/node/index.js +0 -1
- package/dist/node/markdown.d.ts +2 -0
- package/dist/node/markdown.js +48 -0
- package/dist/node/plugin.js +35 -1
- package/dist/node/server.js +0 -1
- package/dist/node/stories.js +0 -1
- package/dist/node/tree.js +0 -1
- package/dist/node/types.js +0 -1
- package/dist/node/util/slugify.d.ts +1 -0
- package/dist/node/util/slugify.js +22 -0
- package/dist/style.css +863 -157
- package/package.json +17 -4
- package/src/client/app/App.vue +8 -8
- package/src/client/app/codegen/vue3.ts +32 -4
- package/src/client/app/components/app/AppHeader.vue +10 -3
- package/src/client/app/components/base/BaseTab.vue +46 -0
- package/src/client/app/components/exposed/Story.vue +21 -1
- package/src/client/app/components/exposed/Variant.vue +1 -0
- package/src/client/app/components/misc/CheckerboardPattern.vue +32 -0
- package/src/client/app/components/sandbox/SandboxVue3.vue +6 -0
- package/src/client/app/components/search/SearchItem.vue +5 -9
- package/{dist/client/app/components → src/client/app/components/story}/StoryControls.vue +3 -3
- package/src/client/app/components/story/StoryDocs.vue +37 -0
- package/src/client/app/components/{StoryList.vue → story/StoryList.vue} +4 -4
- package/src/client/app/components/{StoryListFolder.vue → story/StoryListFolder.vue} +13 -6
- package/src/client/app/components/{StoryListItem.vue → story/StoryListItem.vue} +11 -6
- package/src/client/app/components/story/StoryResponsivePreview.vue +214 -0
- package/{dist/client/app/components → src/client/app/components/story}/StorySourceCode.vue +4 -8
- package/{dist/client/app/components → src/client/app/components/story}/StoryVariantGridItem.vue +14 -6
- package/src/client/app/components/{StoryVariantListItem.vue → story/StoryVariantListItem.vue} +9 -8
- package/src/client/app/components/story/StoryVariantSingleView.vue +182 -0
- package/src/client/app/components/{StoryView.vue → story/StoryView.vue} +37 -10
- package/src/client/app/global-components.ts +3 -0
- package/src/client/app/index.ts +10 -0
- package/src/client/app/router.ts +1 -1
- package/src/client/app/sandbox.ts +37 -3
- package/src/client/app/stores/story.ts +37 -1
- package/src/client/app/style/floating-vue.css +31 -0
- package/src/client/app/style/main.css +17 -1
- package/src/client/app/style/sandbox.css +5 -0
- package/src/client/app/style/transitions.css +12 -0
- package/src/client/app/types.ts +1 -0
- package/src/client/app/util/const.ts +2 -0
- package/src/client/app/util/mapping.ts +5 -0
- package/src/client/app/util/preview-settings.ts +26 -0
- package/src/client/app/util/reactivity.ts +22 -0
- package/src/client/app/util/scroll.ts +27 -0
- package/src/client/app/{composable → util}/variant.ts +0 -0
- package/src/client/server/Story.server.vue +25 -2
- package/src/client/server/index.ts +3 -0
- package/src/controls.ts +1 -0
- package/src/node/build.ts +15 -8
- package/src/node/collect.ts +12 -3
- package/src/node/colors.ts +12 -0
- package/src/node/commands/dev.ts +49 -5
- package/src/node/config.ts +112 -2
- package/src/node/markdown.ts +56 -0
- package/src/node/plugin.ts +38 -0
- package/src/node/tree.spec.ts +28 -0
- package/src/node/util/slugify.ts +26 -0
- package/tailwind.config.cjs +79 -4
- package/tsconfig.json +2 -1
- package/dist/client/app/codegen/serialize-js.js.map +0 -1
- package/dist/client/app/codegen/util.js.map +0 -1
- package/dist/client/app/codegen/vue3.js.map +0 -1
- package/dist/client/app/components/StoryVariantSingleView.vue +0 -145
- 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/sandbox.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/client/app/util/config.js.map +0 -1
- package/dist/client/app/util/const.js.map +0 -1
- package/dist/client/app/util/dark.js.map +0 -1
- package/dist/client/app/util/env.js.map +0 -1
- package/dist/client/app/util/keyboard.js.map +0 -1
- package/dist/client/app/util/mapping.js.map +0 -1
- package/dist/client/app/util/tooltip.js.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/client/server/index.js.map +0 -1
- package/dist/node/alias.js.map +0 -1
- package/dist/node/bin.js.map +0 -1
- package/dist/node/build.js.map +0 -1
- package/dist/node/collect.js.map +0 -1
- package/dist/node/colors.js.map +0 -1
- package/dist/node/commands/build.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/dom/dom-keys.js.map +0 -1
- package/dist/node/dom/env.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/dist/node/tree.js.map +0 -1
- package/dist/node/types.js.map +0 -1
- package/src/client/app/components/StoryVariantSingleView.vue +0 -145
package/dist/node/config.js
CHANGED
|
@@ -22,6 +22,71 @@ export function getDefaultConfig() {
|
|
|
22
22
|
gray: defaultColors.zinc,
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
|
+
responsivePresets: [
|
|
26
|
+
{
|
|
27
|
+
label: 'Mobile (Small)',
|
|
28
|
+
width: 320,
|
|
29
|
+
height: 560,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: 'Mobile (Medium)',
|
|
33
|
+
width: 360,
|
|
34
|
+
height: 640,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: 'Mobile (Large)',
|
|
38
|
+
width: 414,
|
|
39
|
+
height: 896,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
label: 'Tablet',
|
|
43
|
+
width: 768,
|
|
44
|
+
height: 1024,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: 'Laptop (Small)',
|
|
48
|
+
width: 1024,
|
|
49
|
+
height: null,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
label: 'Laptop (Large)',
|
|
53
|
+
width: 1366,
|
|
54
|
+
height: null,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: 'Desktop',
|
|
58
|
+
width: 1920,
|
|
59
|
+
height: null,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: '4K',
|
|
63
|
+
width: 3840,
|
|
64
|
+
height: null,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
backgroundPresets: [
|
|
68
|
+
{
|
|
69
|
+
label: 'Transparent',
|
|
70
|
+
color: 'transparent',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
label: 'White',
|
|
74
|
+
color: '#fff',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
label: 'Light gray',
|
|
78
|
+
color: '#aaa',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
label: 'Dark gray',
|
|
82
|
+
color: '#333',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
label: 'Black',
|
|
86
|
+
color: '#000',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
sandboxDarkClass: 'dark',
|
|
25
90
|
};
|
|
26
91
|
}
|
|
27
92
|
export const configFileNames = [
|
|
@@ -52,12 +117,21 @@ export async function loadConfigFile(configFile) {
|
|
|
52
117
|
try {
|
|
53
118
|
const server = await createServer();
|
|
54
119
|
await server.pluginContainer.buildStart({});
|
|
55
|
-
const node = new ViteNodeServer(server
|
|
120
|
+
const node = new ViteNodeServer(server, {
|
|
121
|
+
deps: {
|
|
122
|
+
inline: [
|
|
123
|
+
/histoire\/dist/,
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
});
|
|
56
127
|
const runner = new ViteNodeRunner({
|
|
57
128
|
root: path.dirname(configFile),
|
|
58
129
|
fetchModule(id) {
|
|
59
130
|
return node.fetchModule(id);
|
|
60
131
|
},
|
|
132
|
+
resolveId(id, importer) {
|
|
133
|
+
return node.resolveId(id, importer);
|
|
134
|
+
},
|
|
61
135
|
});
|
|
62
136
|
const result = await runner.executeFile(configFile);
|
|
63
137
|
await server.close();
|
|
@@ -88,4 +162,3 @@ export function processConfig(config) {
|
|
|
88
162
|
export function defineConfig(config) {
|
|
89
163
|
return config;
|
|
90
164
|
}
|
|
91
|
-
//# sourceMappingURL=config.js.map
|
package/dist/node/context.js
CHANGED
package/dist/node/dom/env.js
CHANGED
package/dist/node/index.js
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import MarkdownIt from 'markdown-it';
|
|
2
|
+
import shiki from 'shiki';
|
|
3
|
+
import anchor from 'markdown-it-anchor';
|
|
4
|
+
import attrs from 'markdown-it-attrs';
|
|
5
|
+
import emoji from 'markdown-it-emoji';
|
|
6
|
+
import { slugify } from './util/slugify.js';
|
|
7
|
+
export async function createMarkdownRenderer() {
|
|
8
|
+
const highlighter = await shiki.getHighlighter({
|
|
9
|
+
theme: 'github-dark',
|
|
10
|
+
});
|
|
11
|
+
const md = new MarkdownIt({
|
|
12
|
+
highlight: (code, lang) => `<div class="htw-relative htw-not-prose __histoire-code"><div class="htw-absolute htw-top-0 htw-right-0 htw-text-xs htw-text-white/40">${lang}</div>${highlighter.codeToHtml(code, {
|
|
13
|
+
lang,
|
|
14
|
+
})}</div>`,
|
|
15
|
+
linkify: true,
|
|
16
|
+
html: true,
|
|
17
|
+
breaks: true,
|
|
18
|
+
});
|
|
19
|
+
md.use(anchor, {
|
|
20
|
+
slugify,
|
|
21
|
+
permalink: anchor.permalink.ariaHidden({}),
|
|
22
|
+
})
|
|
23
|
+
.use(attrs)
|
|
24
|
+
.use(emoji);
|
|
25
|
+
// External links
|
|
26
|
+
{
|
|
27
|
+
const defaultRender = md.renderer.rules.link_open || function (tokens, idx, options, env, self) {
|
|
28
|
+
return self.renderToken(tokens, idx, options);
|
|
29
|
+
};
|
|
30
|
+
md.renderer.rules.link_open = function (tokens, idx, options, env, self) {
|
|
31
|
+
const hrefIndex = tokens[idx].attrIndex('href');
|
|
32
|
+
const classIndex = tokens[idx].attrIndex('class');
|
|
33
|
+
if (hrefIndex >= 0 && !tokens[idx].attrs[hrefIndex][1].startsWith('/') && (classIndex < 0 || !tokens[idx].attrs[classIndex][1].includes('header-anchor'))) {
|
|
34
|
+
// If you are sure other plugins can't add `target` - drop check below
|
|
35
|
+
const aIndex = tokens[idx].attrIndex('target');
|
|
36
|
+
if (aIndex < 0) {
|
|
37
|
+
tokens[idx].attrPush(['target', '_blank']); // add new attribute
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
tokens[idx].attrs[aIndex][1] = '_blank'; // replace value of existing attr
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// pass token to default renderer.
|
|
44
|
+
return defaultRender(tokens, idx, options, env, self);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return md;
|
|
48
|
+
}
|
package/dist/node/plugin.js
CHANGED
|
@@ -5,6 +5,7 @@ import { APP_PATH, DIST_CLIENT_PATH } from './alias.js';
|
|
|
5
5
|
import { notifyStoryChange } from './stories.js';
|
|
6
6
|
import { makeTree } from './tree.js';
|
|
7
7
|
import { parseColor } from './colors.js';
|
|
8
|
+
import { createMarkdownRenderer } from './markdown.js';
|
|
8
9
|
export const STORIES_ID = '$histoire-stories';
|
|
9
10
|
export const RESOLVED_STORIES_ID = `/${STORIES_ID}-resolved`;
|
|
10
11
|
export const SETUP_ID = '$histoire-setup';
|
|
@@ -20,6 +21,14 @@ export async function createVitePlugins(ctx) {
|
|
|
20
21
|
if (!hasVuePlugin) {
|
|
21
22
|
plugins.push((await import('@vitejs/plugin-vue')).default());
|
|
22
23
|
}
|
|
24
|
+
if (ctx.config.vite) {
|
|
25
|
+
plugins.push({
|
|
26
|
+
name: 'histoire-vite-config-override',
|
|
27
|
+
config(config, env) {
|
|
28
|
+
return typeof ctx.config.vite === 'function' ? ctx.config.vite(config, env) : ctx.config.vite;
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
23
32
|
plugins.push({
|
|
24
33
|
name: 'histoire-vite-plugin',
|
|
25
34
|
config() {
|
|
@@ -180,6 +189,8 @@ if (import.meta.hot) {
|
|
|
180
189
|
};
|
|
181
190
|
},
|
|
182
191
|
});
|
|
192
|
+
// Custom blocks
|
|
193
|
+
plugins.push(...await createCustomBlocksPlugins(ctx));
|
|
183
194
|
if (ctx.mode === 'build') {
|
|
184
195
|
// Add file name in build mode to have components names instead of <Anonymous>
|
|
185
196
|
const include = [/\.vue$/];
|
|
@@ -201,4 +212,27 @@ if (import.meta.hot) {
|
|
|
201
212
|
}
|
|
202
213
|
return plugins;
|
|
203
214
|
}
|
|
204
|
-
|
|
215
|
+
async function createCustomBlocksPlugins(ctx) {
|
|
216
|
+
const plugins = [];
|
|
217
|
+
let md = await createMarkdownRenderer();
|
|
218
|
+
if (ctx.config.markdown) {
|
|
219
|
+
const result = await ctx.config.markdown(md);
|
|
220
|
+
if (result) {
|
|
221
|
+
md = result;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
plugins.push({
|
|
225
|
+
name: 'histoire-vue-docs-block',
|
|
226
|
+
transform(code, id) {
|
|
227
|
+
if (!id.includes('?vue&type=docs'))
|
|
228
|
+
return;
|
|
229
|
+
if (!id.includes('lang.md'))
|
|
230
|
+
return;
|
|
231
|
+
const html = md.render(code);
|
|
232
|
+
return `export default Comp => {
|
|
233
|
+
Comp.doc = ${JSON.stringify(html)}
|
|
234
|
+
}`;
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
return plugins;
|
|
238
|
+
}
|
package/dist/node/server.js
CHANGED
package/dist/node/stories.js
CHANGED
package/dist/node/tree.js
CHANGED
package/dist/node/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const slugify: (str: string) => string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// From vitepress
|
|
2
|
+
// string.js slugify drops non ascii chars so we have to
|
|
3
|
+
// use a custom implementation here
|
|
4
|
+
import { remove as removeDiacritics } from 'diacritics';
|
|
5
|
+
// eslint-disable-next-line no-control-regex
|
|
6
|
+
const rControl = /[\u0000-\u001f]/g;
|
|
7
|
+
const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'<>,.?/]+/g;
|
|
8
|
+
export const slugify = (str) => {
|
|
9
|
+
return (removeDiacritics(str)
|
|
10
|
+
// Remove control characters
|
|
11
|
+
.replace(rControl, '')
|
|
12
|
+
// Replace special characters
|
|
13
|
+
.replace(rSpecial, '-')
|
|
14
|
+
// Remove continuous separators
|
|
15
|
+
.replace(/-{2,}/g, '-')
|
|
16
|
+
// Remove prefixing and trailing separators
|
|
17
|
+
.replace(/^-+|-+$/g, '')
|
|
18
|
+
// ensure it doesn't start with a number (#121)
|
|
19
|
+
.replace(/^(\d)/, '_$1')
|
|
20
|
+
// lowercase
|
|
21
|
+
.toLowerCase());
|
|
22
|
+
};
|