Skip to content

Commit db76da7

Browse files
committed
fix(decks): use server commander color identity in deck header and stop clipping mana symbols
The deck detail header computed color identity client-side from the commanders' printed identities, missing chosen colors from commanders like Clara Oswald. Fetch the server-computed commanderColorIdentity in the deck detail query instead, expose the field on the public share schema, and drop the unused client-side helper. Also remove the baseline nudge on mana symbols inside ColorIdentitySymbols so their tops are no longer clipped by line-clamped deck names. Amp-Thread-ID: https://ampcode.com/threads/T-019fe161-a26b-7051-bf37-f5f1e783020d
1 parent 1ff207e commit db76da7

7 files changed

Lines changed: 16 additions & 35 deletions

File tree

‎assets/react/src/components/ui/mana-symbols.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ export function ColorIdentitySymbols({
4646
className={cn("inline-flex shrink-0 items-center gap-0.5", className)}
4747
>
4848
{colors.map((color) => (
49-
<ManaSymbol key={color} symbol={color} />
49+
// Inside this flex container the icons are already centered; drop the
50+
// baseline nudge so they don't poke above the line box and get
51+
// clipped by ancestors with overflow hidden (e.g. line-clamped names).
52+
<ManaSymbol key={color} symbol={color} className="translate-y-0" />
5053
))}
5154
</span>
5255
)

‎assets/react/src/gql/gql.ts‎

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

‎assets/react/src/gql/graphql.ts‎

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

‎assets/react/src/pages/decks/deck-detail-header.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { deckDetailCoverUrl } from "./deck-card-model"
2222
import type { DeckLegalityIssue, DeckPrice, DetailZoneCounts } from "./deck-detail-types"
2323
import { DeckGroupMenu } from "./deck-group-menu"
2424
import { deckLegalityIssueCountLabel, deckLegalityLabel, deckLegalityTone } from "./deck-legality"
25-
import { DeckNameWithCommanderIdentity, commanderColorIdentity } from "./deck-list-model"
25+
import { DeckNameWithCommanderIdentity } from "./deck-list-model"
2626
import { DeckTagsSidebar } from "./deck-tags-sidebar"
2727
import type { DeckCardEntry, DeckCustomTag, DeckDetail } from "./deck-types"
2828

@@ -219,7 +219,7 @@ export function DeckDetailHeader({
219219
}
220220
nameLine={
221221
<DeckNameWithCommanderIdentity
222-
colors={commanderColorIdentity(deckCards)}
222+
colors={deck.commanderColorIdentity}
223223
name={deck.name}
224224
/>
225225
}

‎assets/react/src/pages/decks/deck-list-model.tsx‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { type ReactNode } from "react"
22
import { ColorIdentitySymbols } from "../../components/ui/mana-symbols"
33
import { present } from "../../lib/utils"
4-
import { colorOrder } from "./deck-card-model"
54
import type { DeckSummary } from "./deck-types"
65
import { DECK_FORMATS } from "./deck-types"
76

@@ -43,30 +42,4 @@ export function DeckNameWithCommanderIdentity({
4342
)
4443
}
4544

46-
export function commanderColorIdentity(
47-
deckCards:
48-
| Array<{
49-
card?: { colorIdentity?: Array<string | null> | null } | null
50-
zone?: string | null
51-
} | null>
52-
| null
53-
| undefined,
54-
) {
55-
const commanders = (deckCards || []).filter(
56-
(deckCard) => deckCard?.zone === "commander" && deckCard.card,
57-
)
58-
59-
if (!commanders.length) return null
60-
61-
const colors = new Set<string>()
6245

63-
for (const commander of commanders) {
64-
for (const color of commander?.card?.colorIdentity || []) {
65-
if (color) colors.add(color.toUpperCase())
66-
}
67-
}
68-
69-
return colors.size
70-
? Array.from(colors).sort((left, right) => colorOrder(left) - colorOrder(right))
71-
: ["C"]
72-
}

‎assets/react/src/pages/decks/queries.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export const DeckDocument = graphql(`
154154
status
155155
shareToken
156156
cardCount
157+
commanderColorIdentity
157158
legality {
158159
status
159160
issues {

‎lib/manavault_web/schema/public_share_types.ex‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ defmodule ManavaultWeb.Schema.PublicShareTypes do
316316
resolve(&DeckFields.deck_card_count/3)
317317
end
318318

319+
field :commander_color_identity, list_of(:string) do
320+
resolve(&DeckFields.deck_commander_color_identity/3)
321+
end
322+
319323
field :unique_card_count, :integer do
320324
resolve(&DeckFields.deck_unique_card_count/3)
321325
end

0 commit comments

Comments
 (0)