Add support for 'accessible' prop

This commit is contained in:
Nicolas Gallagher
2015-09-07 22:09:16 -07:00
parent 65559f50e6
commit 2750d70a93
7 changed files with 39 additions and 11 deletions

View File

@@ -64,6 +64,7 @@ class Image extends React.Component {
static propTypes = {
accessibilityLabel: PropTypes.string,
accessible: PropTypes.bool,
children: PropTypes.any,
defaultSource: PropTypes.object,
onError: PropTypes.func,
@@ -79,17 +80,13 @@ class Image extends React.Component {
static stylePropTypes = ImageStylePropTypes
static defaultProps = {
accessible: true,
defaultSource: {},
resizeMode: 'cover',
source: {},
style: styles.initial
}
_cancelEvent(event) {
event.preventDefault()
event.stopPropagation()
}
_createImageLoader() {
const { source } = this.props
@@ -167,6 +164,7 @@ class Image extends React.Component {
render() {
const {
accessibilityLabel,
accessible,
children,
defaultSource,
resizeMode,
@@ -190,6 +188,7 @@ class Image extends React.Component {
*/
return (
<View
accessible={accessible}
accessibilityLabel={accessibilityLabel}
className={'Image'}
component='div'

View File

@@ -16,6 +16,8 @@ class Touchable extends React.Component {
}
static propTypes = {
accessibilityLabel: PropTypes.string,
accessible: PropTypes.bool,
activeHighlight: PropTypes.string,
activeOpacity: PropTypes.number,
children: PropTypes.element,
@@ -77,6 +79,8 @@ class Touchable extends React.Component {
render() {
const {
accessibilityLabel,
accessible,
activeHighlight,
delayLongPress,
style
@@ -90,6 +94,8 @@ class Touchable extends React.Component {
*/
return (
<Tappable
accessibilityLabel={accessibilityLabel}
accessible={accessible}
children={this._getChildren()}
component={View}
onKeyDown={(e) => { this._onKeyEnter(e, this._onPressIn) }}

View File

@@ -31,6 +31,7 @@ const styles = {
class View extends React.Component {
static propTypes = {
accessibilityLabel: PropTypes.string,
accessible: PropTypes.bool,
children: PropTypes.any,
component: CoreComponent.propTypes.component,
pointerEvents: PropTypes.oneOf([
@@ -46,18 +47,20 @@ class View extends React.Component {
static stylePropTypes = ViewStylePropTypes
static defaultProps = {
accessible: true,
component: 'div',
style: styles.initial
}
render() {
const { accessibilityLabel, pointerEvents, style, testID, ...other } = this.props
const { accessible, accessibilityLabel, pointerEvents, style, testID, ...other } = this.props
const pointerEventsStyle = pointerEvents && { pointerEvents }
const resolvedStyle = pickProps(style, viewStyleKeys)
return (
<CoreComponent
{...other}
aria-hidden={accessible ? null : true}
aria-label={accessibilityLabel}
className={'View'}
style={{