Skip to content

Commit 397d2bb

Browse files
committed
Add Style.empty, Style.combineOptional & Style.optional for convenience
1 parent a6dd169 commit 397d2bb

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎lib/js/src/style.js‎

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/style.re‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ let arrayStyle = (key, value) => (key, Encode.array(value));
9595

9696
let style = sarr => sarr |> Js.Dict.fromList |> to_style;
9797

98+
let emptyStyle = style([]);
99+
100+
let combineOptional = (s, so) =>
101+
so->Belt.Option.map(so => s->combine(so))->Belt.Option.getWithDefault(s);
102+
103+
let optional = s => s->Belt.Option.getWithDefault(emptyStyle);
104+
98105
/***
99106
* Layout Props
100107
*/

‎src/style.rei‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ external flatten: array(t) => t = "%identity";
2727
let combine: (t, t) => t;
2828
let concat: list(t) => t;
2929
let style: list(styleElement) => t;
30+
let emptyStyle: t;
31+
let combineOptional: (t, option(t)) => t;
32+
let optional: (option(t)) => t;
33+
3034
type alignContent =
3135
| FlexStart
3236
| FlexEnd

0 commit comments

Comments
 (0)