Skip to content

Commit b84b8d9

Browse files
authored
add quick readme tutorial for creating a design system with uilib
1 parent d9445a7 commit b84b8d9

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,87 @@ please use `react-native-ui-lib@^4.0.0`
2121

2222
#### For React Native < 0.60.0
2323
please use `react-native-ui-lib@^3.0.0`
24+
25+
## Create your own Design System in 3 easy steps
26+
27+
### Step 1
28+
Load your foundations and presets (colors, typography, spacings, etc...)
29+
30+
```
31+
// FoundationConfig.js
32+
33+
import {Colors, Typography, Spacings} from 'react-native-ui-lib';
34+
35+
Colors.loadColors({
36+
primaryColor: '#2364AA',
37+
secondaryColor: '#81C3D7',
38+
textColor: '##221D23',
39+
errorColor: '#E63B2E',
40+
successColor: '#ADC76F',
41+
warnColor: '##FF963C'
42+
});
43+
44+
Typography.loadTypographies({
45+
heading: {fontSize: 36, fontWeight: '600'},
46+
subheading: {fontSize: 28, fontWeight: '500'},
47+
body: {fontSize: 18, fontWeight: '400'},
48+
});
49+
50+
Spacings.loadSpacings({
51+
page: 20,
52+
card: 12,
53+
gridGutter: 16
54+
});
55+
56+
```
57+
58+
### Step 2
59+
Set default configurations to your components
60+
61+
```
62+
// ComponentsConfig.js
63+
64+
import {ThemeManager} from 'react-native-ui-lib';
65+
66+
// with plain object
67+
ThemeManager.setComponentTheme('Card', {
68+
borderRadius: 8
69+
});
70+
71+
// with a dynamic function
72+
ThemeManager.setComponentTheme('Button', (props, context) => {
73+
// 'square' is not an original Button prop, but a custom prop that can
74+
// be used to create different variations of buttons in your app
75+
if (props.square) {
76+
return {
77+
borderRadius: 0
78+
};
79+
}
80+
});
81+
```
82+
83+
### Step 3
84+
Use it all together.
85+
Your configurations will be applied on uilib components so you can use them easily with [modifiers](https://github.com/wix/react-native-ui-lib/wiki/MODIFIERS).
86+
87+
```
88+
// MyScreen.js
89+
90+
import React, {Component} from 'react';
91+
import {View, Text, Card, Button} from 'react-native-ui-lib';
92+
93+
class MyScreen extends Component {
94+
render() {
95+
return (
96+
<View flex padding-page>
97+
<Text heading marginB-s4>My Screen</Text>
98+
<Card height={100} center padding-card marginB-s4>
99+
<Text body>This is an example card </Text>
100+
</Card>
101+
102+
<Button label="Button" body bg-primaryColor square></Button>
103+
</View>
104+
);
105+
}
106+
}
107+
```

0 commit comments

Comments
 (0)