Skip to content

Commit

Permalink
Upgrade to storybook v8 + vite
Browse files Browse the repository at this point in the history
This remove dependency to outdated CRA/webpack
  • Loading branch information
ronnyroeller committed Mar 22, 2024
1 parent 3d51cab commit a839379
Show file tree
Hide file tree
Showing 19 changed files with 19,479 additions and 57,465 deletions.
42 changes: 0 additions & 42 deletions .storybook/main.js

This file was deleted.

15 changes: 15 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
stories: ['./stories/**/*.stories.@(ts|tsx)'],
addons: [
'@storybook/addon-actions',
'@storybook/addon-controls',
'@storybook/addon-toolbars',
],
framework: {
name: '@storybook/react-vite',
options: {},
},
};
export default config;
15 changes: 0 additions & 15 deletions .storybook/preview.js

This file was deleted.

21 changes: 21 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Preview } from '@storybook/react';

const preview: Preview = {
parameters: {
backgrounds: {
default: 'light',
values: [
{
name: 'light',
value: '#fafafa',
},
{
name: 'dark',
value: '#303030',
},
],
},
},
};

export default preview;
6 changes: 1 addition & 5 deletions .storybook/stories/basic.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useCallback } from 'react';

import { Board, Card, Column } from '../../src';

import { withDescription } from '../utils';
import { useColumns, COLUMNS } from './utils/columns';
import { withTheme } from './utils/with-theme';

Expand Down Expand Up @@ -52,7 +51,4 @@ function BasicStory() {
);
}

export const Basic = withDescription(
'The Kanban board provides columns and cards that can be dragged around',
() => <BasicStory />,
);
export const Basic = () => <BasicStory />;
6 changes: 1 addition & 5 deletions .storybook/stories/custom-add-column-button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Board } from '../../src';

import { withDescription } from '../utils';
import { useColumns, COLUMNS } from './utils/columns';
import { withTheme } from './utils/with-theme';

Expand All @@ -24,7 +23,4 @@ function AddColumnButtonStory() {
);
}

export const AddColumnButton = withDescription(
'Add button can be changed',
() => <AddColumnButtonStory />,
);
export const AddColumnButton = () => <AddColumnButtonStory />;
6 changes: 1 addition & 5 deletions .storybook/stories/custom-card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { DraggableProvided } from 'react-beautiful-dnd';

import { Board, Card } from '../../src';

import { withDescription } from '../utils';
import { useColumns, COLUMNS } from './utils/columns';
import { withTheme } from './utils/with-theme';

Expand Down Expand Up @@ -46,7 +45,4 @@ function CustomCardStory() {
);
}

export const CustomCard = withDescription(
'Card renderer can be changed',
() => <CustomCardStory />,
);
export const CustomCard = () => <CustomCardStory />;
11 changes: 2 additions & 9 deletions .storybook/stories/custom-column.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import CallToAction from '@mui/icons-material/CallToAction';

import { Board, Column } from '../../src';

import { withDescription } from '../utils';
import { useColumns, COLUMNS } from './utils/columns';
import { withTheme } from './utils/with-theme';

Expand Down Expand Up @@ -40,10 +39,7 @@ function ColumnActionsStory() {
);
}

export const ColumnActions = withDescription(
'The column header (actions) can be customized',
() => <ColumnActionsStory />,
);
export const ColumnActions = () => <ColumnActionsStory />;

function ColumnNameStory() {
const [columns, setColumns, createColumn, createCard] = useColumns(COLUMNS);
Expand All @@ -61,7 +57,4 @@ function ColumnNameStory() {
);
}

export const ColumnName = withDescription(
'The column header (name) can be customized',
() => <ColumnNameStory />,
);
export const ColumnName = () => <ColumnNameStory />;
5 changes: 1 addition & 4 deletions .storybook/stories/empty.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Board, Column } from '../../src';

import { withDescription } from '../utils';
import { useColumns } from './utils/columns';
import { withTheme } from './utils/with-theme';

Expand All @@ -25,6 +24,4 @@ function EmptyStory() {
);
}

export const Empty = withDescription('A board can be empty initially', () => (
<EmptyStory />
));
export const Empty = () => <EmptyStory />;
6 changes: 1 addition & 5 deletions .storybook/stories/external-change.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Button from '@mui/material/Button';

import { Board } from '../../src';

import { withDescription } from '../utils';
import { useColumns, COLUMNS } from './utils/columns';
import { withTheme } from './utils/with-theme';

Expand Down Expand Up @@ -31,7 +30,4 @@ function ExternalChangeStory() {
);
}

export const ExternalChange = withDescription(
'Changing the data from the outside requires re-creating the component',
() => <ExternalChangeStory />,
);
export const ExternalChange = () => <ExternalChangeStory />;
6 changes: 1 addition & 5 deletions .storybook/stories/generic-data.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import CardContent from '@mui/material/CardContent';

import { Board, Card, Column } from '../../src';

import { withDescription } from '../utils';
import { COLUMNS } from './utils/columns';
import { withTheme } from './utils/with-theme';

Expand Down Expand Up @@ -66,7 +65,4 @@ function GenericDataStory() {
);
}

export const GenericData = withDescription(
'The board handles generic data types and provides the correctly typed "card" in the render prop',
() => <GenericDataStory />,
);
export const GenericData = () => <GenericDataStory />;
6 changes: 1 addition & 5 deletions .storybook/stories/i18n.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Board, Intl } from '../../src';

import { withDescription } from '../utils';
import { useColumns, COLUMNS } from './utils/columns';
import { withTheme } from './utils/with-theme';

Expand Down Expand Up @@ -29,8 +28,5 @@ function I18nStory() {
);
}

export const I18n = withDescription(
'The `intl` parameter can be used to configure the texts in the board controls',
() => <I18nStory />,
);
export const I18n = () => <I18nStory />;
I18n.storyName = 'I18n';
11 changes: 2 additions & 9 deletions .storybook/stories/readonly.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Board } from '../../src';

import { withDescription } from '../utils';
import { useColumns, COLUMNS } from './utils/columns';
import { withTheme } from './utils/with-theme';

Expand All @@ -16,18 +15,12 @@ function ReadOnlyStory() {
return <Board columns={columns} onChange={setColumns} />;
}

export const ReadOnly = withDescription(
'By not providing the `createColumn` and/or `createCard` parameters the board no longer allows creating columns and cards, respectively.',
() => <ReadOnlyStory />,
);
export const ReadOnly = () => <ReadOnlyStory />;

function ViewOnlyStory() {
const [columns] = useColumns(COLUMNS);

return <Board columns={columns} />;
}

export const ViewOnly = withDescription(
'By not providing any callbacks the board will only show the content',
() => <ViewOnlyStory />,
);
export const ViewOnly = () => <ViewOnlyStory />;
6 changes: 1 addition & 5 deletions .storybook/stories/styling.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { makeStyles } from 'tss-react/mui';

import { Board, Column } from '../../src';

import { withDescription } from '../utils';
import { useColumns } from './utils/columns';
import { withTheme } from './utils/with-theme';

Expand Down Expand Up @@ -87,7 +86,4 @@ function StylingStory() {
);
}

export const Styling = withDescription(
'The columns of the board can be styled',
() => <StylingStory />,
);
export const Styling = () => <StylingStory />;
9 changes: 6 additions & 3 deletions .storybook/stories/utils/with-theme.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createTheme, CssBaseline } from '@mui/material';
import { ThemeProvider } from '@mui/material/styles';
import { StoryFn } from '@storybook/react';

import { StoryContext } from '@storybook/addons';
import type { StoryContext } from '@storybook/types';

const theme = createTheme({
components: {
Expand All @@ -17,8 +18,10 @@ const theme = createTheme({
},
});

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const withTheme = (Story: any, context: StoryContext): JSX.Element => {
export const withTheme = (
Story: StoryFn,
context: StoryContext,
): JSX.Element => {
return (
<ThemeProvider theme={theme}>
<CssBaseline />
Expand Down
24 changes: 0 additions & 24 deletions .storybook/utils.ts

This file was deleted.

0 comments on commit a839379

Please sign in to comment.