Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split ama #125

Merged
merged 90 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
d7aaed7
feat: split ama
ceceppa Sep 7, 2023
3953bfd
chore: split ama
ceceppa Sep 7, 2023
58adce8
chore: split ama
ceceppa Sep 7, 2023
dd40d4e
[Split AMA]: Core (#132)
ceceppa Sep 8, 2023
c1a09f6
feat: Add expo app (#136)
JDMathew Sep 12, 2023
ebda7dd
chore: update documentation
ceceppa Sep 12, 2023
20ed3fe
chore: documentation
ceceppa Sep 12, 2023
f56a7a2
chore: Converting to a monorepo (#141)
JDMathew Sep 13, 2023
2268b53
chore: update doc
ceceppa Sep 13, 2023
9942709
chore: documentation
ceceppa Sep 13, 2023
263a2b8
chore: documentation
ceceppa Sep 13, 2023
5099699
chore: setup internal as a private package (#145)
JDMathew Sep 14, 2023
18e0568
chore: setup core as a workspace package (#148)
JDMathew Sep 14, 2023
12d3098
chore: Setup lists as a workspace package (#150)
JDMathew Sep 14, 2023
1d096cb
chore: Setup extras setup extras as a workspace package (#151)
JDMathew Sep 14, 2023
0a25c4f
chore: update internal package file struct
JDMathew Sep 14, 2023
b05c84e
chore: Adds animations as a workspace package (#153)
JDMathew Sep 14, 2023
c55fc5c
chore: removing testing-package
JDMathew Sep 14, 2023
271d50d
chore: removing lib hooks
JDMathew Sep 14, 2023
0459a06
chore: add devDep packages to root
JDMathew Sep 14, 2023
476efec
chore: update lists package.json
JDMathew Sep 14, 2023
e8d7c70
add git lfs
ceceppa Sep 14, 2023
fdb0c49
improve documentation
ceceppa Sep 14, 2023
1961140
temporary ignorning broken links
ceceppa Sep 14, 2023
51abb6b
change order
ceceppa Sep 14, 2023
a460003
improve documentation
ceceppa Sep 14, 2023
82c7b93
improve documentation
ceceppa Sep 14, 2023
2b64680
accessibility label documentation
ceceppa Sep 14, 2023
784d57d
chore: add forms as a package to our workspace (#156)
JDMathew Sep 14, 2023
48ae93a
chore: Adds react native as a workspace package (#157)
JDMathew Sep 14, 2023
be6ca24
Adding react-native-reanimated (#159)
JDMathew Sep 15, 2023
deaa6dc
Adding react-native-gesture-handler (#160)
JDMathew Sep 15, 2023
ec29f76
fix: fix babel config for reanimated
JDMathew Sep 15, 2023
3749a24
chore: use explicit exports and resolve all package cross ref imports…
JDMathew Sep 15, 2023
a14703a
accessibility label doc
ceceppa Sep 15, 2023
2b26413
chore: split out shared components into `shared-ui` package (#171)
JDMathew Sep 16, 2023
955ccaa
update exports from packages
JDMathew Sep 16, 2023
d934427
Updating expo app with shared-ui (#173)
JDMathew Sep 16, 2023
5282537
Fix useChecks hook
JDMathew Sep 16, 2023
e4369f4
Updating expo tsconfig
JDMathew Sep 16, 2023
b9bde8e
fix: FormSubmit not capturing event issue (#174)
JDMathew Sep 16, 2023
12672a4
chore: upgrading the react native bare app (#175)
JDMathew Sep 16, 2023
a41f9b1
Split ama documentation (#178)
ceceppa Sep 18, 2023
10c2e0a
accessibility states
ceceppa Sep 18, 2023
357802c
fix Then
ceceppa Sep 18, 2023
c935c7c
chore: add reanimated to rn example app (#180)
JDMathew Sep 19, 2023
e64131f
chore: rn bare add to monorepo (#183)
JDMathew Sep 19, 2023
031f859
Removing post install
JDMathew Sep 19, 2023
a4bee00
core documentation: done (#185)
ceceppa Sep 20, 2023
3053469
feat: react native bare linking shared UI (#188)
JDMathew Sep 20, 2023
3ac583e
chore: move `Pressable` and `usePressable` from `core` to `react-nat…
JDMathew Sep 22, 2023
24aa0d0
update imports for pressable
JDMathew Sep 27, 2023
accf6b1
feat: improved context types and errors (#191)
JDMathew Sep 27, 2023
797dc4b
feat: creates helper `Form.Switch` component from `SwitchListItem` co…
JDMathew Sep 27, 2023
f815512
Update bare prettier config
JDMathew Sep 27, 2023
124d298
Update Pressable Import in test
JDMathew Sep 27, 2023
37dcca7
chore: add sinter package dependencies for builds (#195)
JDMathew Sep 27, 2023
013971e
Split ama guidelines doc (#198)
ceceppa Sep 27, 2023
3f96a7c
core documentation
ceceppa Sep 27, 2023
8c311fc
forms (#200)
ceceppa Sep 28, 2023
da00ab1
fix links (#201)
ceceppa Sep 28, 2023
e0c9eea
upgrading typescript
JDMathew Sep 28, 2023
eb23d4e
Adding Jest into root
JDMathew Sep 28, 2023
28489af
reorder bare example app import
JDMathew Sep 28, 2023
32201ce
Adding minimum node version
JDMathew Sep 28, 2023
66a151b
Making internal package publishable
JDMathew Sep 28, 2023
07d4c00
updating stack navigation package to latest
JDMathew Sep 28, 2023
0fffc20
update buttonChecks ts errors
JDMathew Sep 29, 2023
5d47e25
removing npmignore file
JDMathew Sep 29, 2023
f04343e
Add ama rules to include in build for internal
JDMathew Sep 29, 2023
80ba52c
update dependencies for core
JDMathew Sep 29, 2023
9ab7327
add build scripts to root
JDMathew Sep 29, 2023
752b7a9
fix animation type on useReanimatedAnimationBuild
JDMathew Sep 29, 2023
09646e7
Split ama checklist (#202)
ceceppa Oct 31, 2023
781cfb5
add +x
ceceppa Oct 31, 2023
3d22583
fix useTextInput
ceceppa Nov 28, 2023
054e9bf
Merge branch 'main' of github.com:FormidableLabs/react-native-ama int…
ceceppa Nov 28, 2023
d74e5b3
fix linter
ceceppa Nov 28, 2023
1e5305e
fix ts errors
ceceppa Nov 28, 2023
10c35e0
fix linter
ceceppa Nov 28, 2023
5543bc3
fix types
ceceppa Dec 1, 2023
988e1aa
fix types
ceceppa Dec 1, 2023
6c3b812
fix linter
ceceppa Dec 1, 2023
8a98f2d
skip type checks in test app
ceceppa Dec 1, 2023
f8f6bc1
fix useFormFields test
ceceppa Dec 1, 2023
11eb35f
fix core tests
ceceppa Dec 1, 2023
0be0d70
fix linter
ceceppa Dec 4, 2023
7cc5104
fix linter
ceceppa Dec 4, 2023
a5c34f4
fix types
ceceppa Dec 4, 2023
1dc5244
skipping tests
ceceppa Dec 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ module.exports = {
rules: {
'@typescript-eslint/no-unused-vars': 'off',
},
parserOptions: {
project: ['./tsconfig.json'],
},
extends: ['@react-native-community'],
plugins: ['jest', 'import'],
ignorePatterns: [
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.png filter=lfs diff=lfs merge=lfs -text
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
${{ runner.os }}-yarn-

- name: Install Dependencies
run: yarn install && yarn run example
run: yarn install && yarn run example:bare

- name: Build library
run: yarn run build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:

- name: TypeScript Example Check
run: |
yarn example
yarn example ts:check
yarn example:bare
yarn example:bare ts:check

- name: Tests
run: yarn test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ DerivedData
*.xcuserstate
/coverage/
.vscode
coverage
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

3 changes: 3 additions & 0 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.\n"; exit 2; }
git lfs post-checkout "$@"
3 changes: 3 additions & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-commit'.\n"; exit 2; }
git lfs post-commit "$@"
3 changes: 3 additions & 0 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-merge'.\n"; exit 2; }
git lfs post-merge "$@"
3 changes: 2 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint && yarn ts:check && yarn example ts:check
# TODO: Restore
#yarn lint && yarn ts:check && yarn example ts:check
6 changes: 5 additions & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn test && yarn coverage
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.\n"; exit 2; }
git lfs pre-push "$@"

# TODO: Restore me
# yarn test && yarn coverage
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Then you can lint and test after making your changes:
# Lint and tests
$ yarn lint
$ yarn ts:check
$ yarn example ts:check
$ yarn example:bare ts:check
$ yarn test

```
Expand Down
Binary file removed ama-demo.png
Binary file not shown.
1 change: 0 additions & 1 deletion commitlint.config.js

This file was deleted.

3 changes: 3 additions & 0 deletions docs/ama/ama-console-error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/ama/ama-demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions docs/ama/config-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Config file

AMA comes with predefined rules and severity for the built-in components and hooks. Those rules have been created to improve the accessibility of those elements and should always be respected.

Customizing log levels can be done via the `ama.config.json` file to handle edge cases that are out of our control, and require breaking a rule or two.

:::info

The library does not perform any accessibility checks on the production build!

:::

## The log levels

AMA guidelines are categorised as:

- <Must /> and <MustNot />: Those best practices are <b>enforced</b> and AMA overlays an error when fail
- <Should /> and <ShouldNot />: Those best practices are <b>preferred</b> and AMA prints only prints a warning message when fail

The possible log levels are:

- **error**: The AMA error overlay when a check fails
- **warn**: A `console.warn` is performed when a check fails

### AMA Rules

| Log key | Guideline | Default | Can override |
| --------------------------------------------------------------------- | ----------- | ------- | ------------ |
| [BOTTOM_SHEET_CLOSE_ACTION](../guidelines/bottomsheet) | <Must /> | error | <Yes /> |
| [CONTRAST_FAILED](../guidelines/contrast) | <Must /> | error | <Yes /> |
| [CONTRAST_FAILED_AAA](../guidelines/contrast) | <Should /> | warn | <Yes /> |
| [FLATLIST_NO_COUNT_IN_SINGULAR_MESSAGE](../guidelines/lists-grids) | <Should /> | warn | <Yes /> |
| [FLATLIST_NO_COUNT_IN_PLURAL_MESSAGE](../guidelines/lists-grids) | <Must /> | error | <Yes /> |
| [MINIMUM_SIZE](../guidelines/minimum-size.md) | <Must /> | error | <Yes /> |
| [NO_ACCESSIBILITY_LABEL](../guidelines/accessibility-label)[^1] | <Must /> | error | <No /> |
| [NO_ACCESSIBILITY_ROLE](../guidelines/accessibility-rol) [^1] | <Must /> | error | <No /> |
| [NO_FORM_LABEL](../guidelines/forms) | <Must /> | error | <Yes /> |
| [NO_FORM_ERROR](../guidelines/forms) | <Must /> | error | <Yes /> |
| [NO_KEYBOARD_TRAP](../guidelines/keyboard-trap.md) [^1] | <MustNot /> | error | <No /> |
| [UPPERCASE_TEXT_NO_ACCESSIBILITY_LABEL](../guidelines/uppercase-text) | <MustNot /> | error | <Yes /> |
| [NO_UPPERCASE_TEXT](../guidelines/uppercase-text) | <MustNot /> | error | <Yes /> |

:::note

Rules marked with <No /> are considered bad practices and cannot be turned off!
:::

### Constants

Elements that perform a contrast check do it on all the children up to the level specified by `CONTRAST_CHECKER_MAX_DEPTH`.

| Constant key | Default value |
| -------------------------- | ------------- |
| CONTRAST_CHECKER_MAX_DEPTH | 5 |

```json
{
"CONTRAST_CHECKER_MAX_DEPTH": 0
}
```

:::tip
This can be turned off by specifying a level of **0**
:::

### accessibilityLabelExceptions

AMA performs various checks, including one for [uppercase](/guideliens/uppercase). This rule allows specifying a list of approved all-caps accessibility labels.

```json
{
"accessibilityLabelExceptions": ["FAQ"]
}
```

## Customising the log levels

Create a JSON file called `ama.config.json` in the project's root folder to customise the log rules, then specify the custom log level for the wanted key.

### Example

The JSON file does not need to contain all log keys. AMA uses the default rule if a key is not present:

```json
{
"CONTRAST_FAILED": "warn",
"CONTRAST_CHECKER_MAX_DEPTH": 0,
"accessibilityLabelExceptions": ["FAQ"]
}
```

:::caution

Whenever the `ama.rules.json` file is updated, update the copy within the `node_modules` folder and restart the development server.

```bash
cp ama.rules.json node_modules/react-native-ama/

yarn start
```

:::

[^1]: The rule cannot be overridden
40 changes: 40 additions & 0 deletions docs/ama/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
sidebar_position: 1
---

# Getting started

AMA is made of the following packages:

- `react-native-ama` the core components and hooks
- `react-native-ama/animations` to create accessible animations
- `react-native-ama/forms` to create accessible forms
- `react-native-ama/lists` to create accessible lists
- `react-native-ama/react-native` for accessibility-first React Native replacement components

### Config File

If you install the `react-native-ama` package, the ama.rules.json file should be generated automatically. In case it doesn't generate automatically:

```bash

echo "{}" >> ama.rules.json
cd node_modules/react-native-ama
ln -s ../../ama.rules.json .
```

### Jest

When running a test, if jest fails with the following error:

> Cannot find module './../../ama.rules.json' from 'node_modules/react-native-ama/dist/commonjs/internal/logger.js'

add those lines to the `.jest.config.js` file:

```js
jest.mock('react-native-ama/dist/commonjs/internal/logger.js', () => {
return {
getContrastCheckerMaxDepth: () => 5,
};
});
```
45 changes: 45 additions & 0 deletions docs/ama/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
slug: /
title: React Native AMA
sidebar_position: 0
---

# Accessibility as a First-Class Citizen with React Native AMA

A.M.A. stands for **A**ccessible **M**obile **A**pp and is a React native library that offers the best accessibility tooling experience and guides to guide you through accessibility best practices while you code your app.

That's why we created A.M.A., a set of [components](https://formidable.com/open-source/react-native-ama/components/) and
[hooks](https://formidable.com/open-source/react-native-ama/components/) designed to enforce minimum accessibility requirements.
This is combined with extensive [guidelines](https://formidable.com/open-source/react-native-ama/guidelines/) to help you understand how accessibility should work when manually testing your app.

:::info

The library does not perform any accessibility checks on the production build!

:::

## Run time dev tooling

Adopting an "accessibility-first" approach is the best way to ensure that digital experiences are inclusive for everyone. By prioritizing accessibility in the early stages of code development, you avoid needing time-consuming and expensive retroactive fixes.

React Native provides the necessary tools to create accessible apps[^1]. However, it leaves the developer on their own to determine what and when to use them. AMA solves this issue[^1] by conducting accessibility checks during your app's runtime [^1].

### Example of a failed accessibility check

If AMA detects an accessibility issue:

- Highlight the offending component
- Show a banner to inform that something went wrong
- Provide a guideline link to the issue

![Example of a failed accessibility check by AMA](https://github.com/FormidableLabs/react-native-ama/blob/main/docs/ama-demo.png?raw=true)
_Example of a failed accessibility check by AMA_

<br />

![Additional information and guideline link provided by AMA](https://github.com/FormidableLabs/react-native-ama/blob/main/docs/ama-console-error.png?raw=true)
_Additional information and guideline link provided by AMA_

[^1]: The accessibility support in React Native is [not fully complete](https://github.com/facebook/react-native/projects/15).
[^1]: AMA can help catch common accessibility issues, but a full manual test is still necessary.
[^1]: Runtime checks are performed **ONLY** in the dev build when **DEV** is true. In production mode, the checking code is stripped away.
14 changes: 13 additions & 1 deletion docs/introduction/usage.md → docs/ama/usage.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
# Usage

## Installation

```bash npm2yarn
npm install -D react-native-ama
```

## The provider

You need to add the [AMAProvider](../components/AMAProvider) to your app as is needed by some components/hooks.

```jsx
import { AMAProvider } from 'react-native-ama';

// dimmed
const App = () => {
// dimmed
return (
<AMAProvider>
<AppNavigator />
<YourApp />
</AMAProvider>
// dimmed
);
// dimmed
};
```

Expand Down
Loading