A module that contains functions for comparing Screen Metrics against Screen Buckets so you can change your app's functionality or presentation based on how big the user's screen is.
This module also contains optional pre-built Buckets.
Depending on the situation you need, you can either check via:
All methods use the same Bucket data type, but doing anything with data in Elm is slower because it relies on JavaScript. So when doing presentation-related things with elm-css, always use the media queries wherever possible.
Converts a list of buckets and a list of elm-css Styles into a Style that become active depending on whether or not the screen size is in the given buckets.
It performs the equivalent of Css.Media.withMedia.
css [ Screen.withMedia [ handset, portable1, portable2 ]
[ height (px 32)
, overflow hidden
]
, Screen.withMedia [ portable3, wide ]
[ width (px 192)
, padding4 (px 64) (px 32) (px 32) (px 48)
]
]This doesn't use your model's Metrics because CSS media
queries don't get checked against the screen size within Elm,
but by the browsers directly.
These are the default buckets that come with this, but you can make your own with Screen.Bucket.
Details about what sizes these buckets are and what they're for can be found in the readme.
Because width tends to be more important than height in creating responsive interfaces, width buckets have more detail, with have two different parallel levels of detail for convenience.
A bucket that covers all 'handset' buckets (handset1, handset2 and handset3).
A bucket that covers all 'portable' buckets (portable1, portable2 and portable3).
A bucket that covers all 'wide' buckets (wide1 and wide2).
The handset1 width bucket.
The handset2 width bucket.
The handset3 width bucket.
The portable1 width bucket.
The portable2 width bucket.
The portable3 width bucket.
The wide1 width bucket.
The wide2 width bucket.
The limited height bucket.
The medium height bucket.
The tall height bucket.
Checks to see if the screen size (represented by
Metrics) matches any buckets that you provide.Useful when you want to swap out functionality, layouts or interface elements based on screen size.