mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-04-23 20:10:41 +08:00
Add support for 'accessible' prop
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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) }}
|
||||
|
||||
@@ -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={{
|
||||
|
||||
Reference in New Issue
Block a user