Skip to content

Commit

Permalink
Storybook Refactor + Mui Stories (#50)
Browse files Browse the repository at this point in the history
* Storybook Refactor + Mui Stories

---------

Co-authored-by: jackson <Jackson Hyde>
  • Loading branch information
jacksonhyde authored Nov 21, 2024
1 parent 4398ba1 commit 15e2933
Show file tree
Hide file tree
Showing 25 changed files with 704 additions and 188 deletions.
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

0 comments on commit 15e2933

Please sign in to comment.