@@ -54,18 +54,6 @@ external style_to_dict : t => Js.Dict.t(Js.Json.t) = "%identity";
5454
5555external array_to_style : array (t ) => t = "% identity " ;
5656
57- type style =
58- | ArrayStyle (string , array (Js . Json . t ))
59- | BooleanStyle (string , bool )
60- | StringStyle (string , string )
61- | IntStyle (string , int )
62- | FloatStyle (string , float )
63- | ObjectStyle (string , Js . Dict . t (Js . Json . t ))
64- | AnimatedStyle (
65- string ,
66- [ | ` value (AnimatedRe . Value . t ) | ` interpolation (AnimatedRe . Interpolation . t )]
67- );
68-
6957let combine = (a, b) => {
7058 let entries =
7159 Array . append(
@@ -77,49 +65,23 @@ let combine = (a, b) => {
7765
7866let concat = (styles) => array_to_style(Array . of_list(styles));
7967
80- let arrayStyle = (key, value) => ArrayStyle (key, value);
81-
82- let booleanStyle = (key, value) => BooleanStyle (key, value);
83-
84- let stringStyle = (key, value) => StringStyle (key, value);
85-
86- let intStyle = (key, value) => IntStyle (key, value);
87-
88- let floatStyle = (key, value) => FloatStyle (key, value);
89-
90- let pctStyle = (key, value) => StringStyle (key, string_of_float(value) ++ "% " );
91-
92- let objectStyle = (key, value) => ObjectStyle (key, value);
68+ let floatStyle = (key, value) => (key, Encode . float(value));
9369
94- let animatedStyle = (key, value) => AnimatedStyle (key, ` value (value));
70+ let stringStyle = (key, value) => (key, Encode . string (value));
9571
96- let interpolatedStyle = (key, value) => AnimatedStyle (key, ` interpolation (value));
72+ let objectStyle = (key, value) => (key, Encode . object_ (value));
9773
98- let encodeStyle =
99- fun
100- | ArrayStyle (key , value ) => (key, Encode . array(value))
101- | BooleanStyle (key , value ) => (key, Encode . boolean(Js . Boolean . to_js_boolean(value)))
102- | IntStyle (key , value ) => (key, Encode . int(value))
103- | FloatStyle (key , value ) => (key, Encode . float(value))
104- | StringStyle (key , value ) => (key, Encode . string(value))
105- | ObjectStyle (key , value ) => (key, Encode . object_(value))
106- | AnimatedStyle (key , value ) => (
107- key,
108- switch value {
109- | ` value (x ) => Encode . animatedValue(x)
110- | ` interpolation (x ) => Encode . interpolatedValue(x)
111- }
112- );
74+ let arrayStyle = (key, value) => (key, Encode . array(value));
11375
114- let style = (sarr) => sarr |> List . map(encodeStyle) |> UtilsRN . dictFromList |> to_style;
76+ let style = (sarr) => sarr |> UtilsRN . dictFromList |> to_style;
11577
11678
11779/** *
11880 * Layout Props
11981 */
120- let alignContent = (v) =>
121- stringStyle(
122- "alignContent" ,
82+ let alignContent = (v) => (
83+ "alignContent" ,
84+ Encode . string(
12385 switch v {
12486 | ` FlexStart => "flex-start"
12587 | ` FlexEnd => "flex-end"
@@ -128,7 +90,8 @@ let alignContent = (v) =>
12890 | ` SpaceAround => "space-around"
12991 | ` SpaceBetween => "space-between"
13092 }
131- );
93+ )
94+ );
13295
13396let alignItems = (v) =>
13497 stringStyle(
@@ -166,7 +129,6 @@ let borderTopWidth = floatStyle("borderTopWidth");
166129
167130let borderWidth = floatStyle("borderWidth" );
168131
169-
170132let display = (v) =>
171133 stringStyle(
172134 "display" ,
@@ -284,7 +246,7 @@ let height = (value) => ("height", encode_px_pct_animated_interpolated(value));
284246
285247let width = (value) => ("width" , encode_px_pct_animated_interpolated(value));
286248
287- let zIndex = intStyle( "zIndex" );
249+ let zIndex = (value) => ( "zIndex" , Encode . int(value) );
288250
289251let direction = (v) =>
290252 stringStyle(
@@ -303,7 +265,10 @@ let direction = (v) =>
303265let shadowColor = stringStyle("shadowColor" );
304266
305267let shadowOffset = (~height, ~width) =>
306- UtilsRN . dictFromArray([| ("height" , Encode . float(height)), ("width" , Encode . float(width))|] )
268+ UtilsRN . dictFromArray([|
269+ ("height" , Encode . float(height)),
270+ ("width" , Encode . float(width))
271+ |] )
307272 |> objectStyle("shadowOffset" );
308273
309274let shadowOpacity = floatStyle("shadowOpacity" );
@@ -565,7 +530,10 @@ let textShadowOffset = (~height, ~width) =>
565530
566531let textShadowRadius = floatStyle("textShadowRadius" );
567532
568- let includeFontPadding = booleanStyle("includeFontPadding" );
533+ let includeFontPadding = (value) => (
534+ "includeFontPadding" ,
535+ Encode . boolean(Js . Boolean . to_js_boolean(value))
536+ );
569537
570538let textAlignVertical = (v) =>
571539 stringStyle(
0 commit comments