UNPKG

2.46 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. Usage example
82```js
83 import { Icon } from '@startupjs/ui'
84 import { faCoffee } from '@fortawesome/free-solid-svg-icons'
85
86 export default observer(function Card ({
87 return pug`
88 Icon(icon=faCoffee size='l')
89 `
90 })
91```
92
93### TextInput
94Set cursor color of the input on android for the same view as web
95and ios in `%PROJECT%/android/app/src/res/values/styles.xml`.
96
97```xml
98 <resources>
99 <!-- ...other configs... -->
100 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
101 <item name="android:textColor">#000000</item>
102 <!-- sets cursor color -->
103 <item name="colorControlActivated">#2962FF</item>
104 </style>
105 <!-- ...other configs... -->
106 </resources>
107```
108
109## Usage
110```js
111import { Button } from '@startupjs/ui'
112```
113
114## Additional materials
115- [Material design](https://material.io/design/)
116
117## TODO
118
119- document `themed()` HOF and theming overall