@vueless/storybook 0.0.1
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/.storybook/configs/main.config.js +20 -0
- package/.storybook/decorators/vue3SourceDecorator.js +119 -0
- package/.storybook/main.js +25 -0
- package/.storybook/manager-head.html +10 -0
- package/.storybook/manager.js +6 -0
- package/.storybook/preview-head.html +72 -0
- package/.storybook/preview.js +50 -0
- package/.storybook/themes/vueless.docs.theme.js +41 -0
- package/.storybook/themes/vueless.theme.js +45 -0
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/package.json +42 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import vuelessDocsTheme from "../themes/vueless.docs.theme";
|
|
2
|
+
import colors from "tailwindcss/colors";
|
|
3
|
+
|
|
4
|
+
export const docs = {
|
|
5
|
+
theme: vuelessDocsTheme,
|
|
6
|
+
source: {
|
|
7
|
+
language: "html",
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const backgrounds = {
|
|
12
|
+
default: "white",
|
|
13
|
+
values: [
|
|
14
|
+
{ name: "white", value: colors.white },
|
|
15
|
+
{ name: "light", value: colors.gray[50] },
|
|
16
|
+
{ name: "dark", value: colors.gray[900] },
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const layout = "fullscreen";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { addons, makeDecorator } from "@storybook/preview-api";
|
|
2
|
+
import { h, onMounted, watch } from "vue";
|
|
3
|
+
import { setBrandColor } from "vueless/service.ui";
|
|
4
|
+
|
|
5
|
+
export const vue3SourceDecorator = makeDecorator({
|
|
6
|
+
name: "vue3SourceDecorator",
|
|
7
|
+
wrapper: (storyFn, context) => {
|
|
8
|
+
const story = storyFn(context);
|
|
9
|
+
|
|
10
|
+
// this returns a new component that computes the source code when mounted
|
|
11
|
+
// and emits an events that is handled by addons-docs
|
|
12
|
+
// watch args and re-emit on change
|
|
13
|
+
return {
|
|
14
|
+
components: { story },
|
|
15
|
+
setup() {
|
|
16
|
+
onMounted(() => {
|
|
17
|
+
setSourceCode();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
watch(context.args, () => {
|
|
21
|
+
setSourceCode();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
setBrandColor();
|
|
25
|
+
|
|
26
|
+
function setSourceCode() {
|
|
27
|
+
try {
|
|
28
|
+
const src = context.originalStoryFn(context.args).template;
|
|
29
|
+
const code = templateSourceCode(src, context.args, context.argTypes);
|
|
30
|
+
const channel = addons.getChannel();
|
|
31
|
+
|
|
32
|
+
const emitFormattedTemplate = async () => {
|
|
33
|
+
const prettier = await import("prettier2");
|
|
34
|
+
const prettierHtml = await import("prettier2/parser-html");
|
|
35
|
+
|
|
36
|
+
const formattedCode = prettier.format(code, {
|
|
37
|
+
parser: "html",
|
|
38
|
+
plugins: [prettierHtml],
|
|
39
|
+
htmlWhitespaceSensitivity: "ignore",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// emits an event when the transformation is completed
|
|
43
|
+
channel.emit("storybook/docs/snippet-rendered", {
|
|
44
|
+
id: context.id,
|
|
45
|
+
args: context.args,
|
|
46
|
+
source: formattedCode,
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
emitFormattedTemplate();
|
|
51
|
+
} catch (e) {
|
|
52
|
+
// eslint-disable-next-line no-console
|
|
53
|
+
console.warn("Failed to render code", e);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return () => h("div", { style: `padding: 2rem 1.5rem 3rem 1.5rem;` }, [h(story)]);
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
function templateSourceCode(templateSource, args, argTypes) {
|
|
64
|
+
const componentArgs = {};
|
|
65
|
+
|
|
66
|
+
for (const [key, val] of Object.entries(argTypes)) {
|
|
67
|
+
const value = args[key];
|
|
68
|
+
|
|
69
|
+
if (
|
|
70
|
+
typeof val !== "undefined" &&
|
|
71
|
+
val.table &&
|
|
72
|
+
val.table.category === "props" &&
|
|
73
|
+
value !== val.defaultValue
|
|
74
|
+
) {
|
|
75
|
+
componentArgs[key] = val;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const slotTemplateCode =
|
|
80
|
+
// eslint-disable-next-line vue/max-len
|
|
81
|
+
'<template v-for="(slot, index) of slots" :key="index" v-slot:[slot]><template v-if="args[slot]">{{ args[slot] }}</template></template>';
|
|
82
|
+
const templateDefaultRegEx = /<template #default>([\s\S]*?)<\/template>/g;
|
|
83
|
+
|
|
84
|
+
return templateSource
|
|
85
|
+
.replace(/>[\s]+</g, "><")
|
|
86
|
+
.trim()
|
|
87
|
+
.replace(slotTemplateCode, "")
|
|
88
|
+
.replace(templateDefaultRegEx, "$1")
|
|
89
|
+
.replace(
|
|
90
|
+
'v-bind="args"',
|
|
91
|
+
Object.keys(componentArgs)
|
|
92
|
+
.map((key) => " " + propToSource(kebabCase(key), args[key]))
|
|
93
|
+
.join(""),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function propToSource(key, val) {
|
|
98
|
+
const type = typeof val;
|
|
99
|
+
|
|
100
|
+
switch (type) {
|
|
101
|
+
case "boolean":
|
|
102
|
+
return val ? key : "";
|
|
103
|
+
case "string":
|
|
104
|
+
return `${key}="${val}"`;
|
|
105
|
+
default:
|
|
106
|
+
return `:${key}="${val}"`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function kebabCase(str) {
|
|
111
|
+
return str
|
|
112
|
+
.split("")
|
|
113
|
+
.map((letter, idx) => {
|
|
114
|
+
return letter.toUpperCase() === letter
|
|
115
|
+
? `${idx !== 0 ? "-" : ""}${letter.toLowerCase()}`
|
|
116
|
+
: letter;
|
|
117
|
+
})
|
|
118
|
+
.join("");
|
|
119
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @type { import('@storybook/vue3-vite').StorybookConfig } */
|
|
2
|
+
export default {
|
|
3
|
+
stories: [
|
|
4
|
+
"../node_modules/vueless/**/*.stories.@(js|jsx|ts|tsx)",
|
|
5
|
+
"../node_modules/vueless/**/*.@(mdx)",
|
|
6
|
+
// TODO: Remove it later
|
|
7
|
+
"../.vueless/**/*.stories.@(js|jsx|ts|tsx)",
|
|
8
|
+
"../.vueless/**/*.@(mdx)"],
|
|
9
|
+
addons: [
|
|
10
|
+
"@storybook/addon-links",
|
|
11
|
+
"@storybook/addon-essentials",
|
|
12
|
+
"@storybook/addon-interactions",
|
|
13
|
+
],
|
|
14
|
+
framework: {
|
|
15
|
+
name: "@storybook/vue3-vite",
|
|
16
|
+
options: {},
|
|
17
|
+
},
|
|
18
|
+
docs: {
|
|
19
|
+
autodocs: true,
|
|
20
|
+
},
|
|
21
|
+
env: (config) => ({
|
|
22
|
+
...config,
|
|
23
|
+
BASE_URL: "/",
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Overrides content of preview IFRAME HTML page's <head> tag,
|
|
3
|
+
affecting rendered component(s) below Canvas and Docs tabs.
|
|
4
|
+
-->
|
|
5
|
+
<!-- Fonts overriding -->
|
|
6
|
+
<link rel="dns-prefetch" href="https://fonts.googleapis.com">
|
|
7
|
+
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
|
|
8
|
+
<link rel="preconnect" crossorigin="anonymous" href="https://fonts.googleapis.com">
|
|
9
|
+
<link rel="preconnect" crossorigin="anonymous" href="https://fonts.gstatic.com">
|
|
10
|
+
<link rel="stylesheet" crossorigin="anonymous" href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap">
|
|
11
|
+
|
|
12
|
+
<!-- Styles overriding -->
|
|
13
|
+
<style>
|
|
14
|
+
body {
|
|
15
|
+
font-family: Roboto, sans-serif;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
#storybook-docs h2 {
|
|
19
|
+
margin-top: 32px !important;
|
|
20
|
+
margin-bottom: 24px !important;
|
|
21
|
+
padding-bottom: 8px !important;
|
|
22
|
+
font-weight: bold !important;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.docblock-argstable-body {
|
|
26
|
+
filter: none !important;
|
|
27
|
+
border-radius: 0.5rem !important;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.docblock-argstable-body tr:not([title]) > td {
|
|
31
|
+
background-color: white !important;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.docblock-argstable-body tr td {
|
|
35
|
+
border-radius: 0 !important;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.sbdocs-preview {
|
|
39
|
+
box-shadow: none !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.docblock-argstable [type='checkbox']:checked,
|
|
43
|
+
.docblock-argstable [type='radio']:checked {
|
|
44
|
+
background-color: rgb(17 24 39) !important;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.docblock-argstable [type='checkbox']:focus,
|
|
48
|
+
.docblock-argstable [type='radio']:focus {
|
|
49
|
+
@apply !ring-gray-300;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.markdown {
|
|
53
|
+
.docblock-source {
|
|
54
|
+
margin: 0px 0 24px !important;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
code {
|
|
58
|
+
background-color: #f3f4f6 !important;
|
|
59
|
+
border-color: #d1d5db !important;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.sbdocs-a {
|
|
63
|
+
border-bottom: dashed 1px #4b5563;
|
|
64
|
+
color: #4b5563;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.sbdocs-a:hover {
|
|
68
|
+
border-bottom: none;
|
|
69
|
+
color: #4b5563;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
</style>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { setup } from "@storybook/vue3";
|
|
2
|
+
import { backgrounds, docs, layout } from "./configs/main.config";
|
|
3
|
+
import { vue3SourceDecorator } from "./decorators/vue3SourceDecorator";
|
|
4
|
+
|
|
5
|
+
// Vue plugins
|
|
6
|
+
import { createStore } from "vuex"; // TODO: remove it later
|
|
7
|
+
import { createRouter, createWebHistory } from "vue-router";
|
|
8
|
+
import NotifyServiceDefault from "vueless/ui.notify/services"; // TODO: move to UI components
|
|
9
|
+
|
|
10
|
+
// Tailwind styles
|
|
11
|
+
import "@/assets/css/index.pcss";
|
|
12
|
+
|
|
13
|
+
// Common stores TODO: move to UI components
|
|
14
|
+
import loader from "vueless/ui.loader-rendering/store";
|
|
15
|
+
import loaderTop from "vueless/ui.loader-top/store";
|
|
16
|
+
import breakpoint from "vueless/ui.viewport/store";
|
|
17
|
+
|
|
18
|
+
// Create store instance
|
|
19
|
+
const store = createStore({
|
|
20
|
+
modules: { loader, loaderTop, breakpoint },
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Create router instance
|
|
24
|
+
const router = createRouter({
|
|
25
|
+
history: createWebHistory("/"),
|
|
26
|
+
routes: [{ path: "/:pathMatch(.*)*", component: () => import("vueless/ui.container-page") }],
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Create storybook app instance
|
|
30
|
+
const storybookApp = (app) => {
|
|
31
|
+
app.use(store);
|
|
32
|
+
app.use(router);
|
|
33
|
+
app.use(new NotifyServiceDefault().notifyInstance);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Setup storybook
|
|
37
|
+
setup(storybookApp);
|
|
38
|
+
|
|
39
|
+
// Set storybook config
|
|
40
|
+
export default {
|
|
41
|
+
decorators: [vue3SourceDecorator],
|
|
42
|
+
parameters: {
|
|
43
|
+
layout,
|
|
44
|
+
docs,
|
|
45
|
+
backgrounds,
|
|
46
|
+
options: {
|
|
47
|
+
storySort: (a, b) => (a.id === b.id ? 0 : a.name === "Docs" && a.id.localeCompare(b.id, undefined, { numeric: true })),
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { create } from "@storybook/theming/create";
|
|
2
|
+
import colors from "tailwindcss/colors";
|
|
3
|
+
|
|
4
|
+
export default create({
|
|
5
|
+
base: "light",
|
|
6
|
+
// Typography
|
|
7
|
+
fontBase: '"Roboto", sans-serif',
|
|
8
|
+
fontCode: "monospace",
|
|
9
|
+
|
|
10
|
+
// Main colors
|
|
11
|
+
colorPrimary: colors.gray["900"],
|
|
12
|
+
colorSecondary: colors.gray["500"],
|
|
13
|
+
|
|
14
|
+
// UI
|
|
15
|
+
appBg: colors.gray["100"],
|
|
16
|
+
appPreviewBg: colors.gray["50"],
|
|
17
|
+
appBorderColor: colors.gray["200"],
|
|
18
|
+
appContentBg: colors.gray["50"],
|
|
19
|
+
appBorderRadius: 8,
|
|
20
|
+
|
|
21
|
+
// Text colors
|
|
22
|
+
textColor: colors.gray["900"],
|
|
23
|
+
textInverseColor: colors.gray["50"],
|
|
24
|
+
|
|
25
|
+
// Toolbar default and active colors
|
|
26
|
+
barTextColor: colors.gray["500"],
|
|
27
|
+
barHoverColor: colors.gray["600"],
|
|
28
|
+
barSelectedColor: colors.gray["700"],
|
|
29
|
+
barBg: colors.white,
|
|
30
|
+
|
|
31
|
+
// Form colors
|
|
32
|
+
inputBg: colors.white,
|
|
33
|
+
inputBorder: colors.gray["300"],
|
|
34
|
+
inputTextColor: colors.gray["900"],
|
|
35
|
+
inputBorderRadius: 4,
|
|
36
|
+
|
|
37
|
+
buttonBg: colors.gray["100"],
|
|
38
|
+
buttonBorder: colors.gray["200"],
|
|
39
|
+
booleanBg: colors.gray["50"],
|
|
40
|
+
booleanSelectedBg: colors.gray["200"],
|
|
41
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { create } from "@storybook/theming/create";
|
|
2
|
+
import colors from "tailwindcss/colors";
|
|
3
|
+
|
|
4
|
+
export default create({
|
|
5
|
+
base: "light",
|
|
6
|
+
// Typography
|
|
7
|
+
fontBase: '"Roboto", sans-serif',
|
|
8
|
+
fontCode: "monospace",
|
|
9
|
+
|
|
10
|
+
brandTitle: "Vueless UI",
|
|
11
|
+
brandUrl: "https://vueless.com",
|
|
12
|
+
brandImage: "/static/storybook/vueless-logo.png",
|
|
13
|
+
brandTarget: "_blank",
|
|
14
|
+
|
|
15
|
+
// Main colors
|
|
16
|
+
colorPrimary: colors.gray["900"],
|
|
17
|
+
colorSecondary: colors.gray["500"],
|
|
18
|
+
|
|
19
|
+
// UI
|
|
20
|
+
appBg: colors.white,
|
|
21
|
+
appPreviewBg: colors.gray["50"],
|
|
22
|
+
appBorderColor: colors.gray["300"],
|
|
23
|
+
appBorderRadius: 0,
|
|
24
|
+
|
|
25
|
+
// Text colors
|
|
26
|
+
textColor: colors.gray["900"],
|
|
27
|
+
textInverseColor: colors.gray["50"],
|
|
28
|
+
|
|
29
|
+
// Toolbar default and active colors
|
|
30
|
+
barTextColor: colors.gray["500"],
|
|
31
|
+
barHoverColor: colors.gray["600"],
|
|
32
|
+
barSelectedColor: colors.gray["700"],
|
|
33
|
+
barBg: colors.gray["50"],
|
|
34
|
+
|
|
35
|
+
// Form colors
|
|
36
|
+
inputBg: colors.white,
|
|
37
|
+
inputBorder: colors.gray["300"],
|
|
38
|
+
inputTextColor: colors.gray["900"],
|
|
39
|
+
inputBorderRadius: 4,
|
|
40
|
+
|
|
41
|
+
buttonBg: colors.gray["100"],
|
|
42
|
+
buttonBorder: colors.gray["100"],
|
|
43
|
+
booleanBg: colors.white,
|
|
44
|
+
booleanSelectedBg: colors.gray["100"],
|
|
45
|
+
});
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 vueless
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vueless/storybook",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "The package simplifies Storybook configuration for Vueless UI library.",
|
|
5
|
+
"homepage": "https://vueless.com",
|
|
6
|
+
"author": "Johnny Grid",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "index.js",
|
|
10
|
+
"private": false,
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"registry": "https://registry.npmjs.org/"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/vuelessjs/vueless-storybook.git"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/vuelessjs/vueless-storybook/issues"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@storybook/addon-essentials": "^8.0.0",
|
|
27
|
+
"@storybook/addon-interactions": "^8.0.0",
|
|
28
|
+
"@storybook/addon-links": "^8.0.0",
|
|
29
|
+
"@storybook/blocks": "^8.0.0",
|
|
30
|
+
"@storybook/manager-api": "^8.0.0",
|
|
31
|
+
"@storybook/test": "^8.0.0",
|
|
32
|
+
"@storybook/theming": "^8.0.0",
|
|
33
|
+
"@storybook/vue3": "^8.0.0",
|
|
34
|
+
"@storybook/vue3-vite": "^8.0.0",
|
|
35
|
+
"prettier2": "npm:prettier@2.8.8",
|
|
36
|
+
"storybook": "^8.0.0",
|
|
37
|
+
"tailwindcss": "^3.3.3"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"vueless": "^0.0.3"
|
|
41
|
+
}
|
|
42
|
+
}
|