Recette design des adresses : barre de l'aide collée, boutons sur une ligne, position en paysage
Barre haute de l'aide en position sticky ; question ou terme ouvert par son adresse arrêté 12 px sous elle ; surlignage du terme effacé après 2 s. Boutons en white-space: nowrap ; actions de la position empilées (Jouer, Copier, Retour). En paysage, plateau à gauche sur toute la hauteur avec la géométrie du jeu (videau entier, sans menu ni annuler), colonne de 288 px à droite. Test navigateur : aucun bouton sur deux lignes, barre de l'aide en vue, actions visibles sans défiler, videau entier. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d1db2b33c8
commit
2b8fa1a0b0
@@ -300,10 +300,49 @@ async function checkStable(when) {
|
||||
stableChecks++;
|
||||
}
|
||||
|
||||
/** Les boutons visibles d'une page dont le texte passe à la ligne : un
|
||||
* bouton tient sur une ligne et fait 48 px de haut (charte). Un bouton plus
|
||||
* haut que 48 px n'est refusé que si son texte occupe plusieurs lignes ;
|
||||
* un texte coupé par le bord (white-space: nowrap) est refusé aussi. */
|
||||
async function wrappedButtons(target) {
|
||||
return target.evaluate(() => {
|
||||
const wrapped = [];
|
||||
for (const el of document.querySelectorAll("button, a.button")) {
|
||||
const r = el.getBoundingClientRect();
|
||||
if (el.closest("[hidden]") || r.width === 0 || r.height === 0) {
|
||||
continue;
|
||||
}
|
||||
const name = el.id ? `#${el.id}` : el.textContent.trim();
|
||||
const tops = new Set();
|
||||
const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);
|
||||
for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {
|
||||
if (node.textContent.trim() === "") {
|
||||
continue;
|
||||
}
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(node);
|
||||
for (const line of range.getClientRects()) {
|
||||
if (line.width > 0 && ![...tops].some((top) => Math.abs(top - line.top) < 4)) {
|
||||
tops.add(line.top);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (r.height > 48.5 && tops.size > 1) {
|
||||
wrapped.push(`${name} sur ${tops.size} lignes (${Math.round(r.height)} px)`);
|
||||
} else if (el.scrollWidth > el.clientWidth + 1) {
|
||||
wrapped.push(`${name} coupé (${el.scrollWidth} px pour ${el.clientWidth})`);
|
||||
}
|
||||
}
|
||||
return wrapped;
|
||||
});
|
||||
}
|
||||
|
||||
/** Les critères de la recette vérifiables sur la vue courante. Renvoie des
|
||||
* mesures pour le compte rendu. */
|
||||
async function checkView(width, height, when) {
|
||||
const where = `${width}x${height} (${when})`;
|
||||
const wrapped = await wrappedButtons(page);
|
||||
check(wrapped.length === 0, `${where} : boutons sur plusieurs lignes : ${wrapped.join(", ")}`);
|
||||
const seen = await page.evaluate(() => {
|
||||
const visible = (el) => {
|
||||
if (el.closest("[hidden]")) {
|
||||
@@ -762,6 +801,65 @@ async function checkAddresses() {
|
||||
await expectScreen(tab, `capture ${name}`, expected);
|
||||
await sleep(300);
|
||||
await tab.screenshot({ path: `${dir}/${browserName}-${name}-${width}x${height}.png` });
|
||||
const where = `${name} ${width}x${height}`;
|
||||
const wrapped = await wrappedButtons(tab);
|
||||
check(wrapped.length === 0, `${where} : boutons sur plusieurs lignes : ${wrapped.join(", ")}`);
|
||||
if (name === "question" || name === "terme") {
|
||||
// La barre haute de l'aide reste en vue, et ce qu'on a
|
||||
// ouvert s'arrête juste sous elle.
|
||||
const seen = await tab.evaluate(() => {
|
||||
const bar = document.getElementById("help-bar").getBoundingClientRect();
|
||||
const target = document.querySelector(
|
||||
"#help-play .question.open, #help-glossary dt.current",
|
||||
).getBoundingClientRect();
|
||||
return { scrolled: window.scrollY, barTop: bar.top, barBottom: bar.bottom, top: target.top };
|
||||
});
|
||||
check(seen.scrolled > 0 && Math.abs(seen.barTop) <= 1,
|
||||
`${where} : barre de l'aide hors de la vue (${JSON.stringify(seen)})`);
|
||||
check(Math.abs(seen.top - (seen.barBottom + 12)) <= 2,
|
||||
`${where} : élément à ${seen.top} px, barre jusqu'à ${seen.barBottom} px`);
|
||||
}
|
||||
if (name === "position") {
|
||||
// Les trois actions, dans l'ordre, visibles sans défiler.
|
||||
const seen = await tab.evaluate(() => ({
|
||||
scrolled: window.scrollY,
|
||||
order: [...document.querySelectorAll(".position-actions > *")].map((el) => el.id),
|
||||
boxes: ["position-play", "position-copy", "position-back"].map((id) => {
|
||||
const r = document.getElementById(id).getBoundingClientRect();
|
||||
return [r.left, r.top, r.right, r.bottom];
|
||||
}),
|
||||
board: (() => {
|
||||
const r = document.getElementById("position-board").getBoundingClientRect();
|
||||
return [r.left, r.top, r.width, r.height];
|
||||
})(),
|
||||
cube: (() => {
|
||||
const r = document.querySelector("#position-board .cube-face")?.getBoundingClientRect();
|
||||
return r === undefined ? null : [r.left, r.top, r.right, r.bottom];
|
||||
})(),
|
||||
controls: document.querySelectorAll("#position-board [data-action]").length,
|
||||
}));
|
||||
check(seen.order.join() === "position-play,position-copy,position-back",
|
||||
`${where} : actions dans l'ordre ${seen.order}`);
|
||||
const inView = seen.boxes.every(([l, t, r, b]) => l >= 0 && t >= 0 && r <= width && b <= height);
|
||||
if (width > height) {
|
||||
check(seen.scrolled === 0 && inView,
|
||||
`${where} : actions hors de la vue sans défiler : ${JSON.stringify(seen.boxes)}`);
|
||||
check(seen.board[0] === 0 && seen.board[1] === 0 && Math.abs(seen.board[3] - height) <= 1,
|
||||
`${where} : plateau pas sur toute la hauteur à gauche : ${seen.board}`);
|
||||
// Le videau, dans la colonne gauche du cadre, entier à
|
||||
// l'écran ; ni menu ni annuler : la position ne se joue pas.
|
||||
const [cl, ct, cr, cb] = seen.cube ?? [-1, -1, -1, -1];
|
||||
check(seen.cube !== null && cl >= 0 && ct >= 0 && cr <= seen.board[2] && cb <= height,
|
||||
`${where} : videau coupé : ${JSON.stringify(seen.cube)}`);
|
||||
check(seen.controls === 0, `${where} : ${seen.controls} commandes sur le plateau`);
|
||||
} else {
|
||||
// Empilées sur toute la largeur.
|
||||
const [first] = seen.boxes;
|
||||
check(seen.boxes.every(([l, , r], i) => Math.abs(l - first[0]) <= 1 &&
|
||||
Math.abs(r - first[2]) <= 1 && (i === 0 || seen.boxes[i - 1][3] <= seen.boxes[i][1])),
|
||||
`${where} : actions pas empilées : ${JSON.stringify(seen.boxes)}`);
|
||||
}
|
||||
}
|
||||
await tab.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user