123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- /* eslint-disable react/prop-types */
- import {Fragment} from 'react';
- import styled from '@emotion/styled';
- import {action} from '@storybook/addon-actions';
- import {Button} from 'sentry/components/button';
- import ButtonBar from 'sentry/components/buttonBar';
- import DropdownButton from 'sentry/components/dropdownButton';
- import DropdownLink from 'sentry/components/dropdownLink';
- import NavigationButtonGroup from 'sentry/components/navigationButtonGroup';
- import {IconDelete} from 'sentry/icons/iconDelete';
- const Item = styled('span')`
- padding: 12px;
- `;
- export default {
- title: 'Components/Buttons',
- component: Button,
- };
- export const _Button = ({icon, onClick, ...args}) => (
- <Button onClick={onClick} icon={icon && <IconDelete />} {...args}>
- Button
- </Button>
- );
- _Button.args = {
- title: 'title',
- priority: undefined,
- size: undefined,
- borderless: false,
- translucentBorder: false,
- icon: false,
- busy: false,
- disabled: false,
- };
- _Button.argTypes = {
- priority: {
- control: {
- type: 'select',
- options: ['default', 'primary', 'danger', 'link', 'form'],
- },
- },
- size: {
- control: {
- type: 'select',
- options: ['zero', 'xs', 'sm', 'md'],
- },
- },
- };
- export const Overview = ({busy}) => (
- <div>
- <div className="section">
- <h2>Priorities</h2>
- <Item>
- <Button to="/test" onClick={action('clicked default')}>
- Default Button
- </Button>
- </Item>
- <Item>
- <Button title="Tooltip" priority="primary" onClick={action('click primary')}>
- Primary Button
- </Button>
- </Item>
- <Item>
- <Button priority="danger" onClick={action('click danger')}>
- Danger Button
- </Button>
- </Item>
- <Item>
- <Button priority="link" onClick={action('click link')}>
- Link Button
- </Button>
- </Item>
- <Item>
- <Button to="" disabled onClick={action('click disabled')}>
- Disabled Button
- </Button>
- </Item>
- </div>
- <div className="section">
- <h2>Sizes</h2>
- <Item>
- <Button size="zero" borderless>
- Zero
- </Button>
- </Item>
- <Item>
- <Button size="xs">X Small</Button>
- </Item>
- <Item>
- <Button size="sm">Small</Button>
- </Item>
- <Item>
- <Button>Default</Button>
- </Item>
- </div>
- <div className="section">
- <h2>Icons</h2>
- <div style={{display: 'flex', alignItems: 'center'}}>
- <Item>
- <Button size="zero" borderless icon={<IconDelete size="xs" />} />
- </Item>
- <Item>
- <Button size="xs" icon={<IconDelete size="xs" />}>
- X Small
- </Button>
- </Item>
- <Item>
- <Button size="sm" icon={<IconDelete size="xs" />}>
- Small
- </Button>
- </Item>
- <Item>
- <Button icon={<IconDelete />}>Default</Button>
- </Item>
- </div>
- </div>
- <div className="section">
- <h2>States (busy/disabled)</h2>
- <div style={{display: 'flex', alignItems: 'center'}}>
- <Item>
- <Button busy={busy} priority="primary" size="xs">
- Extra Small
- </Button>
- </Item>
- <Item>
- <Button busy={busy} priority="primary" size="sm">
- Small
- </Button>
- </Item>
- <Item>
- <Button busy={busy} priority="primary">
- Normal
- </Button>
- </Item>
- <Item>
- <Button priority="primary" disabled onClick={action('click disabled')}>
- Disabled Button
- </Button>
- </Item>
- </div>
- </div>
- </div>
- );
- Overview.storyName = 'Overview';
- Overview.args = {
- busy: true,
- };
- Overview.parameters = {
- docs: {
- description: {
- story: 'An overview of all the different buttons and states',
- },
- },
- };
- export const _DropdownButton = () => (
- <Fragment>
- <Item>
- <DropdownButton isOpen={false}>Closed</DropdownButton>
- </Item>
- <Item>
- <DropdownButton isOpen>Open</DropdownButton>
- </Item>
- </Fragment>
- );
- _DropdownButton.storyName = 'Dropdown Button';
- _DropdownButton.parameters = {
- docs: {
- description: {
- story: 'A button meant to be used with some sort of dropdown',
- },
- },
- };
- export const _ButtonBar = ({gap}) => (
- <div>
- <div className="section">
- <h3>With a Gap</h3>
- <ButtonBar gap={gap}>
- <Button>First Button</Button>
- <Button>Second Button</Button>
- <Button>Third Button</Button>
- </ButtonBar>
- </div>
- <div className="section">
- <h3>Merged Buttons with "active" button</h3>
- <ButtonBar active="left" merged>
- <Button barId="left">Left Button</Button>
- <Button barId="right">Right Button</Button>
- </ButtonBar>
- </div>
- <div className="section">
- <h3>Multiple Merged Buttons with "active" button</h3>
- <ButtonBar active="2" merged>
- <Button barId="1">First Button</Button>
- <Button barId="2">Second Button</Button>
- <Button barId="3">Third Button</Button>
- <Button barId="4">Fourth Button</Button>
- </ButtonBar>
- </div>
- <div className="section">
- <h3>Works with DropdownLink</h3>
- <StartButtonBar merged>
- <DropdownLink customTitle={<Button>First DropdownLink</Button>} />
- <DropdownLink customTitle={<Button>Second DropdownLink</Button>} />
- <DropdownLink customTitle={<Button>Third DropdownLink</Button>} />
- </StartButtonBar>
- <StartButtonBar merged>
- <Button>First Button</Button>
- <DropdownLink customTitle={<Button>Second DropdownLink</Button>} />
- <Button>Third Button</Button>
- </StartButtonBar>
- <StartButtonBar merged>
- <DropdownLink customTitle={<Button>First DropdownLink</Button>} />
- <Button>Second Button</Button>
- <DropdownLink customTitle={<Button>Third DropdownLink</Button>} />
- </StartButtonBar>
- </div>
- </div>
- );
- _ButtonBar.storyName = 'Button Bar';
- _ButtonBar.args = {
- /** Button gap */
- gap: 1,
- };
- _ButtonBar.argTypes = {
- gap: {
- control: {
- type: 'select',
- options: [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4],
- },
- },
- };
- _ButtonBar.parameters = {
- docs: {
- description: {
- story: 'Buttons in a Bar container',
- },
- },
- };
- export const _NavigationButtonGroup = () => (
- <NavigationButtonGroup hasNext={false} hasPrevious links={['#', '#', '#', '#']} />
- );
- _NavigationButtonGroup.storyName = 'Navigation Button Group';
- _NavigationButtonGroup.info = 'Navigation Buttons Group';
- const StartButtonBar = styled(ButtonBar)`
- justify-content: flex-start;
- margin-bottom: 6px;
- `;
|