Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Add Storybook #1326

Merged
merged 3 commits into from
Apr 7, 2022
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
55 changes: 55 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const path = require('path');
const compilationHash = require('../public/compilationHash');

module.exports = {
stories: [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
addons: [
"@storybook/addon-docs",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions"
],
staticDirs: ['../public'],
framework: "@storybook/react",
typescript: {
check: false,
checkOptions: {},
reactDocgen: 'react-docgen-typescript',
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
},
},
webpackFinal: async (config) => {
config.resolve.alias = {
config: path.resolve(__dirname, '../config/'),
src: path.resolve(__dirname, '../src/'),
};

config.module.rules.unshift({
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack',
options: {
svgoConfig: {
plugins: {
removeViewBox: false,
},
},
},
},
'url-loader',
],
})

return config;
},
env: (config) => ({
...config,
COMPILATION_HASH: compilationHash,
}),
}
12 changes: 12 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<link href="/mapstyle/iconfont/iconfont.css" rel="stylesheet" />

<link href="/build/css/app-%COMPILATION_HASH%.css" rel="stylesheet" />

<style>
/* We don't want to have a theme dependant background (dark mode) */
@media (prefers-color-scheme: dark) {
body:not([data-theme='light']) {
background-color: white;
}
}
</style>
9 changes: 9 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function (api) {
browsers: ['Chrome >= 60', 'Firefox >= 44', 'Safari >= 10', 'Edge >= 17'],
},
useBuiltIns: 'entry',
corejs: 2,
corejs: 3,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it an automatic change from babel migration ?

Copy link
Member Author

@pascaloliv pascaloliv Apr 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing automatic.
@babel/polyfill was using inside corejs (in version 2).
This upgrade was necessary because Babel recommend not using @babel/polyfil anymore.
So I update core-js version to 3 in this MR.

},
],
'@babel/preset-react',
Expand Down
Loading