Skip to content

Instantly share code, notes, and snippets.

@geraldodev
Last active June 7, 2018 13:33
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save geraldodev/eb18ea44e7435ee78c470dc30c7124da to your computer and use it in GitHub Desktop.
type breakpoint = [ | `lg | `md | `sm | `xl | `xs ];
type breakpointsObj = {
.
"keys": array(string),
"values": {
.
"lg": int,
"md": int,
"sm": int,
"xl": int,
"xs": int,
},
/* "unit": string, */
};
[@bs.module "material-ui/styles/createBreakpoints"]
external create : Js.t({..}) => breakpointsObj = "default";
let value = (bo: breakpointsObj, k: breakpoint) =>
switch (k) {
| `lg => bo##values##lg
| `md => bo##values##md
| `sm => bo##values##sm
| `xl => bo##values##xl
| `xs => bo##values##xs
};
let defaultBreakpoints = create(Js.Obj.empty());
let minWidth = (value, _unit) =>
"(min-width:" ++ string_of_int(value) ++ _unit ++ ")";
let maxWidth = (value, _unit) =>
"(max-width:" ++ string_of_int(value) ++ _unit ++ ")";
let up = (bo: breakpointsObj, k: breakpoint) => {
minWidth(value(bo, k), "px"); /* How to acess unit property ? bo##unit is invalid*/
};
let upDefault = up(defaultBreakpoints);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment