11---
22slug : /Theme
3- title : Theme
3+ title : Theme 🎨
44---
55
66The Theme folder, at the root of project, includes a nice kit for building and maintaining the UI of application.
77It helps with variables and reusable classes to create harmony between application screens.
88
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+ ```
936---
1037
1138## Variables
@@ -14,14 +41,27 @@ The first file is the variables one. It contains 3 groups of variables :
1441 ``` javascript
1542 export const Colors = {
1643 transparent: ' rgba(0,0,0,0)' ,
17- primary : ' #007bff ' ,
44+ inputBackground : ' #FFFFFF ' ,
1845 white: ' #ffffff' ,
1946 text: ' #212529' ,
47+ primary: ' #E14032' ,
2048 success: ' #28a745' ,
2149 error: ' #dc3545' ,
2250 }
2351 ```
2452
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+
2565 - 🔠 ** FontSize** : defines sizes for your text guidelines. These variables are used in the file [ Font] ( #font- ) described down below.
2666 ``` javascript
2767 export const FontSize = {
@@ -51,14 +91,30 @@ The first file is the variables one. It contains 3 groups of variables :
5191The ` Common ` defines global style. It helps keeping the style at one place and avoid stylesheets everywhere in the code.
5292For example you can defines style for buttons, inputs, background like this :
5393``` 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+
62118```
63119
64120---
@@ -68,37 +124,37 @@ The `Font` presets some text classes using the [FontSize](#variables) variables.
68124It provides these classes:
69125
70126### 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
72128<div align =" center " >
73129 <img src={require('../assets/Theme/Text/textSmall.png').default} />
74130</div >
75131
76132### 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
78134<div align =" center " >
79135 <img src={require('../assets/Theme/Text/textRegular.png').default} />
80136</div >
81137
82138### 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
84140<div align =" center " >
85141 <img src={require('../assets/Theme/Text/textLarge.png').default} />
86142</div >
87143
88144### 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
90146<div align =" center " >
91147 <img src={require('../assets/Theme/Text/titleSmall.png').default} />
92148</div >
93149
94150### 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
96152<div align =" center " >
97153 <img src={require('../assets/Theme/Text/titleRegular.png').default} />
98154</div >
99155
100156### 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
102158<div align =" center " >
103159 <img src={require('../assets/Theme/Text/titleLarge.png').default} />
104160</div >
@@ -160,17 +216,20 @@ This files includes all images used in the application.
160216To use it, you only have to import the image like below
161217
162218``` 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+ }
166224```
167225
168226Then you can use your image like this :
169227
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+ }
174233```
175234
176235---
@@ -298,6 +357,10 @@ rotate an element by 90° clockwise
298357#### rotate90Inverse
299358rotate an element by 90° counterclockwise
300359
301- ::: note
360+ ::: info
302361In 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
303366:::
0 commit comments