diff --git a/packages/@react-spectrum/button/stories/Button.stories.tsx b/packages/@react-spectrum/button/stories/Button.stories.tsx index 1294056d9b2..a2c2e76b4d5 100644 --- a/packages/@react-spectrum/button/stories/Button.stories.tsx +++ b/packages/@react-spectrum/button/stories/Button.stories.tsx @@ -14,86 +14,59 @@ import {action} from '@storybook/addon-actions'; import Bell from '@spectrum-icons/workflow/Bell'; import {Button} from '../'; import {Flex} from '@react-spectrum/layout'; +import {mergeProps} from '@react-aria/utils'; import React, {ElementType} from 'react'; import {SpectrumButtonProps} from '@react-types/button'; import {storiesOf} from '@storybook/react'; import {Text} from '@react-spectrum/text'; +import {Tooltip, TooltipTrigger} from '@react-spectrum/tooltip'; + +const parameters = { + args: { + variant: 'cta' + }, + argTypes: { + variant: { + control: { + type: 'radio', + options: ['cta', 'primary', 'secondary', 'negative', 'overBackground'] + } + } + } +}; + +let actions = { + onPress: action('press'), + onPressStart: action('pressstart'), + onPressEnd: action('pressend') +}; + storiesOf('Button', module) - .addParameters({providerSwitcher: {status: 'positive'}}) + .addParameters({providerSwitcher: {status: 'positive'}, ...parameters}) .add( - 'variant: cta', - () => render({variant: 'cta'}) + 'default', + (args) => render(args) ) .add( 'with icon', - () => ( - - - - - - ) + (args) => renderIconText(args) ) - .add('icon only', () => ( - - )) .add( - 'variant: overBackground', - () => ( -
- {render({variant: 'overBackground'})} -
- ) - ) - .add( - 'variant: primary', - () => render({variant: 'primary'}) - ) - .add( - 'variant: secondary', - () => render({variant: 'secondary'}) - ) - .add( - 'variant: negative', - () => render({variant: 'negative'}) + 'icon only', + (args) => renderIconOnly(args) ) .add( 'element: a', - () => render({elementType: 'a', variant: 'primary'}) + (args) => render({elementType: 'a', ...args}) ) .add( 'element: a, href: \'//example.com\', target: \'_self\'', - () => render({elementType: 'a', href: '//example.com', target: '_self', variant: 'primary'}) + (args) => render({elementType: 'a', href: '//example.com', target: '_self', ...args}) ) .add( 'element: a, rel: \'noopener noreferrer\'', - () => render({elementType: 'a', href: '//example.com', rel: 'noopener noreferrer', variant: 'primary'}) + (args) => render({elementType: 'a', href: '//example.com', rel: 'noopener noreferrer', ...args}) ) .add( 'user-select:none on press test', @@ -106,35 +79,105 @@ storiesOf('Button', module) ); function render(props: SpectrumButtonProps = {variant: 'primary'}) { - return ( + let buttonProps = mergeProps(props, actions); + + let buttons = ( - - {props.variant !== 'cta' && ( - + )} + + ); + + if (props.variant === 'overBackground') { + return ( +
+ {buttons} +
+ ); + } + + return buttons; +} + +function renderIconText(props: SpectrumButtonProps = {variant: 'primary'}) { + let buttonProps = mergeProps(props, actions); + + let buttons = ( + + + + {props.variant !== 'cta' && ( + + )} + + ); + + if (props.variant === 'overBackground') { + return ( +
+ {buttons} +
+ ); + } + + return buttons; +} + +function renderIconOnly(props: SpectrumButtonProps = {variant: 'primary'}) { + let buttonProps = mergeProps(props, actions); + + let buttons = ( + + + + Notifications + + + + Notifications + + {props.variant !== 'cta' && ( + + + Notifications + )} ); + + if (props.variant === 'overBackground') { + return ( +
+ {buttons} +
+ ); + } + + return buttons; } function Example() {