diff --git a/packages/client/src/ui/Chessboard.css b/packages/client/src/ui/Chessboard.css index f66cb6e..5c257c7 100644 --- a/packages/client/src/ui/Chessboard.css +++ b/packages/client/src/ui/Chessboard.css @@ -285,72 +285,6 @@ /* line-height: 0px; */ } -.playerList { - width: 295px; - background: linear-gradient( - 180deg, - rgba(80, 219, 255, 0.27) 0%, - rgba(255, 255, 255, 0) 100% - ); - border-radius: 20px 20px 20px 20px; - opacity: 1; - padding: 20px 10px; - box-sizing: border-box; -} - -.playerList-tit { - height: 21px; - font-size: 16px; - font-family: Arial-Regular, Arial; - font-weight: 400; - color: #ffffff; - line-height: 0px; -} - -.players { - width: 275px; - height: 76px; - background: rgba(0, 0, 0, 0.27); - border-radius: 10px 10px 10px 10px; - opacity: 1; -} - -.player-addr { - width: 100px; - height: 16px; - font-size: 14px; - font-family: Arial-Regular, Arial; - font-weight: 400; - color: #ffffff; - line-height: 1; -} -.player-coin { - width: 30px; - height: 16px; - font-size: 14px; - font-family: Arial-Regular, Arial; - font-weight: 400; - color: #ffd426; - line-height: 1; -} -.player-lv { - width: 30px; - height: 16px; - font-size: 14px; - font-family: Arial-Regular, Arial; - font-weight: 400; - color: #ff7167; - line-height: 1; -} - -.player-hp { - height: 17px; - font-size: 16px; - font-family: Arial-Regular, Arial; - font-weight: 400; - color: red; -} - .notice-board { width: 109px; height: 70px; diff --git a/packages/client/src/ui/Playlist.tsx b/packages/client/src/ui/Playlist.tsx index e08f477..5de5ab5 100644 --- a/packages/client/src/ui/Playlist.tsx +++ b/packages/client/src/ui/Playlist.tsx @@ -1,17 +1,57 @@ -import React from "react"; +import React, { useEffect, useState } from "react"; import useChessboard from "@/hooks/useChessboard"; -interface Player { +interface IPlayerStatus { id: string; + name: string; + isCurrent: boolean; avatar: string; level: number; hp: number; + maxHp: number; coin: number; } -interface Props { - players: Player[]; - currentUserId: string; +function PlayerStatus({ + id, + name, + isCurrent, + avatar, + level, + hp, + maxHp, + coin, +}: IPlayerStatus) { + const healthPercentage = (hp / maxHp) * 100; + + return ( +
+ +
+
+ {name} + ${coin} + Lv. {level} +
+
+
+ +
+ {hp}/{maxHp} +
+
+
+
+
+ ); } const PlayerList: React.FC = () => { @@ -21,6 +61,8 @@ const PlayerList: React.FC = () => { isSinglePlay, } = useChessboard(); + const [showList, setShowList] = useState(true); + const isCurrentUserFn = (id: string) => id.toLocaleLowerCase() === currentUserId.toLocaleLowerCase(); @@ -28,43 +70,40 @@ const PlayerList: React.FC = () => { ? playerListData?.filter((player) => isCurrentUserFn(player.id)) : playerListData; + // monitor windows size to decide whether show player + useEffect(() => { + const handleResize = () => { + if (window.innerWidth / window.innerHeight < 1400 / 980) { + setShowList(false); + } else { + setShowList(true); + } + }; + window.addEventListener("resize", handleResize); + + return () => { + window.removeEventListener("resize", handleResize); + }; + }, []); + + if (!showList) { + return
; + } + return ( -
-
Players Info
- {mapList?.map((player) => { - const isCurrentUser = isCurrentUserFn(player.id); - const healthPercentage = (player.hp / player.maxHp) * 100; - return ( -
redirectToGame(player.id)} - > - +
Players Info
+
+ {mapList?.map((player) => { + const isCurrent = isCurrentUserFn(player.id); + return ( + -
-
- {player.name} - ${player.coin} - Lv. {player.level} -
-
-
- - {player.hp}/{player.maxHp} HP - -
-
-
- ); - })} + ); + })} +
); };