-
Notifications
You must be signed in to change notification settings - Fork 2
/
responsive.js
68 lines (60 loc) · 1.57 KB
/
responsive.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { createMedia } from "@artsy/fresnel";
// Must match breakpoints set in css/settings/_breakpoints.scss
const breakpoints = {
sm: 0,
md: 768,
lg: 1024,
xl: 1192,
xxl: 1440
};
const EDMedia = createMedia({ breakpoints });
const { MediaContextProvider, Media } = EDMedia;
const mediaStyle = EDMedia.createMediaStyle();
function Desktop({ children, className, includeBiggerScreens = true }) {
return (
<Media
{...(includeBiggerScreens && { greaterThanOrEqual: "md" })}
{...(!includeBiggerScreens && { at: "md" })}
className={className}
>
{children}
</Media>
);
}
function DesktopLarge({ children, className, includeBiggerScreens = true }) {
return (
<Media
{...(includeBiggerScreens && { greaterThanOrEqual: "lg" })}
{...(!includeBiggerScreens && { at: "lg" })}
className={className}
>
{children}
</Media>
);
}
function DesktopXLarge({ children, className, includeBiggerScreens = true }) {
return (
<Media
{...(includeBiggerScreens && { greaterThanOrEqual: "xl" })}
{...(!includeBiggerScreens && { at: "xl" })}
className={className}
>
{children}
</Media>
);
}
function DesktopXXLarge(props) {
return (
<Media greaterThanOrEqual="xxl" className={props.className}>
{props.children}
</Media>
);
}
function Mobile(props) {
return (
<Media lessThan="md" className={props.className}>
{props.children}
</Media>
);
}
export { breakpoints, Desktop, DesktopLarge, DesktopXLarge, DesktopXXLarge, Mobile, MediaContextProvider, mediaStyle };