Écrans branchés : planning du jour, semaine, activités, poids, données, profil, analyses, propositions avec aperçu, gamification
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
077f2dc58d
commit
41d5e44daa
+36
-6
@@ -11,10 +11,12 @@ import { TRACKING_MODES, EFFORTS } from "../domain/vocabulary.js";
|
||||
import { resolveExercise, trackingFor } from "../domain/program.js";
|
||||
import { EFFORT_LABELS, TRACKING_LABELS } from "./labels.js";
|
||||
import { kg, parseAmount, restLabel } from "./format.js";
|
||||
import { doneCount, draftExercise, proposedReps, targetLabel, targetReps, usesLoad, usesTime } from "./session-draft.js";
|
||||
import { doneCount, draftExercise, markSet, proposedReps, targetLabel, targetReps, usesLoad, usesTime } from "./session-draft.js";
|
||||
import { progressionAdvice } from "../domain/progression.js";
|
||||
|
||||
/**
|
||||
* @typedef {object} ExerciseCardOptions
|
||||
* @property {import("./session-draft.js").Draft} draft
|
||||
* @property {import("./session-draft.js").DraftExercise} ex exercice du brouillon (modifié sur place)
|
||||
* @property {import("../domain/program.js").ProgramExercise} item
|
||||
* @property {string} sessionKey
|
||||
@@ -59,13 +61,17 @@ export function exerciseCard(o) {
|
||||
let openPanel = null;
|
||||
/** @type {HTMLButtonElement|null} */
|
||||
let chronoBtn = null;
|
||||
/** @type {HTMLInputElement|null} */
|
||||
let loadInput = null;
|
||||
|
||||
const paintSets = () => {
|
||||
setButtons.forEach((b, i) => {
|
||||
const s = ex.done[i];
|
||||
b.classList.toggle("set-btn--done", s !== null);
|
||||
b.dataset.effort = s?.effort ?? "";
|
||||
b.textContent = s === null ? String(i + 1) : typeof s.reps === "number" ? String(s.reps) : "✓";
|
||||
replace(b,
|
||||
h("span", { class: "set-btn__n" }, s === null ? String(i + 1) : typeof s.reps === "number" ? String(s.reps) : "✓"),
|
||||
s?.effort ? h("span", { class: "set-btn__effort" }, EFFORT_LABELS[s.effort].short) : null);
|
||||
const what = s === null ? "à faire"
|
||||
: [typeof s.reps === "number" ? `${s.reps} répétitions` : "faite", s.effort ? EFFORT_LABELS[s.effort].label.toLowerCase() : null]
|
||||
.filter(Boolean).join(", ");
|
||||
@@ -105,7 +111,7 @@ export function exerciseCard(o) {
|
||||
type: "button", class: "effort", data: { effort },
|
||||
"aria-pressed": String(existing?.effort === effort),
|
||||
on: { click: () => {
|
||||
ex.done[i] = { reps: timed ? null : reps, effort };
|
||||
markSet(o.draft, ex, i, { reps: timed ? null : reps, effort });
|
||||
closePanel();
|
||||
changed();
|
||||
// Le repos démarre au ressenti.
|
||||
@@ -130,7 +136,7 @@ export function exerciseCard(o) {
|
||||
timer.startWork(seconds, `${ex.name} · série ${i + 1}`, () => {
|
||||
// Fin du chrono : la série est cochée (bug d'Atelier : « cocher » n'existait
|
||||
// pas), puis on demande le ressenti, qui lancera le repos.
|
||||
if (ex.done[i] === null) ex.done[i] = { reps: null, effort: null };
|
||||
if (ex.done[i] === null) markSet(o.draft, ex, i, { reps: null, effort: null });
|
||||
changed();
|
||||
openPanel = null;
|
||||
showPanel(i);
|
||||
@@ -163,6 +169,7 @@ export function exerciseCard(o) {
|
||||
refreshChrono();
|
||||
o.onChange();
|
||||
});
|
||||
if (isLoad) loadInput = input;
|
||||
input.addEventListener("change", () => {
|
||||
const v = parseAmount(input.value);
|
||||
if (v === undefined || (field === "seconds" && !v)) return;
|
||||
@@ -178,6 +185,7 @@ export function exerciseCard(o) {
|
||||
const drawWork = () => {
|
||||
openPanel = null;
|
||||
chronoBtn = null;
|
||||
loadInput = null;
|
||||
setButtons = Array.from({ length: ex.sets }, (_, i) =>
|
||||
h("button", { type: "button", class: "set-btn", on: { click: () => showPanel(i) } }, String(i + 1)));
|
||||
const fields = h("div", { class: "work__fields" },
|
||||
@@ -210,12 +218,34 @@ export function exerciseCard(o) {
|
||||
ex.loadKg = fresh.loadKg;
|
||||
ex.seconds = fresh.seconds;
|
||||
drawWork();
|
||||
paintAdvice();
|
||||
changed();
|
||||
/** @type {HTMLElement|null} */ (tracking.querySelector("[aria-pressed=true]"))?.focus();
|
||||
} },
|
||||
}, TRACKING_LABELS[mode])));
|
||||
};
|
||||
|
||||
// ---- conseil de progression (double progression) ------------------------------
|
||||
const advice = h("div", { class: "advice", hidden: true });
|
||||
const paintAdvice = () => {
|
||||
const a = usesLoad(ex.tracking) ? progressionAdvice(store.getState(), o.sessionKey, item) : null;
|
||||
if (!a || ex.loadKg === a.newLoadKg) {
|
||||
advice.hidden = true;
|
||||
return;
|
||||
}
|
||||
advice.hidden = false;
|
||||
replace(advice,
|
||||
h("p", { class: "advice__head" }, h("span", { class: "mark" }, "Prêt à monter"), h("span", { class: "num advice__kg" }, `${kg(a.newLoadKg)} kg`)),
|
||||
h("p", { class: "muted" }, `Dernière fois : ${a.reason}.`),
|
||||
h("button", { type: "button", class: "btn btn--primary btn--block", on: { click: () => {
|
||||
store.dispatch("WorkingLoadSet", { key: ex.key, loadKg: a.newLoadKg });
|
||||
ex.loadKg = a.newLoadKg;
|
||||
if (loadInput) { loadInput.value = kg(a.newLoadKg); loadInput.setAttribute("aria-invalid", "false"); }
|
||||
advice.hidden = true;
|
||||
changed();
|
||||
} } }, `Adopter ${kg(a.newLoadKg)} kg`));
|
||||
};
|
||||
|
||||
// ---- consignes ---------------------------------------------------------------
|
||||
const muscles = library
|
||||
? h("ul", { class: "chips", "aria-label": "Muscles sollicités" },
|
||||
@@ -241,12 +271,12 @@ export function exerciseCard(o) {
|
||||
h("a", { class: "btn btn--ghost btn--sm tutorial", href: resolved.tutorial, target: "_blank", rel: "noopener noreferrer" },
|
||||
"Voir un tutoriel", h("span", { class: "visually-hidden" }, " (nouvel onglet)"), h("span", { "aria-hidden": "true" }, " ↗")),
|
||||
h("p", { class: "objective" }, objective, h("span", { class: "objective__rest" }, `Repos ${restLabel(ex.rest)}`)),
|
||||
// À brancher : progression (domaine, sous-lot 1b) pour le conseil « prêt à
|
||||
// monter à X kg » au-dessus des séries.
|
||||
advice,
|
||||
work,
|
||||
h("div", { class: "tracking" }, h("span", { class: "mini-label" }, "Je suis"), tracking)));
|
||||
|
||||
drawWork();
|
||||
refreshLabels();
|
||||
paintAdvice();
|
||||
return card;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user