Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/example/test.re b/example/test.re
- index b657ce1..b6fa6c8 100644
- --- a/example/test.re
- +++ b/example/test.re
- @@ -54,17 +54,20 @@ let rowLayout = Css.[display(flexBox), flexDirection(row), flexWrap(wrap)];
- let mergedStyles = {
- open Css;
- - let buttonStyles = [
- - padding(px(5)),
- - media("(min-width: 768px)", [padding(px(10))]),
- - ];
- + let paddingStyle = style([padding(px(5))]);
- + let fontStyle = style([fontSize(px(14))]);
- +
- + let buttonStyles = [media("(min-width: 768px)", [padding(px(10))])];
- let typographyStyles = [
- - fontSize(px(14)),
- media("(min-width: 768px)", [fontSize(px(16))]),
- ];
- - style(merge([buttonStyles, typographyStyles]));
- + mergeStyles([
- + paddingStyle,
- + fontStyle,
- + styleList([buttonStyles, typographyStyles]),
- + ]);
- };
- let section =
- @@ -1146,6 +1149,7 @@ let tests =
- <Section name="insertRule, the ultimate escape hatch">
- <div className="raw-css" />
- </Section>
- - <Section name="merging styles"> <button className=mergedStyles >
- - {text("Merged")} </button> </Section>
- - </div>;
- + <Section name="merging styles">
- + <button className=mergedStyles> {text("Merged")} </button>
- + </Section>
- + </div>;
- \ No newline at end of file
- diff --git a/src/Css.re b/src/Css.re
- index b8a40f6..c47a45b 100644
- --- a/src/Css.re
- +++ b/src/Css.re
- @@ -3,14 +3,15 @@ include Css_Colors;
- module Emotion = {
- type css = string;
- [@bs.module "emotion"] external _make: Js.Json.t => css = "css";
- + [@bs.module "emotion"] external _makeArray: array(Js.Json.t) => css = "css";
- [@bs.module "emotion"] external injectGlobal: Js.Json.t => unit = "";
- [@bs.module "emotion"]
- external rawInjectGlobal: string => unit = "injectGlobal";
- [@bs.module "emotion"]
- external makeKeyFrames: Js.Dict.t(Js.Json.t) => string = "keyframes";
- - [@bs.module "emotion"] [@bs.splice]
- - external merge: array(css) => css = "cx";
- - let merge: list(css) => css = classes => classes->Array.of_list->merge;
- + [@bs.module "emotion"] external cx: array(css) => css = "cx";
- + let merge: list(css) => css = classes => classes->Array.of_list->cx;
- +
- let rec makeDict = ruleset => {
- let toJs = rule =>
- switch (rule) {
- @@ -59,6 +60,9 @@ module Emotion = {
- };
- let make = rules => rules |> makeDict |> _make;
- +
- + let makeList = rulelist =>
- + rulelist |> List.map(makeDict) |> Array.of_list |> _makeArray;
- };
- let join = (separator, strings) => {
- @@ -321,6 +325,8 @@ type selector = [ | `selector(string, list(rule))];
- let empty = [];
- let merge = List.concat;
- +let mergeStyles = Emotion.merge;
- +
- let global = (selector, rules: list(rule)) =>
- Emotion.injectGlobal(
- [(selector, Emotion.makeDict(rules))]
- @@ -340,6 +346,7 @@ let keyframes = frames => {
- };
- let style = rules => rules |> Emotion.make;
- +let styleList = Emotion.makeList;
- let d = (property, value) => `declaration((property, value));
- diff --git a/src/Css.rei b/src/Css.rei
- index 252bc46..a92b74d 100644
- --- a/src/Css.rei
- +++ b/src/Css.rei
- @@ -8,7 +8,9 @@ type rule = [
- let empty: list(rule);
- let merge: list(list(rule)) => list(rule);
- +let mergeStyles: list(string) => string;
- let style: list(rule) => string;
- +let styleList: list(list(rule)) => string;
- let global: (string, list(rule)) => unit;
- let insertRule: string => unit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement