Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] 반응형 UI 적용 #245

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fe/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.min.css"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Clovapatra</title>
<title>안녕! 클로바파트라</title>
</head>
<body>
<div id="root"></div>
Expand Down
2 changes: 1 addition & 1 deletion fe/src/hooks/useRoomsSSE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const useRoomsSSE = () => {
setRooms(sseData.rooms);
setPagination(sseData.pagination);

if (!sseData.rooms.length && userPage > 0) {
if (sseData.pagination.totalPages === 1 && userPage > 0) {
setUserPage(sseData.pagination.currentPage - 1);
return;
}
Expand Down
35 changes: 32 additions & 3 deletions fe/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,17 @@
box-sizing: border-box;
}

html,
body,
html {
height: 100%;
scroll-behavior: smooth;
}

body {
height: 100%;
margin: 0;
overflow-x: hidden;
}

#root {
height: 100%;
}
Expand All @@ -102,10 +111,30 @@ body {

.app {
@apply flex flex-col mx-auto justify-center max-w-[1074px] lg:px-0 p-8;
height: 100%;
}

.game-wrapper {
@apply relative w-full min-h-screen;
@apply relative w-full;
min-height: 100vh;
}

@media (min-width: 768px) {
.game-wrapper {
height: 100vh;
overflow: hidden;
}
}

@media (max-width: 767px) {
.game-wrapper {
height: auto;
overflow-y: visible;
}

body {
overflow-y: auto;
}
}

.game-wrapper::before {
Expand Down
23 changes: 14 additions & 9 deletions fe/src/pages/GamePage/GameScreen/EndScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@ const EndScreen = () => {
};

const positions = {
0: { top: '18%', left: '49.7%' },
1: { top: '54%', left: '34.5%' },
0: { top: '20%', left: '49.5%' },
1: { top: '54%', left: '38.5%' },
2: { top: '68%', left: '60.5%' },
};

const getRelativePosition = (index: number) => {
const position = positions[index as keyof typeof positions];
return {
top: `calc(${position.top})`,
left: `calc(${position.left})`,
};
};

const getDelay = (index: number) => {
switch (index) {
case 2:
Expand All @@ -48,12 +56,12 @@ const EndScreen = () => {
};

return (
<div className="relative h-[27rem] bg-white rounded-lg overflow-hidden">
<div className="relative w-full h-full flex items-center justify-center">
<div className="relative h-[27rem] md:h-[calc(100vh-20rem)] md:min-h-[27rem] md:max-h-[34rem] bg-white rounded-lg overflow-hidden">
<div className="h-full w-full flex items-center">
<Lottie
animationData={podiumAnimation}
loop={false}
className="w-full max-w-2xl absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2"
className="w-full max-w-2xl absolute left-1/2 transform -translate-x-1/2"
/>

<div className="absolute inset-0 pointer-events-none">
Expand All @@ -62,8 +70,7 @@ const EndScreen = () => {
key={`rank-${index}-${playerName}`}
className="absolute"
style={{
top: positions[index as keyof typeof positions].top,
left: positions[index as keyof typeof positions].left,
...getRelativePosition(index),
transform: 'translate(-50%, -120%)',
}}
initial={{ opacity: 0, y: 10 }}
Expand Down Expand Up @@ -91,7 +98,6 @@ const EndScreen = () => {
</motion.div>
))}
</div>

<motion.div
className="absolute top-4 right-4 bg-white/90 p-4 rounded-lg shadow-lg"
initial={{ opacity: 0, y: -20 }}
Expand All @@ -111,7 +117,6 @@ const EndScreen = () => {
))}
</div>
</motion.div>

<motion.div
className="absolute bottom-4 right-4 z-10"
initial={{ opacity: 0, y: 20 }}
Expand Down
2 changes: 1 addition & 1 deletion fe/src/pages/GamePage/GameScreen/PlayScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const PlayScreen = () => {
if (!turnData && !rank.length) return;

return (
<div className="relative h-[27rem] bg-white rounded-lg overflow-hidden">
<div className="relative h-[27rem] md:h-[calc(100vh-20rem)] md:min-h-[27rem] md:max-h-[34rem] bg-white rounded-lg overflow-hidden">
<AnimatePresence mode="wait">
{gamePhase === 'intro' && (
<motion.div
Expand Down
28 changes: 21 additions & 7 deletions fe/src/pages/GamePage/GameScreen/ReadyScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const ReadyScreen = () => {
};

return (
<div className="h-[27rem] bg-white rounded-lg flex flex-col items-center justify-center space-y-4">
<div className="relative h-[27rem] md:h-[calc(100vh-20rem)] md:min-h-[27rem] md:max-h-[34rem] bg-white rounded-lg flex flex-col items-center justify-center space-y-4">
{isHost ? (
<Button
size="lg"
Expand All @@ -69,13 +69,27 @@ const ReadyScreen = () => {
)}

{!canStartGame ? (
<p className="font-galmuri text-sm text-muted-foreground mt-2">
모든 플레이어가 준비를 완료해야 게임을 시작할 수 있습니다.
</p>
<>
<p className="font-galmuri text-md text-muted-foreground mt-2 hidden md:inline">
모든 플레이어가 준비를 완료해야 게임을 시작할 수 있습니다.
</p>
<p className="font-galmuri text-md text-muted-foreground mt-2 md:hidden">
모든 플레이어가 준비를 완료해야
<br />
게임을 시작할 수 있습니다.
</p>
</>
) : (
<p className="font-galmuri text-sm text-muted-foreground mt-2">
모든 플레이어가 준비 완료되었습니다. 게임을 시작해 주세요!
</p>
<>
<p className="font-galmuri text-md text-muted-foreground mt-2 hidden md:inline">
모든 플레이어가 준비 완료되었습니다. 게임을 시작해 주세요!
</p>
<p className="font-galmuri text-md text-muted-foreground mt-2 md:hidden">
모든 플레이어가 준비 완료되었습니다.
<br />
게임을 시작해 주세요!
</p>
</>
)}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion fe/src/pages/GamePage/PlayerList/PlayerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PlayerList = ({ players }: PlayerListProps) => {
const emptySlots = RULES.maxPlayer - players.length;

return (
<div className="grid grid-cols-2 gap-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
{players.map((player) => (
<Player key={player.playerNickname} {...player} />
))}
Expand Down
2 changes: 1 addition & 1 deletion fe/src/pages/GamePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const GamePage = () => {

return (
<div className="game-wrapper">
<div className="h-screen relative p-4">
<div className="relative overflow-y-auto p-6 mt-2 min-h-screen">
<div className="space-y-6">
<GameScreen />
<PlayerList
Expand Down
2 changes: 1 addition & 1 deletion fe/src/pages/RoomListPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const RoomListPage = () => {

return (
<div className="game-wrapper">
<div className="flex-1">
<div className="relative overflow-y-auto p-6 mt-2 min-h-screen flex-1">
<RoomHeader />
<SearchBar />
{isEmpty ? (
Expand Down
Loading