#/mobile/cards shows the game without the site shell: a title, a footer with the account and a discreet "Version complète" link, and a tab bar fixed at the bottom. Phones opening #/cards are sent to the same section in mobile mode unless the player chose the full version. Account, History and Administration point to the computer. The panels are the computer ones, adapted under .nebula-mobile (and body.nebula-mobile-body for dialogs) for a 393×852 reference phone: small cards with names under them when opening packs, a revealed card shown large on tap, tap-to-pick team recruitment with a single Recruit button and large stars, row lists for explorers and commons in the expedition pickers, a race track and circuit that read at phone size, and full-width actions throughout. Firefox no longer shows a mirrored back on a flipped card. Phone Playwright journeys check that every section fits the screen with no button wrapping, then open a pack, run an expedition and recruit a team by touch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
81 lines
5.9 KiB
JavaScript
81 lines
5.9 KiB
JavaScript
/**
|
|
* @file Une carte jouable dans la préparation d'une expédition ou l'inscription à une expédition ouverte : la
|
|
* carte, sa Puissance en haut à droite, ses stats en icônes (nom au survol) et ses étiquettes : celles
|
|
* utiles à la destination en pastilles (condition, dangers parés, Affinité), toutes au survol de
|
|
* l'icône d'étiquette.
|
|
*
|
|
* Attention : en mode mobile, la tuile devient une ligne entièrement touchable (`MobileCardRow`) : sans survol, le
|
|
* nom, la Puissance, les stats et les étiquettes y sont écrits en clair.
|
|
*/
|
|
|
|
import { useId } from "react";
|
|
import { Tooltip } from "../../../components/Tooltip.jsx";
|
|
import { fillTemplate } from "../textFormat.js";
|
|
import { useCardsMobile } from "../useCardsHref.js";
|
|
import { cardHelps, editionEntry, formatDecimal, STAT_BY_PLAN, STAT_IDS, tagLabel } from "./expeditionFormat.js";
|
|
import { MaskIcon } from "./ExpeditionLabels.jsx";
|
|
import { NebulaCard } from "../rendering/NebulaCard.jsx";
|
|
|
|
/**
|
|
* Ligne d'une carte jouable sur téléphone : un seul bouton (petite carte, nom, Puissance, stats, étiquettes), nommé
|
|
* « Choisir … » comme la tuile de l'ordinateur ; le détail est sa description accessible.
|
|
*/
|
|
function MobileCardRow({ catalog, entry, card, content, selected, sortKey, powerLabel, vocation, helps, tags, onSelect }) {
|
|
const detailsId = useId();
|
|
return <li className="nebula-expedition-card-row" data-busy={card.busy || undefined} data-selected={selected || undefined}>
|
|
<button type="button" className="nebula-expedition-card-pick" disabled={card.busy} aria-label={fillTemplate(content.chooseCard, { card: entry.card.name })} aria-describedby={detailsId} onClick={onSelect}>
|
|
<span className="nebula-expedition-card-frame" aria-hidden="true">
|
|
<NebulaCard catalog={catalog} entry={entry} size="sm" />
|
|
{card.busy && <span className="nebula-expedition-card-busy">{content.busy}</span>}
|
|
</span>
|
|
<span className="nebula-expedition-card-main" id={detailsId}>
|
|
<strong className="nebula-expedition-card-name">{entry.card.name}</strong>
|
|
<span className="nebula-expedition-card-power-line">{vocation && <MaskIcon name={vocation} />}{powerLabel}</span>
|
|
<span className="nebula-expedition-stats">{STAT_IDS.map((stat) => <span key={stat} className="nebula-expedition-stat" data-sorted={stat === sortKey || undefined}>
|
|
<MaskIcon name={stat} /><span className="sr-only">{content.stats[stat]} </span>{formatDecimal(card.stats[stat])}
|
|
</span>)}</span>
|
|
{(helps.condition || helps.dangers.length > 0 || helps.affinity) && <span className="nebula-expedition-card-tags">
|
|
{helps.condition && <span className="nds-badge" data-variant="success">{content.tagCondition}</span>}
|
|
{helps.dangers.map((danger) => <span key={danger.id} className="nds-badge" data-variant="success">{fillTemplate(content.tagParry, { label: danger.label })}</span>)}
|
|
{helps.affinity && <span className="nds-badge" data-variant="gold">{content.tagAffinity}</span>}
|
|
</span>}
|
|
<span className="nebula-expedition-card-taglist"><MaskIcon name="tag" />{tags.length ? tags.join(" · ") : content.tagsNone}</span>
|
|
</span>
|
|
</button>
|
|
</li>;
|
|
}
|
|
|
|
export function ExpeditionCardTile({ catalog, card, destination, content, selected, sortKey = null, onSelect }) {
|
|
const mobile = useCardsMobile();
|
|
const entry = editionEntry(catalog, card.editionId);
|
|
if (!entry) return null;
|
|
const vocation = STAT_BY_PLAN[card.plan];
|
|
const helps = cardHelps(card, destination);
|
|
const tags = (card.tags || []).map((tag) => tagLabel(catalog, tag));
|
|
const powerLabel = vocation ? fillTemplate(content.powerVocation, { power: card.power, stat: content.stats[vocation] }) : fillTemplate(content.power, { power: card.power });
|
|
if (mobile) return <MobileCardRow catalog={catalog} entry={entry} card={card} content={content} selected={selected} sortKey={sortKey} powerLabel={powerLabel} vocation={vocation} helps={helps} tags={tags} onSelect={onSelect} />;
|
|
return <li data-busy={card.busy || undefined} data-selected={selected || undefined}>
|
|
<div className="nebula-expedition-card-frame">
|
|
<NebulaCard catalog={catalog} entry={entry} size="sm" selected={selected} disabled={card.busy} onSelect={card.busy ? undefined : onSelect}
|
|
selectLabel={fillTemplate(content.chooseCard, { card: entry.card.name })} />
|
|
<Tooltip className="nebula-expedition-card-power" content={powerLabel} aria-label={powerLabel} tabIndex={-1}>
|
|
{vocation && <MaskIcon name={vocation} />}<span aria-hidden="true">{card.power}</span>
|
|
</Tooltip>
|
|
{card.busy && <span className="nebula-expedition-card-busy">{content.busy}</span>}
|
|
</div>
|
|
<span className="nebula-expedition-stats" role="list" aria-label={content.chosenStats}>{STAT_IDS.map((stat) => {
|
|
const label = `${content.stats[stat]} : ${formatDecimal(card.stats[stat])}`;
|
|
return <Tooltip key={stat} className="nebula-expedition-stat" content={content.stats[stat]} role="listitem" aria-label={label} tabIndex={-1} data-sorted={stat === sortKey || undefined}>
|
|
<MaskIcon name={stat} /><span aria-hidden="true">{formatDecimal(card.stats[stat])}</span>
|
|
</Tooltip>;
|
|
})}</span>
|
|
<span className="nebula-expedition-card-tags">
|
|
{helps.condition && <span className="nds-badge" data-variant="success">{content.tagCondition}</span>}
|
|
{helps.dangers.map((danger) => <span key={danger.id} className="nds-badge" data-variant="success">{fillTemplate(content.tagParry, { label: danger.label })}</span>)}
|
|
{helps.affinity && <span className="nds-badge" data-variant="gold">{content.tagAffinity}</span>}
|
|
<Tooltip className="nebula-expedition-card-taglist" content={tags.length ? tags.join(" · ") : content.tagsNone} aria-label={fillTemplate(content.tagsLabel, { tags: tags.join(", ") || content.tagsNone })} tabIndex={0}>
|
|
<MaskIcon name="tag" /><span aria-hidden="true">{tags.length}</span>
|
|
</Tooltip>
|
|
</span>
|
|
</li>;
|
|
}
|