Last active
June 7, 2018 13:33
-
-
Save geraldodev/eb18ea44e7435ee78c470dc30c7124da to your computer and use it in GitHub Desktop.
Attempt to type https://github.com/mui-org/material-ui/blob/3e4854b39b17511d9b312071ca93061eeb503f5d/packages/material-ui/src/styles/createBreakpoints.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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