Created
July 25, 2024 11:00
-
-
Save davesnx/31e22eeb6d890208470cbdd3f96a481b to your computer and use it in GitHub Desktop.
Revisions
-
davesnx created this gist
Jul 25, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ /* This type defines a value that 'depends' on the screen size, and changes based on `window.matchMedia` */ type dependant('value) = { default: 'value, mobile: option('value), /* 800px */ desktop: option('value), /* 1200px */ huge: option('value) /* 1900px */ }; type t('value) = | Fixed('value) | ByScreenSize(dependant('value)); module OnMobileOnly = { let className = [%cx {| display: none; @media screen and (min-width: 300px) { display: block; } |} ]; [@react.component] let make = (~children) => { <span className> children </span>; }; }; /* <OnMobileOnly> <div /> </OnMobileOnly> <MediaQuery onMobile={_ => <div />} onDesktop={_ => <div />} /> */