Commit a38b43bd authored by Chunchi Che's avatar Chunchi Che

optimize status ui

parent 70518c92
Pipeline #20758 passed with stages
in 13 minutes and 35 seconds
...@@ -61,6 +61,11 @@ ...@@ -61,6 +61,11 @@
"footer": { "footer": {
"height": 80 "height": 80
} }
},
"status": {
"avatarSize": 40,
"meAvatarColor": "#0e63e1",
"opAvatarColor": "#e10e68"
} }
} }
} }
...@@ -61,6 +61,11 @@ ...@@ -61,6 +61,11 @@
"footer": { "footer": {
"height": 80 "height": 80
} }
},
"status": {
"avatarSize": 40,
"meAvatarColor": "#0e63e1",
"opAvatarColor": "#e10e68"
} }
} }
} }
...@@ -25,24 +25,16 @@ import DuelTimeLine from "./timeLine"; ...@@ -25,24 +25,16 @@ import DuelTimeLine from "./timeLine";
import { Row } from "antd"; import { Row } from "antd";
import SendBox from "./sendBox"; import SendBox from "./sendBox";
import PlayerStatus from "./status"; import PlayerStatus from "./status";
import { useAppSelector } from "../../hook";
import {
selectMeInitInfo,
selectOpInitInfo,
} from "../../reducers/duel/initInfoSlice";
// Ref: https://github.com/brianzinn/react-babylonjs/issues/126 // Ref: https://github.com/brianzinn/react-babylonjs/issues/126
const NeosDuel = () => { const NeosDuel = () => {
const meInfo = useAppSelector(selectMeInitInfo);
const opInfo = useAppSelector(selectOpInitInfo);
return ( return (
<> <>
<NeosLayout <NeosLayout
sider={<NeosSider />} sider={<NeosSider />}
header={<PlayerStatus userName="UserName" hp={opInfo?.life || 0} />} header={<PlayerStatus />}
content={<NeosCanvas />} content={<NeosCanvas />}
footer={<PlayerStatus userName="UserName" hp={meInfo?.life || 0} />} footer={<></>}
/> />
<CardModal /> <CardModal />
<CardListModal /> <CardListModal />
......
import React from "react"; import React from "react";
import { UserOutlined, BackwardOutlined } from "@ant-design/icons"; import { UserOutlined } from "@ant-design/icons";
import { Avatar, Space, Statistic } from "antd"; import { Avatar } from "antd";
import { CheckCard } from "@ant-design/pro-components";
import NeosConfig from "../../../neos.config.json";
import { useAppSelector } from "../../hook";
import {
selectMeInitInfo,
selectOpInitInfo,
} from "../../reducers/duel/initInfoSlice";
const spaceSize = 20; const Config = NeosConfig.ui.status;
const avatarSize = 40; const avatarSize = 40;
const PlayerStatus = (props: { userName: string; hp: number }) => ( const PlayerStatus = () => {
<Space size={spaceSize} direction="horizontal"> const meInfo = useAppSelector(selectMeInitInfo);
<Space wrap size={spaceSize}> const opInfo = useAppSelector(selectOpInitInfo);
<Avatar size={avatarSize} icon={<UserOutlined />} />
</Space> return (
<Space wrap size={spaceSize}> <CheckCard.Group
{props.userName} bordered
</Space> style={{ height: `${NeosConfig.ui.layout.header.height}` }}
<Space wrap size={spaceSize}> >
<Statistic title="Hp" value={props.hp} /> <CheckCard
</Space> avatar={
<Space wrap size={spaceSize}> <Avatar
<Avatar size={avatarSize}
size={avatarSize} style={{ backgroundColor: Config.opAvatarColor }}
style={{ color: "red" }} icon={<UserOutlined />}
icon={<BackwardOutlined />} />
}
title={`opponent`}
description={`Hp: ${opInfo?.life || 0}`}
value="opponent"
style={{
position: "absolute",
left: `${NeosConfig.ui.layout.sider.width}px`,
}}
/>
<CheckCard
avatar={
<Avatar
size={avatarSize}
style={{ backgroundColor: Config.meAvatarColor }}
icon={<UserOutlined />}
/>
}
title={`myself`}
description={`Hp: ${meInfo?.life || 0}`}
value="myself"
style={{
position: "absolute",
right: "0px",
}}
/> />
</Space> </CheckCard.Group>
</Space> );
); };
export default PlayerStatus; export default PlayerStatus;
...@@ -35,6 +35,14 @@ export default function () { ...@@ -35,6 +35,14 @@ export default function () {
</Suspense> </Suspense>
} }
/> />
<Route
path="/test"
element={
<Suspense fallback={<Loading />}>
<NeosDuel />
</Suspense>
}
/>
</Routes> </Routes>
); );
} }
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