{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "trading-card", "type": "registry:ui", "title": "Trading Card", "description": "A 63:88 trading card with a rim, name bar, art window, one move row that can hold a form, flavor text, facts and an optional holo finish.", "dependencies": [ "@fungi.computer/stipe", "class-variance-authority", "cn", "react" ], "registryDependencies": [], "files": [ { "path": "../src/components/trading-card.tsx", "type": "registry:ui", "target": "@ui/trading-card.tsx", "content": "import { forwardRef, useId, type HTMLAttributes, type ReactNode } from \"react\";\n\nimport { cn } from \"@/lib/cn\";\n\n/** Print finish: `holo` adds a foil sheen on hover that stills for reduced motion. */\nexport type TradingCardFinish = \"standard\" | \"holo\";\n\n/** One footer fact, printed like a trading card's weakness or retreat line. */\nexport type TradingCardFact = Readonly<{ label: string; value: ReactNode }>;\n\n/** The card's one move: a cost of symbols, a name, and caller-owned text or controls. */\nexport type TradingCardMove = Readonly<{\n /** Decorative cost symbols, such as Sigils. Hidden from assistive technology. */\n cost?: ReactNode;\n name: string;\n /** An optional figure printed at the end of the move line. */\n value?: ReactNode;\n children?: ReactNode;\n}>;\n\n/** Props accepted by TradingCard. */\nexport type TradingCardProps = Omit<\n HTMLAttributes,\n \"title\" | \"children\"\n> & {\n name: string;\n /** A small stage label printed before the name, such as \"Spore\". */\n stage?: string;\n /** The stat printed at the right of the name bar, such as \"60 SP\". */\n stat?: ReactNode;\n /** The type line under the art window. */\n typeLine?: string;\n art: ReactNode;\n move: TradingCardMove;\n flavor?: ReactNode;\n facts?: readonly TradingCardFact[];\n /** Collector number, such as \"001/001\". */\n setNumber?: string;\n /** A small rarity mark printed by the set number. */\n rarity?: ReactNode;\n finish?: TradingCardFinish;\n};\n\n/**\n * A 63:88 trading card: a bright rim, a name bar with a stage and stat, an art\n * window, one move row that can hold a real form, a flavor line and a footer of\n * facts with a set number and rarity mark. The move body is caller-owned, so a\n * form inside it keeps its own labels, focus and errors.\n */\nexport const TradingCard = forwardRef(\n function TradingCard(\n {\n art,\n className,\n facts = [],\n finish = \"standard\",\n flavor,\n move,\n name,\n rarity,\n setNumber,\n stage,\n stat,\n typeLine,\n ...props\n },\n ref,\n ) {\n const nameId = useId();\n return (\n \n
\n
\n {stage ? (\n {stage}\n ) : null}\n

\n {name}\n

\n {stat ? (\n {stat}\n ) : null}\n
\n
{art}
\n {typeLine ? (\n

{typeLine}

\n ) : null}\n
\n
\n {move.cost ? (\n \n {move.cost}\n \n ) : null}\n

{move.name}

\n {move.value ? (\n \n {move.value}\n \n ) : null}\n
\n {move.children ? (\n
{move.children}
\n ) : null}\n
\n {flavor ?

{flavor}

: null}\n {facts.length > 0 || setNumber || rarity ? (\n
\n {facts.length > 0 ? (\n
\n {facts.map((fact) => (\n
\n
{fact.label}
\n
{fact.value}
\n
\n ))}\n
\n ) : null}\n {setNumber || rarity ? (\n

\n {setNumber ? {setNumber} : null}\n {rarity ? (\n {rarity}\n ) : null}\n

\n ) : null}\n
\n ) : null}\n
\n \n );\n },\n);\n" }, { "path": "../src/lib/cn.ts", "type": "registry:lib", "target": "@lib/cn.ts", "content": "import { STIPE_SPACING_NAMES } from \"@fungi.computer/stipe\";\nimport { cva } from \"class-variance-authority\";\nimport { createCn } from \"cn/config\";\n\n/** A conditional class value accepted by cn. */\nexport type { ClassValue } from \"cn\";\nexport { cva };\n\n/** Merge conditional classes with Tailwind rules and Stipe's named spacing. */\nexport const cn = createCn({\n extend: { theme: { spacing: [...STIPE_SPACING_NAMES] } },\n});\n\n/** Resolve a typed React class-name prop before merging its classes. */\nexport function resolveClassName(\n className: string | ((state: State) => string | undefined) | undefined,\n state: State,\n): string | undefined {\n return typeof className === \"function\" ? className(state) : className;\n}\n" } ], "css": { "@import \"@fungi.computer/stipe/styles.css\"": {} } }