Skip to content

Commit

Permalink
[Mobile] Accessibility Mark I - Button (#14697)
Browse files Browse the repository at this point in the history
* Improving accessibility on Mobile button component.

* Fix lint issues
  • Loading branch information
etoledom authored Apr 3, 2019
1 parent 7a2a9ba commit 342961e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/components/src/button/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function Button( props ) {
children,
onClick,
disabled,
hint,
'aria-disabled': ariaDisabled,
'aria-label': ariaLabel,
'aria-pressed': ariaPressed,
Expand All @@ -67,11 +68,23 @@ export default function Button( props ) {
...( ariaPressed ? styles.buttonActive : styles.buttonInactive ),
};

const states = [];
if ( ariaPressed ) {
states.push( 'selected' );
}

if ( isDisabled ) {
states.push( 'disabled' );
}

return (
<TouchableOpacity
activeOpacity={ 0.7 }
accessible={ true }
accessibilityLabel={ ariaLabel }
accessibilityStates={ states }
accessibilityRole={ 'button' }
accessibilityHint={ hint }
onPress={ onClick }
style={ styles.container }
disabled={ isDisabled }
Expand Down

0 comments on commit 342961e

Please sign in to comment.