improve small elements rendering, bump to 0.4.2

This commit is contained in:
olcxja 2026-10-05 17:37:23 +02:00
commit cb0b071a38
3 changed files with 22 additions and 24 deletions

View file

@ -1,5 +1,17 @@
'use strict'
// The CSS scales the root font size with the window width (max(15px, 100vw/90)),
// which is fractional at almost every width - every rem value in the UI then
// lands on a fractional pixel and text/border rounding drifts a pixel up or
// down while resizing (badges were the most visible case). Snap it to whole
// pixels so the whole layout steps in 1px root increments instead.
function snapRootFontSize() {
const px = Math.max(15, Math.round(window.innerWidth / 90))
document.documentElement.style.fontSize = px + 'px'
}
snapRootFontSize()
window.addEventListener('resize', snapRootFontSize, { passive: true })
const qs = s => document.querySelector(s)
const qsa = s => [...document.querySelectorAll(s)]