Move TCG gauges, badges and tooltips onto the NDS
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 25m18s
Validate and deploy Sokko G / deploy (push) Successful in 16s

- nds-progress tint variant, nds-badge sm size and tint variant
- --color-scrim and --color-bg-inset tokens
- native title attributes replaced by Tooltip
- TCG colors equal to a token now reference it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-12-05 19:44:00 +01:00
parent ced3bc818d
commit ac81b5e22f
44 changed files with 350 additions and 274 deletions

View file

@ -17,6 +17,7 @@
*/
import { useEffect, useId, useRef, useState } from "react";
import { Tooltip } from "../../../components/Tooltip.jsx";
import { CollectionCardBack } from "./CollectionCardBack.jsx";
import { resolveFlare } from "./holoFlares.js";
import { createFireflies } from "./holoFireflies.js";
@ -157,11 +158,12 @@ function RarityGlyph({ rarity }) {
</svg>;
}
/** Symbole de rareté en bas à droite de la carte ; son nom (libellé du catalogue) en infobulle et pour les lecteurs d'écran. */
function RaritySymbol({ rarity, label }) {
return <span className="nebula-card-rarity-symbol" data-rarity={rarity} title={label}>
return <Tooltip className="nebula-card-rarity-symbol" data-rarity={rarity} content={label} tabIndex={-1}>
<RarityGlyph rarity={rarity} />
<span className="sr-only">{label}</span>
</span>;
</Tooltip>;
}
/** Carte de destination : toujours en pleine illustration (son paysage remplit la carte), quelle que soit sa finition. */
@ -304,7 +306,7 @@ function HoloFlareCanvas({ flare, behindSubject, size }) {
return <canvas ref={canvasRef} className="nebula-card-flare" data-flare={flare.effect.id} data-flare-scope={flare.scope} data-behind-subject={behindSubject || undefined} aria-hidden="true" />;
}
function CardFace({ entry, quantity, visual, size, flare = null }) {
function CardFace({ entry, quantity, visual, size, rarityLabel, flare = null }) {
const { card, edition } = entry;
const finishIds = edition.finishIds || [];
const showName = size !== "sm";
@ -349,7 +351,7 @@ function CardFace({ entry, quantity, visual, size, flare = null }) {
{edition.rarity === "mythic" && <span className="nebula-card-finish">{visual.finishLabel}</span>}
</div>}
{(size === "md" || size === "sm") && quantity > 0 && <span className="nebula-card-quantity" aria-label={`${quantity} exemplaires`}>×{quantity}</span>}
<RaritySymbol rarity={edition.rarity} label={edition.rarity} />
<RaritySymbol rarity={edition.rarity} label={rarityLabel || edition.rarity} />
{visual.effectPreset && <>
<span className="nebula-card-holo-layer nebula-card-holo-primary" aria-hidden="true" />
<span className="nebula-card-holo-layer nebula-card-holo-secondary" aria-hidden="true" />
@ -379,6 +381,7 @@ function CardFace({ entry, quantity, visual, size, flare = null }) {
export function NebulaCard({ catalog, entry, quantity = 0, size = "lg", faceUp = true, onReveal, onRevealComplete, onConceal, onSelect, selectLabel, selected, revealed = false, replayable = false, revealLabel = "la carte", disabled = false, concealed = false, backCollection = null, newBadge = null, quietReveal = false, onOpen = null, openLabel = "" }) {
const cardSize = ["sm", "md", "lg"].includes(size) ? size : "lg";
const rarity = entry.edition?.rarity || "common";
const rarityLabel = catalog?.rarities?.find((item) => item.id === rarity)?.label;
const finish = entry.edition?.finishIds?.join(" ") || "standard";
const visual = destinationVisual(entry.card, resolveFinishVisual(entry.edition, catalog));
const flare = resolveFlare(entry.edition, catalog, visual);
@ -511,7 +514,7 @@ export function NebulaCard({ catalog, entry, quantity = 0, size = "lg", faceUp =
data-has-image={backCollection?.back?.image ? "true" : undefined}
style={backCollection?.back?.image ? { "--card-back-image": `url("${backCollection.back.image}")` } : undefined}
><CollectionCardBack collection={backCollection} /></span>
<CardFace entry={entry} quantity={quantity} visual={visual} size={cardSize} flare={revealPhase === "revealed" ? flare : null} />
<CardFace entry={entry} quantity={quantity} visual={visual} size={cardSize} rarityLabel={rarityLabel} flare={revealPhase === "revealed" ? flare : null} />
</span>
{newBadge && revealPhase === "revealed" && <span className="nds-badge nebula-card-new-badge" aria-hidden="true">{newBadge}</span>}
</span>
@ -519,7 +522,7 @@ export function NebulaCard({ catalog, entry, quantity = 0, size = "lg", faceUp =
{particlesVisible && <span className="nebula-card-particles" aria-hidden="true">{rarity === "mythic" && <><span className="nebula-card-particle-ring-glow" data-glow="outer"><span><span /></span></span><span className="nebula-card-particle-ring-glow" data-glow="inner"><span><span /></span></span></>}{Array.from({ length: openingVisual.particlePreset.count }, (_, index) => <i key={index} style={particlePosition(index, openingVisual.particlePreset.count, rarity === "legendary" || rarity === "mythic", openingVisual.particlePalette?.colors[index % openingVisual.particlePalette.colors.length])} />)}</span>}
</button>;
}
const content = <div className="nebula-card-tilt-surface"><CardFace entry={entry} quantity={quantity} visual={visual} size={cardSize} flare={flare} /></div>;
const content = <div className="nebula-card-tilt-surface"><CardFace entry={entry} quantity={quantity} visual={visual} size={cardSize} rarityLabel={rarityLabel} flare={flare} /></div>;
return onSelect
? <button ref={cardRef} className="nebula-card nebula-card-select" data-card-size={cardSize} data-card-layout={visual.layout} data-card-kind={entry.card.kind} data-rarity={rarity} data-finish={finish} {...visualAttributes} type="button" onClick={onSelect} aria-label={selectLabel || `Voir ${entry.card.name}`} aria-pressed={selected}>{content}</button>
: <article ref={cardRef} className="nebula-card" data-card-size={cardSize} data-card-layout={visual.layout} data-card-kind={entry.card.kind} data-rarity={rarity} data-finish={finish} {...visualAttributes}>{content}</article>;