Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions reason-react-native/src/apis/Platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let styles =
Style.{
"wrapper":
style(
~width=Size.pct(Platform.os == Platform.ios ? 100. : 200.),
~width=pct(Platform.os == Platform.ios ? 100. : 200.),
(),
),
},
Expand Down Expand Up @@ -62,7 +62,7 @@ let styles =
| _ => 150.
}
)
->Size.pct,
->pct,
(),
),
},
Expand Down
10 changes: 9 additions & 1 deletion reason-react-native/src/apis/Style.bs.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
'use strict';


function pct(num) {
return num.toString() + "%";
}

exports.pct = pct;
/* No side effect */
132 changes: 50 additions & 82 deletions reason-react-native/src/apis/Style.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,16 @@ wip: true
---

```reason
let pct = num => num->Js.Float.toString ++ "%";
type size;

module Margin = {
type t;
external pt: float => size = "%identity";

external pt: float => t = "%identity";
let pct: float => t = pct->Obj.magic;
let auto: t = "auto"->Obj.magic;
};
let pct: float => size;

module Size = {
type t;
type margin = size;

external pt: float => t = "%identity";
let pct: float => t = pct->Obj.magic;
};

type color;
external color: string => color = "%identity";

module Transform = {
type angle;

let deg: float => angle =
num => (num->Js.Float.toString ++ "deg")->Obj.magic;
let rad: float => angle =
num => (num->Js.Float.toString ++ "rad")->Obj.magic;

type t;
[@bs.obj] external perspective: (~perspective: float) => t = "";
[@bs.obj] external rotate: (~rotate: angle) => t = "";
[@bs.obj] external rotateX: (~rotateX: angle) => t = "";
[@bs.obj] external rotateY: (~rotateY: angle) => t = "";
[@bs.obj] external rotateZ: (~rotateZ: angle) => t = "";
[@bs.obj] external scale: (~scale: float) => t = "";
[@bs.obj] external scaleX: (~scaleX: float) => t = "";
[@bs.obj] external scaleY: (~scaleY: float) => t = "";
[@bs.obj] external translateX: (~translateX: float) => t = "";
[@bs.obj] external translateY: (~translateY: float) => t = "";
[@bs.obj] external skewX: (~skewX: angle) => t = "";
[@bs.obj] external skewY: (~skewY: angle) => t = "";
};
[@bs.inline "auto"]
let auto: margin;

type offset;
[@bs.obj] external offset: (~height: float, ~width: float) => offset = "";
Expand Down Expand Up @@ -85,38 +53,38 @@ external style:
=?,
~aspectRatio: float=?,
~backfaceVisibility: [@bs.string] [ | `visible | `hidden]=?,
~backgroundColor: color=?,
~borderBottomColor: color=?,
~backgroundColor: Color.t=?,
~borderBottomColor: Color.t=?,
~borderBottomEndRadius: float=?,
~borderBottomLeftRadius: float=?,
~borderBottomRightRadius: float=?,
~borderBottomStartRadius: float=?,
~borderBottomWidth: float=?,
~borderColor: color=?,
~borderEndColor: color=?,
~borderColor: Color.t=?,
~borderEndColor: Color.t=?,
~borderEndWidth: float=?,
~borderLeftColor: color=?,
~borderLeftColor: Color.t=?,
~borderLeftWidth: float=?,
~borderRadius: float=?,
~borderRightColor: color=?,
~borderRightColor: Color.t=?,
~borderRightWidth: float=?,
~borderStartColor: color=?,
~borderStartColor: Color.t=?,
~borderStartWidth: float=?,
~borderStyle: [@bs.string] [ | `solid | `dotted | `dashed]=?,
~borderTopColor: color=?,
~borderTopColor: Color.t=?,
~borderTopEndRadius: float=?,
~borderTopLeftRadius: float=?,
~borderTopRightRadius: float=?,
~borderTopStartRadius: float=?,
~borderTopWidth: float=?,
~borderWidth: float=?,
~bottom: Size.t=?,
~bottom: size=?,
~direction: [@bs.string] [ | [@bs.as "inherit"] `inherit_ | `ltr | `ltr]=?,
~display: [@bs.string] [ | `none | `flex]=?,
~elevation: float=?,
~_end: float=?,
~flex: float=?,
~flexBasis: Margin.t=?,
~flexBasis: size=?,
~flexDirection: [@bs.string] [
| `row
| [@bs.as "row-reverse"] `rowReverse
Expand All @@ -127,7 +95,7 @@ external style:
~flexGrow: float=?,
~flexShrink: float=?,
~flexWrap: [@bs.string] [ | `wrap | `nowrap]=?,
~height: Size.t=?,
~height: size=?,
~justifyContent: [@bs.string] [
| [@bs.as "flex-start"] `flexStart
| [@bs.as "flex-end"] `flexEnd
Expand All @@ -137,46 +105,46 @@ external style:
| [@bs.as "space-evenly"] `spaceEvenly
]
=?,
~left: Size.t=?,
~margin: Margin.t=?,
~marginBottom: Margin.t=?,
~marginEnd: Margin.t=?,
~marginHorizontal: Margin.t=?,
~marginLeft: Margin.t=?,
~marginRight: Margin.t=?,
~marginStart: Margin.t=?,
~marginTop: Margin.t=?,
~marginVertical: Margin.t=?,
~maxHeight: Size.t=?,
~maxWidth: Size.t=?,
~minHeight: Size.t=?,
~minWidth: Size.t=?,
~left: size=?,
~margin: size=?,
~marginBottom: size=?,
~marginEnd: size=?,
~marginHorizontal: size=?,
~marginLeft: size=?,
~marginRight: size=?,
~marginStart: size=?,
~marginTop: size=?,
~marginVertical: size=?,
~maxHeight: size=?,
~maxWidth: size=?,
~minHeight: size=?,
~minWidth: size=?,
~opacity: float=?,
~overflow: [@bs.string] [ | `visible | `hidden | `scroll]=?,
~padding: Size.t=?,
~paddingBottom: Size.t=?,
~paddingEnd: Size.t=?,
~paddingHorizontal: Size.t=?,
~paddingLeft: Size.t=?,
~paddingRight: Size.t=?,
~paddingStart: Size.t=?,
~paddingTop: Size.t=?,
~paddingVertical: Size.t=?,
~padding: size=?,
~paddingBottom: size=?,
~paddingEnd: size=?,
~paddingHorizontal: size=?,
~paddingLeft: size=?,
~paddingRight: size=?,
~paddingStart: size=?,
~paddingTop: size=?,
~paddingVertical: size=?,
~position: [@bs.string] [ | `absolute | `relative]=?,
~right: Size.t=?,
~start: Size.t=?,
~top: Size.t=?,
~width: Size.t=?,
~right: size=?,
~start: size=?,
~top: size=?,
~width: size=?,
~zIndex: int=?,
// Shadow Props (https://facebook.github.io/react-native/docs/shadow-props)
~shadowColor: color=?,
~shadowColor: Color.t=?,
~shadowOffset: offset=?,
~shadowOpacity: float=?,
~shadowRadius: float=?,
// Transform Props (https://facebook.github.io/react-native/docs/transforms#props)
~transform: array(Transform.t)=?, // all other transform props are deprecated
// Text Style Props (https://facebook.github.io/react-native/docs/text-style-props)
~color: color=?,
~color: Color.t=?,
~fontFamily: string=?,
~fontSize: float=?,
~fontStyle: [@bs.string] [ | `normal | `italic]=?,
Expand All @@ -200,7 +168,7 @@ external style:
~lineHeight: float=?,
~textAlign: [@bs.string] [ | `auto | `left | `right | `center | `justify]=?,
~textAlignVertical: [@bs.string] [ | `auto | `top | `bottom | `center]=?,
~textDecorationColor: color=?,
~textDecorationColor: Color.t=?,
~textDecorationLine: [@bs.string] [
| `none
| `underline
Expand All @@ -216,7 +184,7 @@ external style:
| `dashed
]
=?,
~textShadowColor: color=?,
~textShadowColor: Color.t=?,
~textShadowOffset: offset=?,
~textShadowRadius: float=?,
~textTransform: [@bs.string] [
Expand All @@ -236,8 +204,8 @@ external style:
| `center
]
=?,
~overlayColor: color=?,
~tintColor: color=?,
~overlayColor: Color.t=?,
~tintColor: Color.t=?,
unit
) =>
t =
Expand Down
71 changes: 41 additions & 30 deletions reason-react-native/src/apis/Style.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
type size = string;

external pt: float => size = "%identity";

let pct = num => num->Js.Float.toString ++ "%";

type margin = size;

[@bs.inline]
let auto = "auto";

type offset;
[@bs.obj] external offset: (~height: float, ~width: float) => offset = "";

Expand Down Expand Up @@ -60,13 +71,13 @@ external style:
~borderTopStartRadius: float=?,
~borderTopWidth: float=?,
~borderWidth: float=?,
~bottom: Size.t=?,
~bottom: size=?,
~direction: [@bs.string] [ | [@bs.as "inherit"] `inherit_ | `ltr | `ltr]=?,
~display: [@bs.string] [ | `none | `flex]=?,
~elevation: float=?,
~_end: float=?,
~flex: float=?,
~flexBasis: Margin.t=?,
~flexBasis: margin=?,
~flexDirection: [@bs.string] [
| `row
| [@bs.as "row-reverse"] `rowReverse
Expand All @@ -77,7 +88,7 @@ external style:
~flexGrow: float=?,
~flexShrink: float=?,
~flexWrap: [@bs.string] [ | `wrap | `nowrap]=?,
~height: Size.t=?,
~height: size=?,
~justifyContent: [@bs.string] [
| [@bs.as "flex-start"] `flexStart
| [@bs.as "flex-end"] `flexEnd
Expand All @@ -87,36 +98,36 @@ external style:
| [@bs.as "space-evenly"] `spaceEvenly
]
=?,
~left: Size.t=?,
~margin: Margin.t=?,
~marginBottom: Margin.t=?,
~marginEnd: Margin.t=?,
~marginHorizontal: Margin.t=?,
~marginLeft: Margin.t=?,
~marginRight: Margin.t=?,
~marginStart: Margin.t=?,
~marginTop: Margin.t=?,
~marginVertical: Margin.t=?,
~maxHeight: Size.t=?,
~maxWidth: Size.t=?,
~minHeight: Size.t=?,
~minWidth: Size.t=?,
~left: size=?,
~margin: margin=?,
~marginBottom: margin=?,
~marginEnd: margin=?,
~marginHorizontal: margin=?,
~marginLeft: margin=?,
~marginRight: margin=?,
~marginStart: margin=?,
~marginTop: margin=?,
~marginVertical: margin=?,
~maxHeight: size=?,
~maxWidth: size=?,
~minHeight: size=?,
~minWidth: size=?,
~opacity: float=?,
~overflow: [@bs.string] [ | `visible | `hidden | `scroll]=?,
~padding: Size.t=?,
~paddingBottom: Size.t=?,
~paddingEnd: Size.t=?,
~paddingHorizontal: Size.t=?,
~paddingLeft: Size.t=?,
~paddingRight: Size.t=?,
~paddingStart: Size.t=?,
~paddingTop: Size.t=?,
~paddingVertical: Size.t=?,
~padding: size=?,
~paddingBottom: size=?,
~paddingEnd: size=?,
~paddingHorizontal: size=?,
~paddingLeft: size=?,
~paddingRight: size=?,
~paddingStart: size=?,
~paddingTop: size=?,
~paddingVertical: size=?,
~position: [@bs.string] [ | `absolute | `relative]=?,
~right: Size.t=?,
~start: Size.t=?,
~top: Size.t=?,
~width: Size.t=?,
~right: size=?,
~start: size=?,
~top: size=?,
~width: size=?,
~zIndex: int=?,
// Shadow Props (https://facebook.github.io/react-native/docs/shadow-props)
~shadowColor: Color.t=?,
Expand Down
Loading