1 | # startupjs ui
|
2 | > UI components for react-native
|
3 |
|
4 | ## Installation
|
5 |
|
6 | ```sh
|
7 | yarn add @startupjs/ui
|
8 | ```
|
9 |
|
10 | ## Configuration
|
11 | 1. Add to your `startupjs.config.js` config file `ui` configuration (pallete, colors, variables and etc).
|
12 |
|
13 | ```js
|
14 | const getConfig = require('@startupjs/ui/config')
|
15 | const { u } = require('@startupjs/ui/config/helpers')
|
16 |
|
17 | module.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 |
|
37 | 2. Add to your root style file `styles/index.styl`.
|
38 | ```css
|
39 | @require '../node_modules/@startupjs/ui/styles/index.styl'
|
40 | ```
|
41 |
|
42 | 3. 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 |
|
51 | 4. Install and configure additional modules below:
|
52 |
|
53 | ### Collapse
|
54 |
|
55 | 1. Install library `react-native-collapsible`
|
56 | ```
|
57 | yarn add react-native-collapsible
|
58 | ```
|
59 |
|
60 | 2. 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 |
|
71 | 1. Install library `react-native-svg`
|
72 | ```
|
73 | yarn add react-native-svg
|
74 | ```
|
75 |
|
76 | 2. Link native code
|
77 | ```
|
78 | cd ios && pod install
|
79 | ```
|
80 |
|
81 | 3. Add `sourceExts` to `metro.config.js`
|
82 | ```js
|
83 | config.resolver.sourceExts = ['ts', 'tsx']
|
84 | ```
|
85 |
|
86 | 4. 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 |
|
100 | 1. Install library `react-native-status-bar-height`
|
101 | ```
|
102 | yarn add react-native-status-bar-height
|
103 | ```
|
104 |
|
105 | 2. 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
|
115 | Set cursor color of the input on android for the same view as web
|
116 | and 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
|
132 | import { 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
|