Écrans branchés : planning du jour, semaine, activités, poids, données, profil, analyses, propositions avec aperçu, gamification

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pierre MARTIN
2026-11-18 05:26:02 +01:00
co-authored by Claude Opus 5.5
parent 077f2dc58d
commit 41d5e44daa
35 changed files with 2931 additions and 367 deletions
+32 -57
View File
@@ -1,11 +1,14 @@
// 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).
// de l'utilisateur (ADR 0008 ; 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";
import { copyText } from "./files.js";
import { href } from "./router.js";
import { buildOnboardingBrief } from "../domain/ai-brief.js";
import { EXAMPLE_PROGRAM } from "../domain/example-program.js";
/** Consigne courte pour une IA qui sait lire une page web. */
export const AI_GUIDE_URL = "https://ia-fit.sans.pub/ia.md";
@@ -14,47 +17,21 @@ 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 status = h("p", { class: "status status--ok", 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 ok = await copyText(buildOnboardingBrief({ baseUrl: location.origin }), manual, "Texte à copier dans ton IA");
status.textContent = ok ? "Copié. Colle-le dans ton IA." : "";
if (ok) toast("Texte copié.");
};
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 startFromExample = () => {
store.dispatch("ProgramProposed", {
program: structuredClone(EXAMPLE_PROGRAM),
source: "example",
reason: "Programme d'exemple : trois séances à domicile avec barre, haltères, banc et élastiques. Ton IA pourra l'adapter ensuite.",
});
};
const copyGuide = async () => {
@@ -67,32 +44,30 @@ export function onboarding({ store }) {
};
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("header", { class: "screen-head" },
h("p", { class: "kicker" }, "IA-Fit · sans compte"),
h("h1", { class: "title title--hero" }, "Ton programme. Ton IA."),
h("p", { class: "lede" }, "Elle le construit, tu le suis ici, série par série. Tes données restent sur ton appareil.")),
h("section", { class: "card card--onboarding", "aria-labelledby": "onb-how" },
h("h2", { class: "card__title", id: "onb-how" }, "En trois gestes"),
h("section", { class: "block", "aria-labelledby": "onb-how" },
h("h2", { class: "h2", id: "onb-how" }, "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."))),
h("li", { class: "how__step" }, h("span", null, h("strong", null, "Copie le texte"), " et colle-le dans ton IA : Claude, ChatGPT, Le Chat…")),
h("li", { class: "how__step" }, h("span", null, h("strong", null, "Réponds à ses questions"), ", ou montre-lui ton programme actuel.")),
h("li", { class: "how__step" }, h("span", null, h("strong", null, "Touche le lien qu'elle renvoie."), " Ton programme s'affiche ici. Tu valides."))),
status,
manual,
h("p", { class: "card__hint" }, "Ou, si ton IA sait lire une page web, dis-lui simplement :"),
h("p", { class: "muted" }, "Ton IA lit les pages web ? Dis-lui :"),
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("button", { type: "button", class: "btn btn--sm", on: { click: copyGuide } }, "Copier"))),
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("h2", { class: "tape" }, "Ou bien"),
h("div", { class: "btn-stack" },
h("button", { type: "button", class: "btn btn--block", on: { click: startFromExample } }, "Programme d'exemple"),
h("a", { class: "btn btn--block btn--ghost", href: href.data() }, "Restaurer une sauvegarde")),
h("footer", { class: "foot" }, "Rien ne part sur un serveur : ce que tu colles dans ton IA, c'est toi qui le choisis."),
h("p", { 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")));
actionBar(h("button", { type: "button", class: "btn btn--primary btn--block btn--lg", on: { click: copyBrief } }, "Créer mon programme")));
}