Skip to content

Commit 6fe2b28

Browse files
committed
Initial Storybook installation. Adds basic configuration for base button component.
1 parent 878ec66 commit 6fe2b28

File tree

9 files changed

+3949
-276
lines changed

9 files changed

+3949
-276
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ yarn.lock
2323
/test-results
2424

2525
*.swp
26+
27+
*storybook.log

.storybook/main.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
3+
/** @type { import('@storybook/react-webpack5').StorybookConfig } */
4+
const config = {
5+
"stories": [
6+
"../assets/src/components/**/*.mdx",
7+
"../assets/src/components/**/*.stories.@(js|jsx|mjs|ts|tsx)"
8+
],
9+
"addons": [
10+
"@storybook/addon-webpack5-compiler-swc",
11+
"@storybook/addon-essentials",
12+
"@storybook/addon-onboarding",
13+
"@storybook/addon-interactions"
14+
],
15+
"framework": {
16+
"name": "@storybook/react-webpack5",
17+
"options": {}
18+
}
19+
};
20+
export default config;

.storybook/preview.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/** @type { import('@storybook/react').Preview } */
2+
const preview = {
3+
parameters: {
4+
controls: {
5+
matchers: {
6+
color: /(background|color)$/i,
7+
date: /Date$/i,
8+
},
9+
},
10+
},
11+
};
12+
13+
export default preview;

assets/build/index.min.js

Lines changed: 23 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/src/components/base/button/Button.jsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
VisuallyHidden
99
} from 'react-aria'
1010

11+
import PropTypes from 'prop-types';
12+
1113
import { triggerEvent } from '../../../events'
1214

1315
/**
@@ -62,4 +64,31 @@ const Button = forwardRef(({
6264
)
6365
})
6466

67+
Button.propTypes = {
68+
/** How large should the button be? */
69+
layout: PropTypes.oneOf(['small', 'medium', 'large']),
70+
/** Button contents */
71+
content: PropTypes.string,
72+
/** Button context for styling */
73+
context: PropTypes.string,
74+
/** Additional class names */
75+
className: PropTypes.string,
76+
/** Inline styles */
77+
style: PropTypes.object,
78+
/** Button name */
79+
name: PropTypes.string,
80+
/** Change the tag used to render the button */
81+
changeTag: PropTypes.oneOf(['button', 'span']),
82+
/** Visually hidden content */
83+
contentVisuallyHidden: PropTypes.bool,
84+
/** Button type attribute */
85+
buttonType: PropTypes.oneOf(['button', 'submit', 'reset']),
86+
/** Children nodes */
87+
children: PropTypes.node,
88+
};
89+
90+
Button.defaultProps = {
91+
buttonType: 'button',
92+
};
93+
6594
export default Button
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { fn } from '@storybook/test';
2+
3+
import Button from './Button.jsx';
4+
5+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
6+
export default {
7+
title: 'Button',
8+
component: Button,
9+
parameters: {
10+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
11+
layout: 'centered',
12+
},
13+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
14+
tags: ['autodocs'],
15+
};
16+
17+
export const Primary = {
18+
args: {
19+
layout: 'large',
20+
content: 'Primary Button',
21+
context: 'primary',
22+
},
23+
};
24+
25+
export const Secondary = {
26+
args: {
27+
layout: 'large',
28+
content: 'Secondary Button',
29+
context: 'secondary',
30+
},
31+
};

0 commit comments

Comments
 (0)