import React from 'react'; import ButtonProps from './Button.types'; export const Button = ({ element, name, type, value, disabled, href, classes, preventDoubleClick, isStartButton, children, ...attributes }: ButtonProps) => { // If href is set, set the element to an anchor tag if (href) { element = 'a'; } const commonAttributes: any = { className: `govuk-button ${classes || ''}${disabled ? ' govuk-button--disabled' : ''}${isStartButton ? ' govuk-button--start' : ''}`, 'data-module': 'govuk-button', ...attributes, } const buttonAttributes: any = { name, disabled, 'aria-disabled': disabled, 'data-prevent-double-click': preventDoubleClick, }; let iconHtml; if (isStartButton) { iconHtml = ( ); } if (element === 'a') { return ( {children} {iconHtml} ); } // TODO: need to add support for value attribute on input element if (element === 'input') { return ( ); } // Default to a button element return ( ); }; export default Button;