Skip to content

Commit

Permalink
Merge pull request #159 from testshallpass/add-test-id-accessibility-…
Browse files Browse the repository at this point in the history
…label-props

Add accessible, accessibilityLabel and testID props
  • Loading branch information
testshallpass authored Dec 15, 2018
2 parents aad4b60 + 191d149 commit 4907238
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
9 changes: 9 additions & 0 deletions DropdownAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export default class DropdownAlert extends Component {
renderCancel: PropTypes.func,
renderTitle: PropTypes.func,
renderMessage: PropTypes.func,
testID: PropTypes.string,
accessibilityLabel: PropTypes.string,
accessible: PropTypes.bool,
};
static defaultProps = {
onClose: null,
Expand Down Expand Up @@ -133,6 +136,9 @@ export default class DropdownAlert extends Component {
renderCancel: undefined,
renderTitle: undefined,
renderMessage: undefined,
testID: undefined,
accessibilityLabel: undefined,
accessible: false,
};
constructor(props) {
super(props);
Expand Down Expand Up @@ -476,6 +482,9 @@ export default class DropdownAlert extends Component {
onPress={!this.props.tapToCloseEnabled ? null : () => this.close('tap')}
disabled={!this.props.tapToCloseEnabled}
onLayout={event => this.onLayoutEvent(event)}
testID={this.props.testID}
accessibilityLabel={this.props.accessibilityLabel}
accessible={this.props.accessible}
>
<View style={style}>
<SafeAreaView style={StyleSheet.flatten(this.props.safeAreaStyle)}>
Expand Down
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
![screenshot](https://raw.github.com/testshallpass/react-native-dropdownalert/master/screenshots/info.png) ![screenshot](https://raw.github.com/testshallpass/react-native-dropdownalert/master/screenshots/warning.png) ![screenshot](https://raw.github.com/testshallpass/react-native-dropdownalert/master/screenshots/error.png) ![screenshot](https://raw.github.com/testshallpass/react-native-dropdownalert/master/screenshots/success.png)

### Table of contents

1. [Support](#support)
2. [Installation](#installation)
3. [Demo](#demo)
Expand All @@ -20,20 +21,24 @@
A simple alert to notify users about new chat messages, something went wrong or everything is ok. It can be closed by tap, cancel button, automatically with `closeInterval`, pan responder up gesture or programmatically.

### Support

| react-native version | package version | reason |
| ---- | :---: | ---- |
| 0.50.0 | >=3.2.0 | Added SafeAreaView (iPhone X) |
| 0.44.0 | >=2.12.0 | Added ViewPropTypes |

### Installation

```
npm i react-native-dropdownalert --save
```

### Demo

![screenshot](https://raw.github.com/testshallpass/react-native-dropdownalert/master/screenshots/demo.gif)

### Usage

```javascript
// ...
import DropdownAlert from 'react-native-dropdownalert';
Expand Down Expand Up @@ -67,8 +72,8 @@ export default class App extends Component {
* [DropdownHolder example #2](https://gist.github.com/testshallpass/6c6c867269348c485a1e0d6ae3f55e90)
* [Redux + router flux example](https://gist.github.com/testshallpass/13f047205d1b966f55340b8962fe99c0)


### Props

| Name | Type | Description | Default |
| ---- | :---: | --- | --- |
| ```closeInterval``` | Number | dismiss alert at a certain time in milliseconds | 4000
Expand Down Expand Up @@ -110,9 +115,12 @@ export default class App extends Component {
| ```sensitivity``` | Number | Sensitivity for the pan responder up gesture | 20
| ```defaultContainer``` | Object | Style for inner view container (**override paddingTop with this**) | ```{ padding: 8, paddingTop: IS_ANDROID ? 0 : 20, flexDirection: 'row' } ```
| ```defaultTextContainer``` | Object | Style for inner text container (holds title and message) | ```{ flex: 1, padding: 8 }```
| ```renderImage``` | Function | Use to overide the left image component | undefined
| ```renderCancel``` | Function | Use to overide the cancel button component | undefined
| ```renderTitle``` | Function | Use to overide the title component | undefined
| ```renderMessage``` | Function | Use to overide the message component | undefined
| ```renderImage``` | Function | Use to override the left image component | undefined
| ```renderCancel``` | Function | Use to override the cancel button component | undefined
| ```renderTitle``` | Function | Use to override the title component | undefined
| ```renderMessage``` | Function | Use to override the message component | undefined
| ```testID``` | String | Top level TouchableOpacity's testID | undefined
| ```accessibilityLabel``` | String | Top level TouchableOpacity's accessibilityLabel | undefined
| ```accessible``` | Boolean | Top level TouchableOpacity's accessible | false

> Inspired by: [RKDropdownAlert](https://github.com/cwRichardKim/RKDropdownAlert)
7 changes: 7 additions & 0 deletions __tests__/__snapshots__/DropdownAlert-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ exports[`renders alert with zIndex correctly 1`] = `
}
>
<TouchableOpacity
accessible={false}
activeOpacity={0.95}
disabled={false}
onLayout={[Function]}
Expand Down Expand Up @@ -153,6 +154,7 @@ exports[`renders custom alert correctly 1`] = `
}
>
<TouchableOpacity
accessible={false}
activeOpacity={0.95}
disabled={false}
onLayout={[Function]}
Expand Down Expand Up @@ -269,6 +271,7 @@ exports[`renders custom alert with cancel correctly 1`] = `
}
>
<TouchableOpacity
accessible={false}
activeOpacity={1}
disabled={false}
onLayout={[Function]}
Expand Down Expand Up @@ -413,6 +416,7 @@ exports[`renders error alert correctly 1`] = `
}
>
<TouchableOpacity
accessible={false}
activeOpacity={0.95}
disabled={false}
onLayout={[Function]}
Expand Down Expand Up @@ -532,6 +536,7 @@ exports[`renders info alert correctly 1`] = `
}
>
<TouchableOpacity
accessible={false}
activeOpacity={0.95}
disabled={false}
onLayout={[Function]}
Expand Down Expand Up @@ -651,6 +656,7 @@ exports[`renders success alert correctly 1`] = `
}
>
<TouchableOpacity
accessible={false}
activeOpacity={0.95}
disabled={false}
onLayout={[Function]}
Expand Down Expand Up @@ -770,6 +776,7 @@ exports[`renders warn alert correctly 1`] = `
}
>
<TouchableOpacity
accessible={false}
activeOpacity={0.95}
disabled={false}
onLayout={[Function]}
Expand Down

0 comments on commit 4907238

Please sign in to comment.