Commit 8b8f00cd by PLN (Algolia)

couple: the refonte — real URLs, new home, the guide out of its hole

The guide was buried behind a text link and every screen shared one URL:
the refonte gives each surface its own address behind the nginx sas.
- /couple/guide, /couple/videos(+/<slug>), /couple/fiches/<slug>,
  /couple/questions/<slug>, /couple/carnet — static-exported, back-button
  works, each page carries 'Clarté couple' metadata, per-page description
  and the shared OG card (public/images/couple/og.png, scripts/couple-og.mjs)
- home refonte (Tailwind v4): hero 'Bonjour + progress + Reprendre où j'en
  étais' (Goal-Gradient, Paradox of the Active User), guide/vidéos/carnet as
  first-rank blocks, questionnaires as calm rows with progress bars, tools
  folded into a details panel. All prior logic kept (share, PDF, compare,
  export, two-tap delete); storage contracts untouched
- the state views for guide/carnet leave ClarteCouple (the questionnaire
  flows stay a state machine, they have no meaning outside /couple)
- copy: 'la praticienne' leaves reader surfaces ('Le guide', 'À deux, et
  pour la séance'); Poursuivre links chain guide items in reading order
- quiz views keep the clarte kit for now: next wave audits them against
  ux-laws and carries them into the new look
parent 949189dd
import CarnetView from '@/components/couple/CarnetView';
export const metadata = {
title: 'Clarté couple · Le carnet',
description:
'Un carnet libre, à deux ou chacun·e de son côté. Tout reste sur cet appareil.',
robots: { index: false, follow: false },
openGraph: { images: ["/images/couple/og.png"] },
};
export default function CoupleCarnetPage() {
return <CarnetView />;
}
import { notFound } from 'next/navigation';
import FicheView from '@/components/couple/FicheView';
import { findCoupleItem, loadCoupleItems } from '@/lib/couple-guide';
export async function generateStaticParams() {
const items = await loadCoupleItems();
return items
.filter(function (it) { return it.kind === 'fiche'; })
.map(function (it) { return { slug: it.id.split(':')[1] }; });
}
export async function generateMetadata({ params }) {
const { slug } = await params;
const found = await findCoupleItem('fiches', slug);
if (!found) return { title: 'Clarté couple' };
return {
title: 'Clarté couple · ' + found.item.title,
description: found.item.summary || 'Une fiche du parcours, à lire à son rythme.',
robots: { index: false, follow: false },
};
}
export default async function CoupleFicheItemPage({ params }) {
const { slug } = await params;
const found = await findCoupleItem('fiches', slug);
if (!found) notFound();
return <FicheView item={found.item} next={found.next} />;
}
import GuideHub from '@/components/couple/GuideHub';
import { loadCoupleGuide } from '@/lib/couple-guide';
export const metadata = {
title: 'Clarté couple · Le guide',
description:
'Les fiches, vidéos et questions d’écriture reçues pendant le parcours, rangées dans l’ordre où elles sont arrivées.',
robots: { index: false, follow: false },
openGraph: { images: ["/images/couple/og.png"] },
};
export default async function CoupleGuidePage() {
const guide = await loadCoupleGuide();
return <GuideHub guide={guide} />;
}
import ClarteCouple from '@/components/couple/ClarteCouple';
import { loadCoupleGuide } from '@/lib/couple-guide';
export const metadata = {
title: 'Clarté · Espace couple',
title: 'Clarté couple',
description:
'Des questionnaires pour mettre des mots, à deux, sur ce qui se passe entre vous. Tout reste sur cet appareil.',
robots: { index: false, follow: false },
openGraph: {
title: 'Clarté couple',
description:
'Des questionnaires pour mettre des mots, à deux, sur ce qui se passe entre vous.',
type: 'website',
images: ['/images/couple/og.png'],
},
};
export default async function CouplePage() {
const guide = await loadCoupleGuide();
return <ClarteCouple guide={guide} />;
export default function CouplePage() {
return <ClarteCouple />;
}
import { notFound } from 'next/navigation';
import QuestionSetView from '@/components/couple/QuestionSetView';
import { findCoupleItem, loadCoupleItems } from '@/lib/couple-guide';
export async function generateStaticParams() {
const items = await loadCoupleItems();
return items
.filter(function (it) { return it.kind === 'questions'; })
.map(function (it) { return { slug: it.id.split(':')[1] }; });
}
export async function generateMetadata({ params }) {
const { slug } = await params;
const found = await findCoupleItem('questions', slug);
if (!found) return { title: 'Clarté couple' };
return {
title: 'Clarté couple · ' + found.item.title,
description: found.item.summary || 'Un espace d’écriture du parcours, à votre rythme.',
robots: { index: false, follow: false },
};
}
export default async function CoupleQuestionsItemPage({ params }) {
const { slug } = await params;
const found = await findCoupleItem('questions', slug);
if (!found) notFound();
return <QuestionSetView item={found.item} next={found.next} />;
}
import { notFound } from 'next/navigation';
import VideoView from '@/components/couple/VideoView';
import { findCoupleItem } from '@/lib/couple-guide';
export async function generateStaticParams() {
const items = await (await import('@/lib/couple-guide')).loadCoupleItems();
return items
.filter(function (it) { return it.kind === 'video'; })
.map(function (it) { return { slug: it.id.split(':')[1] }; });
}
export async function generateMetadata({ params }) {
const { slug } = await params;
const found = await findCoupleItem('videos', slug);
if (!found) return { title: 'Clarté couple' };
return {
title: 'Clarté couple · ' + found.item.title,
description: found.item.summary || 'Une vidéo du parcours, à regarder ensemble.',
robots: { index: false, follow: false },
};
}
export default async function CoupleVideoItemPage({ params }) {
const { slug } = await params;
const found = await findCoupleItem('videos', slug);
if (!found) notFound();
return <VideoView item={found.item} next={found.next} />;
}
import Link from 'next/link';
import { loadCoupleItems } from '@/lib/couple-guide';
export const metadata = {
title: 'Clarté couple · Les vidéos',
description: 'Les vidéos du parcours, à regarder ensemble, dans l’app.',
robots: { index: false, follow: false },
openGraph: { images: ["/images/couple/og.png"] },
};
export default async function CoupleVideosPage() {
const items = await loadCoupleItems();
const videos = items.filter(function (it) { return it.kind === 'video'; });
return (
<div className="mx-auto max-w-2xl px-5 pb-20 pt-10 sm:px-6">
<nav className="text-sm text-[#6f675c]">
<Link href="/couple/guide" className="underline-offset-2 hover:underline">Le guide</Link>
<span aria-hidden="true" className="mx-2">›</span>
<span className="font-medium text-[#2b2620]">Les vidéos</span>
</nav>
<h1 className="mt-4 text-4xl font-bold tracking-tight text-[#2b2620]">Les vidéos</h1>
<p className="mt-3 max-w-prose text-lg text-[#6f675c]">À regarder ensemble, dans l’app, avec une note à côté.</p>
<ul className="mt-6 divide-y divide-[#eee7da] border-y border-[#eee7da]">
{videos.map(function (it) {
return (
<li key={it.id}>
<Link
href={'/couple/videos/' + it.id.split(':')[1]}
className="flex w-full items-center gap-4 py-3.5 transition hover:bg-[#faf3ea] focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[#b85c48]"
>
<span className="min-w-0 flex-1">
<span className="block truncate font-medium text-[#2b2620]">{it.title}</span>
{it.summary && (
<span className="mt-0.5 block truncate text-sm text-[#6f675c]">{it.summary}</span>
)}
</span>
<span aria-hidden="true" className="shrink-0 text-[#b85c48]">▶</span>
</Link>
</li>
);
})}
</ul>
</div>
);
}
'use client';
/* Clarté couple : le carnet libre. Des notes nommées, autosave 300 ms après
la frappe, suppression en deux appuis (panneau en ligne, comme l'accueil).
/* Clarté couple : le carnet libre, sa propre URL (/couple/carnet). Des notes
nommées, autosave 300 ms après la frappe, suppression en deux appuis.
Jamais dans les liens de partage : la donnée reste locale et sort seulement
dans l'export JSON (contrat engine.js couple:v1:pad:<pid>). */
import { useEffect, useState } from 'react';
import Button from '@/components/clarte/Button';
import Link from 'next/link';
import TextArea from '@/components/clarte/TextArea';
import { deletePad, listPads, newPadId, readPad, writePad } from './engine';
import { strings } from './strings';
import styles from './couple.module.css';
function formatUpdated(iso) {
try {
......@@ -22,7 +21,7 @@ function formatUpdated(iso) {
}
}
export default function CarnetView({ goHome, trackWrite = function () {} }) {
export default function CarnetView({ trackWrite = function () {} }) {
const [pads, setPads] = useState(null);
const [openPid, setOpenPid] = useState(null);
const [pad, setPad] = useState(null);
......@@ -82,25 +81,38 @@ export default function CarnetView({ goHome, trackWrite = function () {} }) {
refresh();
};
const backLink = (
<nav className="text-sm text-[#6f675c]">
<Link href="/couple" className="underline-offset-2 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]">
{strings.carnet.backHome}
</Link>
<span aria-hidden="true" className="mx-2">›</span>
<span className="font-medium text-[#2b2620]">{strings.carnet.h1}</span>
</nav>
);
// ---- éditeur --------------------------------------------------------
if (pad !== null && openPid) {
return (
<div>
<h1 className={styles.title}>{pad.title || strings.carnet.h1}</h1>
<div className={styles.nav}>
<Button onClick={closeEditor}>{strings.carnet.backHome}</Button>
<span className={styles.state}>{savedFlash ? strings.carnet.saved : ''}</span>
</div>
<div className="mx-auto max-w-2xl px-5 pb-20 pt-10 sm:px-6">
{backLink}
<h1 className="mt-4 text-3xl font-bold leading-tight tracking-tight text-[#2b2620] sm:text-4xl">
{pad.title || strings.carnet.h1}
</h1>
<p className="mt-2 text-sm text-[#5e7d5a]" role="status">
{savedFlash ? strings.carnet.saved : ''}
</p>
<div className={styles.who}>
<label htmlFor="pad-title">{strings.carnet.titlePlaceholder}</label>
<input
id="pad-title"
maxLength={80}
value={pad.title}
onChange={function (e) { persist(save({ title: e.target.value })); }}
/>
</div>
<label htmlFor="pad-title" className="mt-6 block text-sm font-medium text-[#2b2620]">
{strings.carnet.titlePlaceholder}
</label>
<input
id="pad-title"
maxLength={80}
value={pad.title}
onChange={function (e) { persist(save({ title: e.target.value })); }}
className="mt-1.5 w-full rounded-xl border border-[#e4dccf] bg-white px-3 py-2.5 font-medium text-[#2b2620] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[#b85c48]"
/>
<TextArea
id="pad-text"
......@@ -112,22 +124,21 @@ export default function CarnetView({ goHome, trackWrite = function () {} }) {
onChange={function (v) { save({ text: v }); }}
onDebouncedChange={function (v) { persist(save({ text: v })); }}
/>
<p className={styles.muted}>
<p className="mt-1 text-sm text-[#6f675c]">
{pad.updated ? strings.carnet.updated(formatUpdated(pad.updated)) : ''}
</p>
<p className={styles.muted}>{strings.carnet.shareWarn}</p>
<div className={styles.footlinks}>
<p className="mt-6 max-w-prose text-sm text-[#6f675c]">{strings.carnet.shareWarn}</p>
<div className={'mt-4 text-sm' + (confirmingDelete ? ' text-[#8a3d2e]' : '')}>
{confirmingDelete ? (
<>
{strings.carnet.deleteConfirm}{' '}
<Button onClick={remove}>{strings.carnet.deleteYes}</Button>{' '}
<button type="button" className={styles.linkbtn} onClick={function () { setConfirmingDelete(false); }}>
{strings.carnet.deleteNo}
</button>
<button type="button" className="font-bold text-[#8a3d2e] underline underline-offset-2" onClick={remove}>{strings.carnet.deleteYes}</button>
{' · '}
<button type="button" className="text-[#6f675c] underline underline-offset-2" onClick={function () { setConfirmingDelete(false); }}>{strings.carnet.deleteNo}</button>
</>
) : (
<button type="button" className={`${styles.linkbtn} ${styles.linkbtnDanger}`} onClick={function () { setConfirmingDelete(true); }}>
<button type="button" className="text-[#6f675c] underline underline-offset-2 hover:text-[#8a3d2e] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]" onClick={function () { setConfirmingDelete(true); }}>
{strings.carnet.deleteBtn}
</button>
)}
......@@ -138,25 +149,38 @@ export default function CarnetView({ goHome, trackWrite = function () {} }) {
// ---- sommaire -------------------------------------------------------
return (
<div>
<h1 className={styles.title}>{strings.carnet.h1}</h1>
<p className={styles.muted}>{strings.carnet.intro}</p>
<div className={styles.nav}>
<Button onClick={goHome}>{strings.carnet.backHome}</Button>
<Button variant="primary" onClick={create}>{strings.carnet.newNote}</Button>
</div>
<div className="mx-auto max-w-2xl px-5 pb-20 pt-10 sm:px-6">
{backLink}
<h1 className="mt-4 text-4xl font-bold tracking-tight text-[#2b2620]">{strings.carnet.h1}</h1>
<p className="mt-3 max-w-prose text-lg text-[#6f675c]">{strings.carnet.intro}</p>
<button
type="button"
onClick={create}
className="mt-6 inline-flex min-h-12 items-center gap-2 rounded-full bg-[#2b2620] px-6 py-3 text-base font-bold text-[#faf7f2] transition hover:bg-[#b85c48] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]"
>
<span aria-hidden="true">+</span>
{strings.carnet.newNote}
</button>
{pads.length === 0 ? (
<p className={styles.muted}>{strings.carnet.empty}</p>
<p className="mt-6 max-w-prose text-[#6f675c]">{strings.carnet.empty}</p>
) : (
<ul className={styles.cardlist}>
<ul className="mt-6 divide-y divide-[#eee7da] border-y border-[#eee7da]">
{pads.map(function (p) {
var preview = p.text.trim().split('\n')[0] || strings.carnet.textPlaceholder;
return (
<li key={p.pid}>
<button type="button" className={styles.cardbtn} onClick={function () { open(p.pid); }}>
<span>{p.title || preview}</span>
<span className={styles.meta}>{formatUpdated(p.updated)}</span>
<button
type="button"
onClick={function () { open(p.pid); }}
className="flex w-full items-center gap-4 py-3.5 text-left transition hover:bg-[#faf3ea] focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[#b85c48]"
>
<span className="min-w-0 flex-1">
<span className="block truncate font-medium text-[#2b2620]">{p.title || preview}</span>
<span className="block text-sm text-[#6f675c]">{formatUpdated(p.updated)}</span>
</span>
<span aria-hidden="true" className="shrink-0 text-[#b85c48]">›</span>
</button>
</li>
);
......@@ -164,7 +188,7 @@ export default function CarnetView({ goHome, trackWrite = function () {} }) {
</ul>
)}
<p className={styles.muted}>{strings.carnet.shareWarn}</p>
<p className="mt-8 max-w-prose text-sm text-[#6f675c]">{strings.carnet.shareWarn}</p>
</div>
);
}
'use client';
/* Clarté couple : composant racine. Routage entre les vues (accueil, intro,
question, feuille de travail, récapitulatif, vue partagée), sonde de
stockage, bannière de navigation privée, dispatch du lien de partage (#p=).
Le rendu est différé après le montage : les vues lisent localStorage, qui
n'existe pas au rendu serveur du build statique. */
/* Clarté couple : racine du questionnaire. Routage entre les vues
questionnaire (accueil, intro, question, feuille de travail, récapitulatif,
vue partagée), sonde de stockage, bannière de navigation privée, dispatch
du lien de partage (#p=). Le rendu est différé après le montage : les vues
lisent localStorage, qui n'existe pas au rendu serveur du build statique.
Le guide, les vidéos, les fiches, les questions et le carnet ont quitté
cette machine d'états pour de vraies URLs (/couple/guide, /couple/videos,
/couple/fiches/<slug>, /couple/questions/<slug>, /couple/carnet) : back-button
et partage d'URL, servis par des pages du build. Ici : les questionnaires
et les liens de partage, qui n'ont pas de sens hors de cet écran. */
import { useCallback, useEffect, useState } from 'react';
import { COUPLE_DATA } from './data';
......@@ -19,11 +25,6 @@ import RecapView from './RecapView';
import SharedView, { SharedErrorView } from './SharedView';
import SharedAllView from './SharedAllView';
import CompareView from './CompareView';
import GuideView from './GuideView';
import FicheView from './FicheView';
import VideoView from './VideoView';
import QuestionSetView from './QuestionSetView';
import CarnetView from './CarnetView';
function questionnaireById(qid) {
var q = null;
......@@ -33,7 +34,7 @@ function questionnaireById(qid) {
return q;
}
export default function ClarteCouple({ guide = null }) {
export default function ClarteCouple() {
const [mounted, setMounted] = useState(false);
const [route, setRoute] = useState({ view: 'home' });
const [storageOk, setStorageOk] = useState(true);
......@@ -78,10 +79,6 @@ export default function ClarteCouple({ guide = null }) {
}, []);
const goIntro = useCallback((qid) => setRoute({ view: 'intro', qid: qid }), []);
const goRecap = useCallback((qid) => setRoute({ view: 'recap', qid: qid }), []);
const goGuide = useCallback(() => setRoute({ view: 'guide' }), []);
const goCarnet = useCallback(() => setRoute({ view: 'carnet' }), []);
const goGuideBack = useCallback(() => setRoute({ view: 'guide' }), []);
const goGuideItem = useCallback((item) => setRoute({ view: 'guideItem', item: item }), []);
const goQuiz = useCallback((qid, pos) => {
// Le focus ne traverse jamais les écrans : un anneau de sélection resté
// sur la pilule cliquée se lirait « déjà répondu » sur la question suivante.
......@@ -123,21 +120,6 @@ export default function ClarteCouple({ guide = null }) {
/>
);
if (route.view === 'guide' && guide) return withBanner(
<GuideView guide={guide} goHome={goHome} goItem={goGuideItem} />
);
if (route.view === 'carnet') return withBanner(<CarnetView goHome={goHome} trackWrite={trackWrite} />);
if (route.view === 'guideItem' && guide) {
const item = route.item;
if (item.kind === 'video') return withBanner(
<VideoView item={item} goBack={goGuideBack} trackWrite={trackWrite} />
);
if (item.kind === 'questions') return withBanner(
<QuestionSetView item={item} goBack={goGuideBack} trackWrite={trackWrite} />
);
return withBanner(<FicheView item={item} goBack={goGuideBack} />);
}
const q = route.qid ? questionnaireById(route.qid) : null;
switch (route.view) {
......@@ -183,8 +165,6 @@ export default function ClarteCouple({ guide = null }) {
goQuiz={goQuiz}
goRecap={goRecap}
goCompare={goCompare}
goGuide={goGuide}
goCarnet={goCarnet}
trackWrite={trackWrite}
/>
);
......
'use client';
/* Clarté couple : lecture d'une fiche du guide. Le HTML vient du build
(lib/couple-guide.js, pipeline markdown du site) ; la donnée verbatim n'est
jamais retouchée côté client. L'ouverture pose la marque « lu » : la carte
du sommaire bascule en « Déjà lu », rien d'autre ne bouge. */
/* Clarté couple : lecture d'une fiche, sa propre URL (/couple/fiches/<slug>).
Le HTML vient du build (lib/couple-guide.js, pipeline markdown du site) ;
la donnée verbatim n'est jamais retouchée côté client. L'ouverture pose la
marque « lu » ; le lien Poursuivre enchaîne sur l'item suivant du guide. */
import { useEffect } from 'react';
import Button from '@/components/clarte/Button';
import Link from 'next/link';
import { writeGuideMark } from './engine';
import { itemHref } from './GuideHub';
import { strings } from './strings';
import styles from './couple.module.css';
export default function FicheView({ item, goBack }) {
export default function FicheView({ item, next }) {
useEffect(function () {
writeGuideMark(item.id);
}, [item.id]);
return (
<div>
<h1 className={styles.title}>{item.title}</h1>
{item.summary && <p className={styles.muted}>{item.summary}</p>}
<div className={styles.nav}>
<Button onClick={goBack}>{strings.guide.backHome}</Button>
</div>
<div className="mx-auto max-w-2xl px-5 pb-20 pt-10 sm:px-6">
<nav className="text-sm text-[#6f675c]">
<Link href="/couple/guide" className="underline-offset-2 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]">
{strings.guide.toGuide}
</Link>
<span aria-hidden="true" className="mx-2">›</span>
<span className="font-medium text-[#2b2620]">{item.title}</span>
</nav>
<h1 className="mt-4 text-3xl font-bold leading-tight tracking-tight text-[#2b2620] sm:text-4xl">
{item.title}
</h1>
{item.summary && <p className="mt-3 max-w-prose text-lg text-[#6f675c]">{item.summary}</p>}
{/* HTML de confiance : rendu au build depuis content/couple (repo). */}
<div className={styles.fiche} dangerouslySetInnerHTML={{ __html: item.html }} />
<div
className="couple-prose mt-8"
dangerouslySetInnerHTML={{ __html: item.html }}
/>
{next && (
<Link
href={itemHref(next)}
className="mt-10 flex items-center justify-between rounded-2xl border border-[#e4dccf] bg-white p-4 transition hover:border-[#b85c48] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]"
>
<span>
<span className="block text-sm text-[#6f675c]">{strings.guide.nextLabel}</span>
<span className="block font-bold text-[#2b2620]">{next.title}</span>
</span>
<span aria-hidden="true" className="text-lg text-[#b85c48]">→</span>
</Link>
)}
</div>
);
}
'use client';
/* Clarté couple : sommaire du guide, sa propre URL (/couple/guide). Les
items sont de vrais liens (back-button, partage d'URL interne), groupés
par theme dans la temporalité des vagues (step 1 puis 2). Les marques
d'avancement se relisent à chaque rendu, moteur vanilla. */
import { useEffect, useState } from 'react';
import Link from 'next/link';
import { readGuideMark, readGuideNotes } from './engine';
import { strings } from './strings';
export function itemHref(item) {
return '/couple/' + item.kind + 's/' + item.id.split(':')[1];
}
function itemState(item) {
if (item.kind === 'questions') {
var n = Object.keys(readGuideNotes(item.id)).length;
return n > 0 ? { line: strings.guide.answeredOf(n, item.questions.length), done: n >= item.questions.length } : null;
}
var mark = readGuideMark(item.id);
if (mark) return { line: item.kind === 'video' ? strings.guide.watched : strings.guide.seen, done: true };
return null;
}
const KIND_ACTION = { fiche: 'Lire', video: 'Regarder', questions: 'Écrire' };
export default function GuideHub({ guide }) {
const [mounted, setMounted] = useState(false);
useEffect(function () { setMounted(true); }, []);
return (
<div className="mx-auto max-w-2xl px-5 pb-20 pt-10 sm:px-6">
<nav className="text-sm text-[#6f675c]">
<Link href="/couple" className="underline-offset-2 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]">
{strings.guide.backHome}
</Link>
<span aria-hidden="true" className="mx-2">›</span>
<span className="font-medium text-[#2b2620]">{strings.guide.h1}</span>
</nav>
<h1 className="mt-4 text-4xl font-bold tracking-tight text-[#2b2620]">{strings.guide.h1}</h1>
<p className="mt-3 max-w-prose text-lg text-[#6f675c]">{strings.guide.intro}</p>
{guide.steps.map(function (step) {
return (
<section key={step.step} className="mt-10">
<h2 className="text-sm font-medium uppercase tracking-widest text-[#b85c48]">
{strings.guide.stepLabel(step.step)}
</h2>
{step.themes.map(function (theme) {
return (
<div key={theme.theme} className="mt-3">
<p className="font-bold text-[#2b2620]">{theme.theme}</p>
<ul className="mt-2 divide-y divide-[#eee7da] border-y border-[#eee7da]">
{theme.items.map(function (item) {
var st = mounted ? itemState(item) : null;
return (
<li key={item.id}>
<Link
href={itemHref(item)}
className="flex w-full items-center gap-4 py-3.5 transition hover:bg-[#faf3ea] focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[#b85c48]"
>
<span className="min-w-0 flex-1">
<span className="block truncate font-medium text-[#2b2620]">{item.title}</span>
{item.summary && (
<span className="mt-0.5 block truncate text-sm text-[#6f675c]">{item.summary}</span>
)}
</span>
<span className={'shrink-0 text-sm ' + (st ? 'text-[#5e7d5a]' : 'text-[#b85c48]')}>
{st ? st.line : KIND_ACTION[item.kind]}
</span>
</Link>
</li>
);
})}
</ul>
</div>
);
})}
</section>
);
})}
<p className="mt-8 max-w-prose text-sm text-[#6f675c]">{strings.guide.noteHint}</p>
</div>
);
}
'use client';
/* Clarté couple : sommaire du guide de la praticienne. Les items groupés par
theme, dans la temporalité des vagues de mails (step 1 puis 2). Chaque
carte porte sa marque d'avancement : fiche lue, vidéo vue, écrits comptés.
La liste se relit à chaque rendu (moteur vanilla : pas d'état local). */
import Button from '@/components/clarte/Button';
import { readGuideMark, readGuideNotes } from './engine';
import { strings } from './strings';
import styles from './couple.module.css';
const KIND_LABEL = {
fiche: { action: strings.guide.read, verb: strings.guide.read },
video: { action: strings.guide.watch, verb: strings.guide.watch },
questions: { action: strings.guide.write, verb: strings.guide.write },
};
function itemState(item) {
if (item.kind === 'questions') {
var notes = readGuideNotes(item.id);
var n = Object.keys(notes).length;
return n > 0 ? { done: n >= item.questions.length, line: strings.guide.answeredOf(n, item.questions.length) } : null;
}
var mark = readGuideMark(item.id);
if (mark) {
return { done: true, line: item.kind === 'video' ? strings.guide.watched : strings.guide.seen };
}
return null;
}
export default function GuideView({ guide, goHome, goItem }) {
return (
<div>
<h1 className={styles.title}>{strings.guide.h1}</h1>
<p className={styles.muted}>{strings.guide.intro}</p>
<div className={styles.nav}>
<Button onClick={goHome}>{strings.guide.backHome}</Button>
</div>
{guide.steps.map(function (step) {
return step.themes.map(function (theme) {
return (
<section key={step.step + ':' + theme.theme}>
<h2 className={styles.themeTitle}>{theme.theme}</h2>
<ul className={styles.cardlist}>
{theme.items.map(function (item) {
var st = itemState(item);
var label = item.kind === 'video' ? KIND_LABEL.video : KIND_LABEL[item.kind];
return (
<li key={item.id}>
<button
type="button"
className={styles.cardbtn}
onClick={function () { goItem(item); }}
>
<span>{item.title}</span>
{st ? (
<span className={styles.state}>{st.line}</span>
) : (
<span className={styles.meta}>
{item.kind === 'questions'
? strings.guide.answeredOf(0, item.questions.length)
: label.action}
</span>
)}
</button>
</li>
);
})}
</ul>
</section>
);
});
})}
<p className={styles.muted}>{strings.guide.noteHint}</p>
</div>
);
}
'use client';
/* Clarté couple : accueil. Cartes des 8 questionnaires avec état, champ
« Je réponds en tant que », divulgation de visibilité persistante, export
JSON (un appui) et suppression totale (deux appuis, panneau en ligne).
Le composant remonte à chaque retour sur l'accueil : les états des cartes
sont relus à chaque rendu, donc toujours frais après une suppression. */
/* Clarté couple : accueil refondu. Une phrase, un geste : où j'en suis et
comment reprendre (Goal-Gradient, Paradox of the Active User). Le guide,
les vidéos et le carnet sont des blocs de premier rang, plus un lien noyé.
Les questionnaires deviennent des lignes calmes avec barre d'avancement.
Toute la logique existante (partage, PDF, comparaison, export, effacement)
est conservée ; les contrats de stockage ne bougent pas. */
import { useEffect, useState } from 'react';
import Link from 'next/link';
import Button from '@/components/clarte/Button';
import { COUPLE_DATA } from './data';
import {
allItems,
displayTitle,
answeredCount,
deleteAllCoupleKeys,
displayTitle,
downloadExport,
firstUnanswered,
listPads,
readRecord,
readSession,
serializeAllAnswers,
......@@ -25,7 +28,6 @@ import {
import { exportCouplePdf } from './pdf-export';
import { RIGHTS_LINE } from './attributions';
import { strings } from './strings';
import styles from './couple.module.css';
function cardClick(q, goIntro, goQuiz, goRecap) {
var st = readRecord(q.id);
......@@ -36,20 +38,47 @@ function cardClick(q, goIntro, goQuiz, goRecap) {
else goQuiz(q.id, firstUnanswered(q, st));
}
export default function HomeView({ goIntro, goQuiz, goRecap, trackWrite, goCompare, goGuide, goCarnet }) {
/* L'état du parcours : { answered, total, resumeQ, resumePos, doneCount }.
resumeQ = le questionnaire en cours (partiel) s'il existe, sinon le premier
vierge ; c'est la cible du gros bouton. */
function computeJourney() {
var answered = 0;
var total = 0;
var resumeQ = null;
var doneCount = 0;
COUPLE_DATA.questionnaires.forEach(function (q) {
var t = allItems(q).length;
var st = readRecord(q.id);
var n = st ? answeredCount(q, st) : 0;
answered += n;
total += t;
if (n >= t && t > 0) {
doneCount++;
return;
}
if (n > 0 && !resumeQ) resumeQ = q;
if (!resumeQ) resumeQ = resumeQ || q;
});
return { answered: answered, total: total, resumeQ: resumeQ, doneCount: doneCount };
}
export default function HomeView({ goIntro, goQuiz, goRecap, trackWrite, goCompare }) {
const [session, setSession] = useState(null);
const [journey, setJourney] = useState(null);
const [padCount, setPadCount] = useState(0);
const [confirmingDelete, setConfirmingDelete] = useState(false);
const [shareAllOpen, setShareAllOpen] = useState(false);
const [compareLink, setCompareLink] = useState('');
const [compareError, setCompareError] = useState(false);
const [pdfDone, setPdfDone] = useState(false);
useEffect(() => {
useEffect(function () {
setSession(readSession());
// eslint-disable-next-line react-hooks/exhaustive-deps
setJourney(computeJourney());
setPadCount(listPads().length);
}, []);
if (!session) return null;
if (!session || !journey) return null;
var handleRespondent = function (event) {
var next = {
......@@ -64,83 +93,151 @@ export default function HomeView({ goIntro, goQuiz, goRecap, trackWrite, goCompa
deleteAllCoupleKeys();
setConfirmingDelete(false);
setSession(readSession());
setJourney(computeJourney());
setPadCount(0);
};
var start = function () {
var q = journey.resumeQ;
if (!q) return;
var st = readRecord(q.id);
var total = allItems(q).length;
var n = st ? answeredCount(q, st) : 0;
if (n === 0) goIntro(q.id);
else if (n >= total) goRecap(q.id);
else goQuiz(q.id, firstUnanswered(q, st));
};
var pct = journey.total > 0 ? Math.round((journey.answered / journey.total) * 100) : 0;
return (
<div>
<h1 className={styles.title}>{strings.home.h1}</h1>
<p className={styles.muted}>{strings.home.intro}</p>
<div className="mx-auto max-w-2xl px-5 pb-20 pt-10 sm:px-6">
{/* ---- hero : qui je suis, où j'en suis, le geste suivant ---- */}
<p className="text-sm font-medium uppercase tracking-widest text-[#b85c48]">
{strings.home.brand}
</p>
<h1 className="mt-2 text-4xl font-bold leading-tight tracking-tight text-[#2b2620] sm:text-5xl">
{journey.answered > 0
? strings.home.hello(session.respondent_label)
: strings.home.h1}
</h1>
<p className="mt-3 max-w-prose text-lg text-[#6f675c]">
{journey.answered > 0
? strings.home.journeyLine(journey.answered, journey.total, journey.doneCount)
: strings.home.intro}
</p>
{journey.resumeQ && (
<button
type="button"
onClick={start}
className="mt-6 inline-flex min-h-12 items-center gap-2 rounded-full bg-[#2b2620] px-6 py-3 text-base font-bold text-[#faf7f2] transition hover:bg-[#b85c48] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]"
>
<span aria-hidden="true">→</span>
{journey.answered > 0 ? strings.home.resumeCta : strings.home.beginCta}
</button>
)}
<div className="mt-4 h-1.5 w-full max-w-sm overflow-hidden rounded-full bg-[#e9e2d6]">
<div
className="h-full rounded-full bg-[#b85c48] transition-all duration-300"
style={{ width: pct + '%' }}
/>
</div>
{/* ---- premier rang : guide, vidéos, carnet ---- */}
<div className="mt-10 grid gap-3 sm:grid-cols-3">
{[
{ href: '/couple/guide', title: strings.explorer.guideBtn, line: strings.explorer.guideLine, glyph: '¶' },
{ href: '/couple/videos', title: strings.explorer.videosBtn, line: strings.explorer.videosLine, glyph: '▶' },
{ href: '/couple/carnet', title: strings.explorer.carnetBtn, line: padCount > 0 ? strings.explorer.carnetLineN(padCount) : strings.explorer.carnetLine, glyph: '✎' },
].map(function (b) {
return (
<Link
key={b.href}
href={b.href}
className="group flex min-h-24 flex-col justify-between rounded-2xl border border-[#e4dccf] bg-white p-4 transition hover:border-[#b85c48] hover:shadow-[0_2px_12px_rgba(43,38,32,0.08)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]"
>
<span className="flex items-baseline justify-between">
<span className="font-bold text-[#2b2620]">{b.title}</span>
<span aria-hidden="true" className="text-lg text-[#b85c48] transition group-hover:translate-x-0.5">{b.glyph}</span>
</span>
<span className="mt-2 text-sm text-[#6f675c]">{b.line}</span>
</Link>
);
})}
</div>
<ul className={styles.cardlist}>
{/* ---- questionnaires : lignes calmes, barres fines ---- */}
<h2 className="mt-12 text-sm font-medium uppercase tracking-widest text-[#6f675c]">
{strings.home.listTitle}
</h2>
<ul className="mt-3 divide-y divide-[#eee7da] border-y border-[#eee7da]">
{COUPLE_DATA.questionnaires.map(function (q) {
var total = allItems(q).length;
var st = readRecord(q.id);
var n = st ? answeredCount(q, st) : 0;
var done = st && n >= total;
var rowPct = total > 0 ? Math.round((n / total) * 100) : 0;
return (
<li key={q.id}>
<button
type="button"
className={styles.cardbtn}
onClick={() => cardClick(q, goIntro, goQuiz, goRecap)}
className="flex w-full items-center gap-4 py-3.5 text-left transition hover:bg-[#faf3ea] focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[#b85c48]"
onClick={function () { cardClick(q, goIntro, goQuiz, goRecap); }}
>
<span>{displayTitle(q.title)}</span>
{st && n >= total ? (
<span className={styles.state}>{strings.home.cardDone}</span>
) : n > 0 ? (
<span className={styles.state}>{strings.home.cardPartial(n, total)}</span>
) : (
<span className={styles.meta}>
{q.type === 'worksheet'
? strings.home.cardWorksheet(total)
: strings.home.cardQuestions(total)}
<span className="min-w-0 flex-1">
<span className="block truncate font-medium text-[#2b2620]">{displayTitle(q.title)}</span>
<span className="mt-1 block h-1 w-full max-w-40 overflow-hidden rounded-full bg-[#eee7da]">
<span
className={'block h-full rounded-full ' + (done ? 'bg-[#5e7d5a]' : 'bg-[#b85c48]')}
style={{ width: rowPct + '%' }}
/>
</span>
)}
</span>
<span className={'shrink-0 text-sm tabular-nums ' + (done ? 'text-[#5e7d5a]' : 'text-[#6f675c]')}>
{done
? strings.home.cardDone
: n > 0
? strings.home.cardPartial(n, total)
: q.type === 'worksheet'
? strings.home.cardWorksheet(total)
: strings.home.cardQuestions(total)}
</span>
</button>
</li>
);
})}
</ul>
<div className={styles.who}>
<label htmlFor="respondent-label">{strings.home.whoLabel}</label>
{/* ---- je réponds en tant que ---- */}
<div className="mt-8 max-w-sm">
<label htmlFor="respondent-label" className="text-sm font-medium text-[#2b2620]">
{strings.home.whoLabel}
</label>
<input
id="respondent-label"
maxLength={40}
value={session.respondent_label}
onChange={handleRespondent}
className="mt-1.5 w-full rounded-xl border border-[#e4dccf] bg-white px-3 py-2.5 font-medium text-[#2b2620] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[#b85c48]"
/>
<p className="mt-2 text-sm text-[#6f675c]">{strings.home.disclosure}</p>
</div>
{/* Le guide et le carnet : lire, regarder, écrire, pas seulement répondre. */}
<div className={styles.together}>
<h2>{strings.explorer.title}</h2>
<p className={styles.muted}>{strings.explorer.intro}</p>
<div className={styles.footlinks}>
{goGuide && (
<button type="button" className={styles.linkbtn} onClick={goGuide}>
{strings.explorer.guideBtn}
</button>
)}
{goGuide && ' · '}
<button type="button" className={styles.linkbtn} onClick={goCarnet}>
{strings.explorer.carnetBtn}
</button>
</div>
</div>
{/* Visibilité partagée : à dire avant la première séance, ça change la façon de répondre. */}
<p className={styles.muted}>{strings.home.disclosure}</p>
<p className={styles.muted}>{strings.home.closing}</p>
<div className={styles.together}>
<h2>{strings.home.togetherTitle}</h2>
<p className={styles.muted}>{strings.home.togetherIntro}</p>
<div className={styles.footlinks}>
<button type="button" className={styles.linkbtn} onClick={function () { setShareAllOpen(!shareAllOpen); }}>
{/* ---- à deux : outils repliés ---- */}
<details className="group mt-10 rounded-2xl border border-[#e4dccf] bg-white p-4">
<summary className="cursor-pointer list-none font-bold text-[#2b2620] marker:hidden [&::-webkit-details-marker]:hidden">
<span className="inline-flex items-baseline gap-2">
{strings.home.togetherTitle}
<span aria-hidden="true" className="text-[#b85c48] transition group-open:rotate-90">›</span>
</span>
</summary>
<p className="mt-2 text-sm text-[#6f675c]">{strings.home.togetherIntro}</p>
<div className="mt-4 flex flex-wrap items-baseline gap-x-3 gap-y-2">
<button type="button" className="text-[#b85c48] underline-offset-2 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]" onClick={function () { setShareAllOpen(!shareAllOpen); }}>
{strings.home.shareAllBtn}
</button>
{' · '}
<button type="button" className={styles.linkbtn} onClick={async function () {
<button type="button" className="text-[#b85c48] underline-offset-2 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]" onClick={async function () {
var ok = await exportCouplePdf();
if (ok) { setPdfDone(true); setTimeout(function () { setPdfDone(false); }, 2500); }
}}>
......@@ -148,15 +245,18 @@ export default function HomeView({ goIntro, goQuiz, goRecap, trackWrite, goCompa
</button>
</div>
{shareAllOpen && <ShareAllPanel />}
<div className={styles.compareRow}>
<label htmlFor="compare-link">{strings.compare.pasteLabel}</label>
<div className="mt-4 flex flex-wrap items-baseline gap-2">
<label htmlFor="compare-link" className="text-sm font-medium text-[#2b2620]">
{strings.compare.pasteLabel}
</label>
<input
id="compare-link"
value={compareLink}
placeholder={strings.compare.pasteHint}
onChange={function (e) { setCompareLink(e.target.value); setCompareError(false); }}
className="min-w-0 flex-1 rounded-xl border border-[#e4dccf] bg-white px-3 py-2 text-sm text-[#2b2620] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[#b85c48]"
/>
<button type="button" className={styles.btn} onClick={function () {
<button type="button" className="min-h-11 rounded-xl border border-[#e4dccf] bg-white px-4 py-2 text-sm font-bold text-[#2b2620] transition hover:border-[#b85c48] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]" onClick={function () {
var raw = compareLink.trim();
var hash = raw.indexOf('#p=') !== -1 ? raw.slice(raw.indexOf('#p=') + 3)
: raw.indexOf('#a=') !== -1 ? raw.slice(raw.indexOf('#a=') + 3) : '';
......@@ -164,39 +264,27 @@ export default function HomeView({ goIntro, goQuiz, goRecap, trackWrite, goCompa
goCompare(hash);
}}>{strings.compare.pasteBtn}</button>
</div>
{compareError && <p className={styles.muted}>{strings.compare.pasteError}</p>}
</div>
{compareError && <p className="mt-2 text-sm text-[#8a3d2e]">{strings.compare.pasteError}</p>}
</details>
<footer className={styles.pagefoot}>
<p>{strings.home.footLine}</p>
<p className={styles.muted}>{RIGHTS_LINE}</p>
<p className={styles.footlinks}>
{/* ---- pied : honnêteté + effacement ---- */}
<footer className="mt-12 border-t border-[#eee7da] pt-6">
<p className="text-sm text-[#6f675c]">{strings.home.footLine}</p>
<p className="mt-1 text-sm text-[#6f675c]">{RIGHTS_LINE}</p>
{/* Le texte de confirmation reste un nœud de texte direct du <p> :
les requêtes RTL lisent getNodeText, pas textContent. */}
<p className={'mt-4 text-sm' + (confirmingDelete ? ' text-[#8a3d2e]' : '')}>
{confirmingDelete ? (
<>
{strings.home.deleteConfirm}{' '}
<Button onClick={handleDelete}>{strings.home.deleteYes}</Button>{' '}
<button
type="button"
className={styles.linkbtn}
onClick={() => setConfirmingDelete(false)}
>
{strings.home.deleteNo}
</button>
</>
) : (
<>
<button type="button" className={styles.linkbtn} onClick={() => downloadExport()}>
{strings.home.exportBtn}
</button>
<button type="button" className="font-bold text-[#8a3d2e] underline underline-offset-2" onClick={handleDelete}>{strings.home.deleteYes}</button>
{' · '}
<button
type="button"
className={`${styles.linkbtn} ${styles.linkbtnDanger}`}
onClick={() => setConfirmingDelete(true)}
>
{strings.home.deleteBtn}
</button>
<button type="button" className="text-[#6f675c] underline underline-offset-2" onClick={function () { setConfirmingDelete(false); }}>{strings.home.deleteNo}</button>
</>
) : (
<button type="button" className="text-[#6f675c] underline underline-offset-2 hover:text-[#8a3d2e] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]" onClick={function () { setConfirmingDelete(true); }}>
{strings.home.deleteBtn}
</button>
)}
</p>
</footer>
......@@ -204,7 +292,6 @@ export default function HomeView({ goIntro, goQuiz, goRecap, trackWrite, goCompa
);
}
/* Lien global : toutes les réponses, encodées dans le fragment (#a=),
même avertissement que le lien mono-questionnaire. */
function ShareAllPanel() {
......@@ -232,16 +319,18 @@ function ShareAllPanel() {
}
}
return (
<div className={styles.sharePanel}>
<p>{strings.recap.share.warning}</p>
<div className={styles.shareRow}>
<div className="mt-4 rounded-xl bg-[#faf3ea] p-3">
<p className="text-sm text-[#2b2620]">{strings.recap.share.warning}</p>
<div className="mt-2 flex gap-2">
<input id="share-all-input" readOnly value={url} aria-label={strings.recap.share.inputAria}
onFocus={function (e) { e.target.select(); }} />
<button type="button" className={styles.btn} onClick={copy}>
onFocus={function (e) { e.target.select(); }}
className="min-w-0 flex-1 rounded-xl border border-[#e4dccf] bg-white px-3 py-2 text-sm text-[#2b2620] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[#b85c48]" />
<button type="button" onClick={copy}
className="min-h-11 shrink-0 rounded-xl bg-[#2b2620] px-4 py-2 text-sm font-bold text-[#faf7f2] transition hover:bg-[#b85c48] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]">
{copied ? strings.recap.share.copied : strings.recap.share.copy}
</button>
</div>
<p className={styles.muted}>{strings.home.shareAllNote}</p>
<p className="mt-2 text-sm text-[#6f675c]">{strings.home.shareAllNote}</p>
</div>
);
}
'use client';
/* Clarté couple : set de questions d'écriture du guide. Chaque question est
un espace d'écriture autosave (300 ms après la frappe, comme les feuilles
de travail). La question peut être relue sans rouler l'écran : la zone
garde sa hauteur, on écrit dans n'importe quel ordre. */
/* Clarté couple : set de questions d'écriture, sa propre URL
(/couple/questions/<slug>). Chaque question est un espace d'écriture
autosave (300 ms après la frappe, comme les feuilles de travail), numéroté,
dans l'ordre. On écrit dans n'importe quel ordre, on revient quand on veut. */
import { useEffect, useState } from 'react';
import Button from '@/components/clarte/Button';
import Link from 'next/link';
import TextArea from '@/components/clarte/TextArea';
import { readGuideNotes, writeGuideNote } from './engine';
import { itemHref } from './GuideHub';
import { strings } from './strings';
import styles from './couple.module.css';
export default function QuestionSetView({ item, goBack, trackWrite = function () {} }) {
export default function QuestionSetView({ item, next, trackWrite = function () {} }) {
const [notes, setNotes] = useState({});
useEffect(function () {
......@@ -25,24 +25,34 @@ export default function QuestionSetView({ item, goBack, trackWrite = function ()
};
return (
<div>
<h1 className={styles.title}>{item.title}</h1>
{item.summary && <p className={styles.muted}>{item.summary}</p>}
<div className={styles.nav}>
<Button onClick={goBack}>{strings.guide.backHome}</Button>
</div>
<div className="mx-auto max-w-2xl px-5 pb-20 pt-10 sm:px-6">
<nav className="text-sm text-[#6f675c]">
<Link href="/couple/guide" className="underline-offset-2 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]">
{strings.guide.toGuide}
</Link>
<span aria-hidden="true" className="mx-2">›</span>
<span className="font-medium text-[#2b2620]">{item.title}</span>
</nav>
<h1 className="mt-4 text-3xl font-bold leading-tight tracking-tight text-[#2b2620] sm:text-4xl">
{item.title}
</h1>
{item.summary && <p className="mt-3 max-w-prose text-lg text-[#6f675c]">{item.summary}</p>}
{item.intro && (
/* HTML de confiance : rendu au build depuis content/couple (repo). */
<div className={styles.fiche} dangerouslySetInnerHTML={{ __html: item.intro }} />
<div className="couple-prose mt-6" dangerouslySetInnerHTML={{ __html: item.intro }} />
)}
<ol className={styles.writelist}>
<ol className="mt-6 flex list-none flex-col gap-8 p-0">
{item.questions.map(function (question, qi) {
var key = String(qi);
var value = (notes[key] || {}).text || '';
return (
<li key={key} className={styles.writeitem}>
<p className={styles.writequestion}>{question}</p>
<li key={key} className="border-t border-[#eee7da] pt-5">
<p className="max-w-prose text-balance font-medium text-[#2b2620]">
<span className="mr-1 font-bold text-[#b85c48]">{qi + 1}.</span>
{question}
</p>
<TextArea
id={'gnote-' + item.id + '-' + key}
rows={4}
......@@ -50,9 +60,9 @@ export default function QuestionSetView({ item, goBack, trackWrite = function ()
ariaLabel={question}
value={value}
onChange={function (v) {
var next = Object.assign({}, notes);
next[key] = { text: v, updated: (notes[key] || {}).updated };
setNotes(next);
var nextNotes = Object.assign({}, notes);
nextNotes[key] = { text: v, updated: (notes[key] || {}).updated };
setNotes(nextNotes);
}}
onDebouncedChange={function (v) { save(key, v); }}
/>
......@@ -60,7 +70,20 @@ export default function QuestionSetView({ item, goBack, trackWrite = function ()
);
})}
</ol>
<p className={styles.muted}>{strings.guide.noteHint}</p>
<p className="mt-6 max-w-prose text-sm text-[#6f675c]">{strings.guide.noteHint}</p>
{next && (
<Link
href={itemHref(next)}
className="mt-10 flex items-center justify-between rounded-2xl border border-[#e4dccf] bg-white p-4 transition hover:border-[#b85c48] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]"
>
<span>
<span className="block text-sm text-[#6f675c]">{strings.guide.nextLabel}</span>
<span className="block font-bold text-[#2b2620]">{next.title}</span>
</span>
<span aria-hidden="true" className="text-lg text-[#b85c48]">→</span>
</Link>
)}
</div>
);
}
'use client';
/* Clarté couple : visionnage d'une vidéo du guide, à deux. Façade locale :
l'iframe youtube-nocookie ne charge qu'au clic (aucune requête au lecteur
avant), la note d'après-visionnage s'enregistre avec les écrits du guide.
Voir la vidéo pose la marque « vu » sur la carte du sommaire. */
/* Clarté couple : visionnage d'une vidéo, sa propre URL (/couple/videos/<slug>).
Façade locale : l'iframe youtube-nocookie ne charge qu'au clic, la note
d'après-visionnage s'enregistre avec les écrits du guide. Voir la vidéo
pose la marque « vu » sur le sommaire. */
import { useEffect, useState } from 'react';
import Button from '@/components/clarte/Button';
import Link from 'next/link';
import TextArea from '@/components/clarte/TextArea';
import { readGuideNotes, writeGuideMark, writeGuideNote } from './engine';
import { itemHref } from './GuideHub';
import { strings } from './strings';
import styles from './couple.module.css';
const NOTE_KEY = 'video';
export default function VideoView({ item, goBack, trackWrite = function () {} }) {
export default function VideoView({ item, next, trackWrite = function () {} }) {
const [playing, setPlaying] = useState(false);
const [note, setNote] = useState('');
......@@ -32,36 +32,46 @@ export default function VideoView({ item, goBack, trackWrite = function () {} })
};
return (
<div>
<h1 className={styles.title}>{item.title}</h1>
<p className={styles.muted}>{item.summary}</p>
<div className={styles.nav}>
<Button onClick={goBack}>{strings.guide.backHome}</Button>
</div>
<div className="mx-auto max-w-2xl px-5 pb-20 pt-10 sm:px-6">
<nav className="text-sm text-[#6f675c]">
<Link href="/couple/videos" className="underline-offset-2 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]">
{strings.explorer.videosBtn}
</Link>
<span aria-hidden="true" className="mx-2">›</span>
<span className="font-medium text-[#2b2620]">{item.title}</span>
</nav>
<h1 className="mt-4 text-3xl font-bold leading-tight tracking-tight text-[#2b2620] sm:text-4xl">
{item.title}
</h1>
{item.summary && <p className="mt-3 max-w-prose text-lg text-[#6f675c]">{item.summary}</p>}
<div className={styles.videoframe}>
<div className="relative mt-6 aspect-video overflow-hidden rounded-2xl bg-black">
{playing ? (
<iframe
src={'https://www.youtube-nocookie.com/embed/' + item.youtube}
title={item.title}
allowFullScreen
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
className="absolute inset-0 h-full w-full border-0"
/>
) : (
<button type="button" className={styles.videofacade} onClick={play}>
<button type="button" onClick={play} className="absolute inset-0 w-full cursor-pointer focus-visible:outline focus-visible:outline-[3px] focus-visible:-outline-offset-3 focus-visible:outline-[#b85c48]">
<img
src={'https://i.ytimg.com/vi/' + item.youtube + '/hqdefault.jpg'}
alt=""
loading="lazy"
className="h-full w-full object-cover opacity-85"
/>
<span className={styles.videoplay} aria-hidden="true">▶</span>
<span className={styles.videoplaylabel}>{strings.guide.watch}</span>
<span aria-hidden="true" className="absolute left-1/2 top-1/2 flex h-16 w-16 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-[#2b2620]/85 text-xl text-white">▶</span>
<span className="absolute bottom-3 left-1/2 -translate-x-1/2 text-sm font-bold text-white [text-shadow:0_1px_4px_rgba(0,0,0,0.7)]">
{strings.guide.watch}
</span>
</button>
)}
</div>
<h2 className={styles.themeTitle}>{strings.carnet.h1}</h2>
<p className={styles.muted}>{strings.guide.videoNote}</p>
<h2 className="mt-8 font-bold text-[#2b2620]">{strings.carnet.h1}</h2>
<p className="mt-1 max-w-prose text-sm text-[#6f675c]">{strings.guide.videoNote}</p>
<TextArea
id={'videonote-' + item.id}
rows={6}
......@@ -72,7 +82,20 @@ export default function VideoView({ item, goBack, trackWrite = function () {} })
onChange={setNote}
onDebouncedChange={saveNote}
/>
<p className={styles.muted}>{strings.guide.noteSaved}</p>
<p className="mt-1 text-sm text-[#6f675c]">{strings.guide.noteSaved}</p>
{next && (
<Link
href={itemHref(next)}
className="mt-10 flex items-center justify-between rounded-2xl border border-[#e4dccf] bg-white p-4 transition hover:border-[#b85c48] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#b85c48]"
>
<span>
<span className="block text-sm text-[#6f675c]">{strings.guide.nextLabel}</span>
<span className="block font-bold text-[#2b2620]">{next.title}</span>
</span>
<span aria-hidden="true" className="text-lg text-[#b85c48]">→</span>
</Link>
)}
</div>
);
}
......@@ -8,7 +8,15 @@ export const strings = {
'Impossible d’enregistrer sur cet appareil (navigation privée ?). Vos réponses seront perdues à la fermeture de la page.',
home: {
brand: 'Clarté couple',
h1: 'Espace couple',
hello: (who) => 'Bonjour, ' + who,
journeyLine: (answered, total, done) =>
'Vous avez répondu à ' + answered + ' questions sur ' + total +
(done > 0 ? ', ' + done + ' questionnaire' + (done > 1 ? 's' : '') + ' terminé' + (done > 1 ? 's' : '') : '') + '.',
resumeCta: 'Reprendre où j’en étais',
beginCta: 'Commencer le premier questionnaire',
listTitle: 'Les questionnaires',
intro:
'Des questionnaires pour mettre des mots, à deux, sur ce qui se passe entre vous. Répondez librement, à votre rythme. Tout reste sur cet appareil, rien n’est envoyé nulle part.',
disclosure:
......@@ -26,7 +34,7 @@ export const strings = {
cardQuestions: (total) => total + ' questions',
cardWorksheet: (total) => total + ' écrits à compléter',
cardPartial: (n, total) => 'En cours · ' + n + ' sur ' + total,
togetherTitle: 'À deux, et avec votre praticienne',
togetherTitle: 'À deux, et pour la séance',
togetherIntro:
'Un lien avec toutes vos réponses, un document PDF à apporter en séance, ou la comparaison côte à côte avec la personne que vous aimez.',
shareAllBtn: 'Créer un lien avec toutes mes réponses',
......@@ -39,11 +47,13 @@ export const strings = {
},
explorer: {
title: 'Lire, regarder, écrire',
intro:
'Les fiches et vidéos de la praticienne, et un carnet libre pour garder ce qui se dit.',
guideBtn: 'Le guide de la praticienne',
guideBtn: 'Le guide',
guideLine: 'À lire, à deux ou seul·e',
videosBtn: 'Les vidéos',
videosLine: 'À regarder ensemble',
carnetBtn: 'Le carnet',
carnetLine: 'Écrire librement, ça s’enregistre seul',
carnetLineN: (n) => n + ' note' + (n > 1 ? 's' : ''),
},
intro: {
......@@ -164,10 +174,11 @@ export const strings = {
},
guide: {
h1: 'Le guide de la praticienne',
h1: 'Le guide',
intro:
'Les fiches, vidéos et questions d’écriture envoyées avec les séances, rangées dans l’ordre où elles sont arrivées. À lire, à regarder, à écrire, à votre rythme.',
backHome: 'Retour à l’accueil',
'Les fiches, vidéos et questions d’écriture reçues pendant le parcours, rangées dans l’ordre où elles sont arrivées. À lire, à regarder, à écrire, à votre rythme.',
backHome: 'Retour',
toGuide: 'Le guide',
readAgain: 'Relire',
read: 'Lire',
watch: 'Regarder',
......@@ -175,6 +186,8 @@ export const strings = {
seen: 'Déjà lu',
write: 'Écrire',
answeredOf: (n, total) => n + (n === 1 ? ' écrit' : ' écrits') + ' sur ' + total,
nextLabel: 'Poursuivre',
stepLabel: (step) => (step === 1 ? 'Premier temps' : 'Deuxième temps'),
noteSaved: 'Enregistré sur cet appareil.',
noteHint: 'Vos écrits restent sur cet appareil. On peut les relire, les compléter, en parler à deux.',
videoNote: 'Une note pendant ou après la vidéo, pour garder ce qui vous parle.',
......
......@@ -103,3 +103,26 @@ export async function loadCoupleGuide() {
.map((step) => ({ step, themes: steps[step] })),
};
}
/* Le guide à plat, dans l'ordre de lecture (step puis order) : sert aux
routes /couple/fiches|videos|questions/[slug] et à leurs liens voisin. */
export async function loadCoupleItems() {
const guide = await loadCoupleGuide();
const items = [];
for (const step of guide.steps) {
for (const theme of step.themes) {
for (const item of theme.items) items.push({ ...item, step: step.step, theme: theme.theme });
}
}
return items;
}
/* Route → item : collection = nom de dossier du corpus (fiches, videos,
questions), slug = nom de fichier. Retourne aussi le voisin suivant pour
le lien « poursuivre » en bas de page. */
export async function findCoupleItem(collection, slug) {
const items = await loadCoupleItems();
const index = items.findIndex((it) => it.kind + 's' === collection && it.id.split(':')[1] === slug);
if (index === -1) return null;
return { item: items[index], next: items[index + 1] || null };
}
import { chromium } from 'playwright';
const html = `<!doctype html><html><head><meta charset="utf-8"><style>
@font-face { font-family:'Atkinson'; src:url('file://${process.cwd()}/public/fonts/AtkinsonHyperlegible-Bold.woff2') format('woff2'); font-weight:700; }
@font-face { font-family:'Atkinson'; src:url('file://${process.cwd()}/public/fonts/AtkinsonHyperlegible-Regular.woff2') format('woff2'); font-weight:400; }
*{margin:0;box-sizing:border-box}
body{width:1200px;height:630px;background:#faf7f2;color:#2b2620;font-family:'Atkinson',system-ui,sans-serif;display:flex;flex-direction:column;justify-content:center;padding:0 96px;position:relative;overflow:hidden}
.kicker{font-size:26px;font-weight:700;letter-spacing:.28em;text-transform:uppercase;color:#b85c48;margin-bottom:22px}
h1{font-size:104px;font-weight:700;line-height:1.02;letter-spacing:-0.02em;max-width:900px}
p{margin-top:30px;font-size:30px;color:#6f675c;max-width:640px;line-height:1.4}
.rule{position:absolute;left:96px;bottom:88px;width:220px;height:6px;background:#b85c48;border-radius:3px}
.dot{position:absolute;right:-140px;top:-140px;width:460px;height:460px;border-radius:50%;background:#f3e5da}
</style></head><body>
<div class="dot"></div>
<div class="kicker">me.nech.pl</div>
<h1>Clarté couple</h1>
<p>Des questionnaires, des fiches et un carnet pour mettre des mots, à deux, sur ce qui se passe entre vous.</p>
<div class="rule"></div>
</body></html>`;
const b = await chromium.launch();
const page = await b.newPage({ viewport: { width: 1200, height: 630 } });
await page.setContent(html);
await page.waitForTimeout(400);
await page.screenshot({ path: 'public/images/couple/og.png' });
await b.close();
console.log('og written');
......@@ -70,4 +70,50 @@ html {
:global(.animate-shine) {
animation: shine 1.5s ease-in-out;
}
/* Clarté couple : prose des fiches du guide (HTML rendu au build par
lib/couple-guide.js, injecté via dangerouslySetInnerHTML). */
.couple-prose h2 {
font-size: 1.125rem;
font-weight: 700;
color: var(--couple-ink, #2b2620);
margin: 2rem 0 0.5rem;
}
.couple-prose h3 {
font-size: 1rem;
font-weight: 700;
color: var(--couple-ink, #2b2620);
margin: 1.5rem 0 0.25rem;
}
.couple-prose p {
margin: 0.75rem 0;
max-width: 44ch;
text-wrap: pretty;
}
.couple-prose ul, .couple-prose ol {
margin: 0.75rem 0;
padding-left: 1.3rem;
}
.couple-prose li {
margin: 0.35rem 0;
}
.couple-prose table {
border-collapse: collapse;
margin: 1rem 0;
max-width: 100%;
display: block;
overflow-x: auto;
}
.couple-prose th, .couple-prose td {
border-bottom: 1px solid #eee7da;
text-align: left;
padding: 0.35rem 0.75rem 0.35rem 0;
vertical-align: top;
font-size: 0.9rem;
}
.couple-prose th {
border-bottom-color: #e4dccf;
font-size: 0.8rem;
color: #6f675c;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment