Skip to content

Commit

Permalink
docs: upgraded to storybook 7
Browse files Browse the repository at this point in the history
  • Loading branch information
meza committed Feb 28, 2023
1 parent d193056 commit 6fbe6f9
Show file tree
Hide file tree
Showing 17 changed files with 4,283 additions and 12,080 deletions.
16 changes: 16 additions & 0 deletions .babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"sourceType": "unambiguous",
"presets": [
[
"@babel/preset-env",
{
"targets": {
"chrome": 100
}
}
],
"@babel/preset-typescript",
"@babel/preset-react"
],
"plugins": []
}
45 changes: 25 additions & 20 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,57 @@
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
import { DefinePlugin } from 'webpack';
import type { StorybookConfig } from '@storybook/react/types';

import { StorybookConfig } from '@storybook/react-webpack5';
const storybookConfig: StorybookConfig = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(ts|tsx)'],
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
'@storybook/addon-a11y',
'@storybook/addon-links',
'storybook-react-i18next',
'@storybook/addon-essentials',
// 'storybook-addon-themes', // ignore until we figure out proper theme switching
'@storybook/addon-interactions',
{
name: '@storybook/addon-docs',
options: {
configureJSX: true,
babelOptions: {},
sourceLoaderOptions: null,
transcludeMarkdown: true,
},
transcludeMarkdown: true
}
}
],
core: {
builder: 'webpack5',
disableTelemetry: true,
builder: '@storybook/builder-webpack5',
disableTelemetry: true
},
docs: {
autodocs: true
},
features: {
emotionAlias: false,
buildStoriesJson: true,
storyStoreV7: true
},
framework: {
name: '@storybook/react-webpack5',
options: {}
},
framework: '@storybook/react',
// https://storybook.js.org/docs/react/configure/typescript#mainjs-configuration
typescript: {
check: true,
check: false,
reactDocgen: 'react-docgen-typescript',
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true)
}
},
webpackFinal: async (config) => {
config.plugins?.push(
new DefinePlugin({
__DEV__: process.env.NODE_ENV !== 'production',
}),
);

webpackFinal: async config => {
config.plugins?.push(new DefinePlugin({
__DEV__: process.env.NODE_ENV !== 'production'
}));
if (config.resolve) {
config.resolve.plugins = config.resolve.plugins || [];
config.resolve.plugins.push(new TsconfigPathsPlugin());
}

return config;
}
};

export default storybookConfig;
15 changes: 4 additions & 11 deletions .storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { addons } from '@storybook/addons';
import { create } from '@storybook/theming';

const theme = create({
base: 'dark',
brandTitle: 'Storybook',
brandUrl: 'https://storybook.com',
brandImage: 'https://placekitten.com/350/100',
brandTarget: '_self',
colorPrimary: '#ED117D',
});
import { addons } from '@storybook/manager-api';
import { theme } from './theme';

addons.setConfig({
theme: theme,
});

export default theme;
38 changes: 38 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { themes } from '@storybook/theming';
import i18n from '@test/i18next';
import { theme } from './theme';

/** @type { import('@storybook/react').Preview } */
const preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
dependencies: {
// display only dependencies/dependents that have a story in storybook
// by default this is false
withStoriesOnly: true,

// completely hide a dependency/dependents block if it has no elements
// by default this is false
hideEmpty: true,
},
docs: {
theme: themes.dark,
},
backgrounds: { disable: true },
i18n,
locale: 'en',
locales: {
en: 'English'
}
}
};

export default preview;


37 changes: 0 additions & 37 deletions .storybook/preview.tsx

This file was deleted.

12 changes: 12 additions & 0 deletions .storybook/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { create } from '@storybook/theming/create';

export const theme = create({
base: 'dark',
brandTitle: 'Storybook',
brandUrl: 'https://storybook.com',
brandImage: 'https://placekitten.com/350/150',
brandTarget: '_self',
colorPrimary: '#ED117D',
});

export default theme;
17 changes: 1 addition & 16 deletions .storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
{
"extends": "../tsconfig.json",
"include": ["**/*"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"module": "commonjs",
"jsx": "react-jsx",
"moduleResolution": "node",
"target": "es5",
"rootDir": "../",
"isolatedModules": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"strict": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": ["../src/*"],
Expand All @@ -23,11 +14,5 @@
"@styles": ["../src/styles/"],
"@styles/*": ["../src/styles/*"]
}
},
"ts-node": {
"compilerOptions": {
"module": "commonjs",
"target": "es5"
}
}
}
Loading

0 comments on commit 6fbe6f9

Please sign in to comment.