Refactor BattleTable and GroupMember components

- Updated the styling and structure of the BattleTable component for better layout and readability.
- Added expandable functionality to the GroupMember component's drawer.
- Adjusted styles and content in BattleTable to improve the visual presentation and functionality.
This commit is contained in:
kyuuseiryuu 2026-03-11 11:26:06 +09:00
parent 56159de837
commit 62e9053c79
2 changed files with 34 additions and 13 deletions

View File

@ -11,7 +11,8 @@ const StyledContainer = styled(Flex)`
color: red; color: red;
position: relative; position: relative;
::after { ::after {
content: '胜'; width: 4px
content: '';
font-size: 0.8em; font-size: 0.8em;
background-color: red; background-color: red;
color: white; color: white;
@ -118,7 +119,7 @@ function BattleTable({
<Card <Card
size="small" size="small"
key={`round-${i}`} key={`round-${i}`}
title={`Round: ${i + 1}`} title={`${i + 1}`}
extra={<Button type="link" onClick={() => handleClear(left, right)} icon={<ClearOutlined />}></Button>} extra={<Button type="link" onClick={() => handleClear(left, right)} icon={<ClearOutlined />}></Button>}
> >
{left?.map((l, i) => { {left?.map((l, i) => {
@ -131,12 +132,29 @@ function BattleTable({
const nameL = l?.uid ? `${l?.name}(${l?.score})${resultL}` : '-'; const nameL = l?.uid ? `${l?.name}(${l?.score})${resultL}` : '-';
const nameR = r?.uid ? `${r?.name}(${r?.score})${resultR}` : '-'; const nameR = r?.uid ? `${r?.name}(${r?.score})${resultR}` : '-';
return ( return (
<div key={key}> <div key={key} style={{ minWidth: 280, width: '80vw', maxWidth: 600 }}>
<Space style={{ textAlign: "center" }}> <Flex align="center" justify="space-between">
<div className={winer === l?.uid ? 'winer' : ''} onClick={() => handleWiner(l!, r!, l!, r!)} style={{ width: 120 }}>{nameL}</div> <div
<span>VS</span> className={winer === l?.uid ? 'winer' : ''}
<div className={winer === r?.uid ? 'winer' : ''} onClick={() => handleWiner(l!, r!, r!, l!)} style={{ width: 120 }}>{nameR}</div> onClick={() => handleWiner(l!, r!, l!, r!)}
</Space> style={{
flex: 5,
textAlign: 'center',
}}
>{nameL}</div>
<div style={{
flex: 1,
textAlign: 'center',
}}>-</div>
<div
className={winer === r?.uid ? 'winer' : ''}
onClick={() => handleWiner(l!, r!, r!, l!)}
style={{
flex: 5,
textAlign: 'center',
}}
>{nameR}</div>
</Flex>
{i < left.length - 1 && <Divider size="small" />} {i < left.length - 1 && <Divider size="small" />}
</div> </div>
); );
@ -157,11 +175,11 @@ function BattleTable({
size="small" size="small"
dataSource={playerList} dataSource={playerList}
rowKey={e => e.uid} rowKey={e => e.uid}
style={{ minWidth: 300 }} style={{ minWidth: 300, width: '80vw', maxWidth: 620 }}
columns={[ columns={[
{ dataIndex: 'name' }, { dataIndex: 'name', align: 'center', },
{ dataIndex: 'score' }, { dataIndex: 'score', align: 'center', },
{ dataIndex: 'uid', render: (uid, { score }) => scoreDiff[uid] || score }, { dataIndex: 'uid', align: 'center', render: (uid, { score }) => scoreDiff[uid] || score },
{ dataIndex: 'uid', align: 'right', render: (uid, { score }) => { { dataIndex: 'uid', align: 'right', render: (uid, { score }) => {
const diff = +(scoreDiff[uid] || score) - +score; const diff = +(scoreDiff[uid] || score) - +score;
return diff > 0 ? `+${diff}` : diff; return diff > 0 ? `+${diff}` : diff;

View File

@ -3,6 +3,7 @@ import { Button, Card, Drawer, Table } from "antd";
import type { BasePlayer } from "../types"; import type { BasePlayer } from "../types";
import User from "./User"; import User from "./User";
import BattleTable from "./BattleTable"; import BattleTable from "./BattleTable";
import { ExpandOutlined } from "@ant-design/icons";
interface Props { interface Props {
index: number; index: number;
@ -19,6 +20,7 @@ export const GroupMember: React.FC<Props> = props => {
return `${code}${String.fromCharCode(lastChar)}`; return `${code}${String.fromCharCode(lastChar)}`;
}, []); }, []);
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [expanded, setExpanded] = useState(false);
return ( return (
<Card <Card
title={`${char}`} title={`${char}`}
@ -43,8 +45,9 @@ export const GroupMember: React.FC<Props> = props => {
open={open} open={open}
title={`${char} 组对战表`} title={`${char} 组对战表`}
onClose={() => setOpen(false)} onClose={() => setOpen(false)}
size={'80vh'} size={expanded ? '100vh' : '80vh'}
placement="bottom" placement="bottom"
extra={<ExpandOutlined onClick={() => setExpanded(!expanded)} />}
> >
<BattleTable players={props.players ?? []} /> <BattleTable players={props.players ?? []} />
</Drawer> </Drawer>