Commit 35d9e8ed authored by timel's avatar timel

feat: new waitroom ui

parent 462ef67b
import { Avatar } from "antd"; import { Avatar } from "antd";
import { type LoaderFunction, NavLink, Outlet } from "react-router-dom"; import {
type LoaderFunction,
NavLink,
Outlet,
useLocation,
} from "react-router-dom";
import { useSnapshot } from "valtio"; import { useSnapshot } from "valtio";
import { CookieKeys, getCookie } from "@/api"; import { CookieKeys, getCookie } from "@/api";
...@@ -19,8 +24,11 @@ export const loader: LoaderFunction = () => { ...@@ -19,8 +24,11 @@ export const loader: LoaderFunction = () => {
export const Component = () => { export const Component = () => {
// TODO 根据是否登录,显示内容 // TODO 根据是否登录,显示内容
const { pathname } = useLocation();
const pathnamesHideHeader = ["/waitroom"];
return ( return (
<> <>
{!pathnamesHideHeader.includes(pathname) && (
<nav className={styles.navbar}> <nav className={styles.navbar}>
<div className={styles["logo-container"]}> <div className={styles["logo-container"]}>
<img <img
...@@ -43,6 +51,7 @@ export const Component = () => { ...@@ -43,6 +51,7 @@ export const Component = () => {
<NavLink to="/profile">个人中心</NavLink> <NavLink to="/profile">个人中心</NavLink>
</span> </span>
</nav> </nav>
)}
<main className={styles.main}> <main className={styles.main}>
<Outlet /> <Outlet />
</main> </main>
......
...@@ -6,15 +6,21 @@ ...@@ -6,15 +6,21 @@
--border-radius: 10px; --border-radius: 10px;
--sider-width: 300px; --sider-width: 300px;
.content { .content {
height: 500px; // TODO: 修正这里的高度,或者说修正全局的高度设置。高度不应该超过100% height: 100%;
position: relative; position: relative;
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
// padding-bottom: 5%;
transition: transform 0.3s; transition: transform 0.3s;
.wrap {
height: 500px; // TODO: 修正这里的高度,或者说修正全局的高度设置。高度不应该超过100%
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
} }
.sider { .sider {
position: relative; position: relative;
...@@ -99,26 +105,27 @@ ...@@ -99,26 +105,27 @@
padding-left: 8px; padding-left: 8px;
} }
.btn-sider { .btns-side {
--length: 30px;
width: var(--length);
height: var(--length);
background: hsla(0, 0%, 100%, 0.1);
position: absolute; position: absolute;
right: calc(-1 * var(--length) - 10px); left: 10px;
bottom: 10px; bottom: 10px;
display: flex; display: flex;
align-items: center; flex-direction: column;
justify-content: center; gap: 10px;
font-size: 18px; transition: 0.3s;
transition: 0.2s; .btn {
background: hsla(0, 0%, 100%, 0.1);
}
} }
.collapsed { .collapsed {
.sider { .sider {
transform: translateX(calc(-1 * var(--sider-width))); transform: translateX(calc(-1 * var(--sider-width)));
} }
.main { .content {
transform: translateX(calc(-1 * var(--sider-width) / 2));
}
.btns-side {
transform: translateX(calc(-1 * var(--sider-width) / 2)); transform: translateX(calc(-1 * var(--sider-width) / 2));
} }
} }
...@@ -163,6 +170,6 @@ ...@@ -163,6 +170,6 @@
overflow: hidden; overflow: hidden;
} }
.btn-action { .btns-action {
margin-top: auto; margin-top: auto;
} }
import { CheckCircleFilled } from "@ant-design/icons"; import { CheckCircleFilled, LogoutOutlined } from "@ant-design/icons";
import { import {
sendHsNotReady, sendHsNotReady,
...@@ -12,7 +12,15 @@ import { ...@@ -12,7 +12,15 @@ import {
import socketMiddleWare, { socketCmd } from "@/middleware/socket"; import socketMiddleWare, { socketCmd } from "@/middleware/socket";
import PlayerState = ygopro.StocHsPlayerChange.State; import PlayerState = ygopro.StocHsPlayerChange.State;
import SelfType = ygopro.StocTypeChange.SelfType; import SelfType = ygopro.StocTypeChange.SelfType;
import { Avatar, Button, ConfigProvider, Popover, Skeleton, Space } from "antd"; import {
Avatar,
Button,
ConfigProvider,
Popover,
Skeleton,
Space,
Tooltip,
} from "antd";
import classNames from "classnames"; import classNames from "classnames";
import { import {
forwardRef, forwardRef,
...@@ -72,11 +80,6 @@ export const Component: React.FC = () => { ...@@ -72,11 +80,6 @@ export const Component: React.FC = () => {
> >
<Background /> <Background />
<div className={styles.sider}> <div className={styles.sider}>
<Button
className={styles["btn-sider"]}
icon={<IconFont type="icon-side-bar-fill" size={16} />}
onClick={() => setCollapsed(!collapsed)}
/>
<Chat /> <Chat />
</div> </div>
<div className={styles.content}> <div className={styles.content}>
...@@ -84,6 +87,22 @@ export const Component: React.FC = () => { ...@@ -84,6 +87,22 @@ export const Component: React.FC = () => {
<LoadingOutlined /> <LoadingOutlined />
对方正在选择先后 对方正在选择先后
</div> */} </div> */}
<div className={styles["btns-side"]}>
<Tooltip title="退出房间" placement="right">
<Button
className={styles["btn"]}
danger
icon={<IconFont type="icon-exit" size={16} />}
/>
</Tooltip>
<Button
className={styles["btn"]}
icon={<IconFont type="icon-side-bar-fill" size={16} />}
onClick={() => setCollapsed(!collapsed)}
/>
</div>
<div className={styles.wrap}>
<Controller <Controller
onDeckChange={(deckName: string) => { onDeckChange={(deckName: string) => {
const deck = deckStore.get(deckName); const deck = deckStore.get(deckName);
...@@ -122,11 +141,12 @@ export const Component: React.FC = () => { ...@@ -122,11 +141,12 @@ export const Component: React.FC = () => {
<PlayerZone who={Who.Op} player={room.getOpPlayer()} /> <PlayerZone who={Who.Op} player={room.getOpPlayer()} />
</div> </div>
<SpecialButton className={styles["btn-action"]}> <SpecialButton className={styles["btns-action"]}>
开始游戏 开始游戏
</SpecialButton> </SpecialButton>
</div> </div>
</div> </div>
</div>
</ConfigProvider> </ConfigProvider>
); );
}; };
...@@ -320,15 +340,15 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({ ...@@ -320,15 +340,15 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({
))} ))}
</Avatar.Group> </Avatar.Group>
</Button> </Button>
<Button {/* <Button
size="large" size="large"
icon={<IconFont type="icon-play" size={12} />} icon={<IconFont type="icon-play" size={12} />}
disabled={!snapRoom.isHost} disabled={!snapRoom.isHost}
onClick={() => sendHsStart()} onClick={() => sendHsStart()}
> >
开始游戏 开始游戏
</Button> </Button> */}
<Button {/* <Button
size="large" size="large"
danger danger
onClick={() => { onClick={() => {
...@@ -339,9 +359,6 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({ ...@@ -339,9 +359,6 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({
}} }}
> >
退出房间 退出房间
</Button>
{/* <Button size="large" icon={<IconFont type="icon-play" size={12} />}>
开始游戏
</Button> */} </Button> */}
</Space> </Space>
); );
......
import { createFromIconfontCN } from "@ant-design/icons"; import { createFromIconfontCN } from "@ant-design/icons";
const _IconFont = createFromIconfontCN({ const _IconFont = createFromIconfontCN({
scriptUrl: ["//at.alicdn.com/t/c/font_4188978_6q59nqrc9ix.js"], scriptUrl: ["//at.alicdn.com/t/c/font_4188978_kvwn9bcpnx.js"],
}); });
export const IconFont: React.FC<{ export const IconFont: React.FC<{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment