Skip to main content

check_breakpoints

Function check_breakpoints 

Source
pub fn check_breakpoints(frontend: impl AsRef<Path>, tuning_widths: &[u16])
Expand description

Fail the build if a hand-written breakpoint has drifted from SizeClass.

Every pixel width named by a media query under frontend/css or frontend/js, recursively, must be a SizeClass boundary or one of tuning_widths.

Without this, moving SizeClass::Medium::min_px regenerates the emitted stylesheets and silently leaves every hand-written query behind, and what you get is not an error but a stylesheet that disagrees with itself at the old boundary.

tuning_widths is the one thing an app gets a say in, which is why this takes a parameter where check_touch_density does not. A shell boundary is a SizeClass edge and belongs to makeover-geometry; a tuning width is a point inside a shell where something reflows without the shell changing – a dashboard dropping from three columns to two, a pane’s width cap ending. Nothing switches shells at one, so it should not move when a size class does. Pass &[] if the app has none, and treat every addition as owing a note saying what it tunes: the list is where a genuine boundary goes to hide from this check.

The generated stylesheets are scanned too, and pass by construction: they ask makeover-geometry for the number rather than stating it. Scanning them costs nothing and means a consumer never has to name which files are hand-written.

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

§Panics

If frontend/css or frontend/js cannot be read, or if any width is neither a size-class boundary nor a declared tuning width. A build script has nowhere useful to return an error to.