Skip to content

Commit eb7cfa9

Browse files
Add style modifiers for responsiveness (#137)
* Add style modifiers for responsiveness * Code review feedback
1 parent f74abc5 commit eb7cfa9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/Lumi/Styles/Responsive.purs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module Lumi.Styles.Responsive where
2+
3+
import Prelude
4+
5+
import Lumi.Components (PropsModifier)
6+
import Lumi.Styles (Style, css, nested, styleModifier)
7+
8+
-- | Create a style modifier that, only in a desktop-sized screen, applies the
9+
-- | styles accumulated in the modifier passed in as argument.
10+
-- |
11+
-- | NOTE: the value passed in as argument must be a props modifier that touches
12+
-- | no component-specific props, a property that currently defines style
13+
-- | modifiers.
14+
onDesktop :: forall props. PropsModifier () -> PropsModifier props
15+
onDesktop m =
16+
styleModifier \theme ->
17+
desktopQuery
18+
$ (m identity { className: "", css: mempty }).css
19+
$ theme
20+
21+
-- | Guard a style so that it's only applied in a desktop resolution.
22+
desktopQuery :: Style -> Style
23+
desktopQuery style =
24+
css
25+
{ "@media (min-width: 860px)": nested style
26+
}

0 commit comments

Comments
 (0)