|
| 1 | +# Accessibility |
| 2 | + |
| 3 | +The Accessibility plugin provides functionality to easily make your App more accessible. |
| 4 | + |
| 5 | +Currently it provides functionality to apply a **Colorshifting filter** to your App, helping people with different types of color blindness to properly use your App. |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +The Accessibility plugin is automatically included in the root of your App. In most cases there is no need to specifically import the Accessibility plugin into your App code. |
| 10 | + |
| 11 | +## Colorshift filter |
| 12 | + |
| 13 | +When you want to apply a colorshift filter over your _entire App_, you can do so by calling the |
| 14 | +`colorshift` method attached to the root `application`. |
| 15 | + |
| 16 | +A reference to the root application is made available in every Lightning component (via `this.application`), allowing you to invoke this function from anywhere in your App. |
| 17 | + |
| 18 | +### colorshift |
| 19 | + |
| 20 | +Applies a color filter and optional _brightness_, _contrast_ and _gamma_ configuration. |
| 21 | + |
| 22 | +```js |
| 23 | +const type = 'deuteranopia' |
| 24 | +const config = { |
| 25 | + brightness: 18, |
| 26 | + contrast: 69, |
| 27 | + gamma: 42 |
| 28 | +} |
| 29 | +this.application.colorshift(type, config) |
| 30 | +``` |
| 31 | + |
| 32 | +#### type |
| 33 | + |
| 34 | +Valid values for Colorshift types are: |
| 35 | + |
| 36 | +- `deuteranopia` (red-green, green weak) |
| 37 | +- `protanopia` (red-green, red weak) |
| 38 | +- `tritanopia` (blue-yellow) |
| 39 | +- `monochromacy` (grayscale) |
| 40 | +- `normal` (normal vision) |
| 41 | + |
| 42 | +When passing `false` the entire colorshift filter is disabled. |
| 43 | + |
| 44 | +#### config |
| 45 | + |
| 46 | +`config` is an object where the _brightness_, _contrast_ and _gamma_ of each color filter can be tweaked. The values are expected to be between `0` and `100`, and default to `50`. |
| 47 | + |
| 48 | +It's not required to pass in the entire object. Keys that are omitted are automatically assumed to have the default value (of `50`). |
| 49 | + |
| 50 | +The `normal` type color filter should be used for cases where you only want to adjust the brightness, contrast or gamma values, without applying any specific color blindness filter. |
| 51 | + |
| 52 | + |
| 53 | +### Advanced use |
| 54 | + |
| 55 | +The typical use of the colorshift filter is to apply it over the entire app (using `this.application.colorshift()`). But there may also be cases where you want to apply it only to a single element (for demo purposes or during in-app configuration of the color settings, for example). |
| 56 | + |
| 57 | +In this case you should import the `Accessibility` plugin into your component. |
| 58 | + |
| 59 | +```js |
| 60 | +import { Accessibility } from '@lightningjs/sdk' |
| 61 | +``` |
| 62 | + |
| 63 | +Next you can use the `colorshift` method similarly to the standard use. With the exception that the first argument refers to the Lightning element you want to apply the colorshift filter to. |
| 64 | + |
| 65 | +```js |
| 66 | +const type = 'protanopia' |
| 67 | +const config = { |
| 68 | + brightness: 54, |
| 69 | +} |
| 70 | +const element = this.tag('Logo') |
| 71 | +Accessibility.colorshift(element, type, config) |
| 72 | +``` |
| 73 | + |
| 74 | +Important to remember is that the element you apply the colorshift filter to shouldn't already have a _shader_ applied to it, nor can it have `rtt` set to `true`. In these cases you could create a wrapper and apply the colorshift filter to the wrapper instead. |
| 75 | + |
| 76 | +<!-- |
| 77 | +Todo |
| 78 | +
|
| 79 | +### Colorshift configuration UX |
| 80 | +
|
| 81 | +To make it as easy as possible to make your App colorblindness friendly, we have made available a standard importable [UI component](...) to set and configure the colorshift settings for your App. |
| 82 | +
|
| 83 | +Feel free to use this UI component directly inside your App. Or use it as inspiration to build your own configuration screen. |
| 84 | +
|
| 85 | +--> |
0 commit comments