|
1 | 1 | --- |
2 | 2 | id: apis/Style |
3 | 3 | title: Style |
4 | | -wip: true |
| 4 | +officialDoc: https://facebook.github.io/react-native/docs/style |
5 | 5 | --- |
6 | 6 |
|
7 | | -```reason |
8 | | -type size; |
9 | | -
|
10 | | -external pt: float => size = "%identity"; |
11 | | -
|
12 | | -let pct: float => size; |
13 | | -
|
14 | | -type margin = size; |
15 | | -
|
16 | | -[@bs.inline "auto"] |
17 | | -let auto: margin; |
18 | | -
|
19 | | -type offset; |
20 | | -[@bs.obj] external offset: (~height: float, ~width: float) => offset = ""; |
21 | | -
|
22 | | -type t; |
23 | | -
|
24 | | -[@bs.obj] |
25 | | -// Layout Props (https://facebook.github.io/react-native/docs/layout-props#props) |
26 | | -// View Style Props https://facebook.github.io/react-native/docs/view-style-props#props |
27 | | -external style: |
28 | | - ( |
29 | | - ~alignContent: [@bs.string] [ |
30 | | - | [@bs.as "flex-start"] `flexStart |
31 | | - | [@bs.as "flex-end"] `flexEnd |
32 | | - | `center |
33 | | - | `stretch |
34 | | - | [@bs.as "space-around"] `spaceAround |
35 | | - | [@bs.as "space-between"] `spaceBetween |
36 | | - ] |
37 | | - =?, |
38 | | - ~alignItems: [@bs.string] [ |
39 | | - | [@bs.as "flex-start"] `flexStart |
40 | | - | [@bs.as "flex-end"] `flexEnd |
41 | | - | `center |
42 | | - | `stretch |
43 | | - | `baseline |
44 | | - ] |
45 | | - =?, |
46 | | - ~alignSelf: [@bs.string] [ |
47 | | - | [@bs.as "flex-start"] `flexStart |
48 | | - | [@bs.as "flex-end"] `flexEnd |
49 | | - | `center |
50 | | - | `stretch |
51 | | - | `baseline |
52 | | - ] |
53 | | - =?, |
54 | | - ~aspectRatio: float=?, |
55 | | - ~backfaceVisibility: [@bs.string] [ | `visible | `hidden]=?, |
56 | | - ~backgroundColor: Color.t=?, |
57 | | - ~borderBottomColor: Color.t=?, |
58 | | - ~borderBottomEndRadius: float=?, |
59 | | - ~borderBottomLeftRadius: float=?, |
60 | | - ~borderBottomRightRadius: float=?, |
61 | | - ~borderBottomStartRadius: float=?, |
62 | | - ~borderBottomWidth: float=?, |
63 | | - ~borderColor: Color.t=?, |
64 | | - ~borderEndColor: Color.t=?, |
65 | | - ~borderEndWidth: float=?, |
66 | | - ~borderLeftColor: Color.t=?, |
67 | | - ~borderLeftWidth: float=?, |
68 | | - ~borderRadius: float=?, |
69 | | - ~borderRightColor: Color.t=?, |
70 | | - ~borderRightWidth: float=?, |
71 | | - ~borderStartColor: Color.t=?, |
72 | | - ~borderStartWidth: float=?, |
73 | | - ~borderStyle: [@bs.string] [ | `solid | `dotted | `dashed]=?, |
74 | | - ~borderTopColor: Color.t=?, |
75 | | - ~borderTopEndRadius: float=?, |
76 | | - ~borderTopLeftRadius: float=?, |
77 | | - ~borderTopRightRadius: float=?, |
78 | | - ~borderTopStartRadius: float=?, |
79 | | - ~borderTopWidth: float=?, |
80 | | - ~borderWidth: float=?, |
81 | | - ~bottom: size=?, |
82 | | - ~direction: [@bs.string] [ | [@bs.as "inherit"] `inherit_ | `ltr | `ltr]=?, |
83 | | - ~display: [@bs.string] [ | `none | `flex]=?, |
84 | | - ~elevation: float=?, |
85 | | - ~_end: float=?, |
86 | | - ~flex: float=?, |
87 | | - ~flexBasis: size=?, |
88 | | - ~flexDirection: [@bs.string] [ |
89 | | - | `row |
90 | | - | [@bs.as "row-reverse"] `rowReverse |
91 | | - | `column |
92 | | - | [@bs.as "column-reverse"] `columnReverse |
93 | | - ] |
94 | | - =?, |
95 | | - ~flexGrow: float=?, |
96 | | - ~flexShrink: float=?, |
97 | | - ~flexWrap: [@bs.string] [ | `wrap | `nowrap]=?, |
98 | | - ~height: size=?, |
99 | | - ~justifyContent: [@bs.string] [ |
100 | | - | [@bs.as "flex-start"] `flexStart |
101 | | - | [@bs.as "flex-end"] `flexEnd |
102 | | - | `center |
103 | | - | [@bs.as "space-around"] `spaceAround |
104 | | - | [@bs.as "space-between"] `spaceBetween |
105 | | - | [@bs.as "space-evenly"] `spaceEvenly |
106 | | - ] |
107 | | - =?, |
108 | | - ~left: size=?, |
109 | | - ~margin: size=?, |
110 | | - ~marginBottom: size=?, |
111 | | - ~marginEnd: size=?, |
112 | | - ~marginHorizontal: size=?, |
113 | | - ~marginLeft: size=?, |
114 | | - ~marginRight: size=?, |
115 | | - ~marginStart: size=?, |
116 | | - ~marginTop: size=?, |
117 | | - ~marginVertical: size=?, |
118 | | - ~maxHeight: size=?, |
119 | | - ~maxWidth: size=?, |
120 | | - ~minHeight: size=?, |
121 | | - ~minWidth: size=?, |
122 | | - ~opacity: float=?, |
123 | | - ~overflow: [@bs.string] [ | `visible | `hidden | `scroll]=?, |
124 | | - ~padding: size=?, |
125 | | - ~paddingBottom: size=?, |
126 | | - ~paddingEnd: size=?, |
127 | | - ~paddingHorizontal: size=?, |
128 | | - ~paddingLeft: size=?, |
129 | | - ~paddingRight: size=?, |
130 | | - ~paddingStart: size=?, |
131 | | - ~paddingTop: size=?, |
132 | | - ~paddingVertical: size=?, |
133 | | - ~position: [@bs.string] [ | `absolute | `relative]=?, |
134 | | - ~right: size=?, |
135 | | - ~start: size=?, |
136 | | - ~top: size=?, |
137 | | - ~width: size=?, |
138 | | - ~zIndex: int=?, |
139 | | - // Shadow Props (https://facebook.github.io/react-native/docs/shadow-props) |
140 | | - ~shadowColor: Color.t=?, |
141 | | - ~shadowOffset: offset=?, |
142 | | - ~shadowOpacity: float=?, |
143 | | - ~shadowRadius: float=?, |
144 | | - // Transform Props (https://facebook.github.io/react-native/docs/transforms#props) |
145 | | - ~transform: array(Transform.t)=?, // all other transform props are deprecated |
146 | | - // Text Style Props (https://facebook.github.io/react-native/docs/text-style-props) |
147 | | - ~color: Color.t=?, |
148 | | - ~fontFamily: string=?, |
149 | | - ~fontSize: float=?, |
150 | | - ~fontStyle: [@bs.string] [ | `normal | `italic]=?, |
151 | | - ~fontVariant: array(FontVariant.t)=?, |
152 | | - ~fontWeight: [@bs.string] [ |
153 | | - | `normal |
154 | | - | `bold |
155 | | - | [@bs.as "100"] `_100 |
156 | | - | [@bs.as "200"] `_200 |
157 | | - | [@bs.as "300"] `_300 |
158 | | - | [@bs.as "400"] `_400 |
159 | | - | [@bs.as "500"] `_500 |
160 | | - | [@bs.as "600"] `_600 |
161 | | - | [@bs.as "700"] `_700 |
162 | | - | [@bs.as "800"] `_800 |
163 | | - | [@bs.as "900"] `_900 |
164 | | - ] |
165 | | - =?, |
166 | | - ~includeFontPadding: bool=?, |
167 | | - ~letterSpacing: float=?, |
168 | | - ~lineHeight: float=?, |
169 | | - ~textAlign: [@bs.string] [ | `auto | `left | `right | `center | `justify]=?, |
170 | | - ~textAlignVertical: [@bs.string] [ | `auto | `top | `bottom | `center]=?, |
171 | | - ~textDecorationColor: Color.t=?, |
172 | | - ~textDecorationLine: [@bs.string] [ |
173 | | - | `none |
174 | | - | `underline |
175 | | - | [@bs.as "line-through"] `lineThrough |
176 | | - | [@bs.as "underline line-through"] |
177 | | - `underlineLineThrough |
178 | | - ] |
179 | | - =?, |
180 | | - ~textDecorationStyle: [@bs.string] [ |
181 | | - | `solid |
182 | | - | `double |
183 | | - | `dotted |
184 | | - | `dashed |
185 | | - ] |
186 | | - =?, |
187 | | - ~textShadowColor: Color.t=?, |
188 | | - ~textShadowOffset: offset=?, |
189 | | - ~textShadowRadius: float=?, |
190 | | - ~textTransform: [@bs.string] [ |
191 | | - | `none |
192 | | - | `uppercase |
193 | | - | `lowercase |
194 | | - | `capitalize |
195 | | - ] |
196 | | - =?, |
197 | | - ~writingDirection: [@bs.string] [ | `auto | `ltr | `ltr]=?, |
198 | | - // Image Style Props (https://facebook.github.io/react-native/docs/image-style-props) |
199 | | - ~resizeMode: [@bs.string] [ |
200 | | - | `cover |
201 | | - | `contain |
202 | | - | `stretch |
203 | | - | `repeat |
204 | | - | `center |
205 | | - ] |
206 | | - =?, |
207 | | - ~overlayColor: Color.t=?, |
208 | | - ~tintColor: Color.t=?, |
209 | | - unit |
210 | | - ) => |
211 | | - t = |
212 | | - ""; |
213 | | -
|
214 | | -/* |
215 | | - <View style=array([| |
216 | | - styles##thing, |
217 | | - styles##whatever, |
218 | | - |])> |
219 | | - */ |
220 | | -external array: array(t) => t = "%identity"; |
221 | | -
|
222 | | -/* |
223 | | - <View style=arrayOption([| |
224 | | - Some(styles##thing), |
225 | | - Some(styles##whatever), |
226 | | - optionalStyle, |
227 | | - cond ? Some({something:"dynamic"}) : None |
228 | | - |])> |
229 | | - */ |
230 | | -external arrayOption: array(option(t)) => t = "%identity"; |
231 | | -
|
232 | | -/* list works too since RN accept recursive array of styles (list are just recursive arrays)*/ |
233 | | -/* |
234 | | - <View style=list([ |
235 | | - styles##thing, |
236 | | - styles##whatever, |
237 | | - ])> |
238 | | - */ |
239 | | -external list: list(t) => t = "%identity"; |
240 | | -
|
241 | | -/* |
242 | | - <View style=listOption([ |
243 | | - Some(styles##thing), |
244 | | - Some(styles##whatever), |
245 | | - optionalStyle, |
246 | | - cond ? Some({something:"dynamic"}) : None |
247 | | - ])> |
248 | | - */ |
249 | | -external listOption: list(option(t)) => t = "%identity"; |
250 | | -
|
251 | | -``` |
| 7 | +@todo |
0 commit comments