File tree Expand file tree Collapse file tree 3 files changed +34
-12
lines changed Expand file tree Collapse file tree 3 files changed +34
-12
lines changed Original file line number Diff line number Diff line change 1+ import PropTypes from 'prop-types' ;
2+ import React from 'react' ;
3+
4+ class Button extends React . PureComponent {
5+ static propTypes = {
6+ children : PropTypes . node . isRequired ,
7+ title : PropTypes . string . isRequired ,
8+ } ;
9+
10+ render ( ) {
11+ const { children, title, ...props } = this . props ;
12+
13+ return (
14+ < button
15+ aria-label = { title }
16+ title = { title }
17+ type = "button"
18+ { ...props }
19+ >
20+ { children }
21+ </ button >
22+ ) ;
23+ }
24+ }
25+
26+ export default Button ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
44import React from 'react' ;
55import nanoid from 'nanoid' ;
66
7+ import Button from './Button' ;
78import TreeNode from './TreeNode' ;
89import iconsShape from './iconsShape' ;
910import listShape from './listShape' ;
@@ -332,24 +333,20 @@ class CheckboxTree extends React.Component {
332333
333334 return (
334335 < div className = "rct-options" >
335- < button
336- aria-label = "Expand all"
336+ < Button
337337 className = "rct-option rct-option-expand-all"
338338 title = "Expand all"
339- type = "button"
340339 onClick = { this . onExpandAll }
341340 >
342341 { expandAll }
343- </ button >
344- < button
345- aria-label = "Expand all"
342+ </ Button >
343+ < Button
346344 className = "rct-option rct-option-collapse-all"
347345 title = "Collapse all"
348- type = "button"
349346 onClick = { this . onCollapseAll }
350347 >
351348 { collapseAll }
352- </ button >
349+ </ Button >
353350 </ div >
354351 ) ;
355352 }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import classNames from 'classnames';
22import PropTypes from 'prop-types' ;
33import React from 'react' ;
44
5+ import Button from './Button' ;
56import NativeCheckbox from './NativeCheckbox' ;
67import iconsShape from './iconsShape' ;
78import nodeShape from './nodeShape' ;
@@ -120,16 +121,14 @@ class TreeNode extends React.Component {
120121 }
121122
122123 return (
123- < button
124- aria-label = "Toggle"
124+ < Button
125125 className = "rct-collapse rct-collapse-btn"
126126 disabled = { expandDisabled }
127127 title = "Toggle"
128- type = "button"
129128 onClick = { this . onExpand }
130129 >
131130 { this . renderCollapseIcon ( ) }
132- </ button >
131+ </ Button >
133132 ) ;
134133 }
135134
You can’t perform that action at this time.
0 commit comments