Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SELF-141: Upgrade Storybook #438

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
const path = require('path');

module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],

addons: [
'@storybook/addon-links',
'@storybook/addon-docs',
'@storybook/addon-essentials',
'@storybook/addon-a11y',
'@storybook/addon-postcss'
],

staticDirs: ['../src/assets/images'],
webpackFinal: async (config) => {
config.module.rules.push({
test: /\.scss$/,
use: ['vue-style-loader', 'css-loader', 'sass-loader', 'postcss-loader'],
include: path.resolve(__dirname, '../')
});

config.resolve.alias['@'] = path.resolve(__dirname, '../src');
framework: {
name: '@storybook/vue3-vite',
options: {}
},

return config;
docs: {
autodocs: true
}
};
14 changes: 8 additions & 6 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { app } from '@storybook/vue3';
import { setup } from '@storybook/vue3';
import * as mixins from '@/mixins';
import * as configs from '@/config';

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

app.use(configs.constants);
for (const mixinName in mixins) {
const mixin = mixins[mixinName];
app.mixin(mixin);
}
setup((app) => {
app.use(configs.constants);
for (const mixinName in mixins) {
const mixin = mixins[mixinName];
app.mixin(mixin);
}
});

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
Expand Down
11 changes: 7 additions & 4 deletions .storybook/routeDecorator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createMemoryHistory, createRouter } from 'vue-router';
import { app } from '@storybook/vue3';
import { getCurrentInstance } from 'vue';

let routerInstalled = false;
let router;

export const routeTemplate = (name) => `<div>${name}</div>`;
Expand All @@ -13,13 +12,17 @@ export default (path = '/', routes = []) => {
...routes
];
return (storyFn) => {
if (!routerInstalled) {
// It is not recommended to utilize getCurrentInstance in production code, we should find a way to stop doing this.
const isVueRouterInstalled = Boolean(
getCurrentInstance().appContext.config.globalProperties.$router
);
if (!isVueRouterInstalled) {
const app = getCurrentInstance().appContext.app;
router = createRouter({
history: createMemoryHistory(),
routes
});
app.use(router);
routerInstalled = true;
} else {
routes.forEach((r) => router.addRoute(r));
}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v2.0.5

- Upgrade Storybook

## v2.0.4

- Fix text color for `Link` `upgrade-button` variant.
Expand Down
Loading
Loading