Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
f705f6be
Unverified
Commit
f705f6be
authored
Feb 07, 2020
by
Kyle Keating
Committed by
GitHub
Feb 07, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1760 from hypothesis/button-disabled
Add `disabled` prop to the Button component
parents
a3356649
f39b0810
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
button.js
src/sidebar/components/button.js
+5
-0
button-test.js
src/sidebar/components/test/button-test.js
+10
-0
No files found.
src/sidebar/components/button.js
View file @
f705f6be
...
...
@@ -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
,
...
...
src/sidebar/components/test/button-test.js
View file @
f705f6be
...
...
@@ -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
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment