Skip to content

Commit

Permalink
Refactor stories to enable show code feature
Browse files Browse the repository at this point in the history
  • Loading branch information
maxime-gendron committed May 11, 2020
1 parent ebd2b37 commit 6cc83eb
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 70 deletions.
13 changes: 5 additions & 8 deletions packages/storybook/.storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,17 @@ module.exports = {
},
{
test: /\.stories.tsx?$/,
use: [
{
loader: require.resolve('@storybook/source-loader'),
}
],
enforce: 'pre',
include: path.resolve(__dirname, '../stories')
use: [{ loader: '@storybook/source-loader' }],
enforce: 'pre',
include: path.resolve(__dirname, '../stories')
},
{
test: /\.tsx?$/,
use: [{
loader: 'ts-loader',
options: {
transpileOnly: true,
transpileOnly: false,
ignoreDiagnostics: [7005]
}
}],
},
Expand Down
39 changes: 17 additions & 22 deletions packages/storybook/stories/buttons/add-button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,54 @@
import React from 'react';

import { AddButton } from '@equisoft/design-elements-react';

type ButtonType = 'primary' | 'secondary' | 'tertiary';
import React from 'react';

export default {
title: 'Buttons/Add',
component: AddButton,
};

export const addButtons = () => (
<div>
<>
<AddButton
label="Primary"
buttonType={'primary' as ButtonType}
buttonType="primary"
disabled={false}
/>
<AddButton
label="Secondary"
buttonType={'secondary' as ButtonType}
buttonType="secondary"
disabled={false}
/>
<AddButton
label="Tertiary"
buttonType={'tertiary' as ButtonType}
buttonType="tertiary"
disabled={false}
/>
</div>
</>
);
export const disabled = () => (
<div>
<>
<AddButton
label="Primary"
buttonType={'primary' as ButtonType}
buttonType="primary"
disabled={true}
/>
<AddButton
label="Secondary"
buttonType={'secondary' as ButtonType}
buttonType="secondary"
disabled={true}
/>
<AddButton
label="Tertiary"
buttonType={'tertiary' as ButtonType}
buttonType="tertiary"
disabled={true}
/>
</div>
</>
);
export const eventCallback = () => (
<div>
<AddButton
label="See Console For Callback"
buttonType={'primary' as ButtonType}
onClick={() => { console.log('The button has been clicked!'); }}
disabled={false}
/>
</div>
<AddButton
label="See Console For Callback"
buttonType="primary"
onClick={() => { console.log('The button has been clicked!'); }}
disabled={false}
/>
);
39 changes: 17 additions & 22 deletions packages/storybook/stories/buttons/buttons.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
import React from 'react';

import { Button } from '@equisoft/design-elements-react';

type ButtonType = 'primary' | 'secondary' | 'tertiary';
import React from 'react';

export default {
title: 'Buttons',
component: Button,
};

export const buttons = () => (
<div>
<Button label="Primary" buttonType={'primary' as ButtonType} disabled={false} />
<Button label="Secondary" buttonType={'secondary' as ButtonType} disabled={false} />
<Button label="Tertiary" buttonType={'tertiary' as ButtonType} disabled={false} />
</div>
<>
<Button label="Primary" buttonType="primary" disabled={false} />
<Button label="Secondary" buttonType="secondary" disabled={false} />
<Button label="Tertiary" buttonType="tertiary" disabled={false} />
</>
);
export const disabled = () => (
<div>
<Button label="Primary" buttonType={'primary' as ButtonType} disabled={true} />
<Button label="Secondary" buttonType={'secondary' as ButtonType} disabled={true} />
<Button label="Tertiary" buttonType={'tertiary' as ButtonType} disabled={true} />
</div>
<>
<Button label="Primary" buttonType="primary" disabled={true} />
<Button label="Secondary" buttonType="secondary" disabled={true} />
<Button label="Tertiary" buttonType="tertiary" disabled={true} />
</>
);
export const eventCallback = () => (
<div>
<Button
label="See Console For Callback"
onClick={() => { console.log('The button has been clicked!'); }}
buttonType={'primary' as ButtonType}
disabled={false}
/>
</div>
<Button
label="See Console For Callback"
onClick={() => { console.log('The button has been clicked!'); }}
buttonType="primary"
disabled={false}
/>
);
14 changes: 6 additions & 8 deletions packages/storybook/stories/buttons/icon-button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ export const disabled = () => (
</>
);
export const eventCallback = () => (
<>
<IconButton
label="home"
iconName="home"
onClick={() => { console.log('The button has been clicked!'); }}
buttonType={'primary'}
/>
</>
<IconButton
label="home"
iconName="home"
onClick={() => { console.log('The button has been clicked!'); }}
buttonType={'primary'}
/>
);
2 changes: 1 addition & 1 deletion packages/storybook/stories/card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {

export const normal = () => (
<Card>Hello, World!</Card>
);
);
14 changes: 6 additions & 8 deletions packages/storybook/stories/theme-wrapper.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React from 'react';

import { Button, testTheme, ThemeWrapper } from '@equisoft/design-elements-react';

type ButtonType = 'primary' | 'secondary' | 'tertiary';

export default {
title: 'Theme Wrapper',
component: ThemeWrapper,
Expand All @@ -14,16 +12,16 @@ export const normal = () => (
<ThemeWrapper theme={testTheme}>
<div>
<h3 style={{ marginTop: '0' }} >With wrapper (test theme)</h3>
<Button label="Primary" buttonType={'primary' as ButtonType} disabled={false} />
<Button label="Secondary" buttonType={'secondary' as ButtonType} disabled={false} />
<Button label="Tertiary" buttonType={'tertiary' as ButtonType} disabled={false} />
<Button label="Primary" buttonType="primary" disabled={false} />
<Button label="Secondary" buttonType="secondary" disabled={false} />
<Button label="Tertiary" buttonType="tertiary" disabled={false} />
</div>
</ThemeWrapper>
<div>
<h3>Without wrapper (default Equisoft theme)</h3>
<Button label="Primary" buttonType={'primary' as ButtonType} disabled={false} />
<Button label="Secondary" buttonType={'secondary' as ButtonType} disabled={false} />
<Button label="Tertiary" buttonType={'tertiary' as ButtonType} disabled={false} />
<Button label="Primary" buttonType="primary" disabled={false} />
<Button label="Secondary" buttonType="secondary" disabled={false} />
<Button label="Tertiary" buttonType="tertiary" disabled={false} />
</div>
</>
);
1 change: 0 additions & 1 deletion packages/storybook/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"esModuleInterop": true,
"jsx": "react",
"allowSyntheticDefaultImports": true,
"noEmitOnError": true,
"sourceMap": true,
"baseUrl": "./stories/",
"paths": {
Expand Down

0 comments on commit 6cc83eb

Please sign in to comment.