Skip to content

Commit ebf4f51

Browse files
committed
fix: improve responsiveness
1 parent 1eb94ed commit ebf4f51

File tree

12 files changed

+60
-34
lines changed

12 files changed

+60
-34
lines changed

src/modules/game/ui/GameOverlay.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { GameNextTurnButton } from './GameNextTurnButton'
21
import { GameOverlayMenu } from './GameOverlayMenu'
32
import { GameOverlayScore } from './GameOverlayScore'
43
import { useCurrentPlayer, usePlayers } from '..'
@@ -15,10 +14,10 @@ export const GameOverlay = () => {
1514
const currentPlayer = useCurrentPlayer()
1615

1716
return (
18-
<div className="fixed inset-0 grid grid-cols-1 grid-rows-1 [&>*]:col-span-full [&>*]:row-span-full">
17+
<div className="absolute inset-0 grid grid-cols-1 grid-rows-1 [&>*]:col-span-full [&>*]:row-span-full">
1918
<GameOverlayMenu />
2019

21-
<div className="grid grid-cols-1 grid-rows-1 p-6 [&>*]:col-span-full [&>*]:row-span-full xl:p-12">
20+
<div className="grid grid-cols-1 grid-rows-1 p-4 [&>*]:col-span-full [&>*]:row-span-full lg:p-12 sm:p-8">
2221
{players.map((player, index) => {
2322
const horizontalPlacement = [0, 3].includes(index) ? 'left' : 'right'
2423
const verticalPlacement = [2, 3].includes(index) ? 'bottom' : 'top'
@@ -34,8 +33,6 @@ export const GameOverlay = () => {
3433
/>
3534
)
3635
})}
37-
38-
<GameNextTurnButton className="self-end justify-self-center" />
3936
</div>
4037
</div>
4138
)

src/modules/game/ui/GameOverlayMenu.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ export const GameOverlayMenu = () => {
88
}
99

1010
return (
11-
<div className="z-1 flex self-start justify-self-center gap-4">
11+
<div className="z-20 flex self-start justify-self-center gap-4">
1212
<button
13-
className="group flex items-center gap-2 rounded-b from-slate-100 to-slate-200 bg-gradient-to-r p-4 text-slate-400 hover:from-slate-100 hover:to-slate-300 hover:text-slate-500"
13+
className="group flex items-center gap-2 rounded-b from-slate-100 to-slate-200 bg-gradient-to-r p-2 text-slate-400 hover:from-slate-100 hover:to-slate-300 sm:p-4 hover:text-slate-500"
1414
onClick={onExitClick}
1515
>
1616
<i className="i-lucide-door-closed group-hover:i-lucide-door-open block text-2xl" />
17-
Exit
17+
<span className="hidden sm:block">Exit</span>
1818
</button>
1919
</div>
2020
)

src/modules/game/ui/GameOverlayScore.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ export const GameOverlayScore = ({
2424

2525
return (
2626
<div
27-
className={clsx(className, 'flex flex-col gap-4', {
27+
className={clsx(className, 'flex flex-col gap-2 sm:gap-4', {
2828
'flex-col-reverse': isOnBottom,
2929
})}
3030
>
3131
<div
32-
className={clsx('flex gap-4 items-center', {
32+
className={clsx('flex gap-2 sm:gap-4 items-center', {
3333
'flex-row-reverse': isOnRightSide,
3434
})}
3535
>
3636
<div className="text-xl font-medium text-slate-400">
3737
Player #{player.id + 1}
3838
</div>
3939
{itsTurn && (
40-
<div className="h-5 w-5 animate-pulse rounded-full from-primary-400 to-primary-500 bg-gradient-to-r" />
40+
<div className="h-3 w-3 animate-pulse rounded-full from-primary-400 to-primary-500 bg-gradient-to-r sm:h-5 sm:w-5" />
4141
)}
4242
</div>
4343
<div

src/modules/game/ui/GameScoreboard.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ import { Scoreboard } from '@/shared/ui/Scoreboard'
22

33
import { usePlayers } from '..'
44

5-
export const GameScoreboard = () => {
5+
type GameScoreboardProps = {
6+
className?: string
7+
}
8+
9+
export const GameScoreboard = ({ className }: GameScoreboardProps) => {
610
const players = usePlayers()
711

812
return (
913
<Scoreboard
14+
className={className}
1015
items={players.map((player) => ({
1116
name: `Player #${player.id + 1}`,
1217
score: player.cards.length,

src/modules/game/ui/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export * from './GameManager'
22
export * from './GameBoard'
33
export * from './GameOverlay'
44
export * from './GameStartButton'
5+
export * from './GameNextTurnButton'
56
export * from './GameScoreboard'

src/pages/GameEndPage.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import { Button } from '@/shared/ui/Button'
33

44
export function GameEndPage() {
55
return (
6-
<main className="relative h-screen w-screen flex items-center justify-center">
7-
<div className="flex flex-col items-center gap-16">
8-
<div className="text-6xl font-medium text-slate-400">
9-
Yay! All cats found! 😺
6+
<main className="relative h-screen w-screen flex items-center justify-center p-8">
7+
<div className="w-full flex flex-col items-center gap-16">
8+
<div className="text-center text-2xl font-medium text-slate-400 sm:text-6xl">
9+
Yay! 😺
10+
<br />
11+
All cats found!
1012
</div>
11-
<GameScoreboard />
13+
<GameScoreboard className="w-full" />
1214
<div className="flex flex-col gap-4">
1315
<GameStartButton>Play again</GameStartButton>
1416
<Button icon="i-lucide-settings" navigateTo="/" variant="secondary">

src/pages/GamePage.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
GameBoard,
33
GameManager,
44
GameOverlay,
5+
GameNextTurnButton,
56
useAreCardsLoading,
67
} from '@/modules/game'
78
import { Loader } from '@/shared/ui/Loader'
@@ -10,7 +11,7 @@ export function GamePage() {
1011
const areCardsLoading = useAreCardsLoading()
1112

1213
return (
13-
<main className="relative h-screen w-screen flex items-center justify-center gap-4 p-12 landscape:p-28 xl:p-40">
14+
<main className="relative h-[100dvh] w-auto flex items-center justify-center px-4 pb-16 pt-24 lg:px-12 sm:px-8 lg:pb-12 sm:pb-16 sm:pt-32">
1415
{areCardsLoading ? (
1516
<Loader>
1617
We're preparing <br />
@@ -20,7 +21,11 @@ export function GamePage() {
2021
<>
2122
<GameManager />
2223
<GameOverlay />
23-
<GameBoard className="z-10" />
24+
25+
<div className="grid grid-cols-1 grid-rows-1 max-h-full w-full place-items-center gap-8 lg:justify-start">
26+
<GameBoard className="z-10" />
27+
<GameNextTurnButton className="z-10" />
28+
</div>
2429
</>
2530
)}
2631
</main>

src/pages/GameSettingsPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66

77
export function GameSettingsPage() {
88
return (
9-
<main className="h-screen w-screen flex flex-col items-center justify-center gap-6">
9+
<main className="h-[100dvh] w-screen flex flex-col items-center justify-center gap-6">
1010
<h1 className="mb-8 from-primary-300 to-primary-600 bg-gradient-to-r bg-clip-text text-6xl font-medium text-transparent">
1111
petmemo
1212
</h1>

src/shared/ui/Board.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const Board = ({ className, children }: BoardProps) => {
1313
<div
1414
className={clsx(
1515
className,
16-
'grid h-full w-full content-center justify-center gap-8',
16+
'grid h-full w-full content-center justify-center gap-2 sm:gap-4',
1717
)}
1818
style={{
1919
gridTemplateColumns: `repeat(${matrixSize}, minmax(0, max-content))`,

src/shared/ui/BoardCard.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,25 @@ export const BoardCard = ({
3030
}
3131

3232
return (
33-
<img
33+
<div
3434
tabIndex={0}
35-
src={imageUrl}
36-
width={width}
37-
height={height}
3835
className={clsx(
3936
className,
40-
'rounded-xl object-cover border-slate-2 border-3 transition-shadow transition-opacity select-none aspect-square w-full h-full max-w-[250px]',
37+
'rounded-xl object-cover border-slate-2 border-3 transition-shadow transition-opacity select-none aspect-square w-full h-full overflow-hidden',
4138
{
4239
'cursor-pointer hover:shadow-md': !isDisabled,
4340
},
4441
)}
4542
onClick={handleClick}
4643
onKeyDown={handleKeyDown}
47-
draggable={false}
48-
/>
44+
>
45+
<img
46+
className="h-full w-full object-cover"
47+
src={imageUrl}
48+
width={width}
49+
height={height}
50+
draggable={false}
51+
/>
52+
</div>
4953
)
5054
}

0 commit comments

Comments
 (0)