Rework the daily card page around what the player knows and hints opened in any order
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6993080d81
commit
880f007cce
24 changed files with 812 additions and 415 deletions
|
|
@ -1,15 +1,23 @@
|
|||
// Rôle : fournit un champ NDS d'autocomplete libre pour les catégories.
|
||||
// Rôle : fournit un champ NDS d'autocomplete, libre pour les catégories ou en mode recherche (`searchTexts`) : la liste attend une saisie,
|
||||
// surligne le texte trouvé, dit pourquoi une option apparaît et l'absence de résultat, et Entrée prend la première option.
|
||||
import { forwardRef, useEffect, useId, useMemo, useRef, useState } from "react";
|
||||
|
||||
// Recherche sans casse ni accents : « neant » trouve « Néant ».
|
||||
function searchKey(value) {
|
||||
return value.normalize("NFD").replace(/\p{Diacritic}/gu, "").toLowerCase();
|
||||
return value.normalize("NFD").replace(/\p{Diacritic}/gu, "").replace(/[’`]/g, "'").replace(/œ/gi, "oe").toLowerCase();
|
||||
}
|
||||
|
||||
// Texte trouvé dans l'option, surligné ; tel quel quand la recherche n'a pas la même longueur que le texte (« œ »).
|
||||
function HighlightedText({ text, query }) {
|
||||
const start = searchKey(text).indexOf(query);
|
||||
if (!query || start < 0 || searchKey(text).length !== text.length) return text;
|
||||
return <>{text.slice(0, start)}<mark>{text.slice(start, start + query.length)}</mark>{text.slice(start + query.length)}</>;
|
||||
}
|
||||
|
||||
// Mots proches d'une option (`keywords`, une Map option → mots) : ils ne comptent qu'à partir de trois lettres, par leur début.
|
||||
const MIN_KEYWORD_QUERY = 3;
|
||||
function matchesKeyword(words, query) {
|
||||
return words.some((word) => searchKey(word).startsWith(query));
|
||||
function matchingKeyword(words, query) {
|
||||
return words.find((word) => searchKey(word).startsWith(query));
|
||||
}
|
||||
|
||||
function normalizeOptions(options) {
|
||||
|
|
@ -29,6 +37,8 @@ export const CategoryAutocompleteInput = forwardRef(function CategoryAutocomplet
|
|||
name,
|
||||
options,
|
||||
keywords,
|
||||
usedOptions,
|
||||
searchTexts,
|
||||
placeholder,
|
||||
value,
|
||||
onChange,
|
||||
|
|
@ -46,17 +56,19 @@ export const CategoryAutocompleteInput = forwardRef(function CategoryAutocomplet
|
|||
const [activeIndex, setActiveIndex] = useState(-1);
|
||||
const cleanOptions = useMemo(() => normalizeOptions(options), [options]);
|
||||
const cleanValue = String(value || "");
|
||||
const query = searchKey(cleanValue.trim());
|
||||
const filteredOptions = useMemo(() => {
|
||||
const query = searchKey(cleanValue.trim());
|
||||
if (!query) return cleanOptions.slice(0, maxOptions);
|
||||
const matches = cleanOptions.filter((option) => searchKey(option).includes(query));
|
||||
const close = keywords && query.length >= MIN_KEYWORD_QUERY
|
||||
? cleanOptions.filter((option) => !searchKey(option).includes(query) && matchesKeyword(keywords.get(option) || [], query))
|
||||
? cleanOptions.filter((option) => !searchKey(option).includes(query) && matchingKeyword(keywords.get(option) || [], query))
|
||||
: [];
|
||||
return [...matches, ...close].slice(0, maxOptions);
|
||||
}, [cleanOptions, cleanValue, keywords, maxOptions]);
|
||||
}, [cleanOptions, keywords, maxOptions, query]);
|
||||
// Options déjà prises : citées en fin de liste, sans pouvoir être choisies.
|
||||
const usedMatches = searchTexts && query ? (usedOptions || []).filter((option) => searchKey(option).includes(query)) : [];
|
||||
const menuId = `${inputId}-menu`;
|
||||
const showMenu = open && filteredOptions.length > 0;
|
||||
const showMenu = open && (searchTexts ? Boolean(query) : filteredOptions.length > 0);
|
||||
|
||||
// Au clavier, l'option active reste visible quand la liste défile.
|
||||
useEffect(() => {
|
||||
|
|
@ -98,6 +110,7 @@ export const CategoryAutocompleteInput = forwardRef(function CategoryAutocomplet
|
|||
|
||||
function handleKeyDown(event) {
|
||||
if (!filteredOptions.length) {
|
||||
if (event.key === "Escape") setOpen(false);
|
||||
onKeyDown?.(event);
|
||||
return;
|
||||
}
|
||||
|
|
@ -112,6 +125,9 @@ export const CategoryAutocompleteInput = forwardRef(function CategoryAutocomplet
|
|||
} else if (event.key === "Enter" && open && activeIndex >= 0) {
|
||||
event.preventDefault();
|
||||
selectOption(filteredOptions[activeIndex]);
|
||||
} else if (event.key === "Enter" && open && searchTexts && query && !cleanOptions.some((option) => searchKey(option) === query)) {
|
||||
event.preventDefault();
|
||||
selectOption(filteredOptions[0]);
|
||||
} else if (event.key === "Escape" && open) {
|
||||
setOpen(false);
|
||||
setActiveIndex(-1);
|
||||
|
|
@ -155,9 +171,12 @@ export const CategoryAutocompleteInput = forwardRef(function CategoryAutocomplet
|
|||
onMouseDown={(event) => event.preventDefault()}
|
||||
onClick={() => selectOption(option)}
|
||||
>
|
||||
{option}
|
||||
{searchTexts ? <HighlightedText text={option} query={query} /> : option}
|
||||
{searchTexts && !searchKey(option).includes(query) && <small>{searchTexts.keyword.replace("{word}", matchingKeyword(keywords.get(option) || [], query))}</small>}
|
||||
</button>
|
||||
))}
|
||||
{usedMatches.map((option) => <div className="nds-autocomplete-option" key={option} role="option" aria-disabled="true" aria-selected="false" onMouseDown={(event) => event.preventDefault()}>{option}<small>{searchTexts.used}</small></div>)}
|
||||
{searchTexts && !filteredOptions.length && !usedMatches.length && <div className="nds-autocomplete-option" role="option" aria-disabled="true" aria-selected="false" onMouseDown={(event) => event.preventDefault()}>{searchTexts.none.replace("{query}", cleanValue.trim())}</div>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
54
website/src/features/cards/DailyFeedback.jsx
Normal file
54
website/src/features/cards/DailyFeedback.jsx
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
// Rôle : sous la saisie de la Carte du jour, les règles avant le premier essai, puis le bilan du dernier essai et « Ce que vous savez ».
|
||||
import { Fragment } from "react";
|
||||
import { DailyIcon } from "./DailyIcon.jsx";
|
||||
import { dailyKnowledge, dailyVerdict } from "./dailyKnowledge.js";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
|
||||
// Étapes d'un sujet en pastilles ; `isFound` dit lesquelles le joueur a trouvées, `isNew` celles que le dernier essai vient d'apprendre.
|
||||
export function SubjectChips({ labels, isFound = () => true, isNew = () => false }) {
|
||||
return <span className="nebula-daily-path">{labels.map((label, index) => <span key={label} className="nebula-daily-path-step">
|
||||
{index > 0 && <span aria-hidden="true">›</span>}
|
||||
<span className="nebula-daily-chip" data-found={isFound(index) || undefined} data-new={isNew(index) || undefined}>{label}</span>
|
||||
</span>)}</span>;
|
||||
}
|
||||
|
||||
function RuledOut({ labels, known, content }) {
|
||||
if (!labels.length) return null;
|
||||
return <span className="nebula-daily-ruled-out">{labels.length > 1 ? content.ruledOutMany : content.ruledOutOne} {labels.map((label, index) => <Fragment key={label}>{index > 0 && ", "}<s data-new={!known.includes(label) || undefined}>{label}</s></Fragment>)}</span>;
|
||||
}
|
||||
|
||||
export function DailyRules({ content }) {
|
||||
return <div className="nebula-daily-rules">
|
||||
<p>{content.intro}</p>
|
||||
<ul>{[["zoomOut", content.ruleZoom], ["compare", content.ruleCompare], ["lens", content.ruleHint]].map(([icon, text]) => <li key={icon}><span className="nebula-daily-disc"><DailyIcon name={icon} /></span>{text}</li>)}</ul>
|
||||
</div>;
|
||||
}
|
||||
|
||||
export function DailyFeedback({ catalog, daily, content }) {
|
||||
const guess = daily.guesses.at(-1);
|
||||
const name = catalog.cards.find((card) => card.id === guess.cardId)?.name || guess.cardId;
|
||||
const themeHint = daily.hints.find((hint) => hint.id === "theme")?.value ?? null;
|
||||
const now = dailyKnowledge(daily.guesses, themeHint);
|
||||
const before = dailyKnowledge(daily.guesses.slice(0, -1), themeHint);
|
||||
const verdict = dailyVerdict(daily.guesses, content);
|
||||
return <div className="nebula-daily-feedback" key={guess.cardId}>
|
||||
<div className="nebula-daily-verdict">
|
||||
<p><strong>{name}</strong>{content.missed}</p>
|
||||
<span className="nebula-daily-gains">
|
||||
{daily.hintCredits > 0 && <span data-kind="hint"><DailyIcon name="lens" />{content.hintGained}</span>}
|
||||
{daily.guesses.length === daily.maxGuesses - 1 && <span data-kind="last">{content.lastAttemptNotice}</span>}
|
||||
</span>
|
||||
{verdict.length > 0 && <p className="nebula-daily-verdict-subject">{verdict.map((part, index) => (part.tone ? <b key={index} data-tone={part.tone}>{part.text}</b> : <span key={index}>{part.text}</span>))}</p>}
|
||||
</div>
|
||||
<section className="nebula-daily-know" aria-labelledby="nebula-daily-know-title">
|
||||
<h3 id="nebula-daily-know-title">{content.knowTitle}</h3>
|
||||
<dl>
|
||||
<dt>{content.columnSubject}</dt>
|
||||
<dd>{now.path.length ? <SubjectChips labels={now.path} isNew={(index) => index >= before.path.length} /> : <span>{content.notFoundYet}</span>}<RuledOut labels={now.ruledOut} known={before.ruledOut} content={content} /></dd>
|
||||
<dt>{content.columnTheme}</dt>
|
||||
<dd>{now.theme ? <SubjectChips labels={[now.theme]} isNew={() => !before.theme} /> : <><span>{content.notFoundYet}</span><RuledOut labels={now.ruledOutThemes} known={before.ruledOutThemes} content={content} /></>}</dd>
|
||||
</dl>
|
||||
</section>
|
||||
<span className="sr-only">{fillTemplate(content.attemptsLeft, { count: daily.maxGuesses - daily.guesses.length })}</span>
|
||||
</div>;
|
||||
}
|
||||
|
|
@ -1,40 +1,54 @@
|
|||
// Rôle : grille des six essais de la Carte du jour : la carte proposée, son sujet et son thème comparés à ceux de la réponse.
|
||||
import { Fragment } from "react";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
// Rôle : grille des essais de la Carte du jour : la carte proposée, son sujet et son thème comparés à ceux de la réponse.
|
||||
import { dailyGuessResult, DAILY_MARKS, fillTemplate } from "./dailyShare.js";
|
||||
|
||||
// Chemin du sujet : les étapes trouvées, puis la première qui diffère. Le chemin de la réponse n'est jamais montré.
|
||||
function SubjectPath({ subject, content }) {
|
||||
return <span className="nebula-daily-path">
|
||||
{subject.common.map((label, index) => <Fragment key={label}>
|
||||
{index > 0 && <span aria-hidden="true">›</span>}
|
||||
<span className="nebula-daily-step" data-same="true" aria-label={fillTemplate(content.sameStep, { label })}><span aria-hidden="true">✓</span>{label}</span>
|
||||
</Fragment>)}
|
||||
{subject.different && <>
|
||||
{subject.common.length > 0 && <span aria-hidden="true">›</span>}
|
||||
<span className="nebula-daily-step" aria-label={fillTemplate(content.differentStep, { label: subject.different })}><span aria-hidden="true">✗</span><s>{subject.different}</s></span>
|
||||
</>}
|
||||
</span>;
|
||||
const steps = [...subject.common.map((step) => ({ label: step.label, same: true })), ...(subject.different ? [{ label: subject.different.label, same: false }] : [])];
|
||||
return <span className="nebula-daily-path">{steps.map(({ label, same }, index) => <span key={label} className="nebula-daily-path-step">
|
||||
{index > 0 && <span aria-hidden="true">›</span>}
|
||||
<Compared label={label} same={same} text={same ? content.sameStep : content.differentStep} className="nebula-daily-step" />
|
||||
</span>)}</span>;
|
||||
}
|
||||
|
||||
// Vert : comme la réponse. Barré : différent. Le sens est aussi dit aux lecteurs d'écran.
|
||||
function Compared({ label, same, text, className }) {
|
||||
const Tag = same ? "b" : "s";
|
||||
return <span className={className} data-same={same || undefined}><span className="sr-only">{fillTemplate(text, { label })}</span><Tag aria-hidden="true">{label}</Tag></span>;
|
||||
}
|
||||
|
||||
// Nom de la carte, le mot qui donne son thème souligné.
|
||||
function CardName({ name, theme }) {
|
||||
if (!theme) return <strong>{name}</strong>;
|
||||
const [start, end] = theme.span;
|
||||
return <strong>{name.slice(0, start)}<u data-same={theme.same || undefined}>{name.slice(start, end)}</u>{name.slice(end)}</strong>;
|
||||
}
|
||||
|
||||
function DailyFamilies({ content }) {
|
||||
return <section className="nebula-daily-families" aria-label={content.guessesTitle}>
|
||||
<p>{content.guessesEmpty}</p>
|
||||
<ul>{content.families.map(({ name, text }) => <li key={name}><b>{name}</b><span>{text}</span></li>)}</ul>
|
||||
</section>;
|
||||
}
|
||||
|
||||
export function DailyGuesses({ catalog, daily, content }) {
|
||||
const finished = daily.status !== "playing";
|
||||
const rows = Array.from({ length: finished ? daily.guesses.length : daily.maxGuesses }, (_, index) => daily.guesses[index] || null);
|
||||
if (!daily.guesses.length) return <DailyFamilies content={content} />;
|
||||
const playing = daily.status === "playing";
|
||||
const results = daily.guesses.map(dailyGuessResult);
|
||||
return <section className="nebula-daily-guesses" aria-labelledby="nebula-daily-guesses-title">
|
||||
<h3 id="nebula-daily-guesses-title" className="sr-only">{content.guessesTitle}</h3>
|
||||
<div className="nebula-daily-columns" aria-hidden="true"><span>{content.columnGuess}</span><span>{content.columnSubject}</span><span>{content.columnTheme}</span></div>
|
||||
<ol>{rows.map((guess, index) => {
|
||||
if (!guess) {
|
||||
const next = index === daily.guesses.length;
|
||||
return <li key={index} className="nebula-daily-row" data-empty="true" aria-hidden="true"><strong data-next={next || undefined}>{next ? fillTemplate(content.attempt, { count: index + 1, max: daily.maxGuesses }) : ""}</strong><span /><span /></li>;
|
||||
}
|
||||
const card = catalog.cards.find((item) => item.id === guess.cardId);
|
||||
return <li key={guess.cardId} className="nebula-daily-row nebula-daily-guess" data-correct={guess.correct || undefined}>
|
||||
<strong>{card?.name || guess.cardId}</strong>
|
||||
<div className="nebula-daily-heading">
|
||||
<h3 id="nebula-daily-guesses-title">{content.guessesTitle}</h3>
|
||||
<p aria-hidden="true"><span><b>{content.keySame}</b>{content.keySameText}</span> <span><s>{content.keyDifferent}</s>{content.keyDifferentText}</span></p>
|
||||
</div>
|
||||
<div className="nebula-daily-columns" aria-hidden="true"><span /><span>{content.columnGuess}</span><span>{content.columnSubject}</span><span>{content.columnTheme}</span></div>
|
||||
<ol>{daily.guesses.map((guess, index) => {
|
||||
const result = results[index];
|
||||
return <li key={guess.cardId} className="nebula-daily-guess" data-result={result} data-last={(playing && index === daily.guesses.length - 1) || undefined}>
|
||||
<span className="nebula-daily-mark" data-result={result}><span aria-hidden="true">{DAILY_MARKS[result]}</span><span className="sr-only">{fillTemplate(content.attemptResult, { count: index + 1, result: content.results[result] })}</span></span>
|
||||
<CardName name={catalog.cards.find((item) => item.id === guess.cardId)?.name || guess.cardId} theme={guess.theme} />
|
||||
<SubjectPath subject={guess.subject} content={content} />
|
||||
{guess.theme
|
||||
? <span className="nebula-daily-theme" data-same={guess.theme.same || undefined} aria-label={fillTemplate(guess.theme.same ? content.sameTheme : content.differentTheme, { label: guess.theme.label })}><span aria-hidden="true">{guess.theme.same ? "✓" : "✗"}</span>{guess.theme.label}</span>
|
||||
: <span className="nebula-daily-theme">{content.noTheme}</span>}
|
||||
<span className="nebula-daily-theme-cell" data-label={content.columnTheme}>{guess.theme ? <Compared label={guess.theme.label} same={guess.theme.same} text={guess.theme.same ? content.sameTheme : content.differentTheme} className="nebula-daily-theme" /> : content.noTheme}</span>
|
||||
</li>;
|
||||
})}</ol>
|
||||
<p className="nebula-daily-legend"><span>{content.legendTheme}</span>{results.includes("close") && <span><b aria-hidden="true">{DAILY_MARKS.close}</b> {content.legendClose}</span>}</p>
|
||||
</section>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,44 +1,55 @@
|
|||
// Rôle : indices facultatifs de la Carte du jour : cinq tuiles face cachée, une à retourner par essai raté, au choix du joueur.
|
||||
// Rôle : indices facultatifs de la Carte du jour : cinq cadres de taille fixe, un à dévoiler par essai raté, dans l'ordre choisi par le joueur.
|
||||
import { DailyIcon } from "./DailyIcon.jsx";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
|
||||
const HINT_LABELS = { album: "hintAlbum", collection: "hintCollection", page: "hintPage", theme: "hintTheme", shape: "hintShape" };
|
||||
|
||||
// Texte dont certains mots manquent : le serveur ne les envoie pas.
|
||||
function MaskedText({ parts, content, className }) {
|
||||
return <span className={className}>{parts.map((part, index) => (part.hidden
|
||||
function MaskedText({ parts, content }) {
|
||||
return parts.map((part, index) => (part.hidden
|
||||
? <span key={index} className="nebula-daily-gap"><span className="sr-only">{content.hintHiddenWord}</span></span>
|
||||
: <span key={index}>{part.text}</span>))}</span>;
|
||||
: <span key={index}>{part.text}</span>));
|
||||
}
|
||||
|
||||
function HintValue({ catalog, hint, content }) {
|
||||
if (hint.id === "album") return <span className="nebula-daily-hint-value">{hint.value ? content.hintAlbumYes : content.hintAlbumNo}</span>;
|
||||
if (hint.id === "theme") return <span className="nebula-daily-hint-value">{hint.value}</span>;
|
||||
if (hint.id === "collection") return <span className="nebula-daily-hint-value">{catalog.collections.find((item) => item.id === hint.value)?.name}</span>;
|
||||
return <MaskedText parts={hint.value} content={content} className={hint.id === "page" ? "nebula-daily-hint-page" : "nebula-daily-hint-value"} />;
|
||||
if (hint.id === "album") return <strong>{hint.value ? content.hintAlbumYes : content.hintAlbumNo}</strong>;
|
||||
if (hint.id === "theme") return <strong>{hint.value}</strong>;
|
||||
if (hint.id === "collection") return <strong>{catalog.collections.find((item) => item.id === hint.value)?.name}</strong>;
|
||||
if (hint.id === "page") return <em><MaskedText parts={hint.value} content={content} /></em>;
|
||||
return <strong><MaskedText parts={hint.value} content={content} /></strong>;
|
||||
}
|
||||
|
||||
function hintStatus(choice, daily, wrongCount, content) {
|
||||
if (daily.status !== "playing") return content.hintUnused;
|
||||
if (choice.known) return content.hintKnown;
|
||||
if (choice.available) return content.hintFlip;
|
||||
if (wrongCount >= choice.after) return content.hintNext;
|
||||
return choice.after === 1 ? content.hintAfterOne : fillTemplate(content.hintAfterMany, { count: choice.after });
|
||||
function helpText(daily, content) {
|
||||
if (daily.hintCredits > 1) return content.hintsMany;
|
||||
if (daily.hintCredits === 1) return content.hintsOne;
|
||||
if (!daily.guesses.length) return content.hintsRule;
|
||||
return daily.guesses.length === daily.maxGuesses - 1 || daily.hintChoices.every((choice) => choice.known || daily.hints.some((hint) => hint.id === choice.id)) ? content.hintsSpent : content.hintsNext;
|
||||
}
|
||||
|
||||
// Réserve d'indices : une loupe par indice à dévoiler.
|
||||
function HintPurse({ credits, content }) {
|
||||
return <span className="nebula-daily-purse" data-on={credits > 0 || undefined} role="status">
|
||||
{Array.from({ length: Math.max(1, credits) }, (_, index) => <DailyIcon key={index} name="lens" />)}
|
||||
{credits ? fillTemplate(credits > 1 ? content.hintCreditsMany : content.hintCreditsOne, { count: credits }) : content.hintCreditsNone}
|
||||
</span>;
|
||||
}
|
||||
|
||||
export function DailyHints({ catalog, daily, busy, content, onUse }) {
|
||||
const flipped = new Map(daily.hints.map((hint) => [hint.id, hint]));
|
||||
const wrongCount = daily.guesses.filter((guess) => !guess.correct).length;
|
||||
const credits = daily.hintCredits;
|
||||
const help = daily.status !== "playing" ? "" : credits > 1 ? fillTemplate(content.hintsMany, { count: credits }) : credits === 1 ? content.hintsOne : content.hintsNone;
|
||||
const opened = new Map(daily.hints.map((hint) => [hint.id, hint]));
|
||||
const guessedTheme = daily.guesses.find((guess) => guess.theme?.same)?.theme.label;
|
||||
return <section className="nebula-daily-hints" aria-labelledby="nebula-daily-hints-title">
|
||||
<div className="nebula-daily-hints-heading"><h3 id="nebula-daily-hints-title">{content.hintsTitle}</h3><p role="status">{help}</p></div>
|
||||
<ul>{daily.hintChoices.map((choice) => {
|
||||
const hint = flipped.get(choice.id);
|
||||
const label = content[HINT_LABELS[choice.id]];
|
||||
if (hint) return <li key={choice.id} className="nebula-daily-hint" data-state="open"><small>{label}</small><HintValue catalog={catalog} hint={hint} content={content} /></li>;
|
||||
const status = hintStatus(choice, daily, wrongCount, content);
|
||||
return <li key={choice.id} className="nebula-daily-hint" data-state={choice.available ? "ready" : "locked"}>
|
||||
<button type="button" disabled={busy || !choice.available} onClick={() => onUse(choice.id)}><strong>{label}</strong><small>{status}</small></button>
|
||||
<div className="nebula-daily-heading">
|
||||
<h3 id="nebula-daily-hints-title">{content.hintsTitle}</h3>
|
||||
<p>{helpText(daily, content)}</p>
|
||||
<HintPurse credits={daily.hintCredits} content={content} />
|
||||
</div>
|
||||
<ul>{daily.hintChoices.map(({ id, known, available }) => {
|
||||
const { title, text } = content.hints[id];
|
||||
// Un thème trouvé par un essai s'affiche ouvert, sans coûter d'indice.
|
||||
const found = known && id === "theme" && guessedTheme ? { id, value: guessedTheme } : null;
|
||||
const hint = opened.get(id) || found;
|
||||
const icon = <span className="nebula-daily-disc"><DailyIcon name={id} /></span>;
|
||||
if (hint) return <li key={id} className="nebula-daily-hint" data-hint={id} data-state="open"><div>{icon}<span><small>{opened.has(id) ? title : fillTemplate(content.hintKnown, { title })}</small><HintValue catalog={catalog} hint={hint} content={content} /></span></div></li>;
|
||||
return <li key={id} className="nebula-daily-hint" data-hint={id} data-state={available ? "ready" : "locked"}>
|
||||
<button type="button" disabled={busy || !available} title={available ? content.hintOpen : undefined} onClick={() => onUse(id)}>{icon}<span><strong>{title}</strong><small>{text}</small></span><span className="nebula-daily-lens"><DailyIcon name="lens" /></span></button>
|
||||
</li>;
|
||||
})}</ul>
|
||||
</section>;
|
||||
|
|
|
|||
15
website/src/features/cards/DailyIcon.jsx
Normal file
15
website/src/features/cards/DailyIcon.jsx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Rôle : icônes au trait de la Carte du jour (indices, loupe et règles du départ), teintées par la couleur du texte.
|
||||
const PATHS = {
|
||||
zoomOut: <><rect x="3.5" y="3.5" width="17" height="17" rx="3" /><path d="M8.5 12h-3m13 0h-3M12 8.5v-3m0 13v-3M5.5 12l1.8-1.5M5.5 12l1.8 1.5M18.5 12l-1.8-1.5m1.8 1.5-1.8 1.5" /></>,
|
||||
compare: <><rect x="3.5" y="5" width="7" height="14" rx="1.5" /><rect x="13.5" y="5" width="7" height="14" rx="1.5" /><path d="M6 10h2m8 0h2M6 14h2m8 0h2" /></>,
|
||||
lens: <><circle cx="10.5" cy="10.5" r="6.5" /><path d="m15.5 15.5 5.5 5.5" /></>,
|
||||
album: <><path d="M12 6.5C10 5 7 4.5 3.5 4.8v13.7c3.5-.3 6.5.2 8.5 1.7 2-1.5 5-2 8.5-1.7V4.8C17 4.5 14 5 12 6.5Z" /><path d="M12 6.5v13.7" /></>,
|
||||
collection: <><rect x="9" y="3.5" width="11.5" height="15" rx="2" /><path d="M6.5 6.5v12.2a2 2 0 0 0 2 2h8M3.5 9.5v9" /></>,
|
||||
page: <><path d="M6 3.5h8L18.5 8v12L16 18.5l-2 2-2.5-2-2 2-3-2-.5 1Z" /><path d="M14 3.5V8h4.5M9 11.5h6M9 14.5h4" /></>,
|
||||
theme: <><path d="m12 3.5 2 6.5 6.5 2-6.5 2-2 6.5-2-6.5-6.5-2 6.5-2Z" /><path d="M19 3.5v3M17.5 5h3" /></>,
|
||||
shape: <><path d="M3 18 7.2 6.5h.6L12 18M4.6 14h5.8" /><path d="M14.5 18H21M14.5 13H21" strokeDasharray="2.5 1.6" /></>
|
||||
};
|
||||
|
||||
export function DailyIcon({ name }) {
|
||||
return <svg className="nebula-daily-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">{PATHS[name]}</svg>;
|
||||
}
|
||||
|
|
@ -1,11 +1,14 @@
|
|||
// Rôle : présente la Carte du jour : illustration zoomée, propositions comparées, indices au choix, révélation et résultat à partager.
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { CategoryAutocompleteInput } from "../../components/CategoryAutocompleteInput.jsx";
|
||||
import { flipDailyHint, guessDaily, loadDaily, loadDailyImage } from "./cardsApi.js";
|
||||
import { readCollection } from "./collectionState.js";
|
||||
import { DailyFeedback, DailyRules } from "./DailyFeedback.jsx";
|
||||
import { DailyGuesses } from "./DailyGuesses.jsx";
|
||||
import { DailyHints } from "./DailyHints.jsx";
|
||||
import { dailyGuessResult, dailyShareText, fillTemplate, findCardByName, formatCountdown, formatStreak } from "./dailyShare.js";
|
||||
import { DailyResult } from "./DailyResult.jsx";
|
||||
import { fillTemplate, findCardByName } from "./dailyShare.js";
|
||||
import { DailyTrack } from "./DailyTrack.jsx";
|
||||
import { NebulaCard } from "./NebulaCard.jsx";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
|
||||
|
|
@ -21,40 +24,6 @@ function referenceEntry(catalog, cardId) {
|
|||
return card && edition ? { editionId: edition.id, edition, card } : null;
|
||||
}
|
||||
|
||||
function DailyResult({ catalog, state, daily, content, now }) {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const answer = referenceEntry(catalog, daily.answerCardId);
|
||||
const owned = readCollection(state).ownedCardIds.has(daily.answerCardId);
|
||||
const won = daily.status === "won";
|
||||
async function share() {
|
||||
const text = dailyShareText(daily, { title: content.shareTitle, url: `${window.location.origin}/#/cards/daily` });
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
} catch {
|
||||
setCopied(false);
|
||||
}
|
||||
}
|
||||
return <section className="nds-panel nebula-daily-result" aria-labelledby="nebula-daily-result-title" data-status={daily.status}>
|
||||
<div className="nebula-daily-result-copy">
|
||||
<h3 id="nebula-daily-result-title">{won ? fillTemplate(content.wonTitle, { count: daily.guesses.length, max: daily.maxGuesses }) : content.lostTitle}</h3>
|
||||
{!won && <p>{content.lostText}</p>}
|
||||
{answer && <p className="nebula-daily-answer"><strong>{answer.card.name}</strong>{answer.card.description && <span>{answer.card.description}</span>}</p>}
|
||||
<div className="nebula-daily-result-badges">
|
||||
{won && daily.earned > 0 && <span className="nds-badge" data-variant="gold">{fillTemplate(content.earned, { reward: formatStardust(daily.earned) })}</span>}
|
||||
<span className="nds-badge" data-variant={owned ? "success" : "neutral"}>{owned ? content.owned : content.notOwned}</span>
|
||||
{daily.hints.length > 0 && <span className="nds-badge" data-variant="neutral">{fillTemplate(content.hintsUsed, { count: daily.hints.length })}</span>}
|
||||
{daily.streak > 0 && <span className="nds-badge" data-variant="neutral">{fillTemplate(content.streak, { streak: formatStreak(daily.streak) })}</span>}
|
||||
</div>
|
||||
<div className="nds-toolbar nebula-daily-result-actions">
|
||||
<button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={share}>{copied ? content.shared : content.share}</button>
|
||||
<span className="nebula-daily-next">{fillTemplate(content.next, { time: formatCountdown(daily.nextAt - now) })}</span>
|
||||
</div>
|
||||
</div>
|
||||
{answer && <div className="nebula-daily-result-card"><NebulaCard catalog={catalog} entry={answer} size="md" /></div>}
|
||||
</section>;
|
||||
}
|
||||
|
||||
export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
||||
const [daily, setDaily] = useState(null);
|
||||
const [loadError, setLoadError] = useState("");
|
||||
|
|
@ -63,7 +32,10 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
const [guess, setGuess] = useState("");
|
||||
const [notice, setNotice] = useState("");
|
||||
const [now, setNow] = useState(() => Date.now());
|
||||
const inputRef = useRef(null);
|
||||
const [refocus, setRefocus] = useState(0);
|
||||
const day = daily?.day || "";
|
||||
const answer = useMemo(() => (daily?.answerCardId ? referenceEntry(catalog, daily.answerCardId) : null), [catalog, daily]);
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
|
|
@ -75,9 +47,11 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
|
||||
// Le serveur n'envoie que la zone visible au zoom courant : chaque essai raté recharge un morceau plus large, et
|
||||
// l'illustration entière n'arrive qu'en fin de partie. Le morceau précédent reste affiché pendant le chargement.
|
||||
// La partie finie, la carte elle-même prend la place de l'illustration.
|
||||
const cardShown = Boolean(answer);
|
||||
const zoom = daily?.zoom ?? 0;
|
||||
useEffect(() => {
|
||||
if (!day) return undefined;
|
||||
if (!day || cardShown) return undefined;
|
||||
let active = true;
|
||||
let url = "";
|
||||
loadDailyImage()
|
||||
|
|
@ -91,13 +65,18 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
active = false;
|
||||
if (url) URL.revokeObjectURL(url);
|
||||
};
|
||||
}, [day, zoom]);
|
||||
}, [day, zoom, cardShown]);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => setNow(Date.now()), COUNTDOWN_TICK_MS);
|
||||
return () => clearInterval(timer);
|
||||
}, []);
|
||||
|
||||
// Un essai envoyé rend la main à la saisie, désactivée le temps de la réponse.
|
||||
useEffect(() => {
|
||||
if (refocus) inputRef.current?.focus({ preventScroll: true });
|
||||
}, [refocus]);
|
||||
|
||||
const guessable = useMemo(() => {
|
||||
if (!daily) return [];
|
||||
const collections = new Set(daily.collectionIds);
|
||||
|
|
@ -105,6 +84,7 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
return catalog.cards.filter((card) => collections.has(card.collectionId) && !guessed.has(card.id)).sort((left, right) => left.name.localeCompare(right.name, "fr"));
|
||||
}, [catalog.cards, daily]);
|
||||
const options = useMemo(() => guessable.map((card) => card.name), [guessable]);
|
||||
const guessedNames = useMemo(() => (daily?.guesses || []).map((item) => catalog.cards.find((card) => card.id === item.cardId)?.name).filter(Boolean), [catalog.cards, daily]);
|
||||
const searchWords = daily?.searchWords;
|
||||
const keywords = useMemo(() => new Map(guessable.filter((card) => searchWords?.[card.id]).map((card) => [card.name, searchWords[card.id]])), [guessable, searchWords]);
|
||||
|
||||
|
|
@ -113,6 +93,7 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
|
||||
const expired = now >= daily.nextAt;
|
||||
const finished = daily.status !== "playing";
|
||||
const owned = answer && readCollection(state).ownedCardIds.has(answer.card.id);
|
||||
const imageUrl = image.day === daily.day ? image.url : "";
|
||||
const imageFailed = image.day === daily.day && image.failed;
|
||||
|
||||
|
|
@ -133,16 +114,20 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
return Boolean(result?.daily);
|
||||
}
|
||||
|
||||
const chosen = findCardByName(guessable, guess);
|
||||
const tried = daily.guesses.length;
|
||||
|
||||
async function submit(event) {
|
||||
event.preventDefault();
|
||||
setNotice("");
|
||||
const card = findCardByName(catalog.cards.filter((item) => daily.collectionIds.includes(item.collectionId)), guess);
|
||||
if (!card) return setNotice(content.guessUnknown);
|
||||
if (daily.guesses.some((item) => item.cardId === card.id)) return setNotice(content.guessRepeated);
|
||||
if (await play(() => guessDaily(daily.day, card.id))) setGuess("");
|
||||
if (!chosen) return;
|
||||
if (await play(() => guessDaily(daily.day, chosen.id))) {
|
||||
setGuess("");
|
||||
setRefocus((count) => count + 1);
|
||||
}
|
||||
}
|
||||
|
||||
function flipHint(hint) {
|
||||
function openHint(hint) {
|
||||
setNotice("");
|
||||
return play(() => flipDailyHint(daily.day, hint));
|
||||
}
|
||||
|
|
@ -156,32 +141,30 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
</div>
|
||||
</div>
|
||||
{expired && <div className="nds-inline-notice nebula-daily-expired" data-variant="warning" role="status"><span>{content.expired}</span><button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={() => { setNow(Date.now()); setReloadKey((key) => key + 1); }}>{content.reload}</button></div>}
|
||||
<div className="nebula-daily-layout">
|
||||
<div className="nebula-daily-layout" data-finished={finished || undefined}>
|
||||
<div className="nds-panel nebula-daily-stage">
|
||||
<div className="nebula-daily-frame" data-finished={finished || undefined}>
|
||||
{answer ? <>
|
||||
<NebulaCard catalog={catalog} entry={answer} size="md" />
|
||||
<span className="nds-badge" data-variant={owned ? "success" : "neutral"}>{owned ? content.owned : content.notOwned}</span>
|
||||
</> : <div className="nebula-daily-frame" data-finished={finished || undefined}>
|
||||
{imageUrl ? <img key={imageUrl} src={imageUrl} alt={content.imageAlt} draggable="false" /> : <span className="nebula-daily-frame-status" role={imageFailed ? "alert" : "status"}>{imageFailed ? content.imageError : content.imageLoading}</span>}
|
||||
</div>}
|
||||
</div>
|
||||
{finished ? <DailyResult catalog={catalog} card={answer?.card} daily={daily} content={content} now={now} /> : <form className="nds-panel nebula-daily-form" onSubmit={submit}>
|
||||
<div className="nebula-daily-ask-heading">
|
||||
<label htmlFor="nebula-daily-guess">{content.guessLabel}</label>
|
||||
<span>{tried === daily.maxGuesses - 1 ? content.lastAttempt : fillTemplate(content.attempts, { count: tried + 1, max: daily.maxGuesses })}</span>
|
||||
</div>
|
||||
<ol className="nebula-daily-steps" aria-label={fillTemplate(content.attempts, { count: Math.min(daily.guesses.length + (finished ? 0 : 1), daily.maxGuesses), max: daily.maxGuesses })}>
|
||||
{Array.from({ length: daily.maxGuesses }, (_, index) => {
|
||||
const item = daily.guesses[index];
|
||||
const result = item ? dailyGuessResult(item) : "empty";
|
||||
return <li key={index} data-result={result} />;
|
||||
})}
|
||||
</ol>
|
||||
</div>
|
||||
<div className="nebula-daily-play">
|
||||
{finished ? <DailyResult catalog={catalog} state={state} daily={daily} content={content} now={now} /> : <form className="nds-panel nebula-daily-form" onSubmit={submit}>
|
||||
{daily.guesses.length === 0 && <p>{content.intro} {content.maybeNotOwned}</p>}
|
||||
<label htmlFor="nebula-daily-guess">{content.guessLabel} · {fillTemplate(content.attempts, { count: daily.guesses.length + 1, max: daily.maxGuesses })}</label>
|
||||
<div className="nebula-daily-form-row">
|
||||
<CategoryAutocompleteInput id="nebula-daily-guess" name="guess" options={options} keywords={keywords} value={guess} placeholder={content.guessPlaceholder} maxOptions={MAX_SUGGESTIONS} disabled={busy || expired} onChange={(event) => { setGuess(event.target.value); setNotice(""); }} />
|
||||
<button className="nds-button" data-variant="primary" type="submit" disabled={busy || expired || !guess.trim()}>{content.guessAction}</button>
|
||||
</div>
|
||||
{notice && <p className="nds-inline-notice" data-variant="warning" role="status">{notice}</p>}
|
||||
</form>}
|
||||
<DailyGuesses catalog={catalog} daily={daily} content={content} />
|
||||
</div>
|
||||
<DailyHints catalog={catalog} daily={daily} busy={busy || expired} content={content} onUse={flipHint} />
|
||||
<DailyTrack daily={daily} content={content} />
|
||||
<div className="nebula-daily-form-row">
|
||||
<CategoryAutocompleteInput ref={inputRef} id="nebula-daily-guess" name="guess" options={options} keywords={keywords} usedOptions={guessedNames} searchTexts={content.search} value={guess} placeholder={content.guessPlaceholder} maxOptions={MAX_SUGGESTIONS} disabled={busy || expired} onChange={(event) => { setGuess(event.target.value); setNotice(""); }} />
|
||||
<button className="nds-button" data-variant="primary" type="submit" disabled={busy || expired || !chosen}>{content.guessAction}</button>
|
||||
</div>
|
||||
{notice && <p className="nds-inline-notice" data-variant="warning" role="status">{notice}</p>}
|
||||
<div className="nebula-daily-aside" aria-live="polite">{tried ? <DailyFeedback catalog={catalog} daily={daily} content={content} /> : <DailyRules content={content} />}</div>
|
||||
</form>}
|
||||
{!finished && <DailyHints catalog={catalog} daily={daily} busy={busy || expired} content={content} onUse={openHint} />}
|
||||
<DailyGuesses catalog={catalog} daily={daily} content={content} />
|
||||
</div>
|
||||
</section>;
|
||||
}
|
||||
|
|
|
|||
53
website/src/features/cards/DailyResult.jsx
Normal file
53
website/src/features/cards/DailyResult.jsx
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// Rôle : fin d'une partie de la Carte du jour : résultat, description, réponse détaillée, gains et résultat à partager.
|
||||
import { useState } from "react";
|
||||
import { SubjectChips } from "./DailyFeedback.jsx";
|
||||
import { dailyKnowledge } from "./dailyKnowledge.js";
|
||||
import { dailyShareText, fillTemplate, formatCountdown, formatStreak } from "./dailyShare.js";
|
||||
import { DailyTrack } from "./DailyTrack.jsx";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
|
||||
function wonTitle(count, content) {
|
||||
return count === 1 ? content.wonFirstTitle : fillTemplate(content.wonTitle, { count });
|
||||
}
|
||||
|
||||
export function DailyResult({ catalog, card, daily, content, now }) {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const won = daily.status === "won";
|
||||
const collection = catalog.collections.find((item) => item.id === card?.collectionId)?.name;
|
||||
const { subject, theme } = daily.answerClues;
|
||||
// Après une défaite, ce que les essais et l'indice ont trouvé reste en vert, le reste est en gris.
|
||||
const known = dailyKnowledge(daily.guesses, daily.hints.find((hint) => hint.id === "theme")?.value ?? null);
|
||||
async function share() {
|
||||
const text = dailyShareText(daily, { title: content.shareTitle, url: `${window.location.origin}/#/cards/daily` });
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
} catch {
|
||||
setCopied(false);
|
||||
}
|
||||
}
|
||||
return <section className="nds-panel nebula-daily-result" aria-labelledby="nebula-daily-result-title" data-status={daily.status}>
|
||||
<div className="nebula-daily-ask-heading">
|
||||
<h3 id="nebula-daily-result-title">{won ? wonTitle(daily.guesses.length, content) : content.lostTitle}</h3>
|
||||
{daily.hints.length > 0 && <span>{fillTemplate(daily.hints.length > 1 ? content.hintsUsedMany : content.hintsUsedOne, { count: daily.hints.length })}</span>}
|
||||
</div>
|
||||
<DailyTrack daily={daily} content={content} />
|
||||
{card?.description && <p className="nebula-daily-description">{card.description}</p>}
|
||||
<section className="nebula-daily-know" aria-labelledby="nebula-daily-answer-title">
|
||||
<h4 id="nebula-daily-answer-title">{content.answerTitle}</h4>
|
||||
<dl>
|
||||
{subject.length > 0 && <><dt>{content.columnSubject}</dt><dd><SubjectChips labels={subject.map((step) => step.label)} isFound={(index) => won || index < known.path.length} /></dd></>}
|
||||
{theme && <><dt>{content.columnTheme}</dt><dd><span className="nebula-daily-answer-theme"><SubjectChips labels={[theme.label]} isFound={() => won || Boolean(known.theme)} />{card && <span>« {card.name.slice(...theme.span)} »</span>}</span></dd></>}
|
||||
{collection && <><dt>{content.hints.collection.title}</dt><dd>{collection}</dd></>}
|
||||
</dl>
|
||||
</section>
|
||||
{won && <ul className="nebula-daily-rewards">
|
||||
{daily.earned > 0 && <li>{fillTemplate(content.earned, { reward: formatStardust(daily.earned) })}</li>}
|
||||
{daily.streak > 0 && <li>{fillTemplate(content.streak, { streak: formatStreak(daily.streak) })}</li>}
|
||||
</ul>}
|
||||
<div className="nebula-daily-result-actions">
|
||||
<button className="nds-button" data-variant="primary" type="button" onClick={share}>{copied ? content.shared : content.share}</button>
|
||||
<span>{fillTemplate(content.next, { time: formatCountdown(daily.nextAt - now) })}</span>
|
||||
</div>
|
||||
</section>;
|
||||
}
|
||||
12
website/src/features/cards/DailyTrack.jsx
Normal file
12
website/src/features/cards/DailyTrack.jsx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Rôle : piste des six essais de la Carte du jour : le signe de chaque essai joué, le numéro de ceux à venir.
|
||||
import { dailyGuessResult, DAILY_MARKS, fillTemplate } from "./dailyShare.js";
|
||||
|
||||
export function DailyTrack({ daily, content }) {
|
||||
const playing = daily.status === "playing";
|
||||
return <ol className="nebula-daily-track" aria-label={content.guessesTitle}>{Array.from({ length: daily.maxGuesses }, (_, index) => {
|
||||
const guess = daily.guesses[index];
|
||||
if (!guess) return <li key={index} data-now={(playing && index === daily.guesses.length) || undefined} aria-hidden="true">{playing ? index + 1 : ""}</li>;
|
||||
const result = dailyGuessResult(guess);
|
||||
return <li key={index} data-result={result}><span aria-hidden="true">{DAILY_MARKS[result]}</span><span className="sr-only">{fillTemplate(content.attemptResult, { count: index + 1, result: content.results[result] })}</span></li>;
|
||||
})}</ol>;
|
||||
}
|
||||
32
website/src/features/cards/dailyKnowledge.js
Normal file
32
website/src/features/cards/dailyKnowledge.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Rôle : règles d'affichage de ce qu'un joueur de la Carte du jour a appris : bilan cumulé de ses essais et phrase sur le dernier.
|
||||
|
||||
// Le sujet : le plus long chemin trouvé, puis seulement les étapes écartées juste après lui (une famille écartée n'apprend plus rien
|
||||
// une fois la bonne connue). Le thème : celui d'un essai ou de l'indice, sinon les thèmes écartés.
|
||||
export function dailyKnowledge(guesses, themeHint = null) {
|
||||
const path = guesses.reduce((best, guess) => (guess.subject.common.length > best.length ? guess.subject.common : best), []).map((step) => step.label);
|
||||
const ruledOut = guesses.filter((guess) => guess.subject.different && guess.subject.common.length === path.length).map((guess) => guess.subject.different.label);
|
||||
return {
|
||||
path,
|
||||
ruledOut: [...new Set(ruledOut)],
|
||||
theme: guesses.find((guess) => guess.theme?.same)?.theme.label ?? themeHint,
|
||||
ruledOutThemes: [...new Set(guesses.filter((guess) => guess.theme && !guess.theme.same).map((guess) => guess.theme.label))]
|
||||
};
|
||||
}
|
||||
|
||||
// Phrase sur le sujet du dernier essai, en morceaux ; `tone` marque le sujet nommé (`same` ou `different`). Vide pour une carte sans sujet.
|
||||
export function dailyVerdict(guesses, content) {
|
||||
const { common, different } = guesses.at(-1).subject;
|
||||
const found = common.at(-1);
|
||||
if (!found && !different) return [];
|
||||
const write = (template, step, tone) => {
|
||||
const [before, after] = template.split("{subject}");
|
||||
return [{ text: before }, { text: step.phrase, tone }, { text: after }];
|
||||
};
|
||||
const parts = found ? write(found.sentences?.same ?? content.subjectSame, found, "same") : write(different.sentences?.different ?? content.subjectDifferent, different, "different");
|
||||
if (found && different) parts.push(...write(found.sentences?.but ?? content.subjectBut, different, "different"));
|
||||
const before = dailyKnowledge(guesses.slice(0, -1));
|
||||
const now = dailyKnowledge(guesses);
|
||||
const learned = now.path.length > before.path.length || now.ruledOut.some((label) => !before.ruledOut.includes(label));
|
||||
parts.push({ text: learned ? "." : content.subjectKnown });
|
||||
return parts.filter((part) => part.text);
|
||||
}
|
||||
|
|
@ -27,9 +27,12 @@ export function dailyGuessResult(guess) {
|
|||
return guess.theme?.same || guess.subject.common.length > 1 ? "close" : "miss";
|
||||
}
|
||||
|
||||
// Signe de chaque résultat, sur la piste et dans la grille des essais.
|
||||
export const DAILY_MARKS = { miss: "✗", close: "≈", correct: "✓" };
|
||||
|
||||
const SHARE_SQUARES = { correct: "🟩", close: "🟨", miss: "⬛" };
|
||||
|
||||
// Une défaite se note X, comme dans les jeux du genre. Les indices retournés s'ajoutent au score : sans eux, rien.
|
||||
// Une défaite se note X, comme dans les jeux du genre. Les indices dévoilés s'ajoutent au score : sans eux, rien.
|
||||
export function dailyShareText(daily, { title, url }) {
|
||||
const score = daily.status === "won" ? `${daily.guesses.length}/${daily.maxGuesses}` : `X/${daily.maxGuesses}`;
|
||||
const hints = daily.hints.length ? ` · 💡${daily.hints.length}` : "";
|
||||
|
|
|
|||
|
|
@ -149,98 +149,6 @@
|
|||
.nebula-quest-body .nebula-quest-status { color: var(--color-text-primary); font-weight: 700; }
|
||||
.nebula-quest-body .nds-card-actions { display: flex; justify-self: stretch; justify-content: center; margin-top: var(--space-2); padding: 0; }
|
||||
|
||||
/* Carte du jour : illustration, propositions et grille des essais, puis les indices sur toute la largeur. */
|
||||
.nebula-daily { display: grid; gap: var(--space-4); min-width: 0; }
|
||||
.nebula-daily .nds-section-heading.nebula-section-heading { margin-bottom: 0; }
|
||||
.nebula-daily-heading-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-3); }
|
||||
.nebula-daily-expired { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin: 0; }
|
||||
.nebula-daily-layout { display: grid; grid-template-columns: minmax(240px, 360px) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
|
||||
/* À côté du menu de sections (1280 px de large), l'illustration se resserre pour laisser lire la grille des essais. */
|
||||
@container nebula-dashboard (max-width: 1200px) {
|
||||
.nebula-daily-layout { grid-template-columns: minmax(200px, 268px) minmax(0, 1fr); }
|
||||
}
|
||||
@container nebula-dashboard (max-width: 720px) {
|
||||
.nebula-daily-layout { grid-template-columns: minmax(0, 1fr); }
|
||||
.nebula-daily-stage { justify-self: center; width: min(100%, 360px); }
|
||||
}
|
||||
.nds-panel.nebula-daily-stage { display: grid; gap: var(--space-3); padding: var(--space-3); }
|
||||
.nebula-daily-frame { display: grid; place-items: center; overflow: hidden; aspect-ratio: 1; border-radius: var(--radius-lg); background: var(--color-bg-deep); }
|
||||
/* Chaque morceau envoyé par le serveur (zone visible au zoom courant) apparaît en fondu à la place du précédent. */
|
||||
.nebula-daily-frame img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; animation: nebula-daily-image-in 450ms ease; }
|
||||
@keyframes nebula-daily-image-in { from { opacity: 0; transform: scale(1.04); } }
|
||||
@media (prefers-reduced-motion: reduce) { .nebula-daily-frame img { animation: none; } }
|
||||
.nebula-daily-frame-status { padding: var(--space-4); color: var(--color-text-muted); font-size: var(--font-size-sm); text-align: center; }
|
||||
.nebula-daily-steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
|
||||
.nebula-daily-steps li { height: 8px; border-radius: var(--radius-pill); background: var(--color-bg-hover); }
|
||||
.nebula-daily-steps li[data-result="miss"] { background: var(--color-text-disabled); }
|
||||
.nebula-daily-steps li[data-result="close"] { background: var(--color-warning); }
|
||||
.nebula-daily-steps li[data-result="correct"] { background: var(--color-success); }
|
||||
.nebula-daily-play { display: grid; gap: var(--space-3); min-width: 0; }
|
||||
/* La liste de suggestions dépasse du panneau : il ne la coupe pas et passe au-dessus de la liste des essais. */
|
||||
.nds-panel.nebula-daily-form { z-index: 2; display: grid; gap: var(--space-2); padding: var(--space-4); overflow: visible; }
|
||||
.nebula-daily-form p:not(.nds-inline-notice) { margin: 0; color: var(--color-text-secondary); }
|
||||
.nebula-daily-form label { color: var(--color-text-primary); font-weight: 700; }
|
||||
.nebula-daily-form .nds-inline-notice { margin: 0; }
|
||||
.nebula-daily-form-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); align-items: start; }
|
||||
/* Grille des six essais : la carte proposée, le chemin de son sujet et son thème. Les lignes à venir gardent la hauteur stable. */
|
||||
.nebula-daily-guesses { display: grid; gap: var(--space-1); min-width: 0; }
|
||||
.nebula-daily-guesses ol { display: grid; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
|
||||
.nebula-daily-columns, .nebula-daily-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.9fr) minmax(0, 0.85fr); gap: var(--space-1); }
|
||||
.nebula-daily-columns { padding-inline: 2px; color: var(--color-text-muted); font-size: var(--font-size-xs); }
|
||||
.nebula-daily-row { min-height: 36px; }
|
||||
.nebula-daily-row > * { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 3px 8px; border-radius: var(--radius-sm); background: var(--color-bg-surface); color: var(--color-text-muted); font-size: 0.8125rem; line-height: 1.2; }
|
||||
.nebula-daily-row > strong { color: var(--color-text-primary); }
|
||||
.nebula-daily-row[data-empty] > * { opacity: 0.55; }
|
||||
.nebula-daily-row > strong[data-next] { opacity: 1; outline: 1px dashed var(--color-border-hover); outline-offset: -1px; color: var(--color-text-muted); font-weight: 400; }
|
||||
.nebula-daily-path { flex-wrap: wrap; row-gap: 3px; }
|
||||
.nebula-daily-step { display: inline-flex; align-items: center; gap: 4px; }
|
||||
.nebula-daily-step[data-same] { padding: 1px 8px; border-radius: var(--radius-pill); background: var(--color-success-soft); color: var(--color-success); font-weight: 600; }
|
||||
.nebula-daily-theme[data-same], .nebula-daily-row[data-correct] > * { background: var(--color-success-soft); color: var(--color-success); font-weight: 600; }
|
||||
|
||||
/* Indices au choix : cinq tuiles sur toute la largeur, qui se retournent sur place. */
|
||||
.nebula-daily-hints { display: grid; grid-column: 1 / -1; gap: var(--space-2); min-width: 0; }
|
||||
.nebula-daily-hints-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--space-3); }
|
||||
.nebula-daily-hints-heading :is(h3, p) { margin: 0; }
|
||||
.nebula-daily-hints-heading h3 { font-size: var(--font-size-base); }
|
||||
.nebula-daily-hints-heading p { color: var(--color-text-muted); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-hints ul { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
|
||||
.nebula-daily-hint { display: grid; min-width: 0; min-height: 104px; }
|
||||
.nebula-daily-hint > button { display: grid; align-content: center; justify-items: center; gap: 4px; padding: var(--space-2); border: 1px solid var(--color-border-hover); border-radius: var(--radius-md); background: radial-gradient(circle at 50% 45%, rgba(139, 92, 246, 0.3), transparent 68%), var(--color-bg-sidebar); color: var(--color-text-primary); font: inherit; text-align: center; }
|
||||
.nebula-daily-hint small { color: var(--color-text-muted); font-size: var(--font-size-xs); }
|
||||
.nebula-daily-hint[data-state="locked"] > button { opacity: 0.6; cursor: default; }
|
||||
.nebula-daily-hint[data-state="ready"] > button { border-color: var(--color-accent-gold); box-shadow: 0 0 18px rgba(246, 196, 83, 0.18); cursor: pointer; }
|
||||
.nebula-daily-hint[data-state="ready"] > button:hover { background-color: var(--color-bg-hover); }
|
||||
.nebula-daily-hint[data-state="ready"] > button:focus-visible { outline: 2px solid var(--color-accent-gold); outline-offset: 2px; }
|
||||
.nebula-daily-hint[data-state="ready"] small { color: var(--color-accent-gold); font-weight: 700; }
|
||||
.nebula-daily-hint[data-state="open"] { align-content: start; gap: 4px; padding: 10px 12px; border: 1px solid var(--color-border-hover); border-radius: var(--radius-md); background: var(--color-bg-elevated); animation: nebula-daily-hint-in 320ms var(--ease-standard); }
|
||||
@keyframes nebula-daily-hint-in { from { opacity: 0; transform: perspective(700px) rotateY(-80deg); } }
|
||||
@media (prefers-reduced-motion: reduce) { .nebula-daily-hint[data-state="open"] { animation: none; } }
|
||||
.nebula-daily-hint-value { color: var(--color-text-primary); font-size: var(--font-size-base); font-weight: 600; line-height: 1.3; }
|
||||
.nebula-daily-hint-page { color: var(--color-text-secondary); font-size: var(--font-size-sm); font-style: italic; line-height: 1.4; }
|
||||
.nebula-daily-gap { display: inline-block; width: 3em; height: 0.9em; border-radius: 3px; background: var(--color-text-disabled); vertical-align: -0.1em; }
|
||||
.nebula-daily-hint-value .nebula-daily-gap { width: 2.4em; background: var(--color-primary-border); }
|
||||
@container nebula-dashboard (max-width: 720px) {
|
||||
.nebula-daily-hints ul { grid-template-columns: repeat(6, minmax(0, 1fr)); }
|
||||
.nebula-daily-hint { grid-column: span 2; }
|
||||
.nebula-daily-hint:nth-child(n + 4) { grid-column: span 3; }
|
||||
}
|
||||
.nds-panel.nebula-daily-result { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: var(--space-4); align-items: center; padding: var(--space-5); }
|
||||
@container nebula-dashboard (max-width: 560px) {
|
||||
.nds-panel.nebula-daily-result { grid-template-columns: minmax(0, 1fr); }
|
||||
.nebula-daily-result-card { justify-self: center; }
|
||||
}
|
||||
.nebula-daily-result-copy { display: grid; gap: var(--space-3); min-width: 0; }
|
||||
.nebula-daily-result-copy :is(h3, p) { margin: 0; }
|
||||
.nebula-daily-result-copy h3 { font-size: var(--font-size-xl); }
|
||||
.nebula-daily-answer { display: grid; gap: var(--space-1); }
|
||||
.nebula-daily-answer strong { color: var(--color-text-primary); font-size: var(--font-size-lg); }
|
||||
.nebula-daily-answer span { color: var(--color-text-secondary); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-result-badges { display: flex; flex-wrap: wrap; gap: var(--space-2); }
|
||||
.nds-toolbar.nebula-daily-result-actions { flex-wrap: wrap; align-items: center; gap: var(--space-3); }
|
||||
.nebula-daily-next { color: var(--color-text-muted); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-result-card { width: 180px; }
|
||||
.nebula-daily-result-card .nebula-card { max-width: 180px; }
|
||||
|
||||
.nebula-pack-page { display: grid; gap: var(--space-6); }
|
||||
.nds-section-heading.nebula-pack-page-heading { align-items: stretch; }
|
||||
.nebula-pack-categories { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); }
|
||||
|
|
|
|||
168
website/src/styles/_nebula-daily.scss
Normal file
168
website/src/styles/_nebula-daily.scss
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
// Rôle : page de la Carte du jour : illustration et saisie côte à côte, indices à dévoiler, grille des essais et fin de partie.
|
||||
|
||||
.nebula-daily { display: grid; gap: var(--space-4); min-width: 0; container: nebula-daily / inline-size; }
|
||||
.nebula-daily .nds-section-heading.nebula-section-heading { margin-bottom: 0; }
|
||||
.nebula-daily-heading-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-3); }
|
||||
.nebula-daily-expired { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin: 0; }
|
||||
.nebula-daily-layout :is(h3, h4, p, ul, ol, dl, dd) { margin: 0; }
|
||||
.nebula-daily-layout :is(ul, ol) { padding: 0; list-style: none; }
|
||||
.nebula-daily-layout :is(h3, h4) { font-size: var(--font-size-base); }
|
||||
|
||||
.nebula-daily-layout { display: grid; grid-template: "stage play" auto "hints hints" auto "guesses guesses" auto / min(340px, 44%) minmax(0, 1fr); gap: var(--space-5); }
|
||||
.nebula-daily-layout[data-finished] { grid-template: "stage play" auto "guesses guesses" auto / min(340px, 44%) minmax(0, 1fr); }
|
||||
@container nebula-daily (min-width: 1000px) {
|
||||
.nebula-daily-layout, .nebula-daily-layout[data-finished] { grid-template-columns: 380px minmax(0, 1fr); }
|
||||
}
|
||||
@container nebula-daily (max-width: 620px) {
|
||||
.nebula-daily-layout { grid-template: "stage" auto "play" auto "hints" auto "guesses" auto / minmax(0, 1fr); }
|
||||
.nebula-daily-layout[data-finished] { grid-template: "stage" auto "play" auto "guesses" auto / minmax(0, 1fr); }
|
||||
.nds-panel.nebula-daily-stage { justify-self: center; width: min(100%, 300px); }
|
||||
}
|
||||
|
||||
.nds-panel.nebula-daily-stage { grid-area: stage; display: grid; align-content: center; justify-items: center; gap: var(--space-3); padding: var(--space-3); }
|
||||
.nebula-daily-frame { display: grid; place-items: center; overflow: hidden; width: 100%; aspect-ratio: 1; border-radius: var(--radius-lg); background: var(--color-bg-deep); }
|
||||
/* Chaque morceau envoyé par le serveur (zone visible au zoom courant) apparaît en fondu à la place du précédent. */
|
||||
.nebula-daily-frame img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; animation: nebula-daily-image-in 450ms ease; }
|
||||
@keyframes nebula-daily-image-in { from { opacity: 0; transform: scale(1.04); } }
|
||||
.nebula-daily-frame-status { padding: var(--space-4); color: var(--color-text-muted); font-size: var(--font-size-sm); text-align: center; }
|
||||
.nebula-daily-stage .nebula-card[data-card-size="md"] { width: 100%; max-width: 270px; }
|
||||
|
||||
.nebula-daily-icon { display: block; width: 22px; height: 22px; }
|
||||
.nebula-daily-disc { display: grid; flex: none; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--color-primary-soft); color: var(--color-primary-hover); }
|
||||
|
||||
/* Saisie. La liste de suggestions dépasse du panneau : il ne la coupe pas et passe au-dessus des indices et de la grille. */
|
||||
.nds-panel.nebula-daily-form, .nds-panel.nebula-daily-result { grid-area: play; display: grid; gap: var(--space-3); min-width: 0; padding: var(--space-4) var(--space-5); }
|
||||
.nds-panel.nebula-daily-form { z-index: 2; grid-template-rows: auto auto auto 1fr; overflow: visible; }
|
||||
.nebula-daily-form .nds-inline-notice { margin: 0; }
|
||||
.nebula-daily-ask-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px var(--space-3); }
|
||||
.nebula-daily-ask-heading :is(label, h3) { color: var(--color-text-primary); font-size: var(--font-size-lg); font-weight: 700; }
|
||||
.nebula-daily-ask-heading > span { color: var(--color-text-muted); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-track { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
|
||||
.nebula-daily-track li { display: grid; place-items: center; height: 30px; border: 1px solid var(--color-border); border-radius: 8px; color: var(--color-text-disabled); font-size: var(--font-size-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
|
||||
.nebula-daily-track li[data-now] { border-color: var(--color-primary); background: var(--color-primary-soft); color: var(--color-text-primary); }
|
||||
:is(.nebula-daily-track li, .nebula-daily-mark)[data-result="miss"] { border-color: transparent; background: var(--color-bg-hover); color: var(--color-text-secondary); }
|
||||
:is(.nebula-daily-track li, .nebula-daily-mark)[data-result="close"] { border-color: color-mix(in srgb, var(--color-warning) 50%, transparent); background: var(--color-warning-soft); color: var(--color-warning); }
|
||||
:is(.nebula-daily-track li, .nebula-daily-mark)[data-result="correct"] { border-color: color-mix(in srgb, var(--color-success) 60%, transparent); background: var(--color-success-soft); color: var(--color-success); }
|
||||
/* Au-dessus du bilan, que la liste de suggestions recouvre. */
|
||||
.nds-panel > .nebula-daily-form-row { position: relative; z-index: 3; }
|
||||
.nebula-daily-form-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); align-items: start; }
|
||||
/* La liste prend la largeur de toute la ligne, bouton compris. */
|
||||
.nebula-daily-form .nds-autocomplete-field { position: static; }
|
||||
.nebula-daily-form .nds-autocomplete-option { display: block; font-weight: 400; text-align: left; text-overflow: clip; white-space: normal; }
|
||||
.nebula-daily-form .nds-autocomplete-option mark { background: none; color: var(--color-accent-gold); font-weight: 700; }
|
||||
.nebula-daily-form .nds-autocomplete-option small { margin-left: var(--space-2); color: var(--color-text-muted); }
|
||||
.nebula-daily-form .nds-autocomplete-option[aria-disabled] { color: var(--color-text-muted); }
|
||||
|
||||
/* Sous la saisie : les règles du départ, puis le bilan du dernier essai et ce que le joueur sait. */
|
||||
.nebula-daily-aside { display: grid; min-width: 0; padding-top: var(--space-3); border-top: 1px solid var(--color-border); }
|
||||
.nebula-daily-rules, .nebula-daily-feedback { display: grid; align-content: center; gap: var(--space-2); min-width: 0; color: var(--color-text-secondary); font-size: 0.9375rem; }
|
||||
.nebula-daily-rules ul { display: grid; gap: 5px; }
|
||||
.nebula-daily-rules li { display: flex; align-items: center; gap: 10px; font-size: var(--font-size-sm); }
|
||||
.nebula-daily-rules .nebula-daily-disc { width: 26px; height: 26px; }
|
||||
.nebula-daily-rules .nebula-daily-icon { width: 15px; height: 15px; }
|
||||
.nebula-daily-feedback { animation: nebula-daily-feedback-in 350ms ease; }
|
||||
@keyframes nebula-daily-feedback-in { from { opacity: 0.2; transform: translateY(-4px); } }
|
||||
.nebula-daily-verdict { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px var(--space-3); line-height: 1.4; }
|
||||
.nebula-daily-verdict > p:first-child { flex: 1 1 180px; min-width: 0; }
|
||||
.nebula-daily-verdict strong { color: var(--color-text-primary); }
|
||||
.nebula-daily-verdict-subject { flex: 1 0 100%; font-size: var(--font-size-sm); }
|
||||
.nebula-daily-verdict-subject b { font-weight: 600; }
|
||||
.nebula-daily-verdict-subject b[data-tone="same"] { color: var(--color-success); }
|
||||
.nebula-daily-verdict-subject b[data-tone="different"] { color: var(--color-warning); }
|
||||
.nebula-daily-gains { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.nebula-daily-gains > span { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: var(--radius-pill); font-size: 0.8125rem; font-weight: 700; }
|
||||
.nebula-daily-gains [data-kind="hint"] { background: rgba(246, 196, 83, 0.13); color: var(--color-accent-gold); }
|
||||
.nebula-daily-gains [data-kind="last"] { background: var(--color-warning-soft); color: var(--color-warning); }
|
||||
.nebula-daily-gains .nebula-daily-icon { width: 14px; height: 14px; }
|
||||
.nebula-daily-know { display: grid; gap: 7px; padding: 10px 14px 11px; border: 1px solid var(--color-border-hover); border-radius: 11px; background: rgba(5, 7, 17, 0.45); }
|
||||
.nebula-daily-know :is(h3, h4) { color: var(--color-text-primary); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-know dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; font-size: var(--font-size-sm); line-height: 1.4; }
|
||||
.nebula-daily-know :is(dt, dd > span, .nebula-daily-answer-theme > span) { color: var(--color-text-muted); }
|
||||
.nebula-daily-know dd { display: grid; gap: 2px; min-width: 0; color: var(--color-text-primary); }
|
||||
.nebula-daily-ruled-out { font-size: 0.8125rem; }
|
||||
.nebula-daily-ruled-out s { color: var(--color-text-secondary); }
|
||||
.nebula-daily-ruled-out s[data-new] { color: var(--color-warning); }
|
||||
.nebula-daily-path, .nebula-daily-path-step, .nebula-daily-answer-theme { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
|
||||
.nebula-daily-path-step { flex-wrap: nowrap; color: var(--color-text-muted); white-space: nowrap; }
|
||||
.nebula-daily-chip { padding: 0 8px; border: 1px solid var(--color-border-hover); border-radius: var(--radius-pill); color: var(--color-text-secondary); font-size: 0.8125rem; }
|
||||
.nebula-daily-chip[data-found] { border-color: transparent; background: var(--color-success-soft); color: var(--color-success); font-weight: 600; }
|
||||
.nebula-daily-chip[data-new] { border-color: var(--color-success); }
|
||||
@container nebula-daily (max-width: 380px) {
|
||||
.nebula-daily-form-row, .nebula-daily-know dl { grid-template-columns: minmax(0, 1fr); }
|
||||
}
|
||||
|
||||
/* Indices : des cadres de taille fixe, que l'ouverture d'un autre ne change jamais. */
|
||||
.nebula-daily-hints { grid-area: hints; min-width: 0; }
|
||||
.nebula-daily-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-3); margin-bottom: var(--space-3); }
|
||||
.nebula-daily-heading > p { display: flex; flex: 1; flex-wrap: wrap; gap: 0 14px; min-width: 160px; color: var(--color-text-secondary); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-purse { display: inline-flex; align-items: center; gap: 6px; padding: 4px 13px; border: 1px solid var(--color-border-hover); border-radius: var(--radius-pill); color: var(--color-text-muted); font-size: var(--font-size-sm); font-weight: 700; }
|
||||
.nebula-daily-purse[data-on] { border-color: rgba(246, 196, 83, 0.55); background: rgba(246, 196, 83, 0.13); color: var(--color-accent-gold); }
|
||||
.nebula-daily-purse .nebula-daily-icon, .nebula-daily-lens .nebula-daily-icon { width: 18px; height: 18px; }
|
||||
.nebula-daily-hints ul { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 88px; gap: 10px; }
|
||||
.nebula-daily-hint { display: grid; min-width: 0; border: 1px solid var(--color-border-hover); border-radius: var(--radius-lg); background: var(--color-bg-surface); transition: border-color var(--duration-fast); }
|
||||
.nebula-daily-hint[data-hint="page"] { grid-column: span 2; }
|
||||
.nebula-daily-hint > :is(button, div) { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-width: 0; padding: 4px 12px; border: 0; border-radius: inherit; background: none; color: var(--color-text-primary); font: inherit; line-height: 1.3; text-align: left; }
|
||||
.nebula-daily-hint > * > span:nth-child(2) { display: grid; gap: 1px; min-width: 0; }
|
||||
.nebula-daily-hint strong { color: var(--color-text-primary); font-size: 0.9375rem; line-height: 1.25; overflow-wrap: break-word; }
|
||||
.nebula-daily-hint small { color: var(--color-text-muted); font-size: 0.8125rem; }
|
||||
.nebula-daily-hint em { font-size: var(--font-size-sm); line-height: 1.35; }
|
||||
.nebula-daily-lens { display: grid; place-items: center; width: 34px; height: 34px; border: 1px dashed var(--color-border-hover); border-radius: 50%; color: var(--color-text-disabled); }
|
||||
.nebula-daily-hint[data-state="locked"] > button { cursor: default; opacity: 1; }
|
||||
.nebula-daily-hint[data-state="locked"] strong { color: var(--color-text-secondary); }
|
||||
.nebula-daily-hint[data-state="ready"] { border-color: rgba(246, 196, 83, 0.6); }
|
||||
.nebula-daily-hint[data-state="ready"] > button { cursor: pointer; }
|
||||
.nebula-daily-hint[data-state="ready"]:hover { border-color: var(--color-accent-gold); background: var(--color-bg-elevated); }
|
||||
.nebula-daily-hint[data-state="ready"] > button:focus-visible { outline: 2px solid var(--color-accent-gold); outline-offset: 2px; }
|
||||
.nebula-daily-hint[data-state="ready"] .nebula-daily-disc { background: rgba(246, 196, 83, 0.13); color: var(--color-accent-gold); }
|
||||
.nebula-daily-hint[data-state="ready"] .nebula-daily-lens { border: 0; background: var(--color-accent-gold); color: var(--color-text-inverse); }
|
||||
.nebula-daily-hint[data-state="open"] { border-color: color-mix(in srgb, var(--color-success) 45%, transparent); background: var(--color-bg-elevated); }
|
||||
.nebula-daily-hint[data-state="open"] > div { grid-template-columns: 40px minmax(0, 1fr); animation: nebula-daily-hint-in 450ms ease; }
|
||||
.nebula-daily-hint[data-state="open"] .nebula-daily-disc { background: var(--color-success-soft); color: var(--color-success); }
|
||||
@keyframes nebula-daily-hint-in { from { opacity: 0.2; transform: perspective(600px) rotateX(-80deg); } }
|
||||
.nebula-daily-gap { display: inline-block; width: 2.6em; height: 0.85em; border-radius: 3px; background: var(--color-text-disabled); vertical-align: -0.08em; }
|
||||
|
||||
/* Grille des essais : vert comme la réponse, barré différent. */
|
||||
.nebula-daily-guesses, .nebula-daily-families { grid-area: guesses; min-width: 0; }
|
||||
.nebula-daily-guesses .nebula-daily-heading { margin-bottom: 4px; }
|
||||
.nebula-daily-guesses :is(b, u[data-same], .nebula-daily-heading b) { color: var(--color-success); font-weight: 600; }
|
||||
.nebula-daily-guesses s { color: var(--color-text-muted); }
|
||||
.nebula-daily-guesses ol { display: grid; gap: 5px; }
|
||||
.nebula-daily-columns, .nebula-daily-guess { display: grid; grid-template-columns: 22px minmax(0, 1.4fr) minmax(0, 1.5fr) minmax(0, 0.6fr); gap: 4px 14px; }
|
||||
.nebula-daily-columns { padding: 0 13px 4px; color: var(--color-text-muted); font-size: 0.8125rem; }
|
||||
.nebula-daily-guess { align-items: center; min-height: 46px; padding: 10px 12px; border: 1px solid transparent; border-radius: 9px; background: var(--color-bg-surface); font-size: var(--font-size-sm); line-height: 1.3; }
|
||||
.nebula-daily-guess[data-last] { border-color: var(--color-border-hover); background: var(--color-bg-elevated); }
|
||||
.nebula-daily-guess[data-result="correct"] { background: var(--color-success-soft); }
|
||||
.nebula-daily-guess > * { min-width: 0; overflow-wrap: break-word; }
|
||||
.nebula-daily-guess strong { color: var(--color-text-primary); font-size: 0.9375rem; }
|
||||
.nebula-daily-guess u { text-decoration: underline dotted 2px var(--color-text-muted); text-underline-offset: 3px; }
|
||||
.nebula-daily-guess u[data-same] { font-weight: inherit; text-decoration-color: currentcolor; }
|
||||
.nebula-daily-mark { display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid transparent; border-radius: 6px; font-size: 0.75rem; font-weight: 700; }
|
||||
.nebula-daily-legend { display: flex; flex-wrap: wrap; gap: 2px 16px; padding: 6px 12px 0; color: var(--color-text-muted); font-size: 0.8125rem; }
|
||||
.nebula-daily-guesses .nebula-daily-legend b { color: var(--color-warning); }
|
||||
.nebula-daily-families { padding: 14px; border: 1px dashed var(--color-border-hover); border-radius: var(--radius-md); color: var(--color-text-muted); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-families ul { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; }
|
||||
.nebula-daily-families li { display: grid; line-height: 1.35; }
|
||||
.nebula-daily-families b { color: var(--color-text-secondary); }
|
||||
.nebula-daily-families span { font-size: 0.8125rem; }
|
||||
@container nebula-daily (max-width: 620px) {
|
||||
.nebula-daily-hints ul { grid-template-columns: minmax(0, 1fr); grid-auto-rows: 72px; }
|
||||
.nebula-daily-hint[data-hint="page"] { grid-column: auto; grid-row: span 2; }
|
||||
.nebula-daily-columns { display: none; }
|
||||
.nebula-daily-guess { grid-template-columns: 22px minmax(0, 1fr); }
|
||||
.nebula-daily-guess > :nth-child(n + 3) { grid-column: 2; }
|
||||
.nebula-daily-theme-cell::before { content: attr(data-label) " : "; color: var(--color-text-muted); }
|
||||
}
|
||||
|
||||
/* Fin de partie : la carte à gauche, le résultat à droite. */
|
||||
.nds-panel.nebula-daily-result { align-content: space-between; }
|
||||
.nebula-daily-result[data-status="won"] .nebula-daily-ask-heading h3 { color: var(--color-success); }
|
||||
.nebula-daily-result .nebula-daily-ask-heading h3 { font-size: var(--font-size-xl); }
|
||||
.nebula-daily-description { color: var(--color-text-secondary); font-size: 0.9375rem; font-style: italic; }
|
||||
.nebula-daily-rewards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-2); }
|
||||
.nebula-daily-rewards li { padding: 8px; border-radius: var(--radius-md); background: var(--color-bg-elevated); color: var(--color-accent-gold); font-size: var(--font-size-sm); font-weight: 700; text-align: center; }
|
||||
.nebula-daily-result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
|
||||
.nebula-daily-result-actions > span { color: var(--color-text-muted); font-size: var(--font-size-sm); }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.nebula-daily :is(.nebula-daily-frame img, .nebula-daily-feedback, .nebula-daily-hint > div) { animation: none; }
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
// égale, ces dernières l'emportaient. Chargée après main.scss, cette feuille les ré-émet après les cartes pour garder
|
||||
// exactement cette priorité ; tests/styles-split.test.mjs vérifie que la liste suit main.scss.
|
||||
@use "nebula-cards";
|
||||
@use "nebula-daily";
|
||||
@use "nebula-expeditions";
|
||||
@use "nebula-expedition-destinations";
|
||||
@use "nebula-expedition-loadout";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue