1
1
---
2
2
slug : /Theme
3
- title : Theme
3
+ title : Theme 🎨
4
4
---
5
5
6
6
The Theme folder, at the root of project, includes a nice kit for building and maintaining the UI of application.
7
7
It helps with variables and reusable classes to create harmony between application screens.
8
8
9
+ ## How to use ❓
10
+
11
+ The boilerplate provides a custom hook called ` useTheme ` and you can use it like the example bellow:
12
+
13
+ ``` jsx
14
+ import { useTheme } from ' @/Theme'
15
+
16
+ const Brand = ({ height = 200 , width = 200 , mode = ' contain' }) => {
17
+ const {
18
+ Common ,
19
+ Fonts ,
20
+ Gutters ,
21
+ Images ,
22
+ Layout ,
23
+ Colors ,
24
+ NavigationColors ,
25
+ FontSize ,
26
+ MetricsSizes ,
27
+ } = useTheme () // <- custom hook
28
+
29
+ return (
30
+ < View style= {{ height, width }}>
31
+ < Image style= {Layout .fullSize } source= {Images .logo } resizeMode= {mode} / >
32
+ < / View>
33
+ )
34
+ }
35
+ ```
9
36
---
10
37
11
38
## Variables
@@ -14,14 +41,27 @@ The first file is the variables one. It contains 3 groups of variables :
14
41
``` javascript
15
42
export const Colors = {
16
43
transparent: ' rgba(0,0,0,0)' ,
17
- primary : ' #007bff ' ,
44
+ inputBackground : ' #FFFFFF ' ,
18
45
white: ' #ffffff' ,
19
46
text: ' #212529' ,
47
+ primary: ' #E14032' ,
20
48
success: ' #28a745' ,
21
49
error: ' #dc3545' ,
22
50
}
23
51
```
24
52
53
+ - 🎨 ** NavigationColors** : defines global colors of the react navigation theme,
54
+ ``` javascript
55
+ export const NavigationColors = {
56
+ primary: Colors .primary , // The primary color of the app used to tint various elements. Usually you'll want to use your brand color for this.
57
+ // background: '', The color of various backgrounds, such as background color for the screens
58
+ // card: '', The background color of card-like elements, such as headers, tab bars etc.
59
+ // text: '', The text color of various elements
60
+ // border: '', The color of borders, e.g. header border, tab bar border etc
61
+ // notification: '', The color of Tab Navigator badge
62
+ }
63
+ ```
64
+
25
65
- 🔠 ** FontSize** : defines sizes for your text guidelines. These variables are used in the file [ Font] ( #font- ) described down below.
26
66
``` javascript
27
67
export const FontSize = {
@@ -51,14 +91,30 @@ The first file is the variables one. It contains 3 groups of variables :
51
91
The ` Common ` defines global style. It helps keeping the style at one place and avoid stylesheets everywhere in the code.
52
92
For example you can defines style for buttons, inputs, background like this :
53
93
``` javascript
54
- export default StyleSheet .create ({
55
- button: {
56
- backgroundColor: Colors .primary ,
57
- },
58
- backgroundReset: {
59
- backgroundColor: Colors .transparent ,
60
- },
61
- })
94
+ export default function ({ Colors }) {
95
+ return StyleSheet .create ({
96
+ button: {
97
+ backgroundColor: Colors .primary ,
98
+ },
99
+ backgroundPrimary: {
100
+ backgroundColor: Colors .primary ,
101
+ },
102
+ backgroundReset: {
103
+ backgroundColor: Colors .transparent ,
104
+ },
105
+ textInput: {
106
+ borderWidth: 1 ,
107
+ borderColor: Colors .text ,
108
+ backgroundColor: Colors .inputBackground ,
109
+ color: Colors .text ,
110
+ minHeight: 50 ,
111
+ textAlign: ' center' ,
112
+ marginTop: 10 ,
113
+ marginBottom: 10 ,
114
+ },
115
+ })
116
+ }
117
+
62
118
```
63
119
64
120
---
@@ -68,37 +124,37 @@ The `Font` presets some text classes using the [FontSize](#variables) variables.
68
124
It provides these classes:
69
125
70
126
### textSmall
71
- It applies a ` fontSize: FontSize.small ` on the element.
127
+ It applies a ` fontSize: FontSize.small ` on the element and apply the text color
72
128
<div align =" center " >
73
129
<img src={require('../assets/Theme/Text/textSmall.png').default} />
74
130
</div >
75
131
76
132
### textRegular
77
- It applies a ` fontSize: FontSize.regular ` on the element.
133
+ It applies a ` fontSize: FontSize.regular ` on the element and apply the text color
78
134
<div align =" center " >
79
135
<img src={require('../assets/Theme/Text/textRegular.png').default} />
80
136
</div >
81
137
82
138
### textLarge
83
- It applies a ` fontSize: FontSize.large ` on the element.
139
+ It applies a ` fontSize: FontSize.large ` on the element and apply the text color
84
140
<div align =" center " >
85
141
<img src={require('../assets/Theme/Text/textLarge.png').default} />
86
142
</div >
87
143
88
144
### titleSmall
89
- It applies a ` fontSize: FontSize.small * 2 ` and ` fontWeight: 'bold' ` on the element.
145
+ It applies a ` fontSize: FontSize.small * 2 ` , ` fontWeight: 'bold' ` on the element and apply the text color
90
146
<div align =" center " >
91
147
<img src={require('../assets/Theme/Text/titleSmall.png').default} />
92
148
</div >
93
149
94
150
### titleRegular
95
- It applies a ` fontSize: FontSize.regular * 2 ` and ` fontWeight: 'bold' ` on the element.
151
+ It applies a ` fontSize: FontSize.regular * 2 ` , ` fontWeight: 'bold' ` on the element and apply the text color
96
152
<div align =" center " >
97
153
<img src={require('../assets/Theme/Text/titleRegular.png').default} />
98
154
</div >
99
155
100
156
### titleLarge
101
- It applies a ` fontSize: FontSize.large * 2 ` and ` fontWeight: 'bold' ` on the element.
157
+ It applies a ` fontSize: FontSize.large * 2 ` , ` fontWeight: 'bold' ` on the element and apply the text color
102
158
<div align =" center " >
103
159
<img src={require('../assets/Theme/Text/titleLarge.png').default} />
104
160
</div >
@@ -160,17 +216,20 @@ This files includes all images used in the application.
160
216
To use it, you only have to import the image like below
161
217
162
218
``` javascript
163
- export default {
164
- logo: require (' @/Assets/Images/TOM.png' ),
165
- }
219
+ export default function () {
220
+ return {
221
+ logo: require (' @/Assets/Images/TOM.png' ),
222
+ }
223
+ }
166
224
```
167
225
168
226
Then you can use your image like this :
169
227
170
- ``` javascript
171
- import { Images } from ' @/Theme'
172
- ...
173
- < Image source= {Images .logo } / >
228
+ ``` jsx
229
+ const myComponent = () => {
230
+ const { Images } useTheme ()
231
+ return < Image source= {Images .logo } / >
232
+ }
174
233
```
175
234
176
235
---
@@ -298,6 +357,10 @@ rotate an element by 90° clockwise
298
357
#### rotate90Inverse
299
358
rotate an element by 90° counterclockwise
300
359
301
- ::: note
360
+ ::: info
302
361
In all these groups you can add, remove or edit variables/classes with the values you want
362
+ :::
363
+
364
+ :::note Important
365
+ Each style file is an export default function with all the Theme Variables in parameters
303
366
:::
0 commit comments