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
package/dist/node/stories.js
CHANGED
|
@@ -1,43 +1,62 @@
|
|
|
1
1
|
import chokidar from 'chokidar';
|
|
2
2
|
import { globby } from 'globby';
|
|
3
3
|
import Case from 'case';
|
|
4
|
-
|
|
4
|
+
import { join } from 'pathe';
|
|
5
5
|
const handlers = [];
|
|
6
|
+
let context;
|
|
6
7
|
export function onStoryChange(handler) {
|
|
7
8
|
handlers.push(handler);
|
|
8
9
|
}
|
|
9
|
-
export async function watchStories(
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export async function watchStories(newContext) {
|
|
11
|
+
context = newContext;
|
|
12
|
+
const watcher = chokidar.watch(context.config.storyMatch, {
|
|
13
|
+
cwd: context.root,
|
|
14
|
+
ignored: context.config.storyIgnored,
|
|
12
15
|
});
|
|
13
|
-
watcher
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
watcher
|
|
17
|
+
.on('add', (file) => {
|
|
18
|
+
const storyFile = addStory(file);
|
|
19
|
+
setTimeout(() => notifyStoryChange(storyFile), 100); // Delay in case file renaming fired Add event before Unlink event
|
|
20
|
+
})
|
|
21
|
+
.on('unlink', (file) => {
|
|
22
|
+
removeStory(file);
|
|
23
|
+
notifyStoryChange();
|
|
20
24
|
});
|
|
21
25
|
return watcher;
|
|
22
26
|
}
|
|
23
|
-
function
|
|
27
|
+
export function notifyStoryChange(file) {
|
|
24
28
|
for (const handler of handlers) {
|
|
25
|
-
handler();
|
|
29
|
+
handler(file);
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
function getAbsoluteFilePath(relativeFilePath) {
|
|
33
|
+
return join(context.root, relativeFilePath);
|
|
34
|
+
}
|
|
35
|
+
function addStory(relativeFilePath) {
|
|
36
|
+
const absoluteFilePath = getAbsoluteFilePath(relativeFilePath);
|
|
37
|
+
const fileId = Case.kebab(relativeFilePath);
|
|
38
|
+
const file = {
|
|
39
|
+
id: fileId,
|
|
40
|
+
path: absoluteFilePath,
|
|
41
|
+
moduleId: `/${relativeFilePath}`,
|
|
42
|
+
};
|
|
43
|
+
context.storyFiles.push(file);
|
|
44
|
+
return file;
|
|
45
|
+
}
|
|
46
|
+
function removeStory(relativeFilePath) {
|
|
47
|
+
const fileId = Case.kebab(relativeFilePath);
|
|
48
|
+
const index = context.storyFiles.findIndex((file) => file.id === fileId);
|
|
49
|
+
if (index !== -1)
|
|
50
|
+
context.storyFiles.splice(index, 1);
|
|
33
51
|
}
|
|
34
|
-
export async function
|
|
35
|
-
|
|
36
|
-
|
|
52
|
+
export async function findAllStories(newContext) {
|
|
53
|
+
context = newContext;
|
|
54
|
+
const files = await globby(context.config.storyMatch, {
|
|
55
|
+
cwd: context.root,
|
|
56
|
+
ignore: context.config.storyIgnored,
|
|
37
57
|
});
|
|
38
|
-
|
|
58
|
+
context.storyFiles.length = 0;
|
|
39
59
|
for (const file of files) {
|
|
40
60
|
addStory(file);
|
|
41
61
|
}
|
|
42
62
|
}
|
|
43
|
-
//# sourceMappingURL=stories.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HistoireConfig } from './config.js';
|
|
2
|
+
export declare type TreeFile = {
|
|
3
|
+
title: string;
|
|
4
|
+
path: string;
|
|
5
|
+
};
|
|
6
|
+
export declare type TreeLeaf = {
|
|
7
|
+
title: string;
|
|
8
|
+
index: number;
|
|
9
|
+
};
|
|
10
|
+
export declare type TreeFolder = {
|
|
11
|
+
title: string;
|
|
12
|
+
children: (TreeFolder | TreeLeaf)[];
|
|
13
|
+
};
|
|
14
|
+
export declare type Tree = (TreeFolder | TreeLeaf)[];
|
|
15
|
+
export declare function createPath(config: HistoireConfig, file: TreeFile): string[];
|
|
16
|
+
export declare function makeTree(config: HistoireConfig, files: {
|
|
17
|
+
path: string[];
|
|
18
|
+
index: number;
|
|
19
|
+
}[]): Tree;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export function createPath(config, file) {
|
|
2
|
+
if (config.tree.file === 'title') {
|
|
3
|
+
return file.title.split('/');
|
|
4
|
+
}
|
|
5
|
+
if (config.tree.file === 'path') {
|
|
6
|
+
const path = file.path.split('/');
|
|
7
|
+
path.pop();
|
|
8
|
+
path.push(file.title);
|
|
9
|
+
return path;
|
|
10
|
+
}
|
|
11
|
+
return config.tree.file(file);
|
|
12
|
+
}
|
|
13
|
+
export function makeTree(config, files) {
|
|
14
|
+
const treeObject = {};
|
|
15
|
+
for (const file of files) {
|
|
16
|
+
setPath(file.path, file.index, treeObject);
|
|
17
|
+
}
|
|
18
|
+
let sortingFunction = (a, b) => a.localeCompare(b);
|
|
19
|
+
if (config.tree.order !== 'asc') {
|
|
20
|
+
sortingFunction = config.tree.order;
|
|
21
|
+
}
|
|
22
|
+
return buildTree(treeObject);
|
|
23
|
+
// Undefined behavior for folder and file that share the same name under the same directory
|
|
24
|
+
function setPath(path, value, tree) {
|
|
25
|
+
path.reduce((subtree, key, i) => {
|
|
26
|
+
if (!subtree[key]) {
|
|
27
|
+
subtree[key] = {};
|
|
28
|
+
}
|
|
29
|
+
if (i === path.length - 1) {
|
|
30
|
+
subtree[key] = value;
|
|
31
|
+
}
|
|
32
|
+
return subtree[key];
|
|
33
|
+
}, tree);
|
|
34
|
+
}
|
|
35
|
+
function buildTree(treeObject) {
|
|
36
|
+
const tree = [];
|
|
37
|
+
for (const [key, element] of Object.entries(treeObject)) {
|
|
38
|
+
if (Number.isInteger(element)) {
|
|
39
|
+
tree.push({
|
|
40
|
+
title: key,
|
|
41
|
+
index: element,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
tree.push({
|
|
46
|
+
title: key,
|
|
47
|
+
children: buildTree(element),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
tree.sort((a, b) => sortingFunction(a.title, b.title));
|
|
52
|
+
return tree;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface StoryFile {
|
|
2
|
+
id: string;
|
|
3
|
+
/**
|
|
4
|
+
* Absolute path
|
|
5
|
+
*/
|
|
6
|
+
path: string;
|
|
7
|
+
/**
|
|
8
|
+
* Generated path for tree UI
|
|
9
|
+
*/
|
|
10
|
+
treePath?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Use the module id in imports to allow HMR
|
|
13
|
+
*/
|
|
14
|
+
moduleId: string;
|
|
15
|
+
/**
|
|
16
|
+
* Resolved story data from story file execution
|
|
17
|
+
*/
|
|
18
|
+
story?: Story;
|
|
19
|
+
}
|
|
20
|
+
export interface Story {
|
|
21
|
+
id: string;
|
|
22
|
+
title: string;
|
|
23
|
+
variants: Variant[];
|
|
24
|
+
layout?: {
|
|
25
|
+
type: 'single';
|
|
26
|
+
} | {
|
|
27
|
+
type: 'grid';
|
|
28
|
+
width: number;
|
|
29
|
+
};
|
|
30
|
+
icon?: string;
|
|
31
|
+
iconColor?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface Variant {
|
|
34
|
+
id: string;
|
|
35
|
+
title: string;
|
|
36
|
+
icon?: string;
|
|
37
|
+
iconColor?: string;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|