forked from WikiDeck/wikideck
ui-duel: QA fixes from night-review (#58): hand overflow cue (+N, edge fade), Garrison 0/T in preview, taller cards and 3-line titles on tall phones, larger Doctrine badge
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,22 @@ export function DuelTable({ view, legal, onAct, busy, error, onExit, onRecap }:
|
||||
const [decl, setDecl] = useState<Declaration>(EMPTY_DECL);
|
||||
const [targeting, setTargeting] = useState<{ cardId: string; chosen: string[] }>();
|
||||
const logRef = useRef<HTMLOListElement>(null);
|
||||
// Hand overflow cue (QA #58): how many hand cards are past the right edge.
|
||||
const handRef = useRef<HTMLDivElement>(null);
|
||||
const [hiddenRight, setHiddenRight] = useState(0);
|
||||
useEffect(() => {
|
||||
const el = handRef.current;
|
||||
if (!el) return;
|
||||
const measure = () => {
|
||||
const edge = el.getBoundingClientRect().right;
|
||||
setHiddenRight([...el.children].filter(c => c.getBoundingClientRect().left > edge - 24).length);
|
||||
};
|
||||
measure();
|
||||
el.addEventListener('scroll', measure, { passive: true });
|
||||
const ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(measure) : null;
|
||||
ro?.observe(el);
|
||||
return () => { el.removeEventListener('scroll', measure); ro?.disconnect(); };
|
||||
}, [view.hand.length]);
|
||||
|
||||
const mine = isMyTurn(view);
|
||||
const oppSeat = (1 - view.seat) as Seat;
|
||||
@@ -173,12 +189,15 @@ export function DuelTable({ view, legal, onAct, busy, error, onExit, onRecap }:
|
||||
</div>
|
||||
|
||||
<div className="duel-dock">
|
||||
<div className="duel-hand" aria-label="Your hand">
|
||||
<div className="duel-hand-wrap">
|
||||
<div ref={handRef} className={`duel-hand ${hiddenRight ? 'has-more' : ''}`} aria-label={`Your hand, ${view.hand.length} cards`}>
|
||||
{view.hand.length ? view.hand.map(c => {
|
||||
const playable = !!legal.plays[c.id] && !busy;
|
||||
return <DuelCardFace key={c.id} card={c} size="hand" state={{ dim: !playable || !!targeting, selected: targeting?.cardId === c.id }}
|
||||
onClick={() => setSheet({ kind: 'card', card: c, where: 'hand' })} />;
|
||||
}) : <span className="duel-empty">No cards in hand.</span>}
|
||||
</div>
|
||||
{hiddenRight > 0 && <button type="button" className="duel-hand-more" aria-label={`${hiddenRight} more cards in hand: scroll right`} onClick={() => handRef.current?.scrollBy({ left: handRef.current.clientWidth * 0.8, behavior: 'smooth' })}>+{hiddenRight}</button>}
|
||||
</div>
|
||||
<p className="duel-note" role="status" aria-live="polite">{error ? <span className="dock-error">{error}</span> : note}</p>
|
||||
<div className="duel-actions">
|
||||
|
||||
+15
-1
@@ -31,7 +31,7 @@
|
||||
.duel-row.theirs{align-items:flex-end}
|
||||
.duel-slot{position:relative;display:flex;flex-direction:column;align-items:stretch;flex:1 1 0;min-width:62px;max-width:110px}
|
||||
.duel-empty{flex:1;align-self:center;text-align:center;font-size:12px;color:var(--ctp-overlay1);padding:8px}
|
||||
.duel-attach{position:absolute;top:-4px;right:-3px;z-index:3;font-size:10px;font-weight:800;padding:1px 5px;border-radius:8px;background:var(--ctp-mauve);color:var(--ctp-crust)}
|
||||
.duel-attach{position:absolute;top:-5px;right:-3px;z-index:3;font-size:12px;font-weight:800;padding:1px 5px;border-radius:8px;background:var(--ctp-mauve);color:var(--ctp-crust)}
|
||||
.duel-pair{font-size:9px;line-height:1.2;color:var(--ctp-green);text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:2px}
|
||||
|
||||
.duel-ticker{display:flex;align-items:center;gap:6px;width:100%;min-height:36px;padding:6px 10px;border-radius:8px;background:var(--ctp-crust);border:1px dashed var(--ctp-surface1);text-align:left;font-size:12px;line-height:1.35;color:var(--ctp-subtext1)}
|
||||
@@ -48,6 +48,9 @@
|
||||
.duel-dock{position:sticky;bottom:0;z-index:5;margin:0 -8px;padding:6px 8px calc(8px + env(safe-area-inset-bottom));background:var(--ctp-mantle);border-top:1px solid var(--theme-border);border-radius:0 0 12px 12px;display:flex;flex-direction:column;gap:6px}
|
||||
.duel-hand{display:flex;gap:6px;overflow-x:auto;scrollbar-width:none;padding:6px 0 2px;min-height:112px}
|
||||
.duel-hand::-webkit-scrollbar{display:none}
|
||||
.duel-hand-wrap{position:relative}
|
||||
.duel-hand.has-more{-webkit-mask-image:linear-gradient(to right,#000 78%,transparent);mask-image:linear-gradient(to right,#000 78%,transparent)}
|
||||
.duel-hand-more{position:absolute;right:0;top:50%;transform:translateY(-50%);min-width:40px;min-height:40px;border-radius:20px;background:var(--ctp-surface1);color:var(--ctp-text);font-weight:800;font-size:13px;box-shadow:0 2px 8px rgb(0 0 0/.4)}
|
||||
.duel-note{margin:0;min-height:18px;font-size:12px;line-height:1.35;color:var(--ctp-subtext1);display:flex;align-items:center;gap:6px}
|
||||
.duel-actions{display:flex;gap:8px;justify-content:flex-end}
|
||||
.duel-actions .button{min-height:46px;font-size:13px;padding:10px 16px}
|
||||
@@ -128,6 +131,17 @@
|
||||
.duel-gate-bar{height:10px;border-radius:5px;background:var(--ctp-surface0);overflow:hidden;margin:12px 0 6px}
|
||||
.duel-gate-bar i{display:block;height:100%;background:var(--theme-accent)}
|
||||
|
||||
/* Tall phones (≥ 720 px): give the spare height to the cards, with 3-line titles (QA #58). */
|
||||
@media (max-width:899px) and (min-height:720px){
|
||||
.dface-board{min-height:112px}
|
||||
.dface-board .dface-art{height:42px}
|
||||
.dface-board .dface-title{-webkit-line-clamp:3;min-height:3.6em}
|
||||
.dface-hand{min-height:128px}
|
||||
.dface-hand .dface-art{height:52px}
|
||||
.dface-hand .dface-title{-webkit-line-clamp:3;min-height:3.6em}
|
||||
.duel-hand{min-height:134px}
|
||||
}
|
||||
|
||||
/* Desktop: bigger cards, log always visible beside the field. */
|
||||
@media (min-width:900px){
|
||||
.duel{padding:10px 14px 0;font-size:14px}
|
||||
|
||||
@@ -46,7 +46,8 @@ export function previewCard(c: SampleCard, suffix = ''): BoardCard {
|
||||
const b = 2 * cost + 1, s = Math.min(0.7, Math.max(0.3, c.tiers.attention / (c.tiers.attention + c.tiers.depth || 1)));
|
||||
power = Math.max(1, Math.round(b * s)) - (keywords.length > 1 ? 1 : 0); toughness = Math.max(1, b - Math.round(b * s));
|
||||
} else if (type === 'Location') {
|
||||
rulesText = `Territory. Garrison 0/${1 + Math.floor(c.tiers.depth / 3)}.`;
|
||||
power = 0; toughness = 1 + Math.floor(c.tiers.depth / 3);
|
||||
rulesText = `Territory. Garrison 0/${toughness}.`;
|
||||
} else if (type === 'Event') {
|
||||
rulesText = /storm|nor.easter/i.test(c.description ?? '') ? `Deal ${Math.max(1, k - 1)} damage to each Figure and each Location.`
|
||||
: /election/i.test(c.description ?? '') ? `Create ${k} 1/1 Society Figure tokens named Elected Member.`
|
||||
|
||||
Reference in New Issue
Block a user