Skip to content

Commit 3ac89ee

Browse files
author
Jenn
authored
add accessbility features and a base readme for the template after initialization (#125)
1 parent 393b194 commit 3ac89ee

File tree

5 files changed

+148
-2
lines changed

5 files changed

+148
-2
lines changed

template/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# React Native Project Title
2+
3+
One Paragraph of project description goes here
4+
5+
## Table of Contents
6+
7+
- [Getting Started](getting-started)
8+
- [Prerequisites](prerequisites)
9+
- [Installing](installing)
10+
- [Develop for Accessibility](develop-for-accessibility)
11+
- [Running The Tests](running-the-tests)
12+
- [E2E Tests](e2e-tests)
13+
- [Deployment](deployment)
14+
- [Built With](built-with)
15+
16+
17+
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the app to the respective app stores.
18+
19+
### Prerequisites
20+
21+
In order to get this project running locally, please make sure you ahve followed the "React Native CLI Quickstart" in the [React Native "Getting Started"](https://facebook.github.io/react-native/docs/getting-started) guide.
22+
23+
### Installing
24+
25+
To get the app running locally, please follow these steps:
26+
27+
1. From the root, install the JavaScript dependencies:
28+
29+
```sh
30+
yarn install
31+
```
32+
33+
2. Install the iOS dependencies:
34+
35+
```sh
36+
cd ios && pod install
37+
```
38+
39+
2. Start the app on iOS by running:
40+
41+
```sh
42+
yarn ios
43+
```
44+
45+
4. Start the app on Android by running (make sure you have a device running on the emulator):
46+
47+
```sh
48+
yarn android
49+
```
50+
51+
If all worked correctly, you should have the app running on both the iOS and Android simulators.
52+
53+
54+
## Develop for Accessibility
55+
56+
Mobile applications should be developed with accessbility in mind. Some simple steps to take include adding accessbility labels and roles to elements within your screens. Some convience features have been added to the Styled Text and Button component to ensure the ease of use.
57+
58+
59+
## Running the tests
60+
61+
We use `jest` for testing business logic and functions. To run the test suites, run:
62+
63+
```sh
64+
yarn test
65+
```
66+
67+
68+
### E2E Tests
69+
70+
End to End (E2E) tests are for full integration tests, clicks, screen elements, etc. For this we use [Detox](https://github.com/wix/Detox/)
71+
72+
To run tests you must have the applesimutils installed per the [Getting Started on Detox](https://github.com/wix/Detox/blob/master/docs/Introduction.GettingStarted.md). Tests can be run locally for iOS and Android with the following commands:
73+
74+
```sh
75+
yarn e2e:ios-debug
76+
yarn e2e:ios
77+
yarn e2e:android-debug
78+
yarn e2e:android
79+
```
80+
Each of these will test the platform in either release or debug mode as specified.
81+
82+
83+
## Deployment
84+
85+
Add additional notes about how to deploy this on a live system
86+
87+
## Built With
88+
89+
- [React Native](https://facebook.github.io/react-native/) - The mobile framework used
90+
- [TypeScript](https://typescriptlang.org/) - Static typing
91+
- [styled-system](https://emotion.sh/) - the system we levarage for styling components
92+
- [Emotion](https://emotion.sh/) - CSS-in-JS (used with `styled-system`)

template/src/components/Button/Button.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ import { Container } from '../Container';
1313
import { Text } from '../Text';
1414
import { Touchable } from '../Touchable';
1515
import { colors } from '../../styles';
16+
import { AccessbilityRole } from '../../types/AccessibilityRole';
1617

1718
interface ButtonProps {
18-
/** accessibility label */
19+
/**
20+
* Overrides the text that's read by the screen reader when the user interacts with the element. By default, the
21+
* label is constructed by traversing all the children and accumulating all the Text nodes separated by space.
22+
*/
1923
accessibilityLabel: string;
24+
/** Accessibility Role tells a person using either VoiceOver on iOS or TalkBack on Android the type of element that is focused on. */
25+
accessbilityRole?: AccessbilityRole;
2026
/** disabled button state */
2127
disabled?: boolean;
2228
/** loading button state */

template/src/components/Login/Login.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ export const Login: FC<ComponentProps> = ({
4848
</Text>
4949
<TextInput
5050
placeholder="Email"
51+
accessibilityLabel="Email Address Input"
5152
icon={<Icon name="envelope" type={'font-awesome'} color={colors.lightGray} />}
5253
marginTop={2}
5354
borderRadius={5}
5455
borderColor={colors.lightGray}
5556
/>
5657
<TextInput
5758
placeholder="Password"
59+
accessibilityLabel="Password Input"
5860
icon={<Icon name="key" type={'font-awesome'} color={colors.lightGray} />}
5961
marginTop={2}
6062
borderRadius={5}
@@ -66,6 +68,8 @@ export const Login: FC<ComponentProps> = ({
6668
}}
6769
fullWidth
6870
alignItems={'flex-end'}
71+
accessibilityLabel="Forgot Password Button"
72+
accessbilityRole="button"
6973
>
7074
<Text fontSize={1} marginTop={2} color={colors.blue}>
7175
Forgot Password?
@@ -80,6 +84,7 @@ export const Login: FC<ComponentProps> = ({
8084
onPress={() => {
8185
loginPress();
8286
}}
87+
accessibilityLabel="Login Button"
8388
/>
8489

8590
<Container flexDirection={'row'} marginTop={20}>
@@ -100,6 +105,7 @@ export const Login: FC<ComponentProps> = ({
100105
onPress={() => {
101106
registrationPress();
102107
}}
108+
accessibilityLabel="Create Account Button"
103109
/>
104110
</Container>
105111
);

template/src/components/TextInput/TextInput.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ import { Text } from '../Text';
2323
import { colors } from '../../styles';
2424

2525
interface TextInputProps extends TextInputBaseProps {
26-
/** An optional header label to render about the input */
26+
/** An optional header label to render above the input */
2727
topLabel?: string;
28+
//** An option icon to be displayed to the left of the input box */
2829
icon?: Icon;
30+
/**
31+
* Overrides the text that's read by the screen reader when the user interacts with the element. By default, the
32+
* label is constructed by traversing all the children and accumulating all the Text nodes separated by space.
33+
*/
34+
accessibilityLabel?: string;
2935
}
3036

3137
type ComponentProps = TextInputProps &
@@ -53,6 +59,7 @@ const Input = styled.TextInput`
5359
export const TextInput: FC<ComponentProps> = ({
5460
topLabel,
5561
icon,
62+
accessibilityLabel,
5663
multiline,
5764
borderColor,
5865
borderRadius,
@@ -71,6 +78,7 @@ export const TextInput: FC<ComponentProps> = ({
7178
underlineColorAndroid={colors.transparent}
7279
selectionColor={colors.primary}
7380
multiline={multiline}
81+
accessibilityLabel={accessibilityLabel}
7482
{...inputProps}
7583
/>
7684
</InputContainer>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Accessbility Role communicates the purpose of a component to the user of an assistive technology,
3+
* This tells a person using either VoiceOver on iOS or TalkBack on Android the type of element that is focused on.
4+
* values pulled from official react native docs
5+
* https://facebook.github.io/react-native/docs/accessibility#accessibilityrole-ios-android
6+
*/
7+
export type AccessbilityRole =
8+
| 'none' /** Used when the element has no role */
9+
| 'button' /** Used when the element should be treated as a button */
10+
| 'link' /** Used when the element should be treated as a link */
11+
| 'search' /** Used when the text field element should also be treated as a search field */
12+
| 'image' /** Used when the element should be treated as an image. Can be combined with button or link, for example */
13+
| 'keyboardkey' /** Used when the element acts as a keyboard key */
14+
| 'text' /** Used when the element should be treated as static text that cannot change */
15+
| 'adjustable' /** Used when an element can be "adjusted" (e.g. a slider) */
16+
| 'imagebutton' /** Used when the element should be treated as a button and is also an image. */
17+
| 'header' /** Used when an element acts as a header for a content section (e.g. the title of a navigation bar) */
18+
| 'summary' /** Used when an element can be used to provide a quick summary of current conditions in the app when the app first launches */
19+
| 'alert' /** Used when an element contains important text to be presented to the user */
20+
| 'checkbox' /** Used when an element represents a checkbox which can be checked, unchecked, or have mixed checked state */
21+
| 'combobox' /** Used when an element represents a combo box, which allows the user to select among several choices */
22+
| 'menu' /** Used when the component is a menu of choices */
23+
| 'menubar' /** Used when a component is a container of multiple menus */
24+
| 'menuitem' /** Used to represent an item within a menu */
25+
| 'progressbar' /** Used to represent a component which indicates progress of a task */
26+
| 'radio' /** Used to represent a radio button */
27+
| 'radiogroup' /** Used to represent a group of radio buttons */
28+
| 'scrollbar' /** Used to represent a scroll bar. */
29+
| 'spinbar' /** Used to represent a button which opens a list of choices */
30+
| 'switch' /** Used to represent a switch which can be turned on and off */
31+
| 'tab' /** Used to represent a tab */
32+
| 'tablist' /** Used to represent a list of tabs */
33+
| 'timer' /** Used to represent a timer */
34+
| 'toolbar' /** Used to represent a tool bar (a container of action buttons or components) */;

0 commit comments

Comments
 (0)