diff --git a/packages/button/src/Button.story.tsx b/packages/button/src/Button.story.tsx index 7a2aa28795..7e21446f9a 100644 --- a/packages/button/src/Button.story.tsx +++ b/packages/button/src/Button.story.tsx @@ -10,20 +10,6 @@ const buttonClass = css` } `; -function CustomElement({ - customProp, - ...rest -}: { - customProp: string; -}): React.ReactElement { - return ( -
- Lookit, {customProp}!
-
- ); -} - storiesOf('Buttons', module) .add('Default', () => ( - )); + .add('as custom component', () => { + const CustomRoot = select( + 'div', + { div: 'div', span: 'span', button: 'button' }, + 'div', + ); + + function CustomElement(props: object): React.ReactElement { + return ; + } + + return ( + + ); + }); diff --git a/packages/button/src/Button.tsx b/packages/button/src/Button.tsx index 386ab09fb2..418d9eddc9 100644 --- a/packages/button/src/Button.tsx +++ b/packages/button/src/Button.tsx @@ -308,29 +308,10 @@ export default function Button(props: ButtonProps) { 'children', ]); - if (usesCustomElement(props)) { - const Root = props.as; - - return ( - - {children} - - ); - } - - if (usesLinkElement(props)) { - return ( - )} {...commonProps}> - {children} - - ); - } - - // NOTE(JeT): The button's `type` will be overridden if it is in the passed-in props - return ( - + ); + + if (usesCustomElement(props)) { + return renderButton(props.as); + } + + if (usesLinkElement(props)) { + return renderButton('a'); + } + + return renderButton(); } Button.propTypes = { - variant: PropTypes.oneOf(['default', 'primary', 'info', 'danger', 'dark']), - size: PropTypes.oneOf(['xsmall', 'small', 'normal', 'large']), + variant: PropTypes.oneOf(Object.values(Variant)), + size: PropTypes.oneOf(Object.values(Size)), className: PropTypes.string, children: PropTypes.node, disabled: PropTypes.bool,