-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Impl [General] StoryBook: add stories of buttons (#431)
- Loading branch information
1 parent
dfb5fe3
commit 0fe0307
Showing
28 changed files
with
537 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
module.exports = { | ||
"stories": [ | ||
"../src/**/*.stories.mdx", | ||
"../src/**/*.stories.@(js|jsx|ts|tsx)" | ||
], | ||
"addons": [ | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
'@storybook/preset-scss' | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
export const parameters = { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import classNames from 'classnames' | ||
|
||
import './button.scss' | ||
|
||
const Button = ({ className, label, variant, ...restProps }) => { | ||
const buttonClassName = classNames('btn', `btn-${variant}`, className) | ||
|
||
return ( | ||
<button {...restProps} className={buttonClassName}> | ||
{label} | ||
</button> | ||
) | ||
} | ||
|
||
Button.defaultProps = { | ||
className: '', | ||
label: 'Button', | ||
variant: 'tertiary' | ||
} | ||
|
||
Button.propTypes = { | ||
className: PropTypes.string, | ||
label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), | ||
variant: PropTypes.PropTypes.oneOf([ | ||
'primary', | ||
'secondary', | ||
'tertiary', | ||
'danger', | ||
'label' | ||
]).isRequired | ||
} | ||
|
||
export default Button |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react' | ||
|
||
import Button from './Button' | ||
|
||
export default { | ||
title: 'Example/Button', | ||
component: Button | ||
} | ||
|
||
const commonArgs = { | ||
disabled: false | ||
} | ||
|
||
const Template = args => <Button {...args} /> | ||
|
||
export const Primary = Template.bind({}) | ||
Primary.args = { | ||
...commonArgs, | ||
label: 'Primary button', | ||
variant: 'primary' | ||
} | ||
|
||
export const Secondary = Template.bind({}) | ||
Secondary.args = { | ||
...commonArgs, | ||
label: 'Secondary button', | ||
variant: 'secondary' | ||
} | ||
|
||
export const Tertiary = Template.bind({}) | ||
Tertiary.args = { | ||
...commonArgs, | ||
label: 'Tertiary button', | ||
variant: 'tertiary' | ||
} | ||
|
||
export const Danger = Template.bind({}) | ||
Danger.args = { | ||
...commonArgs, | ||
label: 'Danger button', | ||
variant: 'danger' | ||
} | ||
|
||
export const Label = Template.bind({}) | ||
Label.args = { | ||
...commonArgs, | ||
label: 'Label button', | ||
variant: 'label' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
@import '../../scss/variables'; | ||
@import '../../scss/colors'; | ||
@import '../../scss/borders'; | ||
|
||
.btn { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
min-width: 90px; | ||
height: 36px; | ||
padding: 0 16px; | ||
color: $white; | ||
font-weight: 500; | ||
font-size: 14px; | ||
font-family: Roboto, sans-serif; | ||
font-style: normal; | ||
line-height: 16px; | ||
border: 1px solid transparent; | ||
border-radius: $mainBorderRadius; | ||
|
||
svg { | ||
path { | ||
fill: $white; | ||
} | ||
} | ||
|
||
&:focus { | ||
border-color: rgba($black, 0.4); | ||
} | ||
|
||
&:active { | ||
border-color: rgba($black, 0.4); | ||
} | ||
|
||
&:disabled { | ||
color: $spunPearl; | ||
background: $white; | ||
cursor: not-allowed; | ||
|
||
svg { | ||
path { | ||
fill: $alto; | ||
} | ||
} | ||
} | ||
|
||
:first-child { | ||
margin-right: 5px; | ||
} | ||
|
||
&-primary { | ||
background: $brightTurquoise; | ||
|
||
&:hover { | ||
background: $javaLight; | ||
} | ||
|
||
&:active { | ||
background: $mountainMeadow; | ||
} | ||
|
||
&:disabled { | ||
border: 1px solid $brightTurquoise; | ||
} | ||
} | ||
|
||
&-tertiary { | ||
color: $primary; | ||
background: $white; | ||
border: $primaryBorder; | ||
|
||
svg { | ||
path { | ||
fill: $primary; | ||
} | ||
} | ||
|
||
&:hover { | ||
background: $alabaster; | ||
} | ||
|
||
&:active { | ||
background: $mercury; | ||
} | ||
|
||
&:disabled { | ||
border: $primaryBorder; | ||
} | ||
} | ||
|
||
&-secondary { | ||
background: $malibu; | ||
|
||
&:hover { | ||
background: $cornflowerBlue; | ||
} | ||
|
||
&:active { | ||
background: $indigo; | ||
} | ||
|
||
&:disabled { | ||
border: 1px solid $malibu; | ||
} | ||
} | ||
|
||
&-danger { | ||
color: $white; | ||
background: $amaranth; | ||
|
||
&:hover { | ||
background: $ceriseRed; | ||
} | ||
|
||
&:active { | ||
background: $maroonFlash; | ||
} | ||
|
||
&:disabled { | ||
border: 1px solid $amaranth; | ||
} | ||
} | ||
|
||
&-label { | ||
color: $primary; | ||
background: $white; | ||
border: 0; | ||
|
||
svg { | ||
path { | ||
fill: $primary; | ||
} | ||
} | ||
|
||
&:focus { | ||
border: $dividerBorder; | ||
} | ||
|
||
&:hover { | ||
color: $topaz; | ||
} | ||
|
||
&:active { | ||
color: $black; | ||
border-color: transparent; | ||
} | ||
|
||
&:disabled { | ||
border-color: transparent; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import classNames from 'classnames' | ||
|
||
import './loadButton.scss' | ||
|
||
const LoadButton = ({ className, label, variant, ...restProps }) => { | ||
const buttonClassName = classNames( | ||
'btn-load', | ||
`btn-load-${variant}`, | ||
className | ||
) | ||
|
||
return ( | ||
<button {...restProps} className={buttonClassName}> | ||
{label} | ||
</button> | ||
) | ||
} | ||
|
||
LoadButton.defaultProps = { | ||
classList: '', | ||
label: 'Load button', | ||
variant: 'tertiary' | ||
} | ||
|
||
LoadButton.propTypes = { | ||
classList: PropTypes.string, | ||
label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), | ||
variant: PropTypes.PropTypes.oneOf(['primary', 'secondary', 'tertiary']) | ||
.isRequired | ||
} | ||
|
||
export default LoadButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react' | ||
|
||
import LoadButton from './LoadButton' | ||
|
||
export default { | ||
title: 'Example/LoadButton', | ||
component: LoadButton | ||
} | ||
|
||
const commonArgs = { | ||
disabled: false | ||
} | ||
|
||
const Template = args => <LoadButton {...args} /> | ||
|
||
export const PrimaryLoader = Template.bind({}) | ||
PrimaryLoader.args = { | ||
...commonArgs, | ||
label: 'Primary loader', | ||
variant: 'primary' | ||
} | ||
|
||
export const SecondaryLoader = Template.bind({}) | ||
SecondaryLoader.args = { | ||
...commonArgs, | ||
label: 'Secondary loader', | ||
variant: 'secondary' | ||
} | ||
|
||
export const TertiaryLoader = Template.bind({}) | ||
TertiaryLoader.args = { | ||
...commonArgs, | ||
label: 'Tertiary loader', | ||
variant: 'tertiary' | ||
} |
Oops, something went wrong.