Skip to content

fix(client): size mana cost pips to the printed cost, not a fixed px#6604

Merged
matthewevans merged 2 commits into
mainfrom
ship/mana-pip-printed-cost-sizing
Jul 24, 2026
Merged

fix(client): size mana cost pips to the printed cost, not a fixed px#6604
matthewevans merged 2 commits into
mainfrom
ship/mana-pip-printed-cost-sizing

Conversation

@matthewevans

@matthewevans matthewevans commented Jul 24, 2026

Copy link
Copy Markdown
Member

The card-overlay mana pips were ~2.9x the size of the mana symbols
printed on the card frame they sit on, and anchored above the title bar
rather than inside it. On a desktop hand card a five-symbol cost spanned
67% of the card's width, reducing "Nissa, Ascended Animist" to "Nis".

The badge stands in for the card's PRINTED mana cost (it renders the
engine's effective cost, with a green ring when reduced), so calibrate
its geometry against that cost. Measured on M15-frame art, a printed
symbol is ~5.2% of the card's width, its right edge sits ~7% in and its
top edge ~5.4% down. The fluid pip drops 15cqi -> 6cqi with 0.4cqi
padding, which sizes the symbol to exactly the printed 5.2% and leaves
the disk as a thin ring around it; the printed symbols on the same card
are legible at that size, which is what makes it enough. The three
values solve 5 * 6cqi + 4 * 0.5cqi = 32cqi, so the widest cost the frame
carries spans 32% instead of 67%.

Fold the anchor into ManaCostPips as FLUID_ANCHOR. Diameter and anchor
only look right together, and all five fluid consumers were repeating
the placement by hand -- StackEntry had already drifted to a different
value. CardPreview was the lone fixed-px consumer at 28px, which cannot
be right for both a 300px hand hover and a 472px docked preview; give it
the same @container basis so both land on the same ratio by
construction, and drop the now-orphaned lg size.

Verified in-app on an unrotated 300px preview: symbol 5.2%, pip 6.0%,
five-symbol row 32.0%. Measurements must come from an unrotated frame --
a fan-rotated hand card's getBoundingClientRect returns an axis-aligned
bounding box that inflates the frame and understates the row.

Summary by CodeRabbit

  • Style
    • Improved mana cost “pip” overlay positioning and scaling across card previews, hand cards, and stack entries.
    • Removed hard-coded absolute offsets so mana pips rely on container-aware sizing for more consistent alignment.
    • Updated fluid mana pip sizing behavior and anchoring for better responsiveness to the rendered card size.

The card-overlay mana pips were ~2.9x the size of the mana symbols
printed on the card frame they sit on, and anchored above the title bar
rather than inside it. On a desktop hand card a five-symbol cost spanned
67% of the card's width, reducing "Nissa, Ascended Animist" to "Nis".

The badge stands in for the card's PRINTED mana cost (it renders the
engine's effective cost, with a green ring when reduced), so calibrate
its geometry against that cost. Measured on M15-frame art, a printed
symbol is ~5.2% of the card's width, its right edge sits ~7% in and its
top edge ~5.4% down. The fluid pip drops 15cqi -> 7cqi, which keeps a
legibility margin over printed while fitting inside the title bar: a
five-symbol cost now spans 32% instead of 67%.

Fold the anchor into ManaCostPips as FLUID_ANCHOR. Diameter and anchor
only look right together, and all five fluid consumers were repeating
the placement by hand -- StackEntry had already drifted to a different
value. CardPreview was the lone fixed-px consumer at 28px, which cannot
be right for both a 300px hand hover and a 472px docked preview; give it
the same @container basis so both land on the same ratio by
construction, and drop the now-orphaned lg size.
@matthewevans
matthewevans enabled auto-merge July 24, 2026 20:19
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Mana cost pip overlays now use fluid container-based sizing and centralized anchoring. Card previews, mobile hand views, player hand cards, zone fans, and stack entries remove fixed positional classes and rely on their surrounding overlay containers.

Changes

Responsive mana pip overlays

Layer / File(s) Summary
Fluid pip sizing and anchoring
client/src/components/mana/ManaCostPips.tsx
Removes the lg size option, updates fluid container-query sizing values, and applies fluid overlay anchoring conditionally.
Card and stack overlay integration
client/src/components/card/CardPreview.tsx, client/src/components/hand/*, client/src/components/stack/StackEntry.tsx
Moves placement responsibility to surrounding overlay containers and updates card preview rendering to use fluid pip sizing.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: mana cost pips now scale to the printed cost instead of a fixed pixel size.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ship/mana-pip-printed-cost-sizing

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@client/src/components/mana/ManaCostPips.tsx`:
- Line 24: Update the fluid layout dimensions in ManaCostPips so five symbols
plus four gaps total the intended 32% container width, adjusting the 7cqi pip
size and/or 0.6cqi gap consistently. Preserve the overlap-free layout and
validate the resulting card-name spacing visually.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1610eee7-e9df-4f2e-92b8-5daeda35f854

📥 Commits

Reviewing files that changed from the base of the PR and between 731cffc and ad9507d.

📒 Files selected for processing (6)
  • client/src/components/card/CardPreview.tsx
  • client/src/components/hand/MobileHandDrawer.tsx
  • client/src/components/hand/MobileHeldHandCard.tsx
  • client/src/components/hand/PlayerHand.tsx
  • client/src/components/mana/ManaCostPips.tsx
  • client/src/components/stack/StackEntry.tsx

Comment thread client/src/components/mana/ManaCostPips.tsx Outdated
The prior commit claimed a five-symbol cost spans 32% of the card's
width, but 5 * 7cqi + 4 * 0.6cqi is 37.4cqi. The 32% came from measuring
a fan-rotated hand card, where getBoundingClientRect returns an
axis-aligned bounding box that inflates the frame and understates the
row -- an invalid basis. Measured on an unrotated preview the row was
37.4%, exactly what the arithmetic predicts.

Solve the three values for the stated target instead: 5 * 6cqi + 4 *
0.5cqi = 32cqi exactly. With 0.4cqi padding the symbol lands on 5.2cqi,
which is precisely the printed symbol diameter, so the disk reads as a
thin ring around a printed-size symbol rather than a badge sitting over
one. Dropping the "legibility margin" costs nothing: the printed symbols
on the same card are legible at 5.2%, which is what makes it enough.

Verified in-app on an unrotated 300px preview -- symbol 5.2%, pip 6.0%,
five-symbol row 32.0%. "Nissa, Ascended Animist" now reads to its last
character where it was truncated to "Nissa, Ascended Anim" at 7cqi.
@matthewevans
matthewevans added this pull request to the merge queue Jul 24, 2026
Merged via the queue into main with commit 2c6596d Jul 24, 2026
16 checks passed
@matthewevans
matthewevans deleted the ship/mana-pip-printed-cost-sizing branch July 24, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant