Skip to content

Commit b3806ab

Browse files
authored
V7/ update colors docs (#2488)
* update colors docs * improve docs * add missing comma
1 parent 8ae6a4d commit b3806ab

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

docs/foundation/colors.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,55 @@ sidebar_position: 2
33
sidebar_label: Colors
44
title: "Colors"
55
---
6+
## Colors
7+
Our default library Colors object is using **System Colors** and **Design Tokens**.
8+
9+
### System Colors
10+
The System Colors are all the colors we use in our design system. (red30, grey10 and so on).
11+
12+
### Design Tokens
13+
Design Tokens are contextual colors based on the system colors.
14+
The design token name structure is "$[property]-[semantic]-[weight]". (e.g $backgroundPrimaryHeavy, $textSuccessLight)
15+
* **Property** - The property we use this token for. The properties are:
16+
* `background`
17+
* `text`
18+
* `icon`
19+
* `outline`
20+
21+
22+
* **Semantic** - the meaning of the color, what is the message that we want to pass using this color. The semantics are:
23+
* `neutral`
24+
* `primary` - the primary color of the app, means, blue for Spaces app and green for Fit app.
25+
* `general`
26+
* `success`
27+
* `warning`
28+
* `danger`
29+
* `disabled`
30+
* `inverted`
31+
* `default`
32+
33+
34+
* **Weight** - the weight of the color (optional). The weights are:
35+
* `light`
36+
* `medium`
37+
* `heavy`
38+
39+
So, for example, a valid token can be: `$backgroundPrimaryHeavy` or `$textSuccess`.
40+
A full list of our design tokens can be found here -
41+
42+
### Dark Mode Support
43+
By using design tokens, your getting dark mode support out of the box!
44+
Each token is mapped to a single system color in light mode and to a (usually different) single system color in dark mode.
45+
For example, `$textSuccess` is mapped to `green10` in light (deafult) mode, and to `green60` in dark mode.
46+
All the design tokens and their mapping in light mode can be found [here](https://github.com/wix/react-native-ui-lib/blob/master/src/style/designTokens.ts), dark mode mapping can be found [here](https://github.com/wix/react-native-ui-lib/blob/master/src/style/designTokensDM.ts).
47+
48+
### Add Your Own Design Tokens
49+
Adding or overriding your own design tokens can be done by using the [loadSchemes](https://wix.github.io/react-native-ui-lib/docs/foundation/colors#loadschemes) method.
50+
To generate the design tokens, based on your app primary color and load them automatically into the `Colors` object, use:
51+
```javascript
52+
Colros.loadDesignTokens({primaryColor: <your primary color>});
53+
```
54+
This method will update all the `primary` tokens to be based on your app primary color, both in light and dark mode.
655

756
### loadColors
857
Load a set of colors to be used in the app.
@@ -30,6 +79,7 @@ import {View, Text, Colors} from 'react-native-ui-lib';
3079
### loadSchemes
3180
Load a set of scheme colors to support dark/light mode.
3281
This feature works hand in hand with our modifiers
82+
This method also supports adding and overriding design tokens:
3383

3484
```js
3585
Colors.loadSchemes({
@@ -38,14 +88,18 @@ Colors.loadSchemes({
3888
textColor: Colors.grey10,
3989
moonOrSun: Colors.yellow30,
4090
mountainForeground: Colors.green30,
41-
mountainBackground: Colors.green50
91+
mountainBackground: Colors.green50,
92+
$backgroundSuccess: Colors.green40,
93+
$backgroundSuccessLight: Colors.green70
4294
},
4395
dark: {
4496
screenBG: Colors.grey10,
4597
textColor: Colors.white,
4698
moonOrSun: Colors.grey80,
4799
mountainForeground: Colors.violet10,
48-
mountainBackground: Colors.violet20
100+
mountainBackground: Colors.violet20,
101+
$backgroundSuccess: Colors.green40,
102+
$backgroundSuccessLight: Colors.green20
49103
}
50104
});
51105
```

0 commit comments

Comments
 (0)