Skip to content

Commit 9dcf7fe

Browse files
authored
Infra/docusaurus docs (#1525)
* WIP - create a docusaurus docs site * connect our markdown docs to docusaurus * Update logo and basic configuration * Update sidebar structure * POC - script for generating docs out of json files * Create sub categories for components docs * Add more categories * Support showing component showcase * Reposition navbar items * Add more info to component doc template like extends, modifiers and code example link * Update footer links * Update general info and install scss plugin * Add MainSection * Load Poppins font css * Minor fixes in MainSection layout * Reanme classes in MainSection * Fix link to docs * Implement components section * Add features section * Add code section * Add libraries section * Update theme colors and cleanup * Update favicon * Enable navbar hideOnScroll * Create a global presets and components css * Update docs files copy * Fixes in new docs markdowns * Fix markdown issues * Add v6 readme
1 parent 41c00e6 commit 9dcf7fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+3017
-32
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ dist
6262
dist-ts
6363
yarn.lock
6464
package-lock.json
65+
docs/**/*.md
6566

6667
# CocoaPods
6768
/ios/Pods/

docs/foundation/assets.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
index: 6
3+
path: "/foundation/assets"
4+
title: "Assets"
5+
---
6+
Assets are a big part of the whole UI system, whether it's an icon, placeholder or an illustration, we use them everywhere.
7+
Load groups of assets and easily render them with the _Image_ component.
8+
9+
```javascript
10+
import {Assets, Image} from 'react-native-ui-lib';
11+
12+
Assets.loadAssetsGroup('icons', {
13+
icon1: require('icon1.png'),
14+
icon2: require('icon2.png'),
15+
icon3: require('icon3.png'),
16+
});
17+
18+
// or as a nested group to create your own hierarchy
19+
Assets.loadAssetsGroup('illustrations.placeholders', {
20+
emptyCart: require('emptyCart.png'),
21+
emptyProduct: require('emptyProduct.png'),
22+
});
23+
Assets.loadAssetsGroup('illustrations.emptyStates.', {
24+
noMessages: require('noMessages.png'),
25+
noContacts: require('noContacts.png'),
26+
});
27+
28+
```
29+
30+
And use them like this
31+
```jsx
32+
// Use them with the Image component (our Image component)
33+
<Image assetName="icon1"/> // default assetGroup is "icons"
34+
<Image assetName="emptyCart" assetGroup="illustrations.placeholders"/>
35+
36+
// The old fashion way will work as well
37+
<Image source={Assets.icons.icon1}/>
38+
```

docs/foundation/colors.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
sidebar_position: 7
3+
path: "/foundation/colors"
4+
title: "Colors"
5+
---
6+
7+
#### loadColors
8+
Load a set of colors to be used in the app.
9+
These colors will be accessible through the Colors class and as modifiers.
10+
usage:
11+
```javascript
12+
import {Colors} from 'react-native-ui-lib';
13+
14+
Colors.loadColors({
15+
error: '#ff2442',
16+
success: '#00CD8B',
17+
text: '#20303C'
18+
});
19+
```
20+
21+
```jsx
22+
import {View, Text, Colors} from 'react-native-ui-lib';
23+
24+
<View>
25+
<Text style={{color: Colors.error}}>Error Message</Text>
26+
<Text success>Success Message</Text>
27+
<View>
28+
```
29+
30+
#### loadSchemes
31+
Load a set of scheme colors to support dark/light mode.
32+
This feature works hand in hand with our modifiers
33+
34+
```js
35+
Colors.loadSchemes({
36+
light: {
37+
screenBG: 'transparent',
38+
textColor: Colors.grey10,
39+
moonOrSun: Colors.yellow30,
40+
mountainForeground: Colors.green30,
41+
mountainBackground: Colors.green50
42+
},
43+
dark: {
44+
screenBG: Colors.grey10,
45+
textColor: Colors.white,
46+
moonOrSun: Colors.grey80,
47+
mountainForeground: Colors.violet10,
48+
mountainBackground: Colors.violet20
49+
}
50+
});
51+
```
52+
53+
```jsx
54+
<View flex padding-page bg-screenBG>
55+
<Text h1 textColor>
56+
Dark Mode
57+
</Text>
58+
</View>
59+
```
60+
61+
#### rgba
62+
usage:
63+
```js
64+
import {Colors} from 'react-native-ui-lib';
65+
66+
Colors.rgba('#ff2442', 0.05); // 'rgb(255, 36, 66, 0.05)'
67+
Colors.rgba(44, 224, 112, 0.2); // 'rgb(44, 224, 112, 0.2)'
68+
```
69+
70+
#### getColorTint
71+
usage:
72+
```js
73+
import {Colors} from 'react-native-ui-lib';
74+
75+
Colors.getColorTint(Colors.green30, 70); // will return the value of Colors.green70
76+
Colors.getColorTint('#ff2442', 50); // will return the 5th tint in an autogenerate 8-tints palette based on '#ff2442'
77+
```
78+
79+
#### isDark
80+
returns `true` if a color is considered dark (bright colors will return `false`)
81+
```js
82+
import {Colors} from 'react-native-ui-lib';
83+
84+
Colors.isDark(Colors.grey10); // true
85+
Colors.isDark(Colors.grey80); // false
86+
```

docs/foundation/modifiers.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
index: 5
3+
path: "/foundation/modifiers"
4+
title: "Modifiers"
5+
---
6+
As you have probably noticed already, we translate our style presets into modifiers.
7+
**Modifiers** help you create a stunning UI easily and quickly.
8+
9+
**[!IMPORTANT]**
10+
Make sure to use modifiers only on UILib components, as some modifiers can cause issues on Android when used on React Native components directly.
11+
12+
## Layout Modifiers
13+
Use our alignment properties to quickly position the content of your view without getting confused calculating all those flex rules.
14+
- flex - apply `flex:1` on a view
15+
- flex-[value] - When you want to control the flex value
16+
- flexS - FlexShrink
17+
- flexG - FlexGrow
18+
- left
19+
- top
20+
- right
21+
- bottom
22+
- row - change direction to row (default is column)
23+
- center
24+
- centerH - center content horizontally
25+
- centerV - center content vertically
26+
- spread - spread content (similar to `space-between`)
27+
28+
! Notice that the layout modifiers affect the View's children
29+
30+
```jsx
31+
<View flex left>
32+
<Button label="Button" />
33+
</View>
34+
35+
<View flex right>
36+
<Button label="Button" />
37+
</View>
38+
39+
<View flex top>
40+
<Button label="Button" />
41+
</View>
42+
43+
<View flex bottom>
44+
<Button label="Button" />
45+
</View>
46+
47+
<View flex center>
48+
<Button label="Button" />
49+
</View>
50+
```
51+
<img src="https://cloud.githubusercontent.com/assets/1780255/24798566/4de91efc-1b9f-11e7-9974-e06e3daa7c63.png" width="160"/> <img src="https://cloud.githubusercontent.com/assets/1780255/24798569/50dc99a4-1b9f-11e7-8231-fbcbb139a010.png" width="160"/> <img src="https://cloud.githubusercontent.com/assets/1780255/24798571/52766d08-1b9f-11e7-95a3-b2b262e81170.png" width="160"/> <img src="https://cloud.githubusercontent.com/assets/1780255/24798572/545b7abe-1b9f-11e7-9098-409ceee6ff22.png" width="160"/> <img src="https://cloud.githubusercontent.com/assets/1780255/24798575/55e3c4f4-1b9f-11e7-998d-7986a038abb6.png" width="160"/>
52+
53+
## Spacing Modifiers
54+
It's always important to use your margins and paddings correctly, and that's also easier to do with modifiers:
55+
56+
- padding-[value] - will add padding to all corners (e.g. padding-30 will add 30 pt of padding)
57+
- paddingL-[value] - Left padding
58+
- paddingT-[value] - Top padding
59+
- paddingR-[value] - Right padding
60+
- paddingB-[value] - Bottom padding
61+
- paddingH-[value] - Horizontal padding
62+
- paddingV-[value] - Vertical padding
63+
```jsx
64+
<View paddingV-20 paddingH-30>...</View>
65+
```
66+
67+
- margin-[value]
68+
- marginL-[value] - Left margin
69+
- marginT-[value] - Top margin
70+
- marginR-[value] - Right margin
71+
- marginB-[value] - Bottom margin
72+
- marginH-[value] - Horizontal margin
73+
- marginV-[value] - Vertical margin
74+
75+
```jsx
76+
<View marginT-5 marginB-10>...</View>
77+
```
78+
79+
! padding and margin modifiers can also take [Spacing](https://github.com/wix/react-native-ui-lib/blob/master/src/style/spacings.ts) constants.
80+
```jsx
81+
<View margin-s5 padding-s2>...</View>
82+
```
83+
## Position Modifiers
84+
Use the position modifiers to quickly set an absolute position for your views.
85+
- `abs` will set the absolute position on your View
86+
- `absL`, `absT`, `absR`, `absB` - set the absolute position and align to Left, Top, Right, Bottom accordingly
87+
- `absH` and `absV` - position absolute and stretch horizontally or vertically
88+
- `absF` will set the absolute position and fill the parent view (similar to StyleSheet.absoluteFillObject)
89+
90+
## Styling Modifiers
91+
The last type of modifiers is for styling your components
92+
93+
- [colorKey] - Controls the color of text components
94+
- background-[colorKey] (or bg-[colorKey]) - Background color
95+
96+
```jsx
97+
<Text blue30>...</Text>
98+
<View bg-grey70>...</View>
99+
<TouchableOpacity bg-red30/>
100+
```
101+
102+
- [typographyKey] - Controls the typography of text components
103+
```jsx
104+
<Text text70>...</Text>
105+
<TextInput text80/>
106+
```
107+
108+
- br[borderRadiusKey] - Set the border radius for the view (e.g. `br10`, `br20`, .., `br60`)
109+
```jsx
110+
<View br40>...</View>
111+
```
112+
113+
114+
! all styling modifiers are based on our [`Colors` & `Typography` presets](/react-native-ui-lib/foundation/style).
115+
You can load your own presets and use them as modifiers.
116+
117+
118+
119+
Check out [this example](/react-native-ui-lib/getting-started/usage) where we use most of these props.

docs/foundation/style.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
sidebar_position: 4
3+
path: "/foundation/style"
4+
title: "Style"
5+
---
6+
The base foundation of each UI component is its style.
7+
We use basic style presets to define the rules and the style guide we follow.
8+
9+
Our presets include: **Colors**, **Typography**, **Spacings**, **Shadows**, **Border Radius** and more..
10+
11+
The UILib already comes with a set of predefined constants and [presets](https://github.com/wix/react-native-ui-lib/tree/master/src/style).
12+
13+
You can easily use it anywhere in your code (as you would use any other constant value), or as a component modifier.
14+
15+
It's also very easy to define your own presets..
16+
17+
```jsx
18+
import {Typography, Colors, Spacings} from 'react-native-ui-lib';
19+
20+
Colors.loadColors({
21+
pink: '#FF69B4',
22+
gold: '#FFD700',
23+
});
24+
25+
Typography.loadTypographies({
26+
h1: {fontSize: 58, fontWeight: '300', lineHeight: 80},
27+
h2: {fontSize: 46, fontWeight: '300', lineHeight: 64},
28+
});
29+
30+
Spacings.loadSpacings({
31+
page: isSmallScreen ? 16 : 20
32+
});
33+
```
34+
35+
For example, the following line
36+
37+
```jsx
38+
<Text h1 pink>Hello World</Text>
39+
```
40+
Will generate this text
41+
<img src="https://cloud.githubusercontent.com/assets/1780255/24792314/296b7ebc-1b86-11e7-8580-9252d1ddf5d9.png" width="250"/>
42+
43+
It will use the _h1_ preset for typography and the _pink_ color value we set to style the Text element.

docs/foundation/theme-manager.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
index: 7
3+
path: "/foundation/theme-manager"
4+
title: "Theme Manager"
5+
---
6+
Use `ThemeManager` to set default global behavior for your app.
7+
8+
#### setComponentTheme
9+
10+
Set default props for a component by passing an object or a callback (for dynamic, runtime default props)
11+
The default value will be overridden if a prop is being passed to the component instance (see `setComponentForcedTheme` for that).
12+
13+
- `ThemeManager.setComponentTheme(componentName, defaultPropsObject);`
14+
- `ThemeManager.setComponentTheme(componentName, componentProps => newDefaultPropsObject);`
15+
16+
Example
17+
18+
```js
19+
import {ThemeManager} from 'react-native-ui-lib';
20+
21+
ThemeManager.setComponentTheme('Text', {
22+
text70: true, // will set the text70 typography modifier prop to be true by default
23+
grey10: true, // will set the grey10 color modifier prop to be true by default
24+
});
25+
26+
27+
ThemeManager.setComponentTheme('Button', (props, context) => {
28+
29+
return {
30+
// this will apply a different backgroundColor
31+
// depending on whether the Button has an outline or not
32+
backgroundColor: props.outline ? 'black' : 'green',
33+
};
34+
});
35+
```
36+
37+
#### setComponentForcedTheme
38+
Same as `setComponentTheme`, but can't be overridden by props passed to the component.
39+
40+
Example
41+
42+
```js
43+
ThemeManager.setComponentForcedTheme('Card', (props, context) => {
44+
return {
45+
containerStyle: [styles.defaultContainerStyle, props.containerStyle]
46+
};
47+
});
48+
```
88.2 KB
Loading

0 commit comments

Comments
 (0)