def css.media.feature
gralha-css-style@0.1.0.1 · css.bend:301
import gralha-css-style@0.1.0.1/css.bend as Css
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
301def css.media.feature(scan: U.Scan, +w: F32, +h: F32) -> Bool:
302 U.Scan{k, v} = scan
303 +key = U.trim.both(k)
304 +value = css.lower(U.trim.both(v))
305 +x = U.unit(U.number(value), w)
306 U.choose(Bool, U.string.equal(key, "min-width"), F32.is_ge(w, x),
307 U.choose(Bool, U.string.equal(key, "max-width"), F32.is_le(w, x),
308 U.choose(Bool, U.string.equal(key, "width"), F32.is_eq(w, x),
309 U.choose(Bool, U.string.equal(key, "min-height"), F32.is_ge(h, x),
310 U.choose(Bool, U.string.equal(key, "max-height"), F32.is_le(h, x),
311 U.choose(Bool, U.string.equal(key, "height"), F32.is_eq(h, x),
312 U.string.equal(key, "orientation") && U.choose(Bool, U.string.equal(value, "portrait"), F32.is_ge(h, w), U.string.equal(value, "landscape") && F32.is_gt(w, h))))))))