Run ready tutorial programs with Enter and align planning controls
This commit is contained in:
parent
e953bb4d40
commit
2aa49cc614
3 changed files with 19 additions and 3 deletions
|
|
@ -957,9 +957,16 @@ export function mountConsole(root, host = null) {
|
|||
rerender();
|
||||
}
|
||||
const handlePlanningKey = event => {
|
||||
if (!["Backspace", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key) || event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return;
|
||||
if (!["Enter", "Backspace", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key) || event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return;
|
||||
if (event.target.closest?.("input, textarea, select, [contenteditable]:not([contenteditable=false]), dialog")) return;
|
||||
if (root.querySelector("dialog[open]")) return;
|
||||
if (event.key === "Enter") {
|
||||
const run = $("#basics-run");
|
||||
if (!run || !run.getClientRects().length) return;
|
||||
event.preventDefault();
|
||||
if (!run.disabled && !pending && !event.repeat) run.click();
|
||||
return;
|
||||
}
|
||||
const editable = editableTurns();
|
||||
if (!editable.length) return;
|
||||
event.preventDefault();
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ export function basicsView(view, locale, { started, picked, shipMarkup }) {
|
|||
const turn = r?.step === "damage" ? r.turn : Math.max(0, (r?.turn ?? 0) - 1);
|
||||
const playing = view.stage === "resolution";
|
||||
if (view.tutorial.nativeStep !== undefined) {
|
||||
const control = (id, glyph, description, disabled = false) => `<button id="${id}" class="primary icon-button" title="${description}" aria-label="${description}" ${disabled ? "disabled" : ""}>${pictogram(glyph)}</button>`;
|
||||
const control = (id, glyph, description, disabled = false) => `<button id="${id}" class="primary icon-button" ${id === "basics-run" ? 'aria-keyshortcuts="Enter"' : ""} title="${description}${id === "basics-run" ? " · ↵" : ""}" aria-label="${description}" ${disabled ? "disabled" : ""}>${pictogram(glyph)}</button>`;
|
||||
if (view.tutorial.nativeStep === 0) return "";
|
||||
if (playing) return "";
|
||||
return `<div class="planning-shortcuts" title="${t("Flèches : déplacement · ↑/↓ : changer de pont · Retour arrière : annuler", "Arrows: move · ↑/↓: change deck · Backspace: undo")}" aria-label="${t("Raccourcis : flèches pour se déplacer ; retour arrière pour annuler", "Shortcuts: arrow keys to move; Backspace to undo")}"><kbd>←</kbd><kbd>→</kbd><kbd>↑</kbd><kbd>↓</kbd><kbd>⌫</kbd></div><div class="practice-readiness" role="status" aria-label="${placed}/2 ${t("actions placées", "actions placed")}"><span>${pictogram("cards")} ${placed}/2</span><span class="ready-dots" aria-hidden="true">${[0,1].map(i => `<i class="${i < placed ? "filled" : ""}"></i>`).join("")}</span>${control("basics-run", "step", t("Exécuter le programme", "Run program"), placed !== 2)}</div><div class="practice-clock"><div><strong data-practice-time></strong><small>${t("Préparation", "Planning")}</small></div>${control("lesson-clock", view.tutorial.clockRunning ? "pause" : "clock", view.tutorial.clockRunning ? t("Pause", "Pause") : t("Lancer le chrono", "Start clock"))}</div>`;
|
||||
return `<div class="planning-shortcuts" title="${t("Flèches : déplacement · ↑/↓ : changer de pont · Retour arrière : annuler · Entrée : exécuter", "Arrows: move · ↑/↓: change deck · Backspace: undo · Enter: run")}" aria-label="${t("Raccourcis : flèches pour se déplacer ; retour arrière pour annuler ; entrée pour exécuter", "Shortcuts: arrow keys to move; Backspace to undo; Enter to run")}"><kbd>←</kbd><kbd>→</kbd><kbd>↑</kbd><kbd>↓</kbd><kbd>⌫</kbd><kbd>↵</kbd></div><div class="practice-readiness" role="status" aria-label="${placed}/2 ${t("actions placées", "actions placed")}"><span>${pictogram("cards")} ${placed}/2</span><span class="ready-dots" aria-hidden="true">${[0,1].map(i => `<i class="${i < placed ? "filled" : ""}"></i>`).join("")}</span>${control("basics-run", "step", t("Exécuter le programme", "Run program"), placed !== 2)}</div><div class="practice-clock"><div><strong data-practice-time></strong><small>${t("Préparation", "Planning")}</small></div>${control("lesson-clock", view.tutorial.clockRunning ? "pause" : "clock", view.tutorial.clockRunning ? t("Pause", "Pause") : t("Lancer le chrono", "Start clock"))}</div>`;
|
||||
}
|
||||
const intro = !started && !placed && !playing;
|
||||
const ready = placed === 2;
|
||||
|
|
|
|||
|
|
@ -2411,3 +2411,12 @@ input:not([type="checkbox"]):not([type="range"]) {
|
|||
|
||||
.planning-shortcuts { display: flex; gap: 6px; margin-top: 12px; color: var(--muted); }
|
||||
.planning-shortcuts kbd { min-width: 25px; text-align: center; padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px; font: inherit; font-size: 12px; }
|
||||
.native-tutorial.learning-basics #planning > #basics-guide {
|
||||
width: 100%;
|
||||
max-width: 280px;
|
||||
margin: 12px 0 0;
|
||||
}
|
||||
.native-tutorial.learning-basics #program { width: fit-content; max-width: 100%; }
|
||||
.native-tutorial .practice-readiness #basics-run { margin-left: 12px; }
|
||||
.native-tutorial .practice-clock { margin: 12px 0; padding: 12px; gap: 12px; }
|
||||
.native-tutorial .practice-clock strong { font-size: 1rem; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue