Calio/tests/browser/mobile-layout.check.js
Elijah b19de6f9ea
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 28s
Mobile UI redesign and size fixes
2026-10-20 20:16:25 -07:00

37 lines
2.8 KiB
JavaScript

// Run this expression with the browser tool's read-only evaluate API at phone sizes.
// Exercise Today, Settings and an open food editor; every returned check must pass.
(() => {
const checks = {};
const font = (element) => getComputedStyle(element).fontSize.split('px')[0] * 1;
const visible = (selector) => [...document.querySelectorAll(selector)].filter(e => e.getBoundingClientRect().width > 0);
const dialog = document.querySelector('dialog[open]');
checks.noHorizontalPageOverflow = document.documentElement.scrollWidth <= window.innerWidth + 1;
if (!dialog && visible('.dashboard-grid').length) {
checks.homeFitsViewport = document.documentElement.scrollHeight <= window.innerHeight + 1;
checks.macrosReadable = visible('.macro-label').every(e => font(e) >= 14);
const nav = document.querySelector('.bottom-nav').getBoundingClientRect();
checks.homeControlsAboveNavigation = visible('.mobile-journal-button').length > 0 && visible('.mobile-journal-button').every(e => e.getBoundingClientRect().bottom <= nav.top + 1);
checks.macrosAboveNavigation = visible('.macro-grid').every(e => e.getBoundingClientRect().bottom <= nav.top + 1);
const orb = document.querySelector('.orb').getBoundingClientRect();
checks.circleRemainsVisible = orb.width >= 100 && orb.height >= 100;
if (window.innerHeight > 500) {
const number = document.querySelector('.orb-number').getBoundingClientRect();
checks.circleAndReadoutDoNotOverlap = orb.bottom <= number.top + 1;
}
}
checks.navigationReadable = visible('.bottom-nav button span').every(e => font(e) >= 12);
checks.navigationTapTargets = visible('.bottom-nav button').every(e => e.getBoundingClientRect().height >= 44);
if (!dialog && visible('.settings-card .switch').length) {
checks.switchSize = visible('.switch').every(e => { const r=e.getBoundingClientRect(); return r.width >= 44 && r.height >= 28; });
checks.settingsLabelsReadable = visible('.toggle-label').every(e => font(e) >= 16);
}
if (dialog) {
checks.dialogFitsWidth = dialog.scrollWidth <= dialog.clientWidth + 1;
checks.nativeFieldsStayInColumns = visible('dialog input[type="date"], dialog input[type="time"]').every(e => e.getBoundingClientRect().right <= e.parentElement.getBoundingClientRect().right + 1);
checks.formLabelsReadable = visible('dialog label').every(e => font(e) >= 14);
checks.formControlsReadable = visible('dialog input:not([type="checkbox"]), dialog select').every(e => font(e) >= 16 && e.getBoundingClientRect().height >= 48);
}
const weightChart = visible('.weight-chart svg')[0];
if (weightChart) checks.weightChartTextNotShrunk = weightChart.getBoundingClientRect().width / (weightChart.getAttribute('viewBox').split(' ')[2] * 1) >= 0.9;
return {pass: Object.values(checks).every(Boolean), checks};
})()