UNPKG

2.94 kBMarkdownView Raw
1# startupjs ui
2> UI components for react-native
3
4## Installation
5
6```sh
7yarn add @startupjs/ui
8```
9
10## Configuration
111. Add to your `startupjs.config.js` config file `ui` configuration (pallete, colors, variables and etc).
12
13```js
14const getConfig = require('@startupjs/ui/config')
15const { u } = require('@startupjs/ui/config/helpers')
16
17module.exports = {
18 ui: getConfig({
19 // override defaults
20 blue: {
21 primary: '#4a76a8',
22 },
23 colors: {
24 dark: 'rgba(0, 0, 0, 0.5)'
25 },
26 MyComponent1: {
27 height: u(2)
28 },
29 MyComponent2: {
30 color: config.colors.primary,
31 padding: u(1)
32 }
33 })
34}
35```
36
372. Add to your root style file `styles/index.styl`.
38```css
39@require '../node_modules/@startupjs/ui/styles/index.styl'
40```
41
423. Add `@startupjs/ui` to `forceCompileModules` of your `webpack.web.config.js`:
43```js
44 const getConfig = require('startupjs/bundler').webpackWebConfig
45
46 module.exports = getConfig(undefined, {
47 forceCompileModules: ['@startupjs/ui']
48 })
49```
50
514. Install and configure additional modules below:
52
53### Collapse
54
551. Install library `react-native-collapsible`
56```
57 yarn add react-native-collapsible
58```
59
602. Add library to `forceCompileModules` of your `webpack.web.config.js`.
61```js
62 const getConfig = require('startupjs/bundler').webpackWebConfig
63
64 module.exports = getConfig(undefined, {
65 forceCompileModules: ['react-native-collapsible']
66 })
67```
68
69### Icon component
70
711. Install library `react-native-svg`
72```
73 yarn add react-native-svg
74```
75
762. Link native code
77```
78 cd ios && pod install
79```
80
813. Add `sourceExts` to `metro.config.js`
82```js
83 config.resolver.sourceExts = ['ts', 'tsx']
84```
85
864. Usage example
87```js
88 import { Icon } from '@startupjs/ui'
89 import { faCoffee } from '@fortawesome/free-solid-svg-icons'
90
91 export default observer(function Card ({
92 return pug`
93 Icon(icon=faCoffee size='l')
94 `
95 })
96```
97
98### Status bar
99
1001. Install library `react-native-status-bar-height`
101```
102 yarn add react-native-status-bar-height
103```
104
1052. Add library to `forceCompileModules` of your `webpack.web.config.js`.
106```js
107 const getConfig = require('startupjs/bundler').webpackWebConfig
108
109 module.exports = getConfig(undefined, {
110 forceCompileModules: ['react-native-status-bar-height']
111 })
112```
113
114### TextInput
115Set cursor color of the input on android for the same view as web
116and ios in `%PROJECT%/android/app/src/res/values/styles.xml`.
117
118```xml
119 <resources>
120 <!-- ...other configs... -->
121 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
122 <item name="android:textColor">#000000</item>
123 <!-- sets cursor color -->
124 <item name="colorControlActivated">#2962FF</item>
125 </style>
126 <!-- ...other configs... -->
127 </resources>
128```
129
130## Usage
131```js
132import { Button } from '@startupjs/ui'
133```
134
135## Additional materials
136- [Material design](https://material.io/design/)
137
138## TODO
139
140- document `themed()` HOF and theming overall