Skip to content

Commit a6eb9f2

Browse files
committed
style(ui): added micro game cards within game hud
1 parent ea40992 commit a6eb9f2

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

front/components/GameCard.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,30 @@ export function MiniGameCard({ title, imageUrl, slug, metaDescription }: GameCar
6666
</a>
6767
)
6868
}
69+
70+
/**
71+
* A micro version of the GameCard component for use in compact UI elements
72+
* where minimal space is available.
73+
*/
74+
export function MicroGameCard({ title, imageUrl, slug }: Omit<GameCardProps, 'metaDescription'>) {
75+
return (
76+
<a
77+
href={`/play/${slug}`}
78+
className="block group transition-transform duration-200 hover:scale-[1.03]"
79+
>
80+
<Card className="relative overflow-hidden rounded-md bg-gray-900 drop-shadow-md hover:drop-shadow-lg border-0">
81+
<div className="relative w-full h-12 aspect-square">
82+
<img
83+
alt={title}
84+
src={imageUrl}
85+
className="h-full w-full object-cover brightness-100 group-hover:brightness-110 transition-all duration-300"
86+
/>
87+
<div className="absolute inset-0 bg-black/30" />
88+
<CardTitle className="absolute bottom-1 left-1 text-xs/relaxed text-white truncate w-5/6">
89+
{title}
90+
</CardTitle>
91+
</div>
92+
</Card>
93+
</a>
94+
)
95+
}

front/components/GameHud.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
/* eslint-disable react/jsx-no-undef */
12
import { useEffect, useRef, useState } from 'react'
23
import { Joystick } from 'react-joystick-component'
34
import { Game } from '@/game/Game'
45
import Link from 'next/link'
56
import { SerializedMessageType } from '@shared/network/server/serialized'
67
import { MessageComponent } from '@shared/component/MessageComponent'
7-
import { Twitter, Github, Maximize } from 'lucide-react'
8+
import { Maximize } from 'lucide-react'
9+
import { MicroGameCard } from './GameCard'
10+
import { GameInfo } from '@/types'
11+
import gameData from '../public/gameData.json'
812

913
export interface GameHudProps {
1014
messages: MessageComponent[]
@@ -170,7 +174,19 @@ export default function GameHud({
170174
</div>
171175
</div>
172176

173-
<div className="absolute bottom-4 right-4 bg-black bg-opacity-20 rounded-xl p-4 z-50 hidden lg:flex flex-col w-[360px] pointer-events-auto space-y-4">
177+
<div className="absolute bottom-4 right-4 bg-black bg-opacity-20 rounded-xl p-4 z-50 hidden lg:flex flex-col w-[360px] pointer-events-auto space-y-2">
178+
{/* Other games cards mini section */}
179+
<div className="grid grid-cols-4 gap-3">
180+
{gameData.slice(0, 4).map((game: GameInfo) => (
181+
<MicroGameCard
182+
key={game.slug}
183+
title={game.title}
184+
imageUrl={game.imageUrl}
185+
slug={game.slug}
186+
/>
187+
))}
188+
</div>
189+
174190
<div className="overflow-y-auto max-h-64 h-64 space-y-2 pr-2">
175191
{getFilteredMessages().map((messageComponent, index) => {
176192
return (

0 commit comments

Comments
 (0)