Config file
In dev mode, AMA components try to enforce some accessibility requirements by showing an error banner and printing the reason when a rule is broken. For example, missing accessibility label, poor color contrast, minimum size not met, etc.
Conscious that there might be edge cases where a rule or two might need to be broken, AMA provides a way to change the logging level of each guideline tested.
The library does not perform any accessibility check on the production build!
The log levels
AMA guidelines are categorised as:
- and : Those best practices are enforced and AMA overlays an error when fail
- and : Those best practices are preferred and AMA prints only prints a warning message when fail
Default Rules
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 |
This can be turned off by specifying a level of 0
accessibilityLabelExceptions
This field is empty by default and can be overridden by specifying a list of accessibilityLabel to be excluded from the all caps check.
Customising the log levels
Create a JSON file called ama.rules.json
in the project's root folder to customise the log rules, then specify the custom log level for the wanted key.
Example
{
"rules": {
"CONTRAST_FAILED": "warn",
"CONTRAST_CHECKER_MAX_DEPTH": 0
},
"accessibilityLabelExceptions": ["A A"]
}
The JSON file does not need to contain all the log keys, as AMA defaults to the default rule if not present in the JSON one.
Every time the ama.rules.json
file is updated, you need to update the copy inside the node_modules
folder and restart the development server:
cp ama.rules.json node_modules/react-native-ama/
yarn start