Skip to content

Commit 2571f4a

Browse files
Add 'onMobile' combinator (#205)
1 parent 918c8e5 commit 2571f4a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Lumi/Styles/Responsive.purs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,23 @@ desktopQuery style =
2323
css
2424
{ "@media (min-width: 860px)": nested style
2525
}
26+
27+
-- | Create a style modifier that, only in a mobile-sized screen, applies the
28+
-- | styles accumulated in the modifier passed in as argument.
29+
-- |
30+
-- | NOTE: the value passed in as argument must be a props modifier that touches
31+
-- | no component-specific props, a property that currently defines style
32+
-- | modifiers.
33+
onMobile :: StyleModifier -> StyleModifier
34+
onMobile m =
35+
style \theme ->
36+
mobileQuery
37+
$ toCSS m
38+
$ theme
39+
40+
-- | Guard a style so that it's only applied in a mobile screen resolution.
41+
mobileQuery :: Style -> Style
42+
mobileQuery style =
43+
css
44+
{ "@media (max-width: 859px)": nested style
45+
}

0 commit comments

Comments
 (0)