refactor: make homepage game cards dynamic from game registry

Previously game cards were hardcoded. Now they automatically populate
from getAvailableGames() in the game registry. This means:
- Adding a new game to the registry automatically shows it on homepage
- Game metadata (icon, title, description, gradient, chips) comes from
  game manifests
- No manual homepage updates needed when games are added

Changes:
- Import getAvailableGames from game registry
- Replace hardcoded GameCard components with .map() over available games
- Format maxPlayers into player count string (e.g., "1-4 players")

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock 2025-10-20 17:08:40 -05:00
parent 9f706e9dce
commit 7f516526fb
1 changed files with 19 additions and 36 deletions

View File

@ -8,6 +8,7 @@ import { HomeHeroProvider } from '@/contexts/HomeHeroContext'
import { PageWithNav } from '@/components/PageWithNav' import { PageWithNav } from '@/components/PageWithNav'
import { TutorialPlayer } from '@/components/tutorial/TutorialPlayer' import { TutorialPlayer } from '@/components/tutorial/TutorialPlayer'
import { getTutorialForEditor } from '@/utils/tutorialConverter' import { getTutorialForEditor } from '@/utils/tutorialConverter'
import { getAvailableGames } from '@/lib/arcade/game-registry'
import { css } from '../../styled-system/css' import { css } from '../../styled-system/css'
import { container, grid, hstack, stack } from '../../styled-system/patterns' import { container, grid, hstack, stack } from '../../styled-system/patterns'
import { token } from '../../styled-system/tokens' import { token } from '../../styled-system/tokens'
@ -298,42 +299,24 @@ export default function HomePage() {
</div> </div>
<div className={grid({ columns: { base: 1, sm: 2, lg: 4 }, gap: '5' })}> <div className={grid({ columns: { base: 1, sm: 2, lg: 4 }, gap: '5' })}>
<GameCard {getAvailableGames().map((game) => {
icon="🧠" const playersText =
title="Memory Lightning" game.manifest.maxPlayers === 1
description="Memorize soroban numbers" ? 'Solo challenge'
players="1-8 players" : `1-${game.manifest.maxPlayers} players`
tags={['Memory', 'Pattern Recognition']} return (
gradient="linear-gradient(135deg, #667eea 0%, #764ba2 100%)" <GameCard
href="/games" key={game.manifest.name}
/> icon={game.manifest.icon}
<GameCard title={game.manifest.displayName}
icon="⚔️" description={game.manifest.description}
title="Matching Pairs" players={playersText}
description="Match complement numbers" tags={game.manifest.chips}
players="1-4 players" gradient={game.manifest.gradient}
tags={['Friends of 5', 'Friends of 10']} href="/games"
gradient="linear-gradient(135deg, #f093fb 0%, #f5576c 100%)" />
href="/games" )
/> })}
<GameCard
icon="🏁"
title="Complement Race"
description="Race against time"
players="1-4 players"
tags={['Speed', 'Practice', 'Survival']}
gradient="linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)"
href="/games"
/>
<GameCard
icon="🔢"
title="Card Sorting"
description="Arrange numbers visually"
players="Solo challenge"
tags={['Visual Literacy', 'Ordering']}
gradient="linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)"
href="/games"
/>
</div> </div>
</section> </section>