Merge branch 'main' into lot-2-serveur
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
Copyright 2017 The Barlow Project Authors (https://github.com/jpt/barlow)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||
<rect width="512" height="512" fill="#14171A"/>
|
||||
<rect x="136" y="248" width="240" height="16" rx="4" fill="#EDEAE3"/>
|
||||
<rect x="154" y="190" width="32" height="132" rx="6" fill="#EDEAE3"/>
|
||||
<rect x="326" y="190" width="32" height="132" rx="6" fill="#EDEAE3"/>
|
||||
<rect x="192" y="212" width="20" height="88" rx="4" fill="#3FA06A"/>
|
||||
<rect x="300" y="212" width="20" height="88" rx="4" fill="#3FA06A"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 478 B |
@@ -0,0 +1,8 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
||||
<rect width="512" height="512" rx="96" fill="#14171A"/>
|
||||
<rect x="96" y="244" width="320" height="24" rx="6" fill="#EDEAE3"/>
|
||||
<rect x="120" y="164" width="44" height="184" rx="8" fill="#EDEAE3"/>
|
||||
<rect x="348" y="164" width="44" height="184" rx="8" fill="#EDEAE3"/>
|
||||
<rect x="172" y="196" width="28" height="120" rx="6" fill="#3FA06A"/>
|
||||
<rect x="312" y="196" width="28" height="120" rx="6" fill="#3FA06A"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 487 B |
@@ -0,0 +1,27 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<meta name="color-scheme" content="dark light">
|
||||
<meta name="theme-color" content="#14171A" media="(prefers-color-scheme: dark)">
|
||||
<meta name="theme-color" content="#F3F1EC" media="(prefers-color-scheme: light)">
|
||||
<meta name="description" content="Ton programme de musculation, construit avec ton IA, suivi séance par séance. Sans compte, tes données restent sur ton appareil.">
|
||||
<title>IA-Fit</title>
|
||||
<link rel="manifest" href="manifest.webmanifest">
|
||||
<link rel="icon" href="icons/icon.svg" type="image/svg+xml">
|
||||
<link rel="preload" href="fonts/barlow-condensed-bold.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="stylesheet" href="styles/fonts.css">
|
||||
<link rel="stylesheet" href="styles/tokens.css">
|
||||
<link rel="stylesheet" href="styles/base.css">
|
||||
<link rel="stylesheet" href="styles/components.css">
|
||||
<link rel="stylesheet" href="styles/session.css">
|
||||
<script type="module" src="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a class="skip-link" href="#app">Aller au contenu</a>
|
||||
<main id="app" class="wrap">
|
||||
<noscript><p>IA-Fit a besoin de JavaScript pour fonctionner.</p></noscript>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
// Démarrage de l'app : le magasin, le minuteur, le routeur et ses écrans.
|
||||
|
||||
import { createStore } from "./ui/store.js";
|
||||
import { startRouter } from "./ui/router.js";
|
||||
import { createTimer } from "./ui/timer.js";
|
||||
import { h } from "./ui/dom.js";
|
||||
import { screenHeader } from "./ui/layout.js";
|
||||
import { homeScreen } from "./ui/screens/home.js";
|
||||
import { sessionScreen } from "./ui/screens/session.js";
|
||||
import { historyEditScreen, historyScreen } from "./ui/screens/history.js";
|
||||
|
||||
import { openEventStore } from "./infra/event-store.js";
|
||||
import { decodeProposalFragment } from "./domain/link.js";
|
||||
import { registerServiceWorker } from "./sw-register.js";
|
||||
|
||||
// Le journal est gardé dans IndexedDB : chargé au démarrage, chaque événement
|
||||
// créé y est ajouté (ADR 0006).
|
||||
const db = await openEventStore();
|
||||
const device = await db.deviceId();
|
||||
export const store = createStore({ device, onAppend: (event) => { void db.add([event]); } });
|
||||
store.load(await db.list());
|
||||
|
||||
// Lien d'une IA (#import= ou #import-json=) : il devient une proposition à valider.
|
||||
async function importFromLink() {
|
||||
if (!/^#import(-json)?=/.test(location.hash)) return;
|
||||
try {
|
||||
const event = await decodeProposalFragment(location.hash, { device, now: new Date() });
|
||||
if (!store.getEvents().some((e) => e.id === event.id)) {
|
||||
await db.add([event]);
|
||||
store.load(await db.list());
|
||||
}
|
||||
} catch (e) {
|
||||
alert("Ce lien ne contient pas un programme valide :\n" + (e instanceof Error ? e.message : String(e)));
|
||||
}
|
||||
history.replaceState(null, "", "#/");
|
||||
}
|
||||
await importFromLink();
|
||||
window.addEventListener("hashchange", () => { void importFromLink(); });
|
||||
registerServiceWorker();
|
||||
|
||||
const timer = createTimer();
|
||||
document.body.append(timer.node);
|
||||
|
||||
const root = /** @type {HTMLElement} */ (document.getElementById("app"));
|
||||
|
||||
startRouter(root, (route, nav) => {
|
||||
switch (route.name) {
|
||||
case "session": return sessionScreen({ store, key: route.key, nav, timer });
|
||||
case "history": return historyScreen({ store, nav });
|
||||
case "history-edit": return historyEditScreen({ store, nav, id: route.id });
|
||||
case "not-found":
|
||||
return {
|
||||
title: "Page introuvable",
|
||||
node: h("div", { class: "screen" },
|
||||
screenHeader({ back: { label: "Accueil", onClick: () => nav.go("#/") }, title: "Page introuvable", sub: "Cette adresse ne correspond à aucun écran." })),
|
||||
};
|
||||
default: return homeScreen({ store });
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "IA-Fit",
|
||||
"short_name": "IA-Fit",
|
||||
"description": "Ton programme de musculation, construit avec ton IA, suivi séance par séance.",
|
||||
"lang": "fr",
|
||||
"start_url": "./#/",
|
||||
"scope": "./",
|
||||
"display": "standalone",
|
||||
"orientation": "portrait",
|
||||
"background_color": "#14171A",
|
||||
"theme_color": "#14171A",
|
||||
"icons": [
|
||||
{ "src": "icons/icon.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "any" },
|
||||
{ "src": "icons/icon-maskable.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "maskable" }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/* Base : remise à zéro, typographie, mise en page de l'écran. */
|
||||
*, *::before, *::after { box-sizing: border-box; }
|
||||
html {
|
||||
-webkit-text-size-adjust: 100%; text-size-adjust: 100%;
|
||||
/* Le défilement vers un élément (focus, lien) tient compte de l'en-tête
|
||||
collant de l'exercice et des barres fixées en bas. */
|
||||
scroll-padding-top: 72px;
|
||||
scroll-padding-bottom: calc(var(--action-bar-h) + var(--space-4));
|
||||
}
|
||||
html:has(body.has-timer) { scroll-padding-bottom: calc(var(--action-bar-h) + var(--timer-h) + var(--space-4)); }
|
||||
html, body { margin: 0; padding: 0; }
|
||||
body {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--fs-md);
|
||||
line-height: 1.5;
|
||||
overscroll-behavior-y: none;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
/* place pour la barre d'action collée en bas */
|
||||
padding-bottom: calc(var(--action-bar-h) + env(safe-area-inset-bottom));
|
||||
}
|
||||
body.has-timer { padding-bottom: calc(var(--action-bar-h) + var(--timer-h) + env(safe-area-inset-bottom)); }
|
||||
|
||||
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
|
||||
|
||||
h1, h2, h3, p, ul, ol { margin: 0; }
|
||||
ul, ol { padding: 0; list-style: none; }
|
||||
a { color: inherit; }
|
||||
button, input, select, textarea { font: inherit; color: inherit; }
|
||||
button { cursor: pointer; }
|
||||
[hidden] { display: none !important; }
|
||||
|
||||
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
|
||||
h1:focus { outline: none; }
|
||||
|
||||
.visually-hidden {
|
||||
position: absolute !important; width: 1px; height: 1px; overflow: hidden;
|
||||
clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
|
||||
}
|
||||
.skip-link { position: absolute; left: var(--space-2); top: -100px; z-index: 50; }
|
||||
.skip-link:focus { top: var(--space-2); background: var(--surface); padding: var(--space-2) var(--space-3); }
|
||||
|
||||
/* Chiffres alignés partout où l'on compare des nombres. */
|
||||
.tnum, .timer__time, .stepper__value, .set-btn, .field__input, .exercise__count, .objective__value, .action-bar__meta { font-variant-numeric: tabular-nums; }
|
||||
|
||||
/* Typographie d'affichage : capitales condensées. */
|
||||
.kicker, .section-label, .mini-label, .card__eyebrow, .plate__id, .plate__last, .tag, .back, .btn, .timer__label {
|
||||
font-family: var(--font-display);
|
||||
text-transform: uppercase;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
.title, .card__title, .plate__name, .note__title, .dialog__title, .timer__time, .objective__value, .stepper__value {
|
||||
font-family: var(--font-display);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.screen-head { padding: var(--space-5) 0 var(--space-4); }
|
||||
.kicker { font-size: var(--fs-xs); color: var(--text-muted); letter-spacing: 0.16em; }
|
||||
.title { font-size: var(--fs-3xl); line-height: 0.95; text-transform: uppercase; margin-top: var(--space-1); letter-spacing: -0.005em; }
|
||||
.title--hero { font-size: 3.25rem; }
|
||||
.lede { color: var(--text-muted); font-size: var(--fs-sm); margin-top: var(--space-2); max-width: 46ch; }
|
||||
.muted { color: var(--text-muted); font-size: var(--fs-sm); }
|
||||
.foot { color: var(--text-muted); font-size: var(--fs-xs); margin: var(--space-6) 0 var(--space-4); }
|
||||
.empty { color: var(--text-muted); padding: var(--space-5) 0; }
|
||||
|
||||
.section-label {
|
||||
font-size: var(--fs-sm); color: var(--text-muted); letter-spacing: 0.16em;
|
||||
margin: var(--space-6) 0 var(--space-3); display: flex; align-items: baseline; gap: var(--space-2);
|
||||
}
|
||||
.section-label__hint { font-size: var(--fs-xs); letter-spacing: 0.08em; text-transform: none; font-family: var(--font-body); font-weight: 400; }
|
||||
|
||||
.status { min-height: 1.5em; margin-top: var(--space-3); color: var(--danger); font-size: var(--fs-sm); }
|
||||
.status--ok { color: var(--primary); }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*, *::before, *::after { transition: none !important; animation: none !important; }
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
/* Composants communs (docs/design.md). Un composant = un bloc nommé, avec ses
|
||||
éléments (bloc__element) et variantes (bloc--variante). */
|
||||
|
||||
/* ---- Bouton ------------------------------------------------------------- */
|
||||
.btn {
|
||||
display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
|
||||
min-height: var(--tap); padding: 0 var(--space-4);
|
||||
background: var(--surface-2); color: var(--text);
|
||||
border: 1px solid var(--line-strong); border-radius: var(--radius);
|
||||
font-size: var(--fs-md); text-decoration: none; text-align: center;
|
||||
transition: background-color .12s, border-color .12s, transform .06s;
|
||||
}
|
||||
.btn:hover { border-color: var(--text-muted); }
|
||||
.btn:active { transform: scale(.985); }
|
||||
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
|
||||
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 700; }
|
||||
.btn--primary:hover { border-color: var(--text); }
|
||||
.btn--ghost { background: transparent; }
|
||||
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
|
||||
.btn--work { background: transparent; border-color: var(--work); color: var(--work); }
|
||||
.btn--block { display: flex; width: 100%; }
|
||||
.btn--lg { min-height: 56px; font-size: var(--fs-lg); letter-spacing: 0.06em; }
|
||||
.btn--sm { min-height: 44px; padding: 0 var(--space-3); font-size: var(--fs-sm); }
|
||||
|
||||
.link-btn {
|
||||
background: none; border: 0; padding: 0 var(--space-2); min-height: 44px; min-width: 44px;
|
||||
color: var(--text); text-decoration: underline; text-underline-offset: 3px; font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.back {
|
||||
display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-2) 0 0;
|
||||
background: none; border: 0; color: var(--text-muted); font-size: var(--fs-sm); letter-spacing: 0.12em;
|
||||
}
|
||||
.back:hover { color: var(--text); }
|
||||
|
||||
/* ---- Barre d'action collée en bas -------------------------------------- */
|
||||
.action-bar {
|
||||
position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
|
||||
background: color-mix(in srgb, var(--bg) 92%, transparent);
|
||||
border-top: 1px solid var(--line);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
backdrop-filter: blur(6px);
|
||||
}
|
||||
.action-bar__in {
|
||||
max-width: var(--max); margin: 0 auto; padding: var(--space-3) var(--gutter);
|
||||
display: flex; align-items: center; gap: var(--space-3);
|
||||
}
|
||||
.action-bar__in > .btn { flex: 1; }
|
||||
/* Le minuteur s'empile sous la barre d'action : « Terminer la séance » reste
|
||||
accessible pendant un repos. */
|
||||
body.has-timer .action-bar { bottom: calc(var(--timer-h) + env(safe-area-inset-bottom)); padding-bottom: 0; border-top-color: transparent; }
|
||||
.action-bar__meta { color: var(--text-muted); font-family: var(--font-display); font-weight: 600; font-size: var(--fs-md); white-space: nowrap; }
|
||||
|
||||
/* ---- Cartes ------------------------------------------------------------- */
|
||||
.card {
|
||||
display: block; position: relative; text-decoration: none; color: inherit;
|
||||
background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
|
||||
padding: var(--space-4);
|
||||
}
|
||||
/* La carte du jour domine l'accueil : plus grande, bordée de la couleur de séance. */
|
||||
.card--today {
|
||||
border-left: 6px solid var(--accent); padding: var(--space-5) var(--space-4);
|
||||
}
|
||||
a.card--today:hover { border-color: var(--line-strong); border-left-color: var(--accent); }
|
||||
.card--proposal { border-left: 6px solid var(--primary); margin-bottom: var(--space-4); }
|
||||
.card__eyebrow { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-4); font-size: var(--fs-sm); letter-spacing: 0.16em; }
|
||||
.card__title { font-size: var(--fs-2xl); line-height: 1; text-transform: uppercase; margin-top: var(--space-1); }
|
||||
.card__meta { color: var(--text-muted); font-size: var(--fs-sm); margin-top: var(--space-2); }
|
||||
.card__text { margin-top: var(--space-3); font-size: var(--fs-sm); }
|
||||
.card__hint { color: var(--text-muted); font-size: var(--fs-xs); margin-top: var(--space-3); }
|
||||
.card__actions { display: grid; gap: var(--space-2); margin-top: var(--space-4); }
|
||||
|
||||
.swatch { width: 12px; height: 12px; border-radius: 2px; background: var(--accent); flex: none; }
|
||||
|
||||
/* ---- Plaque de séance (liste de l'accueil) ----------------------------- */
|
||||
.plates { display: grid; gap: var(--space-2); }
|
||||
.plate {
|
||||
display: flex; align-items: stretch; min-height: 72px; text-decoration: none; color: inherit;
|
||||
background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
|
||||
}
|
||||
.plate:hover { border-color: var(--line-strong); }
|
||||
.plate__bar { width: 8px; flex: none; background: var(--accent); }
|
||||
.plate__body { flex: 1; min-width: 0; padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; }
|
||||
.plate__id { font-size: var(--fs-xs); color: var(--text-muted); letter-spacing: 0.16em; }
|
||||
.plate__name { font-size: var(--fs-xl); line-height: 1.05; text-transform: uppercase; }
|
||||
.plate__meta { color: var(--text-muted); font-size: var(--fs-xs); margin-top: var(--space-1); }
|
||||
.plate__last { padding: var(--space-3) var(--space-3) 0 0; font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; text-align: right; }
|
||||
|
||||
/* ---- Note (cardio, repères) --------------------------------------------- */
|
||||
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-2); }
|
||||
.note__title { font-size: var(--fs-lg); text-transform: uppercase; letter-spacing: 0.03em; }
|
||||
.note__text { color: var(--text-muted); font-size: var(--fs-sm); margin-top: var(--space-1); }
|
||||
|
||||
.coach-note { color: var(--warn); border-left: 3px solid var(--warn); padding-left: var(--space-3); font-size: var(--fs-sm); margin: var(--space-3) 0; }
|
||||
|
||||
/* ---- Puces (muscles) et étiquettes -------------------------------------- */
|
||||
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-3) 0; }
|
||||
.chip {
|
||||
display: inline-flex; align-items: center; min-height: 28px; padding: 0 var(--space-3);
|
||||
border-radius: 999px; font-size: var(--fs-xs); font-weight: 600;
|
||||
background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong);
|
||||
}
|
||||
.chip--secondary { background: transparent; color: var(--text-muted); border-style: dashed; font-weight: 400; }
|
||||
.tag {
|
||||
display: inline-block; padding: 1px 6px; margin-right: var(--space-2); border-radius: var(--radius-sm);
|
||||
font-size: var(--fs-xs); background: var(--accent); color: var(--accent-ink); letter-spacing: 0.08em; vertical-align: 1px;
|
||||
}
|
||||
.tag--superset { background: var(--work); color: var(--surface-sunk); }
|
||||
.badge {
|
||||
display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: var(--radius-sm);
|
||||
background: var(--accent); color: var(--accent-ink); font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md);
|
||||
}
|
||||
.badge--warmup { background: var(--primary); color: var(--on-primary); }
|
||||
.inline-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-xs); background: var(--surface-2); color: var(--text); padding: 2px 6px; border-radius: var(--radius-sm); overflow-wrap: anywhere; }
|
||||
|
||||
/* ---- Champs ------------------------------------------------------------- */
|
||||
.field { display: flex; align-items: center; gap: var(--space-2); }
|
||||
.field--inline { justify-content: space-between; margin: var(--space-2) 0; }
|
||||
.field__label { font-family: var(--font-display); text-transform: uppercase; font-weight: 600; letter-spacing: 0.1em; font-size: var(--fs-sm); color: var(--text-muted); }
|
||||
.field__input {
|
||||
min-height: var(--tap); min-width: 0; padding: 0 var(--space-3);
|
||||
background: var(--surface-2); color: var(--text);
|
||||
border: 1px solid var(--line-strong); border-radius: var(--radius);
|
||||
font-family: var(--font-display); font-weight: 600; font-size: var(--fs-lg);
|
||||
}
|
||||
.field__input:focus { outline: 3px solid var(--focus); outline-offset: 0; }
|
||||
.field__input[aria-invalid="true"] { border-color: var(--danger); outline-color: var(--danger); }
|
||||
.field__input--date { font-size: var(--fs-md); }
|
||||
.field__input--area { width: 100%; min-height: 160px; padding: var(--space-3); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-xs); font-weight: 400; }
|
||||
.field--amount .field__input { width: 5.5em; text-align: right; }
|
||||
.field--compact .field__input { width: 4.5em; }
|
||||
.field__unit { font-family: var(--font-display); font-weight: 600; text-transform: uppercase; color: var(--text-muted); font-size: var(--fs-sm); }
|
||||
|
||||
/* ---- Choix segmenté (mode de suivi) ------------------------------------ */
|
||||
.segmented { display: flex; flex-wrap: wrap; gap: var(--space-2); }
|
||||
.segmented__opt {
|
||||
min-height: 44px; padding: 0 var(--space-3); border-radius: var(--radius);
|
||||
background: transparent; border: 1px solid var(--line-strong); color: var(--text-muted); font-size: var(--fs-sm);
|
||||
}
|
||||
.segmented__opt[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
|
||||
|
||||
/* ---- Liens de l'accueil, onboarding ------------------------------------ */
|
||||
.links { display: grid; gap: var(--space-2); }
|
||||
.hero { padding-top: var(--space-6); }
|
||||
.how { counter-reset: how; display: grid; gap: var(--space-3); margin-top: var(--space-4); }
|
||||
.how__step { counter-increment: how; position: relative; padding-left: 44px; min-height: 32px; font-size: var(--fs-sm); }
|
||||
.how__step::before {
|
||||
content: counter(how); position: absolute; left: 0; top: -2px; width: 32px; height: 32px; border-radius: 50%;
|
||||
display: grid; place-items: center; background: var(--primary); color: var(--on-primary);
|
||||
font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg);
|
||||
}
|
||||
.card--onboarding { border-left: 6px solid var(--primary); padding: var(--space-5) var(--space-4); }
|
||||
.how__step strong { font-weight: 700; }
|
||||
.how__step span { color: var(--text-muted); }
|
||||
.status--info { color: var(--text); }
|
||||
.copy-line { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
|
||||
.copy-line__text {
|
||||
flex: 1; min-width: 0; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
|
||||
background: var(--surface-sunk); color: var(--text); border: 1px solid var(--line);
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-xs); overflow-wrap: anywhere;
|
||||
}
|
||||
.alt { display: grid; gap: var(--space-2); margin-top: var(--space-5); }
|
||||
.manual-copy { margin-top: var(--space-3); display: grid; gap: var(--space-2); }
|
||||
|
||||
.preview { display: grid; gap: var(--space-3); margin-top: var(--space-4); }
|
||||
.preview__session { display: grid; gap: 2px; font-size: var(--fs-sm); }
|
||||
|
||||
/* ---- Historique --------------------------------------------------------- */
|
||||
.history__list { display: grid; gap: var(--space-2); }
|
||||
.history__item {
|
||||
display: grid; grid-template-columns: 1fr auto; grid-template-areas: "date chev" "name chev" "meta chev";
|
||||
min-height: 72px; padding: var(--space-3) var(--space-4); text-decoration: none; color: inherit;
|
||||
background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
|
||||
}
|
||||
.history__item:hover { border-color: var(--line-strong); }
|
||||
.history__date { grid-area: date; font-family: var(--font-display); text-transform: uppercase; font-weight: 600; letter-spacing: 0.1em; font-size: var(--fs-xs); color: var(--text-muted); }
|
||||
.history__name { grid-area: name; font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: var(--fs-lg); line-height: 1.1; }
|
||||
.history__meta { grid-area: meta; color: var(--text-muted); font-size: var(--fs-xs); }
|
||||
.history__item .chevron { grid-area: chev; align-self: center; }
|
||||
|
||||
.edit-list { display: grid; gap: var(--space-3); }
|
||||
.edit-ex { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3) var(--space-4); display: grid; gap: var(--space-3); }
|
||||
.edit-ex__head { display: flex; justify-content: space-between; gap: var(--space-2); align-items: baseline; }
|
||||
.edit-sets { display: grid; gap: var(--space-2); }
|
||||
.edit-set { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
|
||||
.edit-set__n { color: var(--text-muted); font-size: var(--fs-sm); }
|
||||
.edit-sets__btns { display: flex; gap: var(--space-2); }
|
||||
|
||||
/* ---- Chevron ------------------------------------------------------------ */
|
||||
.chevron { width: 10px; height: 10px; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted); transform: rotate(-45deg); flex: none; margin: 0 var(--space-1); transition: transform .15s; }
|
||||
|
||||
/* ---- Dialogue et message bref ------------------------------------------- */
|
||||
.dialog {
|
||||
width: min(100% - 2 * var(--gutter), 480px); padding: var(--space-5) var(--space-4) var(--space-4);
|
||||
background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius);
|
||||
}
|
||||
.dialog::backdrop { background: rgb(0 0 0 / .6); }
|
||||
.dialog__title { font-size: var(--fs-xl); text-transform: uppercase; line-height: 1.05; margin-bottom: var(--space-3); }
|
||||
.dialog__text { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: var(--space-2); }
|
||||
.dialog__actions { display: grid; gap: var(--space-2); margin-top: var(--space-4); }
|
||||
|
||||
.toast {
|
||||
position: fixed; left: 50%; bottom: calc(var(--action-bar-h) + var(--space-4) + env(safe-area-inset-bottom)); z-index: 40;
|
||||
transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
|
||||
max-width: calc(100% - 2 * var(--gutter)); padding: var(--space-3) var(--space-4);
|
||||
background: var(--text); color: var(--bg); border-radius: var(--radius); font-size: var(--fs-sm); font-weight: 600;
|
||||
transition: opacity .2s, transform .2s;
|
||||
}
|
||||
.toast--on { opacity: 1; transform: translate(-50%, 0); }
|
||||
body.has-timer .toast { bottom: calc(var(--action-bar-h) + var(--timer-h) + var(--space-4) + env(safe-area-inset-bottom)); }
|
||||
|
||||
/* ---- Minuteur ----------------------------------------------------------- */
|
||||
.timer {
|
||||
position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
|
||||
background: var(--surface); border-top: 1px solid var(--line-strong);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
box-shadow: 0 -8px 24px rgb(0 0 0 / .25);
|
||||
}
|
||||
.timer__bar { height: 4px; background: var(--surface-2); position: relative; overflow: hidden; }
|
||||
.timer__bar::after {
|
||||
content: ""; position: absolute; inset: 0; background: var(--text);
|
||||
transform-origin: left; transform: scaleX(var(--progress, 1)); transition: transform .25s linear;
|
||||
}
|
||||
.timer__in { max-width: var(--max); height: calc(var(--timer-h) - 4px); margin: 0 auto; padding: 0 var(--gutter); display: flex; align-items: center; gap: var(--space-3); }
|
||||
.timer__read { flex: 1; min-width: 0; }
|
||||
.timer__label { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.timer__time { font-size: 2.75rem; line-height: 1; }
|
||||
.timer__btns { display: flex; gap: var(--space-2); }
|
||||
.timer__btn { min-width: 64px; }
|
||||
.timer--work .timer__time { color: var(--work); }
|
||||
.timer--work .timer__bar::after { background: var(--work); }
|
||||
.timer--low .timer__time { color: var(--warn); }
|
||||
.timer--zero .timer__time { color: var(--primary); }
|
||||
.timer--zero .timer__bar::after { background: var(--primary); }
|
||||
@@ -0,0 +1,23 @@
|
||||
/* Barlow Condensed, SIL Open Font License 1.1 (app/fonts/OFL.txt). Auto-hébergée
|
||||
(ADR 0007), sous-ensemble latin, depuis le dépôt google/fonts. */
|
||||
@font-face {
|
||||
font-family: "Barlow Condensed";
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url("../fonts/barlow-condensed-medium.woff2") format("woff2");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Barlow Condensed";
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
font-display: swap;
|
||||
src: url("../fonts/barlow-condensed-semibold.woff2") format("woff2");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Barlow Condensed";
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
font-display: swap;
|
||||
src: url("../fonts/barlow-condensed-bold.woff2") format("woff2");
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/* Composants de la séance guidée : exercice, superset, séries, ressenti. */
|
||||
|
||||
.exercises { display: grid; gap: var(--space-2); margin-top: var(--space-4); }
|
||||
|
||||
/* ---- Exercice (details/summary natif, accessible sans script) ---------- */
|
||||
.exercise { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
|
||||
.exercise[open] { border-color: var(--line-strong); }
|
||||
.exercise__head {
|
||||
display: flex; align-items: center; gap: var(--space-3);
|
||||
min-height: 64px; padding: var(--space-3) var(--space-4); cursor: pointer; list-style: none;
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
.exercise__head::-webkit-details-marker { display: none; }
|
||||
/* Piège d'Atelier : combinateur enfant, et pas d'overflow:hidden sur la carte,
|
||||
sinon l'en-tête collant ne colle plus. */
|
||||
.exercise[open] > .exercise__head {
|
||||
position: sticky; top: 0; z-index: 5; background: var(--surface);
|
||||
border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0;
|
||||
}
|
||||
.exercise[open] > .exercise__head .chevron { transform: rotate(45deg); }
|
||||
.exercise__name { flex: 1; min-width: 0; display: grid; }
|
||||
.exercise__name strong { font-size: var(--fs-md); font-weight: 600; line-height: 1.25; }
|
||||
.exercise__sub { color: var(--text-muted); font-size: var(--fs-xs); }
|
||||
.exercise__count { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); color: var(--text-muted); }
|
||||
.exercise__count--done { color: var(--primary); }
|
||||
.exercise__body { padding: var(--space-3) var(--space-4) var(--space-4); }
|
||||
|
||||
.mini-label { font-family: var(--font-display); text-transform: uppercase; font-weight: 600; letter-spacing: 0.14em; font-size: var(--fs-xs); color: var(--text-muted); margin: var(--space-4) 0 var(--space-2); }
|
||||
.cues li, .mistakes li { position: relative; padding-left: 20px; margin-bottom: var(--space-2); font-size: var(--fs-sm); }
|
||||
.cues li::before { content: ""; position: absolute; left: 4px; top: .55em; width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
|
||||
.mistakes { border-left: 3px solid var(--danger); padding-left: var(--space-1); }
|
||||
.mistakes li { color: var(--text-muted); padding-left: var(--space-3); }
|
||||
.tutorial { margin-top: var(--space-2); }
|
||||
|
||||
.objective { display: flex; align-items: baseline; gap: var(--space-3); margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--line); }
|
||||
.objective__value { font-size: var(--fs-xl); line-height: 1; }
|
||||
.objective__rest { margin-left: auto; font-family: var(--font-display); text-transform: uppercase; font-weight: 600; letter-spacing: .1em; font-size: var(--fs-sm); color: var(--text-muted); }
|
||||
|
||||
/* ---- Zone de saisie ----------------------------------------------------- */
|
||||
.work { display: grid; gap: var(--space-3); margin-top: var(--space-3); }
|
||||
.work__fields { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-4); align-items: center; }
|
||||
.set-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
|
||||
.set-btn {
|
||||
position: relative; width: 52px; height: 52px; border-radius: var(--radius);
|
||||
background: transparent; border: 1px solid var(--line-strong); color: var(--text);
|
||||
font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg);
|
||||
}
|
||||
.set-btn[aria-expanded="true"] { outline: 3px solid var(--text); outline-offset: 1px; }
|
||||
.set-btn--done { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
|
||||
/* Pastille du ressenti : la couleur double le texte (aria-label), jamais seule. */
|
||||
.set-btn--done::after {
|
||||
content: ""; position: absolute; right: 4px; top: 4px; width: 10px; height: 10px; border-radius: 50%;
|
||||
border: 2px solid var(--on-primary); background: var(--dot, transparent);
|
||||
}
|
||||
.set-btn[data-effort="easy"] { --dot: var(--effort-easy); }
|
||||
.set-btn[data-effort="ok"] { --dot: var(--effort-ok); }
|
||||
.set-btn[data-effort="hard"] { --dot: var(--effort-hard); }
|
||||
.set-btn[data-effort="failure"] { --dot: var(--effort-failure); }
|
||||
|
||||
.set-panel { background: var(--surface-sunk); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: var(--space-3); display: grid; gap: var(--space-3); }
|
||||
.set-panel__title, .set-panel__ask { font-family: var(--font-display); text-transform: uppercase; font-weight: 600; letter-spacing: .12em; font-size: var(--fs-sm); color: var(--text-muted); }
|
||||
|
||||
.stepper { display: flex; align-items: center; gap: var(--space-3); }
|
||||
.stepper__btn { width: 56px; height: 56px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text); font-size: 1.75rem; line-height: 1; }
|
||||
.stepper__value { min-width: 2.2ch; text-align: center; font-size: 2.5rem; line-height: 1; }
|
||||
.stepper__unit { font-family: var(--font-display); text-transform: uppercase; font-weight: 600; letter-spacing: .1em; font-size: var(--fs-sm); color: var(--text-muted); }
|
||||
|
||||
.effort-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
|
||||
.effort {
|
||||
display: grid; gap: 2px; text-align: left; min-height: 64px; padding: var(--space-2) var(--space-3);
|
||||
background: var(--surface); border: 1px solid var(--line-strong); border-left: 6px solid var(--c); border-radius: var(--radius); color: var(--text);
|
||||
}
|
||||
.effort[data-effort="easy"] { --c: var(--effort-easy); }
|
||||
.effort[data-effort="ok"] { --c: var(--effort-ok); }
|
||||
.effort[data-effort="hard"] { --c: var(--effort-hard); }
|
||||
.effort[data-effort="failure"] { --c: var(--effort-failure); }
|
||||
.effort[aria-pressed="true"] { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
|
||||
.effort__label { font-family: var(--font-display); text-transform: uppercase; font-weight: 700; letter-spacing: .06em; font-size: var(--fs-lg); color: var(--c); }
|
||||
.effort__hint { font-size: var(--fs-xs); color: var(--text-muted); }
|
||||
|
||||
.tracking { display: grid; gap: 0; margin-top: var(--space-3); padding-top: var(--space-1); border-top: 1px solid var(--line); }
|
||||
|
||||
/* ---- Superset ----------------------------------------------------------- */
|
||||
.superset { border: 1px solid var(--work); border-radius: var(--radius); padding: var(--space-2); display: grid; gap: var(--space-2); }
|
||||
.superset__head { padding: var(--space-2); }
|
||||
.superset__text { color: var(--text-muted); font-size: var(--fs-xs); margin-top: var(--space-1); }
|
||||
.superset .exercise { background: var(--surface); }
|
||||
|
||||
/* ---- Échauffement ------------------------------------------------------- */
|
||||
.exercise--warmup { border-color: var(--primary); }
|
||||
.steps { display: grid; }
|
||||
.step { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--line); }
|
||||
.step:first-child { border-top: 0; }
|
||||
.step__text { flex: 1; min-width: 0; display: grid; }
|
||||
.step__text strong { font-size: var(--fs-sm); font-weight: 600; }
|
||||
.step__text span { color: var(--text-muted); font-size: var(--fs-xs); }
|
||||
.tick {
|
||||
width: 44px; height: 44px; flex: none; border-radius: var(--radius); background: transparent;
|
||||
border: 1px solid var(--line-strong); position: relative;
|
||||
}
|
||||
.tick[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); }
|
||||
.tick[aria-pressed="true"]::after {
|
||||
content: ""; position: absolute; left: 15px; top: 9px; width: 10px; height: 18px;
|
||||
border-right: 3px solid var(--on-primary); border-bottom: 3px solid var(--on-primary); transform: rotate(45deg);
|
||||
}
|
||||
.step__go { flex: none; }
|
||||
@@ -0,0 +1,88 @@
|
||||
/* Jetons de design (docs/design.md). Toute couleur de l'interface passe par
|
||||
eux ; les ratios de contraste y sont notés. Thème sombre par défaut (« fonte et
|
||||
craie »), thème clair selon la préférence du système. */
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
|
||||
/* Surfaces */
|
||||
--bg: #14171A; /* iron */
|
||||
--surface: #1E2328; /* cartes */
|
||||
--surface-2: #272D33; /* champs, boutons secondaires */
|
||||
--surface-sunk: #0E1113; /* zones en creux */
|
||||
|
||||
/* Texte : AA sur toutes les surfaces */
|
||||
--text: #EDEAE3; /* chalk : 15,0 bg, 13,2 surface, 11,6 surface-2 */
|
||||
--text-muted: #A3AAB1; /* 7,7 bg, 6,7 surface, 5,9 surface-2 */
|
||||
|
||||
/* Traits */
|
||||
--line: #333A41; /* séparateurs décoratifs */
|
||||
--line-strong: #6B737B; /* bord des contrôles : 3,7 bg, 3,3 surface (≥ 3:1) */
|
||||
|
||||
/* Rôles */
|
||||
--primary: #3FA06A; /* action principale, séries faites */
|
||||
--on-primary: #0E1113; /* 5,8 sur primary */
|
||||
--warn: #E3B505; /* note du coach : 8,2 surface */
|
||||
--danger: #E0787C; /* 5,4 surface, 6,1 bg */
|
||||
--work: #7FB6CB; /* chrono de série : 7,1 surface */
|
||||
--focus: #7FB6CB;
|
||||
|
||||
/* Ressenti */
|
||||
--effort-easy: #3FA06A; /* 4,9 surface */
|
||||
--effort-ok: #E3B505; /* 8,2 surface */
|
||||
--effort-hard: #D9762B; /* 5,0 surface */
|
||||
--effort-failure: #EF6B70;/* 5,1 surface */
|
||||
|
||||
/* Couleur de la séance, posée par le programme (setAccent) */
|
||||
--accent: #8A9199;
|
||||
--accent-ink: #0E1113;
|
||||
|
||||
/* Typographie */
|
||||
--font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif-condensed, sans-serif;
|
||||
--font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
--fs-xs: 0.8125rem; /* 13 px */
|
||||
--fs-sm: 0.875rem; /* 14 px */
|
||||
--fs-md: 1rem; /* 16 px */
|
||||
--fs-lg: 1.25rem;
|
||||
--fs-xl: 1.75rem;
|
||||
--fs-2xl: 2.25rem;
|
||||
--fs-3xl: 2.75rem;
|
||||
|
||||
/* Espaces, rayons, tailles */
|
||||
--space-1: 4px;
|
||||
--space-2: 8px;
|
||||
--space-3: 12px;
|
||||
--space-4: 16px;
|
||||
--space-5: 24px;
|
||||
--space-6: 32px;
|
||||
--radius: 6px;
|
||||
--radius-sm: 4px;
|
||||
--tap: 48px; /* cible tactile minimale (≥ 44 px) */
|
||||
--gutter: 16px;
|
||||
--max: 560px;
|
||||
--action-bar-h: 80px;
|
||||
--timer-h: 80px; /* minuteur, barre de progression comprise */
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root {
|
||||
color-scheme: light;
|
||||
--bg: #F3F1EC;
|
||||
--surface: #FFFFFF;
|
||||
--surface-2: #E8E5DE;
|
||||
--surface-sunk: #ECE9E2;
|
||||
--text: #14171A; /* 15,9 bg, 18,0 surface, 14,3 surface-2 */
|
||||
--text-muted: #555D65; /* 5,9 bg, 6,7 surface, 5,3 surface-2 */
|
||||
--line: #D6D2C9;
|
||||
--line-strong: #8A857B; /* 3,3 bg, 3,7 surface */
|
||||
--primary: #2B7A4B;
|
||||
--on-primary: #FFFFFF; /* 5,3 */
|
||||
--warn: #806200; /* 5,0 bg, 5,6 surface */
|
||||
--danger: #B3262C; /* 6,5 surface */
|
||||
--work: #2E6E8A; /* 5,7 surface */
|
||||
--focus: #2E6E8A;
|
||||
--effort-easy: #2B7A4B;
|
||||
--effort-ok: #806200;
|
||||
--effort-hard: #A9531A;
|
||||
--effort-failure: #B3262C;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Couleurs venues du programme (choisies par l'IA ou l'utilisateur) : on calcule
|
||||
// la couleur du texte posé dessus pour garder un contraste lisible.
|
||||
|
||||
/** Luminance relative WCAG d'une couleur #RRGGBB. @param {string} hex */
|
||||
export function luminance(hex) {
|
||||
const [r, g, b] = [1, 3, 5]
|
||||
.map((i) => parseInt(hex.slice(i, i + 2), 16) / 255)
|
||||
.map((v) => (v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4));
|
||||
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||||
}
|
||||
|
||||
/** Ratio de contraste WCAG entre deux couleurs #RRGGBB. @param {string} a @param {string} b */
|
||||
export function contrastRatio(a, b) {
|
||||
const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
|
||||
return (hi + 0.05) / (lo + 0.05);
|
||||
}
|
||||
|
||||
export const INK_DARK = "#0E1113";
|
||||
export const INK_LIGHT = "#FFFFFF";
|
||||
|
||||
/**
|
||||
* Texte à poser sur un fond de couleur : le plus contrasté du presque-noir et
|
||||
* du blanc.
|
||||
* @param {string} background #RRGGBB
|
||||
*/
|
||||
export function inkOn(background) {
|
||||
return contrastRatio(INK_DARK, background) >= contrastRatio(INK_LIGHT, background) ? INK_DARK : INK_LIGHT;
|
||||
}
|
||||
|
||||
/** Couleur d'une séance, ou un gris neutre si le programme n'en donne pas. @param {string|undefined} color */
|
||||
export function sessionColor(color) {
|
||||
return color && /^#[0-9A-Fa-f]{6}$/.test(color) ? color : "#8A9199";
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// Petits outils DOM. Aucun innerHTML : les textes passent par des nœuds texte,
|
||||
// ce qui protège des données venues de l'utilisateur ou de l'IA. Aucun style en
|
||||
// ligne non plus (CSP stricte, lot 1f) : seules des variables CSS de couleur
|
||||
// venues du programme passent par style.setProperty (voir setAccent).
|
||||
|
||||
/** @typedef {Node|string|number|null|undefined|false|Children} Child */
|
||||
/** @typedef {Array<Child>} Children */
|
||||
|
||||
/**
|
||||
* Crée un élément.
|
||||
* - `class` : classes CSS ;
|
||||
* - `on` : { click: fn, … } branchés par addEventListener ;
|
||||
* - `data` : { cle: valeur } vers dataset ;
|
||||
* - une valeur `true` pose l'attribut vide, `false`, null ou undefined l'omet ;
|
||||
* - le reste devient un attribut.
|
||||
* @template {keyof HTMLElementTagNameMap} K
|
||||
* @param {K} tag
|
||||
* @param {Record<string, any>|null} [attrs]
|
||||
* @param {...Child} children
|
||||
* @returns {HTMLElementTagNameMap[K]}
|
||||
*/
|
||||
export function h(tag, attrs, ...children) {
|
||||
const el = document.createElement(tag);
|
||||
for (const [key, value] of Object.entries(attrs ?? {})) {
|
||||
if (value === null || value === undefined || value === false) continue;
|
||||
if (key === "class") el.className = String(value);
|
||||
else if (key === "on") for (const [type, fn] of Object.entries(value)) el.addEventListener(type, fn);
|
||||
else if (key === "data") for (const [k, v] of Object.entries(value)) el.dataset[k] = String(v);
|
||||
else if (key === "style") throw new Error("Pas de style en ligne : utiliser une classe CSS.");
|
||||
else if (key === "value" && "value" in el) /** @type {any} */ (el).value = String(value);
|
||||
else el.setAttribute(key, value === true ? "" : String(value));
|
||||
}
|
||||
append(el, children);
|
||||
return el;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element} parent
|
||||
* @param {Child[]} children
|
||||
*/
|
||||
export function append(parent, children) {
|
||||
for (const child of /** @type {any[]} */ (children).flat(Infinity)) {
|
||||
if (child === null || child === undefined || child === false) continue;
|
||||
parent.append(typeof child === "object" ? child : String(child));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remplace le contenu d'un élément.
|
||||
* @param {Element} el
|
||||
* @param {...Child} children
|
||||
*/
|
||||
export function replace(el, ...children) {
|
||||
el.replaceChildren();
|
||||
append(el, children);
|
||||
}
|
||||
|
||||
/**
|
||||
* Couleur d'accent d'une séance (donnée du programme) : variable CSS posée par
|
||||
* le CSSOM, permise par une CSP sans 'unsafe-inline', contrairement à un
|
||||
* attribut style.
|
||||
* @param {HTMLElement} el
|
||||
* @param {string|undefined} color #RRGGBB
|
||||
* @param {string} ink couleur du texte posé sur l'accent
|
||||
*/
|
||||
export function setAccent(el, color, ink) {
|
||||
if (!color) return;
|
||||
el.style.setProperty("--accent", color);
|
||||
el.style.setProperty("--accent-ink", ink);
|
||||
}
|
||||
|
||||
/** Vibration courte, si l'appareil sait le faire. @param {number[]} pattern */
|
||||
export function vibrate(pattern) {
|
||||
try {
|
||||
if ("vibrate" in navigator) navigator.vibrate(pattern);
|
||||
} catch {
|
||||
// vibration indisponible : sans conséquence
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Le brouillon de la séance en cours est gardé dans le stockage local du
|
||||
// navigateur : un rechargement de la page ou un téléphone mis en veille ne le
|
||||
// perd pas. Ce n'est pas un événement (ADR 0006, point 3) : il ne se synchronise
|
||||
// pas et disparaît quand la séance est terminée.
|
||||
|
||||
const KEY = "ia-fit.draft";
|
||||
|
||||
/** @returns {unknown} */
|
||||
export function loadDraft() {
|
||||
try {
|
||||
const raw = localStorage.getItem(KEY);
|
||||
return raw ? JSON.parse(raw) : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {import("./session-draft.js").Draft} draft */
|
||||
export function saveDraft(draft) {
|
||||
try {
|
||||
localStorage.setItem(KEY, JSON.stringify(draft));
|
||||
} catch {
|
||||
// stockage plein ou interdit (navigation privée) : le brouillon reste en mémoire
|
||||
}
|
||||
}
|
||||
|
||||
export function clearDraft() {
|
||||
try {
|
||||
localStorage.removeItem(KEY);
|
||||
} catch {
|
||||
// rien à effacer
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
// Carte d'un exercice dans la séance : consignes, tutoriel, charge, séries.
|
||||
//
|
||||
// Piège d'Atelier (docs/lot-1.md) : ne jamais reconstruire une zone qui contient
|
||||
// un champ en cours de saisie. Ici, une frappe ne met à jour que des libellés
|
||||
// (refreshLabels) ; la zone de saisie n'est reconstruite (drawWork) que lorsque le
|
||||
// mode de suivi change, par un bouton, donc sans champ actif.
|
||||
|
||||
import { h, replace } from "./dom.js";
|
||||
import { MUSCLES, EXERCISES } from "../domain/exercises.js";
|
||||
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";
|
||||
|
||||
/**
|
||||
* @typedef {object} ExerciseCardOptions
|
||||
* @property {import("./session-draft.js").DraftExercise} ex exercice du brouillon (modifié sur place)
|
||||
* @property {import("../domain/program.js").ProgramExercise} item
|
||||
* @property {string} sessionKey
|
||||
* @property {string} number « 3 »
|
||||
* @property {string|null} letter « A » dans un superset
|
||||
* @property {boolean} open
|
||||
* @property {import("./store.js").Store} store
|
||||
* @property {import("./timer.js").Timer} timer
|
||||
* @property {() => void} onChange le brouillon a changé (à garder, compteur de séries)
|
||||
*/
|
||||
|
||||
/** @param {ExerciseCardOptions} o */
|
||||
export function exerciseCard(o) {
|
||||
const { ex, item, store, timer } = o;
|
||||
const resolved = resolveExercise(item);
|
||||
const library = item.ref ? EXERCISES[item.ref] ?? null : null;
|
||||
|
||||
const sub = h("span", { class: "exercise__sub" });
|
||||
const count = h("span", { class: "exercise__count" });
|
||||
const objective = h("span", { class: "objective__value" });
|
||||
const work = h("div", { class: "work" });
|
||||
const tracking = h("div", { class: "segmented", role: "group", "aria-label": "Ce que je suis" });
|
||||
|
||||
const refreshLabels = () => {
|
||||
const load = usesLoad(ex.tracking) && ex.loadKg !== null ? ` · ${kg(ex.loadKg)} kg` : "";
|
||||
sub.textContent = `${targetLabel(ex)}${load} · repos ${restLabel(ex.rest)}`;
|
||||
count.textContent = `${doneCount(ex)}/${ex.sets}`;
|
||||
count.classList.toggle("exercise__count--done", doneCount(ex) === ex.sets);
|
||||
objective.textContent = targetLabel(ex);
|
||||
};
|
||||
|
||||
const changed = () => {
|
||||
refreshLabels();
|
||||
o.onChange();
|
||||
};
|
||||
|
||||
// ---- séries ----------------------------------------------------------------
|
||||
/** @type {HTMLButtonElement[]} */
|
||||
let setButtons = [];
|
||||
const panelSlot = h("div", { class: "work__panel" });
|
||||
/** @type {number|null} */
|
||||
let openPanel = null;
|
||||
/** @type {HTMLButtonElement|null} */
|
||||
let chronoBtn = 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) : "✓";
|
||||
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(", ");
|
||||
b.setAttribute("aria-label", `Série ${i + 1} : ${what}`);
|
||||
b.setAttribute("aria-expanded", String(openPanel === i));
|
||||
});
|
||||
};
|
||||
|
||||
const closePanel = () => {
|
||||
openPanel = null;
|
||||
panelSlot.replaceChildren();
|
||||
paintSets();
|
||||
};
|
||||
|
||||
/** @param {number} i */
|
||||
const showPanel = (i) => {
|
||||
if (openPanel === i) return closePanel();
|
||||
openPanel = i;
|
||||
const existing = ex.done[i];
|
||||
const timed = usesTime(ex.tracking);
|
||||
let reps = typeof existing?.reps === "number" ? existing.reps : proposedReps(ex, i);
|
||||
const range = targetReps(ex.reps);
|
||||
const value = h("output", { class: "stepper__value", "aria-live": "polite" }, String(reps));
|
||||
const step = (/** @type {number} */ d) => { reps = Math.max(0, reps + d); value.textContent = String(reps); };
|
||||
|
||||
const panel = h("div", { class: "set-panel", role: "group", "aria-label": `Série ${i + 1}` },
|
||||
h("p", { class: "set-panel__title" }, `Série ${i + 1}`,
|
||||
timed ? ` · ${ex.seconds} s` : range ? ` · objectif ${range.low === range.high ? range.low : range.low + "–" + range.high} répétitions` : ""),
|
||||
!timed && h("div", { class: "stepper" },
|
||||
h("button", { type: "button", class: "stepper__btn", "aria-label": "Une répétition de moins", on: { click: () => step(-1) } }, "−"),
|
||||
value,
|
||||
h("button", { type: "button", class: "stepper__btn", "aria-label": "Une répétition de plus", on: { click: () => step(1) } }, "+"),
|
||||
h("span", { class: "stepper__unit" }, "répétitions")),
|
||||
h("p", { class: "set-panel__ask" }, "Ressenti ?"),
|
||||
h("div", { class: "effort-picker" }, EFFORTS.map((effort) =>
|
||||
h("button", {
|
||||
type: "button", class: "effort", data: { effort },
|
||||
"aria-pressed": String(existing?.effort === effort),
|
||||
on: { click: () => {
|
||||
ex.done[i] = { reps: timed ? null : reps, effort };
|
||||
closePanel();
|
||||
changed();
|
||||
// Le repos démarre au ressenti.
|
||||
if (ex.rest > 0) timer.startRest(ex.rest, `Repos · ${ex.name}`);
|
||||
} },
|
||||
}, h("span", { class: "effort__label" }, EFFORT_LABELS[effort].label), h("span", { class: "effort__hint" }, EFFORT_LABELS[effort].hint)))),
|
||||
existing && h("button", {
|
||||
type: "button", class: "btn btn--ghost btn--block btn--sm",
|
||||
on: { click: () => { ex.done[i] = null; closePanel(); changed(); } },
|
||||
}, "Annuler cette série"));
|
||||
panelSlot.replaceChildren(panel);
|
||||
paintSets();
|
||||
};
|
||||
|
||||
const startChrono = () => {
|
||||
const i = ex.done.findIndex((s) => s === null);
|
||||
if (i < 0) {
|
||||
if (chronoBtn) chronoBtn.textContent = "Toutes les séries sont faites";
|
||||
return;
|
||||
}
|
||||
const seconds = ex.seconds ?? 45;
|
||||
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 };
|
||||
changed();
|
||||
openPanel = null;
|
||||
showPanel(i);
|
||||
});
|
||||
};
|
||||
|
||||
const refreshChrono = () => {
|
||||
if (chronoBtn) chronoBtn.textContent = `Lancer la série · ${ex.seconds ?? 45} s`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Champ de charge ou de durée. La frappe ne change que le brouillon et les
|
||||
* libellés ; la charge de travail (WorkingLoadSet) est enregistrée à la
|
||||
* validation du champ (événement change : sortie du champ ou touche Entrée).
|
||||
* @param {"loadKg"|"seconds"} field
|
||||
*/
|
||||
const amountField = (field) => {
|
||||
const isLoad = field === "loadKg";
|
||||
const id = `f-${o.sessionKey}-${o.number}-${field}`;
|
||||
const input = h("input", {
|
||||
id, class: "field__input", type: "text", inputmode: "decimal", autocomplete: "off",
|
||||
placeholder: "—", value: ex[field] === null ? "" : kg(/** @type {number} */ (ex[field])),
|
||||
});
|
||||
input.addEventListener("input", () => {
|
||||
const v = parseAmount(input.value);
|
||||
input.setAttribute("aria-invalid", String(v === undefined || (field === "seconds" && v === 0)));
|
||||
if (v === undefined) return;
|
||||
ex[field] = field === "seconds" && !v ? null : v;
|
||||
refreshLabels();
|
||||
refreshChrono();
|
||||
o.onChange();
|
||||
});
|
||||
input.addEventListener("change", () => {
|
||||
const v = parseAmount(input.value);
|
||||
if (v === undefined || (field === "seconds" && !v)) return;
|
||||
const saved = store.getState().workingLoads[ex.key]?.[field] ?? null;
|
||||
if (saved !== v) store.dispatch("WorkingLoadSet", isLoad ? { key: ex.key, loadKg: v } : { key: ex.key, seconds: v });
|
||||
});
|
||||
return h("div", { class: "field field--amount" },
|
||||
h("label", { class: "field__label", for: id }, isLoad ? "Charge" : "Durée"),
|
||||
input,
|
||||
h("span", { class: "field__unit" }, isLoad ? "kg" : "s"));
|
||||
};
|
||||
|
||||
const drawWork = () => {
|
||||
openPanel = null;
|
||||
chronoBtn = 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" },
|
||||
usesTime(ex.tracking) && amountField("seconds"),
|
||||
usesLoad(ex.tracking) && amountField("loadKg"),
|
||||
ex.tracking === "none" && h("p", { class: "muted" }, "Poids du corps : rien à saisir."));
|
||||
if (usesTime(ex.tracking))
|
||||
chronoBtn = h("button", { type: "button", class: "btn btn--block btn--work", on: { click: startChrono } });
|
||||
replace(work,
|
||||
fields,
|
||||
h("div", { class: "set-row", role: "group", "aria-label": "Séries" }, setButtons),
|
||||
panelSlot,
|
||||
chronoBtn);
|
||||
panelSlot.replaceChildren();
|
||||
paintSets();
|
||||
refreshChrono();
|
||||
drawTracking();
|
||||
};
|
||||
|
||||
const drawTracking = () => {
|
||||
replace(tracking, TRACKING_MODES.map((mode) =>
|
||||
h("button", {
|
||||
type: "button", class: "segmented__opt", "aria-pressed": String(mode === ex.tracking),
|
||||
on: { click: () => {
|
||||
if (mode === ex.tracking) return;
|
||||
const programMode = trackingFor(item, undefined);
|
||||
store.dispatch("TrackingModeSet", { key: ex.key, mode: mode === programMode ? null : mode });
|
||||
const fresh = draftExercise(o.sessionKey, item, store.getState());
|
||||
ex.tracking = fresh.tracking;
|
||||
ex.loadKg = fresh.loadKg;
|
||||
ex.seconds = fresh.seconds;
|
||||
drawWork();
|
||||
changed();
|
||||
/** @type {HTMLElement|null} */ (tracking.querySelector("[aria-pressed=true]"))?.focus();
|
||||
} },
|
||||
}, TRACKING_LABELS[mode])));
|
||||
};
|
||||
|
||||
// ---- consignes ---------------------------------------------------------------
|
||||
const muscles = library
|
||||
? h("ul", { class: "chips", "aria-label": "Muscles sollicités" },
|
||||
library.primary.map((m) => h("li", { class: "chip" }, MUSCLES[m]?.name ?? m)),
|
||||
library.secondary.map((m) => h("li", { class: "chip chip--secondary" }, MUSCLES[m]?.name ?? m)))
|
||||
: null;
|
||||
|
||||
const card = h("details", { class: "exercise", open: o.open },
|
||||
h("summary", { class: "exercise__head" },
|
||||
h("span", { class: "badge", "aria-hidden": "true" }, o.number),
|
||||
h("span", { class: "exercise__name" },
|
||||
h("strong", null, o.letter && h("span", { class: "tag" }, o.letter), resolved.name),
|
||||
sub),
|
||||
count,
|
||||
h("span", { class: "chevron", "aria-hidden": "true" })),
|
||||
h("div", { class: "exercise__body" },
|
||||
resolved.note && h("p", { class: "coach-note" }, resolved.note),
|
||||
muscles,
|
||||
resolved.cues.length > 0 && [h("h3", { class: "mini-label" }, "Le geste"),
|
||||
h("ul", { class: "cues" }, resolved.cues.map((c) => h("li", null, c)))],
|
||||
resolved.mistakes.length > 0 && [h("h3", { class: "mini-label" }, "À éviter"),
|
||||
h("ul", { class: "mistakes" }, resolved.mistakes.map((c) => h("li", null, c)))],
|
||||
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.
|
||||
work,
|
||||
h("div", { class: "tracking" }, h("span", { class: "mini-label" }, "Je suis"), tracking)));
|
||||
|
||||
drawWork();
|
||||
refreshLabels();
|
||||
return card;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// Retours à l'utilisateur : message bref (toast) et demande de confirmation.
|
||||
|
||||
import { h } from "./dom.js";
|
||||
|
||||
/** @type {HTMLElement|null} */
|
||||
let toastNode = null;
|
||||
/** @type {ReturnType<typeof setTimeout>|null} */
|
||||
let toastTimer = null;
|
||||
|
||||
/**
|
||||
* Message bref en bas de l'écran, lu par les lecteurs d'écran.
|
||||
* @param {string} message
|
||||
*/
|
||||
export function toast(message) {
|
||||
if (!toastNode) {
|
||||
toastNode = h("div", { class: "toast", role: "status", "aria-live": "polite" });
|
||||
document.body.append(toastNode);
|
||||
}
|
||||
toastNode.textContent = message;
|
||||
toastNode.classList.add("toast--on");
|
||||
if (toastTimer) clearTimeout(toastTimer);
|
||||
toastTimer = setTimeout(() => toastNode?.classList.remove("toast--on"), 3500);
|
||||
}
|
||||
|
||||
/**
|
||||
* Demande de confirmation dans une boîte de dialogue native (<dialog>).
|
||||
* @param {{title: string, lines?: string[], confirm: string, cancel?: string, danger?: boolean}} options
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
export function confirmDialog({ title, lines = [], confirm, cancel = "Annuler", danger = false }) {
|
||||
return new Promise((resolve) => {
|
||||
const yes = h("button", { type: "button", class: `btn btn--block ${danger ? "btn--danger" : "btn--primary"}` }, confirm);
|
||||
const no = h("button", { type: "button", class: "btn btn--block btn--ghost" }, cancel);
|
||||
const dialog = h("dialog", { class: "dialog", "aria-labelledby": "dialog-title" },
|
||||
h("h2", { class: "dialog__title", id: "dialog-title" }, title),
|
||||
lines.map((l) => h("p", { class: "dialog__text" }, l)),
|
||||
h("div", { class: "dialog__actions" }, yes, no));
|
||||
/** @param {boolean} answer */
|
||||
const done = (answer) => {
|
||||
dialog.close();
|
||||
dialog.remove();
|
||||
resolve(answer);
|
||||
};
|
||||
yes.addEventListener("click", () => done(true));
|
||||
no.addEventListener("click", () => done(false));
|
||||
dialog.addEventListener("cancel", (e) => { e.preventDefault(); done(false); });
|
||||
document.body.append(dialog);
|
||||
dialog.showModal();
|
||||
no.focus();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
// Mise en forme pour l'affichage, en français. Fonctions pures, testées.
|
||||
// À brancher : dates.js (domaine, sous-lot 1b) fournira les calculs de jours ;
|
||||
// ici, seulement ce que l'interface affiche.
|
||||
|
||||
/**
|
||||
* Jour local AAAA-MM-JJ (pas UTC : une séance faite à 23 h reste le bon jour).
|
||||
* @param {Date} [d]
|
||||
*/
|
||||
export function localDay(d = new Date()) {
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
/** @param {string} day AAAA-MM-JJ */
|
||||
const noon = (day) => new Date(day + "T12:00:00");
|
||||
|
||||
/** « jeudi 18 novembre » @param {string} day */
|
||||
export function longDay(day) {
|
||||
return noon(day).toLocaleDateString("fr-FR", { weekday: "long", day: "numeric", month: "long" });
|
||||
}
|
||||
|
||||
/** « 18/11 » @param {string} day */
|
||||
export function shortDay(day) {
|
||||
return noon(day).toLocaleDateString("fr-FR", { day: "2-digit", month: "2-digit" });
|
||||
}
|
||||
|
||||
/** « 18 nov. 2026 » @param {string} day */
|
||||
export function mediumDay(day) {
|
||||
return noon(day).toLocaleDateString("fr-FR", { day: "numeric", month: "short", year: "numeric" });
|
||||
}
|
||||
|
||||
/** Chrono : 90 → « 1:30 », 5 → « 0:05 ». @param {number} seconds */
|
||||
export function clock(seconds) {
|
||||
const s = Math.max(0, Math.round(seconds));
|
||||
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
/** Repos lisible : 90 → « 1 min 30 », 45 → « 45 s », 120 → « 2 min ». @param {number} seconds */
|
||||
export function restLabel(seconds) {
|
||||
if (seconds < 60) return `${seconds} s`;
|
||||
const m = Math.floor(seconds / 60), s = seconds % 60;
|
||||
return s ? `${m} min ${String(s).padStart(2, "0")}` : `${m} min`;
|
||||
}
|
||||
|
||||
/** Charge : 62.5 → « 62,5 ». @param {number} kg */
|
||||
export function kg(kg) {
|
||||
return String(kg).replace(".", ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* Lit un nombre saisi (virgule ou point), positif ou nul. Champ vide : null.
|
||||
* Texte illisible : undefined (la saisie est refusée).
|
||||
* @param {string} text
|
||||
* @returns {number|null|undefined}
|
||||
*/
|
||||
export function parseAmount(text) {
|
||||
const t = text.trim().replace(",", ".");
|
||||
if (t === "") return null;
|
||||
const n = Number(t);
|
||||
return Number.isFinite(n) && n >= 0 ? n : undefined;
|
||||
}
|
||||
|
||||
/** Accord simple : plural(3, "série") → « 3 séries ». @param {number} n @param {string} word */
|
||||
export function plural(n, word) {
|
||||
return `${n} ${word}${n > 1 ? "s" : ""}`;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// Ce que l'accueil affiche, calculé à partir de l'état. Module pur, testé.
|
||||
//
|
||||
// À brancher : planning.weekPlan(state, monday) (domaine, sous-lot 1b). Tant
|
||||
// qu'il n'existe pas, la carte du jour propose la séance faite le moins
|
||||
// récemment (rotation simple) et le dit à l'utilisateur.
|
||||
|
||||
import { groupBlocks, resolveExercise, targetSeconds } from "../domain/program.js";
|
||||
|
||||
/**
|
||||
* Dernière date (AAAA-MM-JJ) où chaque séance de force a été faite.
|
||||
* @param {import("../domain/state.js").State} state
|
||||
* @returns {Record<string, string>}
|
||||
*/
|
||||
export function lastDoneByKey(state) {
|
||||
/** @type {Record<string, string>} */
|
||||
const last = {};
|
||||
for (const s of state.sessions)
|
||||
if (s.kind === "strength" && (!last[s.ref] || s.date > last[s.ref])) last[s.ref] = s.date;
|
||||
return last;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prochaine séance par rotation : une séance jamais faite d'abord (dans l'ordre
|
||||
* du programme), sinon celle faite le moins récemment.
|
||||
* @param {import("../domain/state.js").State} state
|
||||
* @returns {import("../domain/program.js").ProgramSession|null}
|
||||
*/
|
||||
export function nextByRotation(state) {
|
||||
const sessions = state.program?.sessions ?? [];
|
||||
if (!sessions.length) return null;
|
||||
const last = lastDoneByKey(state);
|
||||
const never = sessions.find((s) => !last[s.key]);
|
||||
if (never) return never;
|
||||
return [...sessions].sort((a, b) => (last[a.key] < last[b.key] ? -1 : last[a.key] > last[b.key] ? 1 : 0))[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Durée estimée d'une séance, en minutes, arrondie à 5 : dix minutes
|
||||
* d'échauffement, puis pour chaque bloc le travail des séries et les repos
|
||||
* (40 s par série quand l'objectif est en répétitions). Reprise d'Atelier.
|
||||
* @param {import("../domain/program.js").ProgramSession} session
|
||||
*/
|
||||
export function estimateMinutes(session) {
|
||||
let total = 10 * 60;
|
||||
for (const block of groupBlocks(session.exercises)) {
|
||||
const items = block.items.map(resolveExercise);
|
||||
const rounds = Math.max(...items.map((x) => x.sets));
|
||||
const work = items.reduce((n, x) => n + (targetSeconds(x.reps) ?? 40), 0);
|
||||
const rest = items.reduce((n, x) => n + x.rest, 0);
|
||||
total += rounds * work + (rounds - 1) * rest + 45 * items.length;
|
||||
}
|
||||
return Math.round(total / 60 / 5) * 5;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Libellés français des valeurs fermées du domaine (app/domain/vocabulary.js).
|
||||
|
||||
/** @type {Record<import("../domain/vocabulary.js").TrackingMode, string>} */
|
||||
export const TRACKING_LABELS = {
|
||||
load: "Charge",
|
||||
time: "Durée",
|
||||
"time+load": "Durée et charge",
|
||||
none: "Rien à saisir",
|
||||
};
|
||||
|
||||
/**
|
||||
* Ressenti d'une série. Glossaire : docs/glossaire/ressenti.md
|
||||
* @type {Record<import("../domain/vocabulary.js").Effort, {label: string, hint: string}>}
|
||||
*/
|
||||
export const EFFORT_LABELS = {
|
||||
easy: { label: "Facile", hint: "3 répétitions ou plus en réserve" },
|
||||
ok: { label: "Correct", hint: "1 ou 2 répétitions en réserve" },
|
||||
hard: { label: "Dur", hint: "Rien en réserve" },
|
||||
failure: { label: "Échec", hint: "Série non terminée" },
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
// Morceaux de mise en page communs aux écrans.
|
||||
|
||||
import { h } from "./dom.js";
|
||||
|
||||
/**
|
||||
* En-tête d'écran : surtitre, titre en capitales condensées, sous-titre.
|
||||
* @param {{kicker?: string, title: string, sub?: string|null, back?: {label: string, onClick: () => void}}} o
|
||||
*/
|
||||
export function screenHeader({ kicker, title, sub, back }) {
|
||||
return h("header", { class: "screen-head" },
|
||||
back && h("button", { type: "button", class: "back", on: { click: back.onClick } },
|
||||
h("span", { "aria-hidden": "true" }, "← "), back.label),
|
||||
kicker && h("p", { class: "kicker" }, kicker),
|
||||
h("h1", { class: "title" }, title),
|
||||
sub && h("p", { class: "lede" }, sub));
|
||||
}
|
||||
|
||||
/**
|
||||
* Titre de section.
|
||||
* @param {string} text
|
||||
* @param {string} [hint]
|
||||
*/
|
||||
export function sectionLabel(text, hint) {
|
||||
return h("h2", { class: "section-label" }, text, hint && h("span", { class: "section-label__hint" }, hint));
|
||||
}
|
||||
|
||||
/**
|
||||
* Barre d'action collée en bas de l'écran, à portée de pouce.
|
||||
* @param {...(Node|null|false)} children
|
||||
*/
|
||||
export function actionBar(...children) {
|
||||
return h("div", { class: "action-bar" }, h("div", { class: "action-bar__in" }, ...children));
|
||||
}
|
||||
|
||||
/**
|
||||
* Petite carte de texte (cardio, repères).
|
||||
* @param {string} title
|
||||
* @param {string} text
|
||||
*/
|
||||
export function note(title, text) {
|
||||
return h("article", { class: "note" }, h("h3", { class: "note__title" }, title), h("p", { class: "note__text" }, text));
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
// Premier lancement : pas de programme, pas de proposition en attente.
|
||||
// But : un programme dans l'app en moins de deux minutes, construit avec l'IA
|
||||
// de l'utilisateur (ADR 0005, point 7 : le circuit par lien).
|
||||
|
||||
import { h } from "./dom.js";
|
||||
import { actionBar } from "./layout.js";
|
||||
import { toast } from "./feedback.js";
|
||||
import { exampleProgram, onboardingBrief } from "./pending.js";
|
||||
|
||||
/** Consigne courte pour une IA qui sait lire une page web. */
|
||||
export const AI_GUIDE_URL = "https://ia-fit.sans.pub/ia.md";
|
||||
|
||||
/**
|
||||
* @param {{store: import("./store.js").Store}} o
|
||||
*/
|
||||
export function onboarding({ store }) {
|
||||
const status = h("p", { class: "status status--info", role: "status", "aria-live": "polite" });
|
||||
const manual = h("div", { class: "manual-copy", hidden: true });
|
||||
|
||||
const copyBrief = async () => {
|
||||
const text = await onboardingBrief(location.origin);
|
||||
if (!text) {
|
||||
// À brancher : ai-brief.buildOnboardingBrief({baseUrl}) (autre sous-agent).
|
||||
status.textContent = "Le texte à donner à ton IA arrive bientôt. En attendant, dis-lui de lire " + AI_GUIDE_URL + ".";
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
status.textContent = "Copié. Colle-le maintenant dans ton IA.";
|
||||
toast("Texte copié.");
|
||||
} catch {
|
||||
// Presse-papiers refusé (http, navigateur ancien) : copie à la main.
|
||||
const area = h("textarea", { class: "field__input field__input--area", readonly: true, "aria-label": "Texte à copier dans ton IA" });
|
||||
area.value = text;
|
||||
manual.replaceChildren(h("p", { class: "muted" }, "Copie ce texte à la main :"), area);
|
||||
manual.hidden = false;
|
||||
area.select();
|
||||
status.textContent = "";
|
||||
}
|
||||
};
|
||||
|
||||
const startFromExample = async () => {
|
||||
const program = await exampleProgram();
|
||||
if (!program) {
|
||||
// À brancher : example-program.EXAMPLE_PROGRAM (autre sous-agent).
|
||||
toast("Le programme d'exemple arrive bientôt.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
store.dispatch("ProgramProposed", {
|
||||
program,
|
||||
source: /** @type {any} */ ("example"),
|
||||
reason: "Programme d'exemple : trois séances à domicile avec barre, haltères, banc et élastiques. Ton IA pourra l'adapter ensuite.",
|
||||
});
|
||||
} catch (e) {
|
||||
toast("Le programme d'exemple n'a pas pu être proposé : " + (e instanceof Error ? e.message : String(e)));
|
||||
}
|
||||
};
|
||||
|
||||
const copyGuide = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(`Lis ${AI_GUIDE_URL}`);
|
||||
toast("Phrase copiée.");
|
||||
} catch {
|
||||
toast("Copie impossible : recopie l'adresse à la main.");
|
||||
}
|
||||
};
|
||||
|
||||
return h("div", { class: "onboarding" },
|
||||
h("header", { class: "screen-head hero" },
|
||||
h("p", { class: "kicker" }, "IA-Fit"),
|
||||
h("h1", { class: "title title--hero" }, "Ton programme, construit avec ton IA"),
|
||||
h("p", { class: "lede" }, "Puis suivi séance par séance : séries, charges, repos. Tes données restent sur ton appareil, sans compte.")),
|
||||
|
||||
h("section", { class: "card card--onboarding", "aria-labelledby": "onb-how" },
|
||||
h("h2", { class: "card__title", id: "onb-how" }, "En trois gestes"),
|
||||
h("ol", { class: "how" },
|
||||
h("li", { class: "how__step" }, h("strong", null, "Copie le texte"), h("span", null, " et colle-le dans ton IA : Claude, ChatGPT, Le Chat…")),
|
||||
h("li", { class: "how__step" }, h("strong", null, "Réponds à ses questions"), h("span", null, ", ou montre-lui ton programme actuel : export d'une autre app, texte, captures d'écran.")),
|
||||
h("li", { class: "how__step" }, h("strong", null, "Touche le lien qu'elle te renvoie"), h("span", null, " : ton programme s'affiche ici, et tu le valides."))),
|
||||
status,
|
||||
manual,
|
||||
h("p", { class: "card__hint" }, "Ou, si ton IA sait lire une page web, dis-lui simplement :"),
|
||||
h("div", { class: "copy-line" },
|
||||
h("code", { class: "copy-line__text" }, `lis ${AI_GUIDE_URL}`),
|
||||
h("button", { type: "button", class: "btn btn--sm btn--ghost", on: { click: copyGuide } }, "Copier")),
|
||||
h("p", { class: "card__hint" }, "Connecteur MCP pour ton IA : bientôt.")),
|
||||
|
||||
h("section", { class: "alt", "aria-label": "Autres façons de commencer" },
|
||||
h("button", { type: "button", class: "btn btn--block", on: { click: startFromExample } }, "Partir d'un programme d'exemple"),
|
||||
// À brancher : import d'un instantané (snapshot.js, autre sous-agent).
|
||||
h("button", { type: "button", class: "btn btn--block btn--ghost", disabled: true, "aria-describedby": "onb-restore" }, "Restaurer une sauvegarde"),
|
||||
h("p", { class: "muted", id: "onb-restore" }, "Restaurer une sauvegarde : bientôt.")),
|
||||
|
||||
h("footer", { class: "foot" }, "Rien ne part sur un serveur : ce que tu colles dans ton IA, c'est toi qui le choisis."),
|
||||
|
||||
actionBar(h("button", { type: "button", class: "btn btn--primary btn--block btn--lg", on: { click: copyBrief } }, "Créer mon programme avec mon IA")));
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Modules du domaine utilisés par l'accueil.
|
||||
import { buildOnboardingBrief } from "../domain/ai-brief.js";
|
||||
import { EXAMPLE_PROGRAM } from "../domain/example-program.js";
|
||||
|
||||
/** Le prompt d'onboarding à coller dans son IA. @param {string} baseUrl */
|
||||
export async function onboardingBrief(baseUrl) {
|
||||
return buildOnboardingBrief({ baseUrl });
|
||||
}
|
||||
|
||||
/** Le programme d'exemple (celui d'Atelier). */
|
||||
export async function exampleProgram() {
|
||||
return structuredClone(EXAMPLE_PROGRAM);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// Une proposition de programme en attente : un aperçu simple, « Adopter » ou
|
||||
// « Refuser ». Glossaire : docs/glossaire/proposition.md
|
||||
//
|
||||
// À brancher (sous-lot 1e) : l'écran de proposition avec l'aperçu détaillé des
|
||||
// changements (exercices ajoutés, retirés, modifiés). Ce rendu provisoire montre
|
||||
// le programme proposé tel quel.
|
||||
|
||||
import { h } from "./dom.js";
|
||||
import { plural } from "./format.js";
|
||||
import { resolveExercise } from "../domain/program.js";
|
||||
import { toast } from "./feedback.js";
|
||||
|
||||
/** @type {Record<string, string>} */
|
||||
const SOURCE_LABELS = {
|
||||
ai: "Proposé par ton IA",
|
||||
link: "Reçu par un lien",
|
||||
import: "Venu d'une sauvegarde",
|
||||
atelier: "Repris d'Atelier",
|
||||
example: "Programme d'exemple",
|
||||
default: "Programme de départ",
|
||||
app: "Modifié dans l'app",
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {{proposal: import("../domain/state.js").Proposal, store: import("./store.js").Store}} o
|
||||
*/
|
||||
export function proposalCard({ proposal, store }) {
|
||||
const p = proposal.program;
|
||||
// Le profil proposé est facultatif (onboarding par l'IA) : adopté avec le programme.
|
||||
const profile = /** @type {any} */ (proposal).profile;
|
||||
|
||||
const adopt = () => {
|
||||
store.dispatch("ProgramAdopted", { program: p, source: proposal.source, proposalId: proposal.id, ...(proposal.reason ? { reason: proposal.reason } : {}) });
|
||||
if (profile) store.dispatch("ProfileUpdated", { profile });
|
||||
toast(`Programme « ${p.name} » adopté.`);
|
||||
};
|
||||
const reject = () => {
|
||||
store.dispatch("ProposalRejected", { proposalId: proposal.id });
|
||||
toast("Proposition refusée.");
|
||||
};
|
||||
|
||||
return h("section", { class: "card card--proposal", "aria-labelledby": `prop-${proposal.id}` },
|
||||
h("p", { class: "kicker" }, "À valider · ", SOURCE_LABELS[proposal.source] ?? proposal.source),
|
||||
h("h2", { class: "card__title", id: `prop-${proposal.id}` }, p.name),
|
||||
p.subtitle && h("p", { class: "card__text" }, p.subtitle),
|
||||
proposal.reason && h("p", { class: "coach-note" }, proposal.reason),
|
||||
h("ul", { class: "preview" }, p.sessions.map((s) =>
|
||||
h("li", { class: "preview__session" },
|
||||
h("strong", null, `Séance ${s.key} · ${s.name}`),
|
||||
h("span", { class: "muted" }, `${plural(s.exercises.length, "exercice")} : ${s.exercises.map((x) => resolveExercise(x).name).join(", ")}`)))),
|
||||
profile && h("p", { class: "muted" }, "Ton profil (objectif, matériel, contraintes) sera aussi mis à jour."),
|
||||
h("div", { class: "card__actions" },
|
||||
h("button", { type: "button", class: "btn btn--primary btn--block btn--lg", on: { click: adopt } }, "Adopter ce programme"),
|
||||
h("button", { type: "button", class: "btn btn--ghost btn--block", on: { click: reject } }, "Refuser")));
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
// Un écran par adresse, dans le fragment (#/…) : l'app reste un site statique
|
||||
// et le bouton retour du navigateur fonctionne.
|
||||
//
|
||||
// Les fragments #import= (lien d'une IA, ADR 0005 point 7) et #pair=
|
||||
// (appariement, lot 2) sont réservés : le routeur ne les interprète pas et ne
|
||||
// les réécrit pas. À brancher : link.js (#import=), appariement (#pair=).
|
||||
|
||||
/**
|
||||
* @typedef {{name: "home"}
|
||||
* | {name: "session", key: string}
|
||||
* | {name: "history"}
|
||||
* | {name: "history-edit", id: string}
|
||||
* | {name: "reserved"}
|
||||
* | {name: "not-found"}} Route
|
||||
*/
|
||||
|
||||
/** Fragments réservés à d'autres modules. */
|
||||
export const RESERVED = ["#import=", "#pair="];
|
||||
|
||||
/**
|
||||
* Lit une adresse. Fonction pure, testée.
|
||||
* @param {string} hash location.hash, avec son #
|
||||
* @returns {Route}
|
||||
*/
|
||||
export function parseRoute(hash) {
|
||||
if (RESERVED.some((p) => hash.startsWith(p))) return { name: "reserved" };
|
||||
const path = hash.replace(/^#\/?/, "").replace(/\/+$/, "");
|
||||
if (path === "") return { name: "home" };
|
||||
const parts = path.split("/").map((p) => {
|
||||
try { return decodeURIComponent(p); } catch { return p; }
|
||||
});
|
||||
if (parts[0] === "seance" && parts.length === 2 && parts[1]) return { name: "session", key: parts[1] };
|
||||
if (parts[0] === "historique" && parts.length === 1) return { name: "history" };
|
||||
if (parts[0] === "historique" && parts.length === 2 && parts[1]) return { name: "history-edit", id: parts[1] };
|
||||
return { name: "not-found" };
|
||||
}
|
||||
|
||||
/** Adresses, pour écrire les liens sans les recopier. */
|
||||
export const href = {
|
||||
home: () => "#/",
|
||||
session: (/** @type {string} */ key) => "#/seance/" + encodeURIComponent(key),
|
||||
history: () => "#/historique",
|
||||
historyEdit: (/** @type {string} */ id) => "#/historique/" + encodeURIComponent(id),
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {object} Screen
|
||||
* @property {HTMLElement} node
|
||||
* @property {string} title titre de l'onglet
|
||||
* @property {() => void} [destroy] appelé quand on quitte l'écran
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} Navigation
|
||||
* @property {(hash: string, options?: {replace?: boolean}) => void} go
|
||||
* @property {(fallback?: string) => void} back retour dans l'app, ou vers fallback
|
||||
*/
|
||||
|
||||
/**
|
||||
* Branche le routeur sur la fenêtre.
|
||||
* @param {HTMLElement} root
|
||||
* @param {(route: Route, nav: Navigation) => Screen} render
|
||||
*/
|
||||
export function startRouter(root, render) {
|
||||
/** Adresses vues pendant la visite, pour savoir si « retour » reste dans l'app. */
|
||||
const visited = [location.hash];
|
||||
/** @type {Screen|null} */
|
||||
let current = null;
|
||||
|
||||
/** @type {Navigation} */
|
||||
const nav = {
|
||||
go(hash, { replace = false } = {}) {
|
||||
if (replace) {
|
||||
history.replaceState(null, "", hash);
|
||||
visited[visited.length - 1] = hash;
|
||||
show();
|
||||
} else location.hash = hash;
|
||||
},
|
||||
back(fallback = href.home()) {
|
||||
if (visited.length > 1) history.back();
|
||||
else nav.go(fallback, { replace: true });
|
||||
},
|
||||
};
|
||||
|
||||
const show = () => {
|
||||
let route = parseRoute(location.hash);
|
||||
// Un fragment réservé ne change pas l'écran ; au démarrage, on montre l'accueil.
|
||||
if (route.name === "reserved") {
|
||||
if (current) return;
|
||||
route = { name: "home" };
|
||||
}
|
||||
current?.destroy?.();
|
||||
current = render(route, nav);
|
||||
root.replaceChildren(current.node);
|
||||
document.title = current.title ? `${current.title} · IA-Fit` : "IA-Fit";
|
||||
window.scrollTo(0, 0);
|
||||
// Le focus suit l'écran (lecteurs d'écran, clavier).
|
||||
const heading = current.node.querySelector("h1");
|
||||
if (heading) {
|
||||
heading.setAttribute("tabindex", "-1");
|
||||
heading.focus({ preventScroll: true });
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("hashchange", () => {
|
||||
if (visited.length > 1 && visited[visited.length - 2] === location.hash) visited.pop();
|
||||
else visited.push(location.hash);
|
||||
show();
|
||||
});
|
||||
show();
|
||||
return nav;
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
// Historique : la liste des séances faites, et la correction ou la suppression
|
||||
// d'une séance passée (SessionCorrected, SessionDeleted).
|
||||
|
||||
import { h, replace } from "../dom.js";
|
||||
import { kg, localDay, longDay, mediumDay, parseAmount } from "../format.js";
|
||||
import { actionBar, screenHeader, sectionLabel } from "../layout.js";
|
||||
import { href } from "../router.js";
|
||||
import { sessionDataOf, sessionSummary, usesLoad, usesTime } from "../session-draft.js";
|
||||
import { confirmDialog, toast } from "../feedback.js";
|
||||
|
||||
/**
|
||||
* @param {{store: import("../store.js").Store, nav: import("../router.js").Navigation}} ctx
|
||||
* @returns {import("../router.js").Screen}
|
||||
*/
|
||||
export function historyScreen({ store, nav }) {
|
||||
const list = h("div", { class: "history" });
|
||||
const paint = () => {
|
||||
const sessions = [...store.getState().sessions].reverse();
|
||||
if (!sessions.length) {
|
||||
replace(list, h("p", { class: "empty" }, "Aucune séance enregistrée pour l'instant. Termine ta première séance : elle apparaîtra ici."));
|
||||
return;
|
||||
}
|
||||
replace(list, h("ul", { class: "history__list" }, sessions.map((s) =>
|
||||
h("li", null, h("a", { class: "history__item", href: href.historyEdit(s.id) },
|
||||
h("span", { class: "history__date" }, mediumDay(s.date)),
|
||||
h("span", { class: "history__name" }, s.name),
|
||||
h("span", { class: "history__meta" }, sessionSummary(s) || kindLabel(s.kind)),
|
||||
h("span", { class: "chevron", "aria-hidden": "true" }))))));
|
||||
};
|
||||
paint();
|
||||
const unsubscribe = store.subscribe(paint);
|
||||
const node = h("div", { class: "screen" },
|
||||
screenHeader({ back: { label: "Accueil", onClick: () => nav.back(href.home()) }, kicker: "Ton parcours", title: "Historique", sub: "Touche une séance pour la corriger ou la retirer." }),
|
||||
list);
|
||||
return { node, title: "Historique", destroy: unsubscribe };
|
||||
}
|
||||
|
||||
/** @param {string} kind */
|
||||
const kindLabel = (kind) => (kind === "cardio" ? "Cardio" : kind === "activity" ? "Activité" : "Séance");
|
||||
|
||||
/**
|
||||
* Correction d'une séance passée. Le formulaire travaille sur une copie ; rien
|
||||
* n'est enregistré avant « Enregistrer les modifications ».
|
||||
* @param {{store: import("../store.js").Store, nav: import("../router.js").Navigation, id: string}} ctx
|
||||
* @returns {import("../router.js").Screen}
|
||||
*/
|
||||
export function historyEditScreen({ store, nav, id }) {
|
||||
const back = { label: "Historique", onClick: () => nav.back(href.history()) };
|
||||
const logged = store.getState().sessions.find((s) => s.id === id);
|
||||
if (!logged) {
|
||||
return {
|
||||
title: "Séance introuvable",
|
||||
node: h("div", { class: "screen" }, screenHeader({ back, title: "Séance introuvable", sub: "Elle a peut-être été retirée de l'historique." })),
|
||||
};
|
||||
}
|
||||
const data = sessionDataOf(logged);
|
||||
const today = localDay();
|
||||
const status = h("p", { class: "status", role: "alert" });
|
||||
|
||||
const dateInput = h("input", { id: "edit-date", class: "field__input field__input--date", type: "date", max: today, value: data.date });
|
||||
dateInput.addEventListener("change", () => {
|
||||
if (/^\d{4}-\d{2}-\d{2}$/.test(dateInput.value) && dateInput.value <= today) data.date = dateInput.value;
|
||||
else dateInput.value = data.date;
|
||||
});
|
||||
|
||||
/** @type {Set<HTMLInputElement>} */
|
||||
const invalid = new Set();
|
||||
/**
|
||||
* Champ numérique qui écrit dans la copie à chaque frappe (aucune
|
||||
* reconstruction : le focus reste).
|
||||
* @param {string} label
|
||||
* @param {number|null} value
|
||||
* @param {(v: number|null) => void} write
|
||||
* @param {string} unit
|
||||
*/
|
||||
const numberField = (label, value, write, unit) => {
|
||||
const input = h("input", { class: "field__input", type: "text", inputmode: "decimal", autocomplete: "off", placeholder: "—", "aria-label": label, value: value === null ? "" : kg(value) });
|
||||
input.addEventListener("input", () => {
|
||||
const v = parseAmount(input.value);
|
||||
input.setAttribute("aria-invalid", String(v === undefined));
|
||||
if (v === undefined) invalid.add(input);
|
||||
else { invalid.delete(input); write(v); }
|
||||
});
|
||||
return h("span", { class: "field field--amount field--compact" }, input, h("span", { class: "field__unit" }, unit));
|
||||
};
|
||||
|
||||
const exercises = data.exercises.map((x) => {
|
||||
const sets = h("div", { class: "edit-sets" });
|
||||
const drawSets = () => {
|
||||
replace(sets,
|
||||
x.sets.map((s, i) => h("div", { class: "edit-set" },
|
||||
h("span", { class: "edit-set__n" }, `Série ${i + 1}`),
|
||||
// Série au temps : la durée est celle de l'exercice, pas de répétitions à corriger.
|
||||
usesTime(x.tracking) && s.reps === null
|
||||
? h("span", { class: "muted" }, "Faite")
|
||||
: numberField(`Répétitions de la série ${i + 1}, ${x.name}`, s.reps, (v) => { s.reps = v === null ? null : Math.round(v); }, "rép."))),
|
||||
h("div", { class: "edit-sets__btns" },
|
||||
h("button", { type: "button", class: "btn btn--sm", on: { click: () => {
|
||||
const prev = x.sets[x.sets.length - 1];
|
||||
x.sets.push({ reps: prev?.reps ?? null, effort: null });
|
||||
drawSets();
|
||||
} } }, "+ Série"),
|
||||
x.sets.length > 0 && h("button", { type: "button", class: "btn btn--sm btn--ghost", on: { click: () => { x.sets.pop(); drawSets(); } } }, "− Série")));
|
||||
};
|
||||
drawSets();
|
||||
return h("li", { class: "edit-ex" },
|
||||
h("div", { class: "edit-ex__head" },
|
||||
h("strong", null, x.name),
|
||||
h("span", { class: "muted" }, x.target)),
|
||||
h("div", { class: "work__fields" },
|
||||
usesLoad(x.tracking) && numberField(`Charge, ${x.name}`, x.loadKg, (v) => { x.loadKg = v; }, "kg"),
|
||||
usesTime(x.tracking) && numberField(`Durée, ${x.name}`, x.seconds, (v) => { x.seconds = v; }, "s")),
|
||||
sets);
|
||||
});
|
||||
|
||||
const save = () => {
|
||||
if (invalid.size) {
|
||||
status.textContent = "Un nombre est illisible : corrige le champ signalé.";
|
||||
return;
|
||||
}
|
||||
try {
|
||||
store.dispatch("SessionCorrected", { sessionId: id, session: data });
|
||||
} catch (e) {
|
||||
status.textContent = "La correction n'a pas pu être enregistrée : " + (e instanceof Error ? e.message : String(e));
|
||||
return;
|
||||
}
|
||||
toast("Séance corrigée.");
|
||||
nav.back(href.history());
|
||||
};
|
||||
|
||||
const remove = async () => {
|
||||
const ok = await confirmDialog({
|
||||
title: "Retirer cette séance ?",
|
||||
lines: [`${data.name}, ${longDay(data.date)}.`, "Elle disparaît de l'historique et des calculs de progression."],
|
||||
confirm: "Retirer la séance", cancel: "Garder", danger: true,
|
||||
});
|
||||
if (!ok) return;
|
||||
store.dispatch("SessionDeleted", { sessionId: id });
|
||||
toast("Séance retirée de l'historique.");
|
||||
nav.back(href.history());
|
||||
};
|
||||
|
||||
const node = h("div", { class: "screen" },
|
||||
screenHeader({ back, kicker: mediumDay(logged.date), title: "Corriger", sub: logged.name }),
|
||||
h("div", { class: "field field--inline" }, h("label", { class: "field__label", for: "edit-date" }, "Date"), dateInput),
|
||||
data.exercises.length > 0 && [sectionLabel("Exercices", "séries faites et charge"), h("ul", { class: "edit-list" }, exercises)],
|
||||
sectionLabel("Retirer"),
|
||||
h("button", { type: "button", class: "btn btn--danger btn--block", on: { click: remove } }, "Retirer cette séance de l'historique"),
|
||||
status,
|
||||
actionBar(h("button", { type: "button", class: "btn btn--primary btn--block btn--lg", on: { click: save } }, "Enregistrer les modifications")));
|
||||
return { node, title: "Corriger une séance" };
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
// Accueil. Par priorité : une proposition en attente, sinon l'onboarding s'il
|
||||
// n'y a pas encore de programme, sinon la carte du jour, les séances, le
|
||||
// cardio et les repères.
|
||||
|
||||
import { h, setAccent } from "../dom.js";
|
||||
import { inkOn, sessionColor } from "../color.js";
|
||||
import { longDay, localDay, shortDay, plural } from "../format.js";
|
||||
import { estimateMinutes, lastDoneByKey, nextByRotation } from "../home-model.js";
|
||||
import { actionBar, note, screenHeader, sectionLabel } from "../layout.js";
|
||||
import { href } from "../router.js";
|
||||
import { onboarding } from "../onboarding.js";
|
||||
import { proposalCard } from "../proposal-card.js";
|
||||
|
||||
/**
|
||||
* Un programme a-t-il été adopté ? Il n'y a pas de programme par défaut
|
||||
* (décision du porteur du projet, 2026-11-18) : tant qu'aucun ProgramAdopted
|
||||
* n'est au journal, l'accueil montre l'onboarding.
|
||||
* @param {import("../../domain/state.js").State} state
|
||||
*/
|
||||
export const hasProgram = (state) => !!state.program && state.programVersions.length > 0;
|
||||
|
||||
/**
|
||||
* @param {{store: import("../store.js").Store}} ctx
|
||||
* @returns {import("../router.js").Screen}
|
||||
*/
|
||||
export function homeScreen({ store }) {
|
||||
const node = h("div", { class: "screen screen--home" });
|
||||
// L'accueil n'a aucun champ de saisie : le reconstruire à chaque changement est sans risque.
|
||||
const paint = () => node.replaceChildren(homeContent(store));
|
||||
paint();
|
||||
return { node, title: "", destroy: store.subscribe(paint) };
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../store.js").Store} store
|
||||
* @returns {Node}
|
||||
*/
|
||||
function homeContent(store) {
|
||||
const state = store.getState();
|
||||
// Une proposition en attente passe avant tout le reste.
|
||||
if (state.proposals.length) {
|
||||
return h("div", null,
|
||||
h("header", { class: "screen-head" }, h("p", { class: "kicker" }, "IA-Fit"), h("h1", { class: "title" }, "Un programme t'attend")),
|
||||
state.proposals.map((proposal) => proposalCard({ proposal, store })));
|
||||
}
|
||||
if (!hasProgram(state)) return onboarding({ store });
|
||||
|
||||
const program = /** @type {import("../../domain/program.js").Program} */ (state.program);
|
||||
const last = lastDoneByKey(state);
|
||||
const today = localDay();
|
||||
|
||||
// À brancher : planning.weekPlan(state, monday) donnera le créneau du jour
|
||||
// (séance, cardio, activité, repos), les créneaux en retard et l'avancement de
|
||||
// la semaine. En attendant : rotation simple, annoncée comme telle.
|
||||
const next = nextByRotation(state);
|
||||
|
||||
const todayCard = next
|
||||
? sessionLink(next, "card card--today", [
|
||||
h("p", { class: "kicker" }, "Aujourd'hui · ", longDay(today)),
|
||||
h("p", { class: "card__eyebrow" }, h("span", { class: "swatch", "aria-hidden": "true" }), `Séance ${next.key}`),
|
||||
h("h2", { class: "card__title" }, next.name),
|
||||
h("p", { class: "card__meta" },
|
||||
`${plural(next.exercises.length, "exercice")} · environ ${estimateMinutes(next)} min`,
|
||||
last[next.key] ? ` · faite le ${shortDay(last[next.key])}` : " · jamais faite"),
|
||||
next.subtitle && h("p", { class: "card__text" }, next.subtitle),
|
||||
h("p", { class: "card__hint" },
|
||||
"Proposée par rotation : la séance faite le moins récemment. Le planning de la semaine arrive bientôt."),
|
||||
])
|
||||
: h("div", { class: "card card--today" }, h("p", { class: "card__text" }, "Le programme ne contient aucune séance."));
|
||||
|
||||
return h("div", null,
|
||||
screenHeader({ kicker: "IA-Fit", title: program.name, sub: program.subtitle }),
|
||||
todayCard,
|
||||
|
||||
sectionLabel("Séances"),
|
||||
h("ul", { class: "plates" }, program.sessions.map((s) =>
|
||||
h("li", null, sessionLink(s, "plate", [
|
||||
h("span", { class: "plate__bar", "aria-hidden": "true" }),
|
||||
h("span", { class: "plate__body" },
|
||||
h("span", { class: "plate__id" }, `Séance ${s.key}${s.tag ? " · " + s.tag : ""}`),
|
||||
h("span", { class: "plate__name" }, s.name),
|
||||
h("span", { class: "plate__meta" }, `${plural(s.exercises.length, "exercice")} · environ ${estimateMinutes(s)} min`)),
|
||||
h("span", { class: "plate__last" }, last[s.key] ? `Faite le ${shortDay(last[s.key])}` : "Jamais faite"),
|
||||
])))),
|
||||
|
||||
program.cardio?.length ? [sectionLabel("Cardio"), program.cardio.map((c) => note(c.name, c.text))] : null,
|
||||
program.rules?.length ? [sectionLabel("Repères"), program.rules.map((r) => note(r.name, r.text))] : null,
|
||||
|
||||
sectionLabel("Aller plus loin"),
|
||||
h("nav", { class: "links", "aria-label": "Autres écrans" },
|
||||
h("a", { class: "btn btn--block btn--ghost", href: href.history() }, "Historique des séances"),
|
||||
// À brancher (sous-lot 1d) : semaine, activités, poids, données, profil.
|
||||
h("p", { class: "muted" }, "Semaine, activités, poids et sauvegarde : bientôt.")),
|
||||
|
||||
h("footer", { class: "foot" }, "Tes données restent sur cet appareil."),
|
||||
|
||||
next && actionBar(h("a", { class: "btn btn--primary btn--block btn--lg", href: href.session(next.key) },
|
||||
`Commencer la séance ${next.key}`)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Lien vers une séance, coloré par sa couleur.
|
||||
* @param {import("../../domain/program.js").ProgramSession} s
|
||||
* @param {string} cls
|
||||
* @param {import("../dom.js").Child[]} children
|
||||
*/
|
||||
function sessionLink(s, cls, children) {
|
||||
const a = h("a", { class: cls, href: href.session(s.key) }, ...children);
|
||||
const color = sessionColor(s.color);
|
||||
setAccent(a, color, inkOn(color));
|
||||
return a;
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
// La séance guidée : échauffement, blocs et supersets, séries, minuteur.
|
||||
// Le brouillon est local ; « Terminer » crée un seul SessionLogged.
|
||||
|
||||
import { h, setAccent } from "../dom.js";
|
||||
import { groupBlocks, resolveExercise } from "../../domain/program.js";
|
||||
import { inkOn, sessionColor } from "../color.js";
|
||||
import { localDay, longDay, plural } from "../format.js";
|
||||
import { estimateMinutes } from "../home-model.js";
|
||||
import { actionBar, screenHeader } from "../layout.js";
|
||||
import { href } from "../router.js";
|
||||
import { buildSessionData, completion, createDraft, doneCount, draftMatches } from "../session-draft.js";
|
||||
import { clearDraft, loadDraft, saveDraft } from "../draft-storage.js";
|
||||
import { exerciseCard } from "../exercise-card.js";
|
||||
import { WARMUP_STEPS, warmupCard } from "../warmup-card.js";
|
||||
import { confirmDialog, toast } from "../feedback.js";
|
||||
|
||||
/**
|
||||
* @param {{store: import("../store.js").Store, key: string, nav: import("../router.js").Navigation, timer: import("../timer.js").Timer}} ctx
|
||||
* @returns {import("../router.js").Screen}
|
||||
*/
|
||||
export function sessionScreen({ store, key, nav, timer }) {
|
||||
const state = store.getState();
|
||||
const session = state.program?.sessions.find((s) => s.key === key);
|
||||
const back = { label: "Accueil", onClick: () => nav.back(href.home()) };
|
||||
if (!session) {
|
||||
return {
|
||||
title: "Séance introuvable",
|
||||
node: h("div", { class: "screen" },
|
||||
screenHeader({ back, title: "Séance introuvable", sub: `Le programme n'a pas de séance « ${key} ».` })),
|
||||
};
|
||||
}
|
||||
|
||||
const today = localDay();
|
||||
const stored = loadDraft();
|
||||
const draft = draftMatches(stored, session, WARMUP_STEPS.length)
|
||||
? stored
|
||||
: createDraft(session, state, today, WARMUP_STEPS.length);
|
||||
const resumed = draft === stored;
|
||||
|
||||
const progress = h("span", { class: "action-bar__meta", "aria-live": "polite" });
|
||||
const status = h("p", { class: "status", role: "alert" });
|
||||
const totalSets = draft.exercises.reduce((n, ex) => n + ex.sets, 0);
|
||||
const paintProgress = () => {
|
||||
const done = draft.exercises.reduce((n, ex) => n + doneCount(ex), 0);
|
||||
progress.textContent = `${done}/${totalSets} séries`;
|
||||
};
|
||||
// Le brouillon n'est gardé qu'au premier changement : ouvrir une séance pour
|
||||
// la regarder n'écrase pas celle qu'on a commencée.
|
||||
const onChange = () => {
|
||||
saveDraft(draft);
|
||||
paintProgress();
|
||||
status.textContent = "";
|
||||
};
|
||||
|
||||
// ---- date de la séance (saisie a posteriori possible) ------------------------
|
||||
const dateNotice = h("p", { class: "coach-note", hidden: draft.date === today });
|
||||
const paintDate = () => {
|
||||
dateNotice.hidden = draft.date === today;
|
||||
dateNotice.textContent = `Cette séance sera enregistrée au ${longDay(draft.date)}.`;
|
||||
};
|
||||
const dateInput = h("input", { id: "session-date", class: "field__input field__input--date", type: "date", max: today, value: draft.date });
|
||||
dateInput.addEventListener("change", () => {
|
||||
const value = dateInput.value;
|
||||
draft.date = /^\d{4}-\d{2}-\d{2}$/.test(value) && value <= today ? value : today;
|
||||
if (draft.date !== value) dateInput.value = draft.date;
|
||||
paintDate();
|
||||
onChange();
|
||||
});
|
||||
paintDate();
|
||||
|
||||
// ---- blocs ---------------------------------------------------------------------
|
||||
const color = sessionColor(session.color);
|
||||
const firstOpen = draft.exercises.findIndex((ex) => doneCount(ex) < ex.sets);
|
||||
let index = 0;
|
||||
const blocks = groupBlocks(session.exercises).map((block) => {
|
||||
const cards = block.items.map((item, k) => {
|
||||
const i = index++;
|
||||
return exerciseCard({
|
||||
ex: draft.exercises[i], item, sessionKey: session.key, number: String(i + 1),
|
||||
letter: block.items.length > 1 ? String.fromCharCode(65 + k) : null,
|
||||
open: resumed && i === firstOpen, store, timer, onChange,
|
||||
});
|
||||
});
|
||||
if (block.items.length === 1) return cards[0];
|
||||
const names = block.items.map((item) => resolveExercise(item).name).join(" + ");
|
||||
const rounds = Math.max(...block.items.map((item) => item.sets));
|
||||
return h("section", { class: "superset", "aria-label": `Superset : ${names}` },
|
||||
h("div", { class: "superset__head" },
|
||||
h("span", { class: "tag tag--superset" }, "Superset"),
|
||||
h("p", { class: "superset__text" }, `${rounds} tours : enchaîne les exercices, le vrai repos vient après le dernier.`)),
|
||||
cards);
|
||||
});
|
||||
|
||||
const finish = async () => {
|
||||
const c = completion(draft);
|
||||
if (c.doneSets === 0) {
|
||||
status.textContent = "Aucune série validée : rien à enregistrer.";
|
||||
return;
|
||||
}
|
||||
if (!c.complete) {
|
||||
const lines = [];
|
||||
if (c.missing.length)
|
||||
lines.push(`${plural(c.missing.length, "exercice")} pas commencé${c.missing.length > 1 ? "s" : ""} : ${c.missing.slice(0, 3).join(", ")}${c.missing.length > 3 ? "…" : "."}`);
|
||||
if (c.partial.length) lines.push(`${plural(c.partial.length, "exercice")} incomplet${c.partial.length > 1 ? "s" : ""}.`);
|
||||
lines.push("Tu pourras la corriger ensuite depuis l'historique.");
|
||||
const ok = await confirmDialog({ title: "La séance n'est pas finie", lines, confirm: "Enregistrer quand même", cancel: "Continuer la séance" });
|
||||
if (!ok) return;
|
||||
}
|
||||
try {
|
||||
store.dispatch("SessionLogged", buildSessionData(draft));
|
||||
} catch (e) {
|
||||
status.textContent = "La séance n'a pas pu être enregistrée : " + (e instanceof Error ? e.message : String(e));
|
||||
return;
|
||||
}
|
||||
clearDraft();
|
||||
timer.stop();
|
||||
toast(draft.date === today ? "Séance enregistrée." : `Séance enregistrée au ${longDay(draft.date)}.`);
|
||||
nav.go(href.home(), { replace: true });
|
||||
};
|
||||
|
||||
const node = h("div", { class: "screen screen--session" },
|
||||
screenHeader({
|
||||
back,
|
||||
kicker: `Séance ${session.key}${session.tag ? " · " + session.tag : ""} · environ ${estimateMinutes(session)} min`,
|
||||
title: session.name,
|
||||
sub: session.subtitle,
|
||||
}),
|
||||
resumed && h("p", { class: "coach-note" }, "Séance reprise là où tu l'avais laissée."),
|
||||
h("div", { class: "field field--inline" },
|
||||
h("label", { class: "field__label", for: "session-date" }, "Date de la séance"),
|
||||
dateInput),
|
||||
dateNotice,
|
||||
h("div", { class: "exercises" },
|
||||
warmupCard({ done: draft.warmup, timer, onChange, open: !resumed }),
|
||||
blocks),
|
||||
status,
|
||||
h("p", { class: "foot" }, "Touche une série pour noter tes répétitions et ton ressenti : le repos démarre tout seul."),
|
||||
actionBar(progress, h("button", { type: "button", class: "btn btn--primary btn--lg", on: { click: finish } }, "Terminer la séance")));
|
||||
setAccent(node, color, inkOn(color));
|
||||
paintProgress();
|
||||
|
||||
return { node, title: session.name, destroy: () => timer.stop() };
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
// La séance en cours : un brouillon local, jamais un événement par série
|
||||
// (ADR 0006, point 3). « Terminer » le transforme en un seul SessionLogged.
|
||||
// Module pur (sans DOM), testé dans tests/ui/session-draft.test.js.
|
||||
|
||||
import { resolveExercise, exerciseKey, trackingFor, targetSeconds } from "../domain/program.js";
|
||||
|
||||
/** @typedef {import("../domain/vocabulary.js").TrackingMode} TrackingMode */
|
||||
/** @typedef {import("../domain/events.js").LoggedSet} LoggedSet */
|
||||
/** @typedef {import("../domain/events.js").SessionData} SessionData */
|
||||
|
||||
/**
|
||||
* @typedef {object} DraftExercise
|
||||
* @property {string} key clé de charge et de mode de suivi : « A-squat »
|
||||
* @property {string} id clé stable de l'exercice (ref, sinon nom)
|
||||
* @property {string} name
|
||||
* @property {number} sets séries prévues
|
||||
* @property {string} reps objectif de répétitions du programme (« 6–8 »)
|
||||
* @property {number} rest repos en secondes
|
||||
* @property {TrackingMode} tracking
|
||||
* @property {number|null} loadKg charge du jour (modes avec charge)
|
||||
* @property {number|null} seconds durée d'une série (modes au temps)
|
||||
* @property {(LoggedSet|null)[]} done une case par série prévue, null tant qu'elle n'est pas faite
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} Draft
|
||||
* @property {string} sessionKey
|
||||
* @property {string} name
|
||||
* @property {string} date jour local AAAA-MM-JJ de la séance
|
||||
* @property {boolean[]} warmup étapes d'échauffement cochées
|
||||
* @property {DraftExercise[]} exercises
|
||||
*/
|
||||
|
||||
/** Durée par défaut d'une série au temps quand le programme n'en donne pas. */
|
||||
export const DEFAULT_SECONDS = 45;
|
||||
|
||||
/** @param {TrackingMode} mode */
|
||||
export const usesLoad = (mode) => mode === "load" || mode === "time+load";
|
||||
/** @param {TrackingMode} mode */
|
||||
export const usesTime = (mode) => mode === "time" || mode === "time+load";
|
||||
|
||||
/**
|
||||
* Exercice du brouillon, lu dans le programme et l'état (charge de travail, mode
|
||||
* de suivi choisi).
|
||||
* @param {string} sessionKey
|
||||
* @param {import("../domain/program.js").ProgramExercise} item
|
||||
* @param {import("../domain/state.js").State} state
|
||||
* @returns {DraftExercise}
|
||||
*/
|
||||
export function draftExercise(sessionKey, item, state) {
|
||||
const ex = resolveExercise(item);
|
||||
const key = exerciseKey(sessionKey, item);
|
||||
const tracking = trackingFor(item, state.trackingOverrides[key]);
|
||||
const saved = state.workingLoads[key];
|
||||
return {
|
||||
key,
|
||||
id: ex.id,
|
||||
name: ex.name,
|
||||
sets: ex.sets,
|
||||
reps: ex.reps,
|
||||
rest: ex.rest,
|
||||
tracking,
|
||||
loadKg: usesLoad(tracking) ? saved?.loadKg ?? null : null,
|
||||
seconds: usesTime(tracking) ? saved?.seconds ?? targetSeconds(ex.reps) ?? DEFAULT_SECONDS : null,
|
||||
done: Array(ex.sets).fill(null),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../domain/program.js").ProgramSession} session
|
||||
* @param {import("../domain/state.js").State} state
|
||||
* @param {string} date
|
||||
* @param {number} warmupSteps
|
||||
* @returns {Draft}
|
||||
*/
|
||||
export function createDraft(session, state, date, warmupSteps) {
|
||||
return {
|
||||
sessionKey: session.key,
|
||||
name: session.name,
|
||||
date,
|
||||
warmup: Array(warmupSteps).fill(false),
|
||||
exercises: session.exercises.map((item) => draftExercise(session.key, item, state)),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Un brouillon gardé (rechargement de la page, téléphone verrouillé) est repris
|
||||
* s'il porte sur la même séance du programme, avec les mêmes exercices.
|
||||
* @param {unknown} draft
|
||||
* @param {import("../domain/program.js").ProgramSession} session
|
||||
* @param {number} warmupSteps
|
||||
* @returns {draft is Draft}
|
||||
*/
|
||||
export function draftMatches(draft, session, warmupSteps) {
|
||||
const d = /** @type {any} */ (draft);
|
||||
if (!d || d.sessionKey !== session.key || !Array.isArray(d.exercises) || !Array.isArray(d.warmup)) return false;
|
||||
if (d.warmup.length !== warmupSteps || d.exercises.length !== session.exercises.length) return false;
|
||||
return session.exercises.every((item, i) => {
|
||||
const ex = resolveExercise(item);
|
||||
const x = d.exercises[i];
|
||||
return x && x.id === ex.id && Array.isArray(x.done) && x.done.length === ex.sets;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Objectif lisible : « 4 × 8 », « 3 × 40 s ».
|
||||
* @param {DraftExercise} ex
|
||||
*/
|
||||
export function targetLabel(ex) {
|
||||
return usesTime(ex.tracking) ? `${ex.sets} × ${ex.seconds ?? DEFAULT_SECONDS} s` : `${ex.sets} × ${ex.reps}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fourchette de répétitions d'un objectif : « 6–8 » → {low: 6, high: 8}. Null si
|
||||
* l'objectif est un temps ou n'a pas de nombre.
|
||||
* @param {string} reps
|
||||
* @returns {{low: number, high: number}|null}
|
||||
*/
|
||||
export function targetReps(reps) {
|
||||
if (targetSeconds(reps) !== null) return null;
|
||||
const m = /(\d+)\s*(?:[–-]\s*(\d+))?/.exec(reps || "");
|
||||
if (!m) return null;
|
||||
const low = Number(m[1]);
|
||||
return { low, high: m[2] ? Number(m[2]) : low };
|
||||
}
|
||||
|
||||
/**
|
||||
* Répétitions proposées pour une série : celles de la série précédente faite,
|
||||
* sinon le haut de la fourchette.
|
||||
* @param {DraftExercise} ex
|
||||
* @param {number} index
|
||||
*/
|
||||
export function proposedReps(ex, index) {
|
||||
for (let i = index - 1; i >= 0; i--) {
|
||||
const reps = ex.done[i]?.reps;
|
||||
if (typeof reps === "number") return reps;
|
||||
}
|
||||
return targetReps(ex.reps)?.high ?? 0;
|
||||
}
|
||||
|
||||
/** @param {DraftExercise} ex */
|
||||
export const doneCount = (ex) => ex.done.filter((s) => s !== null).length;
|
||||
|
||||
/**
|
||||
* Où en est la séance : exercices pas commencés et incomplets.
|
||||
* @param {Draft} draft
|
||||
*/
|
||||
export function completion(draft) {
|
||||
const doneSets = draft.exercises.reduce((n, ex) => n + doneCount(ex), 0);
|
||||
const missing = draft.exercises.filter((ex) => doneCount(ex) === 0).map((ex) => ex.name);
|
||||
const partial = draft.exercises.filter((ex) => doneCount(ex) > 0 && doneCount(ex) < ex.sets).map((ex) => ex.name);
|
||||
return { doneSets, missing, partial, complete: missing.length === 0 && partial.length === 0 };
|
||||
}
|
||||
|
||||
/**
|
||||
* Le contenu du SessionLogged (docs/evenements.md). Tous les exercices
|
||||
* prévus y figurent, avec leurs seules séries faites : un exercice sauté garde
|
||||
* `sets: []`, ce qui reste visible dans l'historique et les analyses.
|
||||
* @param {Draft} draft
|
||||
* @returns {SessionData}
|
||||
*/
|
||||
export function buildSessionData(draft) {
|
||||
return {
|
||||
date: draft.date,
|
||||
kind: "strength",
|
||||
ref: draft.sessionKey,
|
||||
name: draft.name,
|
||||
warmup: draft.warmup.length ? { done: draft.warmup.filter(Boolean).length, total: draft.warmup.length } : null,
|
||||
exercises: draft.exercises.map((ex) => ({
|
||||
id: ex.id,
|
||||
name: ex.name,
|
||||
target: targetLabel(ex),
|
||||
tracking: ex.tracking,
|
||||
loadKg: usesLoad(ex.tracking) ? ex.loadKg : null,
|
||||
seconds: usesTime(ex.tracking) ? ex.seconds : null,
|
||||
plannedSets: ex.sets,
|
||||
sets: /** @type {LoggedSet[]} */ (ex.done.filter((s) => s !== null)).map((s) => ({ reps: s.reps, effort: s.effort })),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Le contenu d'une séance enregistrée, sans ce que le repli ajoute (id,
|
||||
* loggedAt) : la base d'un SessionCorrected.
|
||||
* @param {import("../domain/state.js").LoggedSession} logged
|
||||
* @returns {SessionData}
|
||||
*/
|
||||
export function sessionDataOf(logged) {
|
||||
const { id: _id, loggedAt: _at, ...data } = structuredClone(logged);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Résumé d'une séance enregistrée : « 5 exercices · 17 séries ».
|
||||
* @param {SessionData} s
|
||||
*/
|
||||
export function sessionSummary(s) {
|
||||
const sets = s.exercises.reduce((n, x) => n + x.sets.length, 0);
|
||||
const done = s.exercises.filter((x) => x.sets.length > 0).length;
|
||||
if (s.kind !== "strength") return "";
|
||||
return `${done} exercice${done > 1 ? "s" : ""} · ${sets} série${sets > 1 ? "s" : ""}`;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// Le magasin de l'interface : il tient le journal (les événements), l'appareil
|
||||
// et l'état replié. Chaque intention passe par dispatch, qui crée UN événement
|
||||
// métier validé, l'ajoute au journal, recalcule l'état et prévient les abonnés.
|
||||
// Sans DOM : testé sous Node (tests/ui/store.test.js).
|
||||
//
|
||||
// À brancher : event-store.js (app/infra/, stockage IndexedDB, autre sous-agent).
|
||||
// Le journal vit pour l'instant en mémoire : il est perdu au rechargement.
|
||||
|
||||
import { createEvent } from "../domain/events.js";
|
||||
import { foldEvents } from "../domain/state.js";
|
||||
import { randomId } from "../domain/ids.js";
|
||||
|
||||
/** @typedef {import("../domain/events.js").DomainEvent} DomainEvent */
|
||||
/** @typedef {import("../domain/events.js").EventType} EventType */
|
||||
/** @typedef {import("../domain/state.js").State} State */
|
||||
|
||||
/**
|
||||
* @typedef {object} Store
|
||||
* @property {string} device
|
||||
* @property {() => State} getState
|
||||
* @property {() => readonly DomainEvent[]} getEvents
|
||||
* @property {<T extends EventType>(type: T, data: Extract<DomainEvent, {type: T}>["data"]) => Extract<DomainEvent, {type: T}>} dispatch
|
||||
* @property {(events: DomainEvent[]) => void} load remplace le journal (au démarrage)
|
||||
* @property {(fn: (state: State) => void) => () => void} subscribe renvoie de quoi se désabonner
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {{events?: DomainEvent[], device?: string, onAppend?: (event: DomainEvent) => void}} [options]
|
||||
* onAppend : appelé pour chaque événement créé (persistance, à brancher)
|
||||
* @returns {Store}
|
||||
*/
|
||||
export function createStore(options = {}) {
|
||||
// Provisoire : l'identifiant d'appareil sera gardé par event-store.js.
|
||||
const device = options.device ?? "browser-" + randomId();
|
||||
/** @type {DomainEvent[]} */
|
||||
let events = [...(options.events ?? [])];
|
||||
let state = foldEvents(events);
|
||||
/** @type {Set<(state: State) => void>} */
|
||||
const listeners = new Set();
|
||||
const notify = () => { for (const fn of [...listeners]) fn(state); };
|
||||
|
||||
return {
|
||||
device,
|
||||
getState: () => state,
|
||||
getEvents: () => events,
|
||||
dispatch(type, data) {
|
||||
const event = createEvent(type, /** @type {any} */ (data), { device });
|
||||
events = [...events, event];
|
||||
state = foldEvents(events);
|
||||
options.onAppend?.(event);
|
||||
notify();
|
||||
return event;
|
||||
},
|
||||
load(list) {
|
||||
events = [...list];
|
||||
state = foldEvents(events);
|
||||
notify();
|
||||
},
|
||||
subscribe(fn) {
|
||||
listeners.add(fn);
|
||||
return () => listeners.delete(fn);
|
||||
},
|
||||
};
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
// Le minuteur, fixé en bas de l'écran : repos entre les séries, ou chrono d'une
|
||||
// série au temps. Il se cale sur l'horloge (Date.now) et non sur le nombre de
|
||||
// tics : il reste juste si le téléphone met l'onglet en veille.
|
||||
// Ce n'est pas un événement (ADR 0006, point 3).
|
||||
|
||||
import { h, vibrate } from "./dom.js";
|
||||
import { clock } from "./format.js";
|
||||
|
||||
/**
|
||||
* @typedef {object} Timer
|
||||
* @property {(seconds: number, label: string, endText?: string) => void} startRest
|
||||
* repos, ou toute durée simple (échauffement) ; endText s'affiche à la fin
|
||||
* @property {(seconds: number, label: string, onDone: () => void) => void} startWork
|
||||
* chrono de série : onDone est appelé à la fin, ou si l'on touche « Terminer »
|
||||
* @property {(seconds: number) => void} add
|
||||
* @property {() => void} stop
|
||||
* @property {HTMLElement} node
|
||||
*/
|
||||
|
||||
/** @returns {Timer} */
|
||||
export function createTimer() {
|
||||
const bar = h("div", { class: "timer__bar", "aria-hidden": "true" });
|
||||
const label = h("div", { class: "timer__label" }, "Repos");
|
||||
const time = h("div", { class: "timer__time" }, "0:00");
|
||||
const live = h("div", { class: "visually-hidden", role: "status", "aria-live": "polite" });
|
||||
const close = h("button", { type: "button", class: "btn btn--primary timer__btn" }, "Terminer");
|
||||
const more = h("button", { type: "button", class: "btn timer__btn", "aria-label": "Ajouter 30 secondes" }, "+30 s");
|
||||
const node = h("section", { class: "timer", "aria-label": "Minuteur", hidden: true },
|
||||
bar,
|
||||
h("div", { class: "timer__in" },
|
||||
h("div", { class: "timer__read" }, label, time),
|
||||
h("div", { class: "timer__btns" }, more, close)),
|
||||
live);
|
||||
|
||||
let end = 0, total = 0, labelText = "";
|
||||
/** @type {ReturnType<typeof setInterval>|null} */
|
||||
let tick = null;
|
||||
/** @type {(() => void)|null} */
|
||||
let onDone = null;
|
||||
let work = false;
|
||||
let endText = "Repos terminé";
|
||||
|
||||
const paint = () => {
|
||||
const left = Math.max(0, Math.round((end - Date.now()) / 1000));
|
||||
time.textContent = clock(left);
|
||||
node.classList.toggle("timer--low", left > 0 && left <= 10);
|
||||
node.classList.toggle("timer--zero", left === 0);
|
||||
bar.style.setProperty("--progress", String(total ? left / total : 0));
|
||||
if (left === 0 && tick) finish();
|
||||
};
|
||||
|
||||
const finish = () => {
|
||||
if (tick) clearInterval(tick);
|
||||
tick = null;
|
||||
vibrate(work ? [300, 120, 300, 120, 300] : [180, 90, 180]);
|
||||
label.textContent = work ? "Série terminée" : endText;
|
||||
live.textContent = work ? "Série terminée" : endText;
|
||||
close.textContent = "Fermer";
|
||||
const done = onDone;
|
||||
onDone = null;
|
||||
done?.();
|
||||
};
|
||||
|
||||
/** @param {number} seconds @param {string} text @param {boolean} isWork */
|
||||
const start = (seconds, text, isWork) => {
|
||||
// Un chrono de série interrompu par un nouveau minuteur ne coche rien.
|
||||
onDone = null;
|
||||
work = isWork;
|
||||
labelText = text;
|
||||
total = seconds;
|
||||
end = Date.now() + seconds * 1000;
|
||||
label.textContent = text;
|
||||
live.textContent = "";
|
||||
close.textContent = "Terminer";
|
||||
node.classList.toggle("timer--work", isWork);
|
||||
node.hidden = false;
|
||||
document.body.classList.add("has-timer");
|
||||
if (!tick) tick = setInterval(paint, 250);
|
||||
paint();
|
||||
};
|
||||
|
||||
const stop = () => {
|
||||
if (tick) clearInterval(tick);
|
||||
tick = null;
|
||||
end = 0;
|
||||
onDone = null;
|
||||
node.hidden = true;
|
||||
document.body.classList.remove("has-timer");
|
||||
};
|
||||
|
||||
more.addEventListener("click", () => {
|
||||
if (!end) return;
|
||||
const left = Math.max(0, end - Date.now());
|
||||
end = Date.now() + left + 30_000;
|
||||
total = Math.max(total, Math.round((end - Date.now()) / 1000));
|
||||
label.textContent = labelText;
|
||||
close.textContent = "Terminer";
|
||||
if (!tick) tick = setInterval(paint, 250);
|
||||
paint();
|
||||
});
|
||||
close.addEventListener("click", () => {
|
||||
// « Terminer » pendant un chrono de série : la série est faite.
|
||||
if (tick && onDone) {
|
||||
const done = onDone;
|
||||
onDone = null;
|
||||
stop();
|
||||
done();
|
||||
return;
|
||||
}
|
||||
stop();
|
||||
});
|
||||
|
||||
return {
|
||||
node,
|
||||
startRest: (seconds, text, end = "Repos terminé") => { start(seconds, text, false); endText = end; },
|
||||
startWork: (seconds, text, done) => { start(seconds, text, true); onDone = done; },
|
||||
add: (seconds) => { end += seconds * 1000; total += seconds; paint(); },
|
||||
stop,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// L'échauffement guidé, en tête de séance. Glossaire : docs/glossaire/echauffement.md
|
||||
//
|
||||
// À brancher : warmup.warmupPlan (domaine, sous-lot 1b) calculera les étapes et
|
||||
// les séries d'approche à partir de la charge de travail du premier exercice.
|
||||
// En attendant, les étapes de mobilité sont codées ici (reprises d'Atelier) et
|
||||
// les séries d'approche ne sont pas chiffrées.
|
||||
|
||||
import { h } from "./dom.js";
|
||||
import { restLabel } from "./format.js";
|
||||
|
||||
/** @typedef {{title: string, detail: string, seconds: number}} WarmupStep */
|
||||
|
||||
/** @type {WarmupStep[]} */
|
||||
export const WARMUP_STEPS = [
|
||||
{ title: "Vélo, marche ou corde légère", detail: "Allure tranquille, juste de quoi avoir chaud et le souffle un peu plus court.", seconds: 360 },
|
||||
{ title: "Cercles de bras et rotations d'épaules", detail: "Bras tendus, 10 cercles en avant puis 10 en arrière. Puis les épaules qui montent et descendent.", seconds: 45 },
|
||||
{ title: "Balancements de jambe", detail: "Appuie-toi au mur. 10 balancements avant-arrière par jambe, puis 10 latéraux.", seconds: 60 },
|
||||
{ title: "Squats au poids du corps", detail: "10 répétitions, descente lente, en cherchant un peu plus de profondeur à chaque fois.", seconds: 60 },
|
||||
];
|
||||
|
||||
/**
|
||||
* @param {{done: boolean[], timer: import("./timer.js").Timer, onChange: () => void, open: boolean}} o
|
||||
* done : étapes cochées, modifié sur place
|
||||
*/
|
||||
export function warmupCard(o) {
|
||||
const count = h("span", { class: "exercise__count" });
|
||||
const refresh = () => {
|
||||
const n = o.done.filter(Boolean).length;
|
||||
count.textContent = `${n}/${o.done.length}`;
|
||||
count.classList.toggle("exercise__count--done", n === o.done.length);
|
||||
};
|
||||
|
||||
const steps = WARMUP_STEPS.map((step, i) => {
|
||||
const tick = h("button", {
|
||||
type: "button", class: "tick", "aria-pressed": String(o.done[i]),
|
||||
"aria-label": `Fait : ${step.title}`,
|
||||
});
|
||||
tick.addEventListener("click", () => {
|
||||
o.done[i] = !o.done[i];
|
||||
tick.setAttribute("aria-pressed", String(o.done[i]));
|
||||
refresh();
|
||||
o.onChange();
|
||||
});
|
||||
return h("li", { class: "step" },
|
||||
tick,
|
||||
h("div", { class: "step__text" }, h("strong", null, step.title), h("span", null, step.detail)),
|
||||
h("button", {
|
||||
type: "button", class: "btn btn--sm step__go", "aria-label": `Lancer ${restLabel(step.seconds)} : ${step.title}`,
|
||||
on: { click: () => o.timer.startRest(step.seconds, step.title, "Étape terminée") },
|
||||
}, restLabel(step.seconds)));
|
||||
});
|
||||
|
||||
const card = h("details", { class: "exercise exercise--warmup", open: o.open },
|
||||
h("summary", { class: "exercise__head" },
|
||||
h("span", { class: "badge badge--warmup", "aria-hidden": "true" }, "0"),
|
||||
h("span", { class: "exercise__name" },
|
||||
h("strong", null, "Échauffement"),
|
||||
h("span", { class: "exercise__sub" }, "À faire en premier · environ 10 min")),
|
||||
count,
|
||||
h("span", { class: "chevron", "aria-hidden": "true" })),
|
||||
h("div", { class: "exercise__body" },
|
||||
h("ol", { class: "steps" }, steps),
|
||||
h("h3", { class: "mini-label" }, "Séries d'approche"),
|
||||
h("p", { class: "muted" },
|
||||
"Monte progressivement jusqu'à ta charge du jour sur le premier exercice. Le calcul chiffré des séries d'approche arrive bientôt.")));
|
||||
refresh();
|
||||
return card;
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
# Design
|
||||
|
||||
L'identité d'Atelier, « fonte et craie », reprise et rendue plus lisible : fond
|
||||
sombre couleur de fonte, texte couleur de craie, titres en capitales condensées,
|
||||
une couleur par séance. Pas d'illustration (ADR 0004). Les styles sont dans
|
||||
`app/styles/`, les jetons dans `app/styles/tokens.css`.
|
||||
|
||||
## Règles
|
||||
|
||||
- **Contraste AA partout** : 4,5:1 minimum pour le texte, 3:1 pour le bord des
|
||||
contrôles. Toute nouvelle couleur passe par un jeton, avec son ratio noté.
|
||||
- **Deux thèmes** : sombre par défaut, clair si le système le demande
|
||||
(`prefers-color-scheme`). Les composants n'utilisent que des jetons.
|
||||
- **D'une main, à la salle** : cibles tactiles de 44 px minimum (48 px par défaut),
|
||||
action principale dans une barre collée en bas de l'écran (`.action-bar`), le
|
||||
minuteur s'empile sous cette barre.
|
||||
- **Chiffres tabulaires** (`font-variant-numeric: tabular-nums`) pour les charges,
|
||||
les répétitions et le chrono.
|
||||
- **Hiérarchie** : la carte du jour (`.card--today`) domine l'accueil ; un écran a
|
||||
un seul titre `h1`.
|
||||
- **Aucun style en ligne, aucun script en ligne** (CSP stricte au sous-lot 1f).
|
||||
Seule exception, par le CSSOM : la couleur d'une séance, donnée du programme,
|
||||
posée en variables `--accent` et `--accent-ink` (`setAccent`). La couleur du
|
||||
texte posé dessus est calculée (`inkOn`) pour rester lisible (test : AA).
|
||||
- **La couleur ne porte jamais seule une information** : le ressenti d'une série
|
||||
est aussi dans son libellé (`aria-label`).
|
||||
- **Polices** : Barlow Condensed auto-hébergée (500, 600, 700 ; sous-ensemble latin ;
|
||||
SIL OFL 1.1, `app/fonts/OFL.txt`) pour les titres et les libellés ; police
|
||||
système pour le texte courant. Aucune ressource tierce.
|
||||
- **Mouvement** : transitions courtes, coupées si `prefers-reduced-motion`.
|
||||
|
||||
## Jetons de couleur et contrastes
|
||||
|
||||
Ratios WCAG mesurés (texte sur fond).
|
||||
|
||||
| Jeton | Sombre | Clair | Ratios sombre | Ratios clair |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `--bg` | #14171A | #F3F1EC | | |
|
||||
| `--surface` (cartes) | #1E2328 | #FFFFFF | | |
|
||||
| `--surface-2` (champs) | #272D33 | #E8E5DE | | |
|
||||
| `--surface-sunk` (creux) | #0E1113 | #ECE9E2 | | |
|
||||
| `--text` | #EDEAE3 | #14171A | 15,0 bg · 13,2 surface · 11,6 surface-2 | 15,9 bg · 18,0 surface · 14,3 surface-2 |
|
||||
| `--text-muted` | #A3AAB1 | #555D65 | 7,7 bg · 6,7 surface · 5,9 surface-2 · 8,1 creux | 5,9 bg · 6,7 surface · 5,3 surface-2 · 5,5 creux |
|
||||
| `--primary` | #3FA06A | #2B7A4B | 5,5 bg · 4,9 surface | 4,7 bg · 5,3 surface |
|
||||
| `--on-primary` | #0E1113 | #FFFFFF | 5,8 sur primary | 5,3 sur primary |
|
||||
| `--warn` (note du coach) | #E3B505 | #806200 | 9,3 bg · 8,2 surface | 5,1 bg · 5,7 surface |
|
||||
| `--danger` | #E0787C | #B3262C | 6,1 bg · 5,4 surface | 5,8 bg · 6,5 surface |
|
||||
| `--work` (chrono, superset) | #7FB6CB | #2E6E8A | 8,1 bg · 7,1 surface | 5,0 bg · 5,7 surface |
|
||||
| `--effort-easy` | #3FA06A | #2B7A4B | 4,9 surface | 5,3 surface |
|
||||
| `--effort-ok` | #E3B505 | #806200 | 8,2 surface | 5,7 surface |
|
||||
| `--effort-hard` | #D9762B | #A9531A | 5,0 surface | 5,3 surface |
|
||||
| `--effort-failure` | #EF6B70 | #B3262C | 5,3 surface | 6,5 surface |
|
||||
| `--line-strong` (bord des contrôles) | #6B737B | #8A857B | 3,7 bg · 3,3 surface | 3,3 bg · 3,7 surface |
|
||||
| `--line` (séparateurs décoratifs) | #333A41 | #D6D2C9 | décoratif | décoratif |
|
||||
|
||||
Pour mémoire, le gris secondaire d'Atelier (#5C646C sur #14171A) faisait 3,0:1 ; le
|
||||
nouveau `--text-muted` fait 7,7:1. Les couleurs de séance du programme d'exemple
|
||||
reçoivent un texte à 4,6 (bleu A), 9,8 (jaune B) et 5,1 (rouge C).
|
||||
|
||||
## Typographie et tailles
|
||||
|
||||
- `--font-display` : Barlow Condensed, capitales, interlettrage 0,1 à 0,16 em pour
|
||||
les surtitres et libellés ; 700 pour les titres.
|
||||
- `--font-body` : police système, 16 px, interligne 1,5.
|
||||
- Échelle : 13, 14, 16, 20, 28, 36, 44 px (`--fs-xs` à `--fs-3xl`).
|
||||
- Espaces : 4, 8, 12, 16, 24, 32 px (`--space-1` à `--space-6`), marge latérale
|
||||
16 px, largeur maximale 560 px.
|
||||
|
||||
## Composants
|
||||
|
||||
| Composant | Rôle |
|
||||
| --- | --- |
|
||||
| `.btn` (`--primary`, `--ghost`, `--danger`, `--work`, `--block`, `--lg`, `--sm`) | Bouton ; 48 px de haut, 56 px en `--lg`, 44 px en `--sm` |
|
||||
| `.action-bar` | Barre collée en bas, porte l'action principale de l'écran |
|
||||
| `.card` (`--today`, `--proposal`, `--onboarding`) | Carte ; la carte du jour porte la couleur de sa séance |
|
||||
| `.plate` | Séance dans la liste de l'accueil (barre de couleur, nom, dernière fois) |
|
||||
| `.note` | Texte court : cardio, repères |
|
||||
| `.coach-note` | Remarque du coach ou avertissement doux, filet jaune |
|
||||
| `.chip` (`--secondary`) | Muscle sollicité : plein = principal, pointillé = secondaire |
|
||||
| `.tag`, `.badge` | Lettre de superset, numéro d'exercice (couleur de séance) |
|
||||
| `.exercise` | Exercice repliable (`details`/`summary`), en-tête collant une fois ouvert |
|
||||
| `.superset` | Bloc d'exercices enchaînés, filet `--work` |
|
||||
| `.set-row`, `.set-btn` (`--done`) | Séries : 52 px, la série faite montre ses répétitions et une pastille de ressenti |
|
||||
| `.set-panel`, `.stepper`, `.effort-picker`, `.effort` | Saisie d'une série : répétitions ± et ressenti en quatre boutons |
|
||||
| `.field` (`--amount`, `--inline`, `--compact`) | Champ de saisie (charge, durée, date) |
|
||||
| `.segmented` | Choix exclusif (mode de suivi) |
|
||||
| `.timer` (`--work`, `--low`, `--zero`) | Minuteur fixé en bas : repos, ou chrono d'une série au temps |
|
||||
| `.dialog`, `.toast` | Confirmation (`<dialog>` natif), message bref |
|
||||
| `.step`, `.tick` | Étape d'échauffement et sa case |
|
||||
@@ -0,0 +1,21 @@
|
||||
// Programme de test pour l'interface : indépendant du programme d'exemple.
|
||||
|
||||
/** @type {import("../../app/domain/program.js").Program} */
|
||||
export const PROGRAM = {
|
||||
name: "Programme de test",
|
||||
sessions: [
|
||||
{
|
||||
key: "A",
|
||||
name: "Bas du corps",
|
||||
color: "#3A7FCB",
|
||||
exercises: [
|
||||
{ ref: "squat", sets: 3, reps: "6–8", rest: 120 },
|
||||
{ ref: "band-pull-apart", group: "A1", sets: 2, reps: "15", rest: 20 },
|
||||
{ ref: "plank", group: "A1", tracking: "time", sets: 2, reps: "30–45 s", rest: 60 },
|
||||
{ name: "Pompes lestées", sets: 2, reps: "10", rest: 60, tracking: "load" },
|
||||
],
|
||||
},
|
||||
{ key: "B", name: "Haut du corps", exercises: [{ ref: "bench-press", sets: 3, reps: "8", rest: 90 }] },
|
||||
{ key: "C", name: "Complet", exercises: [{ ref: "deadlift", sets: 3, reps: "5", rest: 180 }] },
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,125 @@
|
||||
// Le brouillon de séance et le SessionLogged qu'il produit (app/ui/session-draft.js).
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { createEvent } from "../../app/domain/events.js";
|
||||
import { foldEvents } from "../../app/domain/state.js";
|
||||
import {
|
||||
buildSessionData, completion, createDraft, draftMatches, proposedReps, sessionDataOf, sessionSummary, targetLabel, targetReps,
|
||||
} from "../../app/ui/session-draft.js";
|
||||
import { PROGRAM } from "./fixtures.js";
|
||||
|
||||
const device = "test";
|
||||
const adopted = createEvent("ProgramAdopted", { program: PROGRAM, source: "ai" }, { device, at: "2026-11-01T10:00:00.000Z" });
|
||||
const A = PROGRAM.sessions[0];
|
||||
|
||||
test("le brouillon reprend la charge de travail et le mode de suivi choisis", () => {
|
||||
const state = foldEvents([
|
||||
adopted,
|
||||
createEvent("WorkingLoadSet", { key: "A-squat", loadKg: 60 }, { device, at: "2026-11-02T10:00:00.000Z" }),
|
||||
createEvent("TrackingModeSet", { key: "A-plank", mode: "none" }, { device, at: "2026-11-02T10:01:00.000Z" }),
|
||||
]);
|
||||
const d = createDraft(A, state, "2026-11-18", 4);
|
||||
assert.equal(d.exercises[0].key, "A-squat");
|
||||
assert.equal(d.exercises[0].tracking, "load");
|
||||
assert.equal(d.exercises[0].loadKg, 60);
|
||||
assert.equal(d.exercises[2].tracking, "none");
|
||||
assert.equal(d.exercises[2].seconds, null);
|
||||
assert.deepEqual(d.exercises[0].done, [null, null, null]);
|
||||
assert.deepEqual(d.warmup, [false, false, false, false]);
|
||||
});
|
||||
|
||||
test("un exercice au temps prend la durée du programme (le haut de la fourchette)", () => {
|
||||
const d = createDraft(A, foldEvents([adopted]), "2026-11-18", 0);
|
||||
assert.equal(d.exercises[2].tracking, "time");
|
||||
assert.equal(d.exercises[2].seconds, 45);
|
||||
assert.equal(targetLabel(d.exercises[2]), "2 × 45 s");
|
||||
assert.equal(targetLabel(d.exercises[0]), "3 × 6–8");
|
||||
});
|
||||
|
||||
test("objectif de répétitions et répétitions proposées", () => {
|
||||
assert.deepEqual(targetReps("6–8"), { low: 6, high: 8 });
|
||||
assert.deepEqual(targetReps("10 / jambe"), { low: 10, high: 10 });
|
||||
assert.equal(targetReps("40 s"), null);
|
||||
const d = createDraft(A, foldEvents([adopted]), "2026-11-18", 0);
|
||||
const squat = d.exercises[0];
|
||||
assert.equal(proposedReps(squat, 0), 8);
|
||||
squat.done[0] = { reps: 7, effort: "ok" };
|
||||
assert.equal(proposedReps(squat, 1), 7);
|
||||
});
|
||||
|
||||
test("Terminer produit un SessionLogged valide, conforme à docs/evenements.md", () => {
|
||||
const state = foldEvents([adopted, createEvent("WorkingLoadSet", { key: "A-squat", loadKg: 60 }, { device })]);
|
||||
const d = createDraft(A, state, "2026-11-17", 4);
|
||||
d.warmup[0] = d.warmup[1] = true;
|
||||
d.exercises[0].done = [{ reps: 8, effort: "ok" }, null, { reps: 6, effort: "hard" }];
|
||||
d.exercises[2].done[0] = { reps: null, effort: null }; // série au temps cochée par le chrono
|
||||
const data = buildSessionData(d);
|
||||
assert.deepEqual(data.warmup, { done: 2, total: 4 });
|
||||
assert.equal(data.date, "2026-11-17");
|
||||
assert.equal(data.kind, "strength");
|
||||
assert.equal(data.ref, "A");
|
||||
assert.equal(data.exercises.length, 4);
|
||||
assert.deepEqual(data.exercises[0], {
|
||||
id: "squat", name: "Squat barre", target: "3 × 6–8", tracking: "load", loadKg: 60, seconds: null, plannedSets: 3,
|
||||
sets: [{ reps: 8, effort: "ok" }, { reps: 6, effort: "hard" }],
|
||||
});
|
||||
assert.deepEqual(data.exercises[1].sets, []);
|
||||
assert.equal(data.exercises[2].seconds, 45);
|
||||
assert.equal(data.exercises[2].loadKg, null);
|
||||
assert.equal(data.exercises[3].id, "Pompes lestées");
|
||||
// L'événement passe la validation du domaine et devient une séance de l'état.
|
||||
const e = createEvent("SessionLogged", data, { device, at: "2026-11-18T18:00:00.000Z" });
|
||||
const after = foldEvents([adopted, e]);
|
||||
assert.equal(after.sessions.length, 1);
|
||||
assert.equal(after.sessions[0].id, e.id);
|
||||
});
|
||||
|
||||
test("sans échauffement, warmup vaut null", () => {
|
||||
const d = createDraft(A, foldEvents([adopted]), "2026-11-18", 0);
|
||||
assert.equal(buildSessionData(d).warmup, null);
|
||||
});
|
||||
|
||||
test("la charge n'est pas enregistrée pour un mode sans charge", () => {
|
||||
const d = createDraft(A, foldEvents([adopted]), "2026-11-18", 0);
|
||||
d.exercises[1].loadKg = 12; // reste d'un ancien mode
|
||||
assert.equal(buildSessionData(d).exercises[1].loadKg, null);
|
||||
});
|
||||
|
||||
test("complétion : exercices pas commencés et incomplets", () => {
|
||||
const d = createDraft(A, foldEvents([adopted]), "2026-11-18", 0);
|
||||
assert.deepEqual(completion(d), { doneSets: 0, missing: d.exercises.map((x) => x.name), partial: [], complete: false });
|
||||
for (const ex of d.exercises) ex.done = ex.done.map(() => ({ reps: 5, effort: "ok" }));
|
||||
d.exercises[1].done[1] = null;
|
||||
const c = completion(d);
|
||||
assert.equal(c.doneSets, 8);
|
||||
assert.deepEqual(c.partial, [d.exercises[1].name]);
|
||||
assert.deepEqual(c.missing, []);
|
||||
d.exercises[1].done[1] = { reps: 15, effort: "easy" };
|
||||
assert.equal(completion(d).complete, true);
|
||||
});
|
||||
|
||||
test("un brouillon gardé n'est repris que pour la même séance", () => {
|
||||
const state = foldEvents([adopted]);
|
||||
const d = JSON.parse(JSON.stringify(createDraft(A, state, "2026-11-18", 4)));
|
||||
assert.equal(draftMatches(d, A, 4), true);
|
||||
assert.equal(draftMatches(d, PROGRAM.sessions[1], 4), false);
|
||||
assert.equal(draftMatches(d, A, 3), false);
|
||||
assert.equal(draftMatches(null, A, 4), false);
|
||||
const changed = { ...A, exercises: A.exercises.map((x, i) => (i === 0 ? { ...x, sets: 5 } : x)) };
|
||||
assert.equal(draftMatches(d, changed, 4), false);
|
||||
});
|
||||
|
||||
test("une séance enregistrée redonne son contenu, base d'une correction", () => {
|
||||
const d = createDraft(A, foldEvents([adopted]), "2026-11-18", 0);
|
||||
d.exercises[0].done = [{ reps: 8, effort: "ok" }, { reps: 8, effort: "ok" }, null];
|
||||
const data = buildSessionData(d);
|
||||
const e = createEvent("SessionLogged", data, { device });
|
||||
const logged = foldEvents([adopted, e]).sessions[0];
|
||||
const copy = sessionDataOf(logged);
|
||||
assert.deepEqual(copy, data);
|
||||
copy.exercises[0].sets.push({ reps: 6, effort: null });
|
||||
assert.equal(logged.exercises[0].sets.length, 2, "la copie est indépendante");
|
||||
const fixed = createEvent("SessionCorrected", { sessionId: e.id, session: copy }, { device, at: "2099-01-01T00:00:00.000Z" });
|
||||
assert.equal(foldEvents([adopted, e, fixed]).sessions[0].exercises[0].sets.length, 3);
|
||||
assert.equal(sessionSummary(copy), "1 exercice · 3 séries");
|
||||
});
|
||||
@@ -0,0 +1,96 @@
|
||||
// Les modules purs de l'interface : magasin, routeur, mise en forme, couleurs, accueil.
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { createEvent } from "../../app/domain/events.js";
|
||||
import { foldEvents } from "../../app/domain/state.js";
|
||||
import { createStore } from "../../app/ui/store.js";
|
||||
import { parseRoute, href } from "../../app/ui/router.js";
|
||||
import { clock, kg, localDay, parseAmount, plural, restLabel } from "../../app/ui/format.js";
|
||||
import { contrastRatio, inkOn } from "../../app/ui/color.js";
|
||||
import { estimateMinutes, lastDoneByKey, nextByRotation } from "../../app/ui/home-model.js";
|
||||
import { PROGRAM } from "./fixtures.js";
|
||||
|
||||
const device = "test";
|
||||
const adopted = createEvent("ProgramAdopted", { program: PROGRAM, source: "ai" }, { device, at: "2026-11-01T10:00:00.000Z" });
|
||||
/** @param {string} key @param {string} date */
|
||||
const done = (key, date) => createEvent("SessionLogged", { date, kind: "strength", ref: key, name: key, warmup: null, exercises: [] }, { device });
|
||||
|
||||
test("dispatch crée un événement, recalcule l'état et prévient les abonnés", () => {
|
||||
const appended = [];
|
||||
const store = createStore({ events: [adopted], device: "d1", onAppend: (e) => appended.push(e) });
|
||||
let calls = 0;
|
||||
const unsubscribe = store.subscribe(() => calls++);
|
||||
const e = store.dispatch("WorkingLoadSet", { key: "A-squat", loadKg: 62.5 });
|
||||
assert.equal(e.device, "d1");
|
||||
assert.equal(store.getState().workingLoads["A-squat"].loadKg, 62.5);
|
||||
assert.equal(store.getEvents().length, 2);
|
||||
assert.deepEqual(appended, [e]);
|
||||
assert.equal(calls, 1);
|
||||
unsubscribe();
|
||||
store.dispatch("ModeChanged", { mode: "recovery" });
|
||||
assert.equal(calls, 1);
|
||||
});
|
||||
|
||||
test("dispatch refuse un événement invalide sans toucher au journal", () => {
|
||||
const store = createStore();
|
||||
assert.throws(() => store.dispatch("WeightRecorded", { date: "2026-11-18", kg: 5 }));
|
||||
assert.equal(store.getEvents().length, 0);
|
||||
assert.match(store.device, /^browser-/);
|
||||
});
|
||||
|
||||
test("routeur : une adresse par écran, #import= et #pair= réservés", () => {
|
||||
assert.deepEqual(parseRoute(""), { name: "home" });
|
||||
assert.deepEqual(parseRoute("#/"), { name: "home" });
|
||||
assert.deepEqual(parseRoute("#/seance/A"), { name: "session", key: "A" });
|
||||
assert.deepEqual(parseRoute(href.session("B2")), { name: "session", key: "B2" });
|
||||
assert.deepEqual(parseRoute("#/historique"), { name: "history" });
|
||||
assert.deepEqual(parseRoute("#/historique/"), { name: "history" });
|
||||
assert.deepEqual(parseRoute(href.historyEdit("abc-1")), { name: "history-edit", id: "abc-1" });
|
||||
assert.deepEqual(parseRoute("#import=xyz"), { name: "reserved" });
|
||||
assert.deepEqual(parseRoute("#pair=ABCD"), { name: "reserved" });
|
||||
assert.deepEqual(parseRoute("#/nimporte/quoi/ici"), { name: "not-found" });
|
||||
});
|
||||
|
||||
test("mise en forme française", () => {
|
||||
assert.equal(clock(90), "1:30");
|
||||
assert.equal(clock(5), "0:05");
|
||||
assert.equal(clock(-3), "0:00");
|
||||
assert.equal(restLabel(45), "45 s");
|
||||
assert.equal(restLabel(120), "2 min");
|
||||
assert.equal(restLabel(90), "1 min 30");
|
||||
assert.equal(kg(62.5), "62,5");
|
||||
assert.equal(parseAmount("62,5"), 62.5);
|
||||
assert.equal(parseAmount(" "), null);
|
||||
assert.equal(parseAmount("abc"), undefined);
|
||||
assert.equal(parseAmount("-2"), undefined);
|
||||
assert.equal(plural(1, "série"), "1 série");
|
||||
assert.equal(plural(3, "série"), "3 séries");
|
||||
assert.equal(localDay(new Date(2026, 0, 5, 23, 30)), "2026-01-05");
|
||||
});
|
||||
|
||||
test("le texte posé sur une couleur de séance reste lisible (AA)", () => {
|
||||
for (const color of ["#3A7FCB", "#E3B505", "#C93A3F", "#3FA06A", "#000000", "#FFFFFF", "#8A9199"])
|
||||
assert.ok(contrastRatio(inkOn(color), color) >= 4.5, `${color} : ${contrastRatio(inkOn(color), color).toFixed(2)}`);
|
||||
});
|
||||
|
||||
test("rotation : une séance jamais faite d'abord, sinon la moins récente", () => {
|
||||
assert.equal(nextByRotation(foldEvents([adopted]))?.key, "A");
|
||||
const state = foldEvents([adopted, done("A", "2026-11-10"), done("B", "2026-11-12"), done("C", "2026-11-14")]);
|
||||
assert.equal(nextByRotation(state)?.key, "A");
|
||||
assert.deepEqual(lastDoneByKey(state), { A: "2026-11-10", B: "2026-11-12", C: "2026-11-14" });
|
||||
const later = foldEvents([adopted, done("A", "2026-11-16"), done("B", "2026-11-12"), done("C", "2026-11-14")]);
|
||||
assert.equal(nextByRotation(later)?.key, "B");
|
||||
const partial = foldEvents([adopted, done("A", "2026-11-16")]);
|
||||
assert.equal(nextByRotation(partial)?.key, "B");
|
||||
});
|
||||
|
||||
test("rotation sans programme : rien à proposer", () => {
|
||||
const state = { ...foldEvents([]), program: /** @type {any} */ (null) };
|
||||
assert.equal(nextByRotation(state), null);
|
||||
});
|
||||
|
||||
test("durée estimée d'une séance, arrondie à 5 minutes", () => {
|
||||
const m = estimateMinutes(PROGRAM.sessions[0]);
|
||||
assert.equal(m % 5, 0);
|
||||
assert.ok(m >= 20 && m <= 60, String(m));
|
||||
});
|
||||
Reference in New Issue
Block a user