Unverified Commit f705f6be authored by Kyle Keating's avatar Kyle Keating Committed by GitHub

Merge pull request #1760 from hypothesis/button-disabled

Add `disabled` prop to the Button component
parents a3356649 f39b0810
......@@ -19,6 +19,7 @@ import SvgIcon from './svg-icon';
export default function Button({
buttonText = '',
className = '',
disabled = false,
icon = '',
isActive = false,
onClick = () => null,
......@@ -51,6 +52,7 @@ export default function Button({
aria-pressed={isActive}
title={title}
style={style}
disabled={disabled}
>
{icon && <SvgIcon name={icon} className="button__icon" />}
{buttonText}
......@@ -108,6 +110,9 @@ Button.propTypes = {
/** callback for button clicks */
onClick: propTypes.func,
/** disables the button when true */
disabled: propTypes.bool,
/** optional inline styling */
style: propTypes.object,
......
......@@ -91,6 +91,16 @@ describe('Button', () => {
assert.isTrue(wrapper.find('button').hasClass('button--primary'));
});
it('disables the button when `disabled` prop is true', () => {
const wrapper = createComponent({ disabled: true });
assert.isTrue(wrapper.find('button[disabled=true]').exists());
});
it('shall not disable the button by default', () => {
const wrapper = createComponent();
assert.isTrue(wrapper.find('button[disabled=false]').exists());
});
it(
'should pass a11y checks',
checkAccessibility({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment