Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit 0923190

Browse files
feat: upgrade storybook (#438)
1 parent 71b138c commit 0923190

File tree

54 files changed

+12574
-21536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+12574
-21536
lines changed

.storybook/main.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
const path = require('path');
2-
31
module.exports = {
42
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
3+
54
addons: [
65
'@storybook/addon-links',
76
'@storybook/addon-docs',
87
'@storybook/addon-essentials',
98
'@storybook/addon-a11y',
109
'@storybook/addon-postcss'
1110
],
11+
1212
staticDirs: ['../src/assets/images'],
13-
webpackFinal: async (config) => {
14-
config.module.rules.push({
15-
test: /\.scss$/,
16-
use: ['vue-style-loader', 'css-loader', 'sass-loader', 'postcss-loader'],
17-
include: path.resolve(__dirname, '../')
18-
});
1913

20-
config.resolve.alias['@'] = path.resolve(__dirname, '../src');
14+
framework: {
15+
name: '@storybook/vue3-vite',
16+
options: {}
17+
},
2118

22-
return config;
19+
docs: {
20+
autodocs: true
2321
}
2422
};

.storybook/preview.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import { app } from '@storybook/vue3';
1+
import { setup } from '@storybook/vue3';
22
import * as mixins from '@/mixins';
33
import * as configs from '@/config';
44

55
import '@/assets/styles/main.scss';
66

7-
app.use(configs.constants);
8-
for (const mixinName in mixins) {
9-
const mixin = mixins[mixinName];
10-
app.mixin(mixin);
11-
}
7+
setup((app) => {
8+
app.use(configs.constants);
9+
for (const mixinName in mixins) {
10+
const mixin = mixins[mixinName];
11+
app.mixin(mixin);
12+
}
13+
});
1214

1315
export const parameters = {
1416
actions: { argTypesRegex: '^on[A-Z].*' },

.storybook/routeDecorator.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { createMemoryHistory, createRouter } from 'vue-router';
2-
import { app } from '@storybook/vue3';
2+
import { getCurrentInstance } from 'vue';
33

4-
let routerInstalled = false;
54
let router;
65

76
export const routeTemplate = (name) => `<div>${name}</div>`;
@@ -13,13 +12,17 @@ export default (path = '/', routes = []) => {
1312
...routes
1413
];
1514
return (storyFn) => {
16-
if (!routerInstalled) {
15+
// It is not recommended to utilize getCurrentInstance in production code, we should find a way to stop doing this.
16+
const isVueRouterInstalled = Boolean(
17+
getCurrentInstance().appContext.config.globalProperties.$router
18+
);
19+
if (!isVueRouterInstalled) {
20+
const app = getCurrentInstance().appContext.app;
1721
router = createRouter({
1822
history: createMemoryHistory(),
1923
routes
2024
});
2125
app.use(router);
22-
routerInstalled = true;
2326
} else {
2427
routes.forEach((r) => router.addRoute(r));
2528
}

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## v2.0.5
4+
5+
- Upgrade Storybook
6+
37
## v2.0.4
48

59
- Fix text color for `Link` `upgrade-button` variant.

0 commit comments

Comments
 (0)