Skip to main content

check_touch_density

Function check_touch_density 

Source
pub fn check_touch_density(js_dir: impl AsRef<Path>)
Expand description

Fail the build if a JS copy of the touch-density query has drifted from Density::Touch.

Every .js file under js_dir, recursively, must state the crate’s own media condition in a const TOUCH_DENSITY = '...', at least one file must declare it, and no file may name a capability sniff.

The string is the crate’s and no app gets a say in it, which is why this check takes no policy argument. The generated geometry.css already keys its touch gap overrides on the same condition, so the gestures and the spacing agree by construction rather than by two people remembering.

Emits cargo:rerun-if-changed for every file it read.

§Panics

If js_dir cannot be read, if no declaration is found, or if any file disagrees with the crate. A build script has nowhere useful to return an error to, and a frontend that disagrees with its own stylesheet is worse than a failed build.