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

Storybook Refactor + Mui Stories #50

Merged
merged 2 commits into from
Nov 21, 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
21 changes: 19 additions & 2 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { StorybookConfig } from '@storybook/react-webpack5';
const config: StorybookConfig = {
stories: [
'../src/**/*.stories.mdx',
'../src/**/*.mdx',
'../src/**/*.stories.@(js|jsx|ts|tsx)'
],

Expand All @@ -14,6 +14,7 @@ const config: StorybookConfig = {
'@storybook/addon-themes',
'@storybook/addon-webpack5-compiler-babel',
'@storybook/addon-a11y',
'@kemuridama/storybook-addon-github',
],

framework: {
Expand All @@ -24,7 +25,23 @@ const config: StorybookConfig = {
docs: {},

typescript: {
reactDocgen: 'react-docgen-typescript'
reactDocgen: 'react-docgen-typescript',
reactDocgenTypescriptOptions: {
// Speeds up Storybook build time
compilerOptions: {
allowSyntheticDefaultImports: false,
esModuleInterop: false,
},
// Makes union prop types like variant and size appear as select controls
shouldExtractLiteralValuesFromEnum: true,
// Makes string and boolean types that can be undefined appear as inputs and switches
shouldRemoveUndefinedFromOptional: true,
// Filter out third-party props from node_modules except @mui packages
propFilter: (prop) =>
prop.parent
? !/node_modules\/(?!@mui)/.test(prop.parent.fileName)
: true,
},
},
webpackFinal: async config => {
// Grab the existing rule that handles SVG imports
Expand Down
17 changes: 15 additions & 2 deletions .storybook/preview.ts → .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import * as React from 'react';
import { Preview, ReactRenderer } from "@storybook/react";
import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { fn } from '@storybook/test';
import { withTests } from '@storybook/addon-jest';
import { withThemeFromJSXProvider } from '@storybook/addon-themes';
Expand Down Expand Up @@ -26,16 +29,26 @@ const preview: Preview = {
}),
withTests({
results,
})
}),
(Story) => (
<LocalizationProvider dateAdapter={AdapterMoment}>
<Story />
</LocalizationProvider>
)
],
parameters: {
actions: { onClick: fn() },
actions: { onClick: fn(), argTypesRegex: '^on[A-Z].*' },
controls: {
expanded: true, // Adds the description and default columns
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
github: {
repository: "UKHomeOffice/drt-react",
branch: "main",
}
},
};

Expand Down
Loading
Loading