-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1314 from vtex/feat/add-storybook
#trivial Add storybook to the master branch
- Loading branch information
Showing
18 changed files
with
5,477 additions
and
106 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
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
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,22 @@ | ||
const path = require('path') | ||
|
||
const custom = require('../config/webpack.config.js') | ||
|
||
module.exports = { | ||
stories: [ | ||
'../react/playground/stories.tsx', | ||
'../react/components/**/*.stories.tsx', | ||
], | ||
addons: [ | ||
'@storybook/addon-essentials', | ||
'@storybook/addon-a11y', | ||
'@storybook/addon-links', | ||
], | ||
webpackFinal: config => { | ||
config.resolve.extensions.push('.ts', '.tsx') | ||
return { | ||
...config, | ||
module: { ...config.module, rules: custom.module.rules }, | ||
} | ||
}, | ||
} |
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,23 @@ | ||
import { addons } from '@storybook/addons' | ||
import { create } from '@storybook/theming' | ||
|
||
addons.setConfig({ | ||
panelPosition: 'bottom', | ||
|
||
theme: create({ | ||
base: 'light', | ||
|
||
// UI | ||
appBorderRadius: 4, | ||
appBg: '#FFFFFF', | ||
textColor: '#3f3f40', | ||
|
||
// Typography | ||
fontBase: '"Fabriga", sans-serif', | ||
fontCode: 'monospace', | ||
|
||
brandTitle: 'VTEX Styleguide', | ||
brandUrl: '/', | ||
brandImage: null, | ||
}), | ||
}) |
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,6 @@ | ||
import '@storybook/addon-console' | ||
import 'vtex-tachyons' | ||
|
||
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
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
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,97 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { Story, Meta } from '@storybook/react' | ||
import { action } from '@storybook/addon-actions' | ||
|
||
import Button, { propTypes } from '.' | ||
|
||
type ButtonProps = PropTypes.InferProps<typeof propTypes> | ||
|
||
const variations = [ | ||
'primary', | ||
'secondary', | ||
'tertiary', | ||
'danger', | ||
'danger-tertiary', | ||
'inverted-tertiary', | ||
] | ||
const sizes = ['small', 'regular', 'large'] | ||
|
||
export default { | ||
title: 'Components/Button', | ||
component: Button, | ||
argTypes: { | ||
variation: { | ||
control: { | ||
type: 'select', | ||
options: variations, | ||
}, | ||
}, | ||
size: { | ||
control: { | ||
type: 'inline-radio', | ||
options: sizes, | ||
}, | ||
}, | ||
onClick: { | ||
action: 'button-click', | ||
}, | ||
}, | ||
} as Meta | ||
|
||
const Template: Story<ButtonProps> = args => <Button {...args} type="button" /> | ||
|
||
export const Default = Template.bind({}) | ||
Default.args = { | ||
variation: 'primary', | ||
isLoading: false, | ||
disabled: false, | ||
block: false, | ||
size: 'regular', | ||
children: 'Button', | ||
} | ||
|
||
export const withLoadingState = Template.bind({}) | ||
withLoadingState.args = { | ||
...Default.args, | ||
isLoading: true, | ||
} | ||
|
||
export const withDifferentVariations = () => ( | ||
<> | ||
{variations.map(variation => ( | ||
<> | ||
<Button type="button" variation={variation}> | ||
{variation} | ||
</Button> | ||
<br /> | ||
<br /> | ||
</> | ||
))} | ||
</> | ||
) | ||
|
||
export const withOnMouseEvents = Template.bind({}) | ||
withOnMouseEvents.args = { | ||
...Default.args, | ||
onMouseDown: action('button-on-mouse-down'), | ||
onMouseEnter: action('button-on-mouse-enter'), | ||
onMouseOver: action('button-on-mouse-over'), | ||
onMouseLeave: action('button-on-mouse-leave'), | ||
onMouseOut: action('button-on-mouse-out'), | ||
onMouseUp: action('button-on-mouse-up'), | ||
} | ||
|
||
export const withDifferentSizes = () => ( | ||
<> | ||
{sizes.map(size => ( | ||
<> | ||
<Button type="button" size={size}> | ||
{size} | ||
</Button> | ||
<br /> | ||
<br /> | ||
</> | ||
))} | ||
</> | ||
) |
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,53 @@ | ||
import React from 'react' | ||
import { Story, Meta } from '@storybook/react' | ||
|
||
import { Position } from './TooltipPopup' | ||
import Tooltip, { Props } from '.' | ||
import Button from '../Button' | ||
|
||
const positions: Position[] = ['top', 'left', 'right', 'bottom'] | ||
|
||
export default { | ||
title: 'Components/Tooltip', | ||
component: Tooltip, | ||
argTypes: { | ||
position: { | ||
control: { | ||
type: 'select', | ||
options: positions, | ||
}, | ||
}, | ||
fallbackPosition: { | ||
control: { | ||
type: 'select', | ||
options: positions, | ||
}, | ||
}, | ||
trigger: { | ||
control: { | ||
type: 'inline-radio', | ||
options: ['click', 'hover', 'focus'], | ||
}, | ||
}, | ||
wordBreak: { | ||
control: { | ||
type: 'select', | ||
options: ['normal', 'break-all', 'keep-all', 'break-word'], | ||
}, | ||
}, | ||
}, | ||
} as Meta | ||
|
||
const Template: Story<Props> = args => <Tooltip {...args} /> | ||
|
||
export const Default = Template.bind({}) | ||
Default.args = { | ||
label: 'Tooltip Label', | ||
trigger: 'hover', | ||
wordBreak: 'normal', | ||
position: 'bottom', | ||
delay: 0, | ||
fallbackPosition: 'right', | ||
children: <Button type="button">Button</Button>, | ||
size: 'small', | ||
} |
Oops, something went wrong.
fa0c439
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.
Successfully deployed to the following URLs: