-
Notifications
You must be signed in to change notification settings - Fork 311
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
add storybook with buttons #3792
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** @type { import('@storybook/react-webpack5').StorybookConfig } */ | ||
const config = { | ||
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], | ||
addons: [ | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@storybook/addon-onboarding", | ||
"@storybook/addon-interactions", | ||
], | ||
framework: { | ||
name: "@storybook/react-webpack5", | ||
options: { | ||
builder: { | ||
useSWC: true, | ||
}, | ||
}, | ||
}, | ||
docs: { | ||
autodocs: "tag", | ||
}, | ||
}; | ||
export default config; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** @type { import('@storybook/react').Preview } */ | ||
const preview = { | ||
parameters: { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default preview; |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const colors = { | ||
primary: '#0834CD', | ||
primaryHover: '#09288A', | ||
secondaryHover: '#F5F7FD', | ||
darkGrey: '#454F69', | ||
middleGrey: '#8C92A2', | ||
grey: '#AEB2BE', | ||
lightGrey: '#E5E6EA', | ||
white: '#ffffff', | ||
}; | ||
|
||
export default colors; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// import React from 'react'; | ||
// import PropTypes from 'prop-types'; | ||
// import './button.css'; | ||
|
||
// /** | ||
// * Primary UI component for user interaction | ||
// */ | ||
// export const Button = ({ primary, backgroundColor, size, label, ...props }) => { | ||
// const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary'; | ||
// return ( | ||
// <button | ||
// type="button" | ||
// className={['storybook-button', `storybook-button--${size}`, mode].join(' ')} | ||
// style={backgroundColor && { backgroundColor }} | ||
// {...props} | ||
// > | ||
// {label} | ||
// </button> | ||
// ); | ||
// }; | ||
|
||
// Button.propTypes = { | ||
// /** | ||
// * Is this the principal call to action on the page? | ||
// */ | ||
// primary: PropTypes.bool, | ||
// /** | ||
// * What background color to use | ||
// */ | ||
// backgroundColor: PropTypes.string, | ||
// /** | ||
// * How large should the button be? | ||
// */ | ||
// size: PropTypes.oneOf(['small', 'medium', 'large']), | ||
// /** | ||
// * Button contents | ||
// */ | ||
// label: PropTypes.string.isRequired, | ||
// /** | ||
// * Optional click handler | ||
// */ | ||
// onClick: PropTypes.func, | ||
// }; | ||
|
||
// Button.defaultProps = { | ||
// backgroundColor: null, | ||
// primary: false, | ||
// size: 'medium', | ||
// onClick: undefined, | ||
// }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import Button from '../../components/Buttons/BaseButton'; | ||
|
||
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export | ||
export default { | ||
title: 'Example/Button', | ||
component: Button, | ||
parameters: { | ||
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout | ||
layout: 'centered', | ||
}, | ||
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs | ||
tags: ['autodocs'], | ||
// More on argTypes: https://storybook.js.org/docs/api/argtypes | ||
// argTypes: { | ||
// backgroundColor: { control: 'color' }, | ||
// }, | ||
args: { | ||
primary: true, | ||
}, | ||
}; | ||
|
||
export const Primary = { | ||
args: { | ||
primary: true, | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args | ||
export const AllButtons = (args) => ( | ||
<ButtonContainer> | ||
<Button {...Primary.args} primary size="large" label="Primary Large Disabled Button" /> | ||
<Button {...Primary.args} primary={false} size="large" label="PrimaryLarge Disabled Button" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control. |
||
<Button {...Primary.args} primary label="Primary Medium Button" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control. |
||
<Button {...PrimaryDisabled.args} primary={false} label="Primary Medium Disabled Button" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control. |
||
<Button {...Primary.args} primary size="small" label="Primary Small Button" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control. |
||
<Button {...PrimaryDisabled.args} primary={false} size="small" label="Primary Small Disabled" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control. |
||
<Button {...Secondary.args} secondary label="Secondary Button" /> | ||
</ButtonContainer> | ||
); | ||
|
||
export const PrimaryDisabled = { | ||
args: { | ||
primary: false, | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
export const Secondary = { | ||
args: { | ||
secondary: true, | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
export const Large = { | ||
args: { | ||
primary: true, | ||
size: 'large', | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
export const Medium = { | ||
args: { | ||
primary: true, | ||
size: 'medium', | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
export const Small = { | ||
args: { | ||
primary: true, | ||
size: 'small', | ||
label: 'Button', | ||
}, | ||
}; | ||
|
||
const ButtonContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 34px; | ||
flex-direction: column; | ||
`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.