Commit 679c2d85 authored by timel's avatar timel

feat: small

parent bfe20ce5
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -11,3 +11,7 @@ ...@@ -11,3 +11,7 @@
border-radius: 6px; border-radius: 6px;
overflow: hidden; overflow: hidden;
} }
:global(.ant-dropdown-menu-item) {
gap: 8px;
}
...@@ -2,8 +2,8 @@ import { ...@@ -2,8 +2,8 @@ import {
ArrowRightOutlined, ArrowRightOutlined,
CheckOutlined, CheckOutlined,
CloseCircleFilled, CloseCircleFilled,
createFromIconfontCN,
MessageFilled, MessageFilled,
SettingOutlined,
StepForwardFilled, StepForwardFilled,
} from "@ant-design/icons"; } from "@ant-design/icons";
import { import {
...@@ -25,11 +25,15 @@ import { ...@@ -25,11 +25,15 @@ import {
sendSurrender, sendSurrender,
ygopro, ygopro,
} from "@/api"; } from "@/api";
import { cardStore, matStore } from "@/stores"; import { cardStore, ChainSetting, matStore } from "@/stores";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import PhaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType; import PhaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType;
const IconFont = createFromIconfontCN({
scriptUrl: ["//at.alicdn.com/t/c/font_4188978_z6f9ellbtoc.js"],
});
const { phase } = matStore; const { phase } = matStore;
const { useToken } = theme; const { useToken } = theme;
export const Menu = () => { export const Menu = () => {
...@@ -38,8 +42,7 @@ export const Menu = () => { ...@@ -38,8 +42,7 @@ export const Menu = () => {
const enableBp = snapPhase.enableBp; const enableBp = snapPhase.enableBp;
const enableM2 = snapPhase.enableM2; const enableM2 = snapPhase.enableM2;
const enableEp = snapPhase.enableEp; const enableEp = snapPhase.enableEp;
const { currentPlayer } = useSnapshot(matStore); const { currentPlayer, chainSetting } = useSnapshot(matStore);
const { chainSetting } = useSnapshot(matStore);
const clearAllIdleInteractivities = () => { const clearAllIdleInteractivities = () => {
for (const card of cardStore.inner) { for (const card of cardStore.inner) {
...@@ -110,15 +113,21 @@ export const Menu = () => { ...@@ -110,15 +113,21 @@ export const Menu = () => {
danger: phase === PhaseType.END, danger: phase === PhaseType.END,
})); }));
const chainSettingTexts = ["全部连锁", "忽略连锁", "智能连锁"]; const chainSettingTexts = [
const chainSettingItems: MenuProps["items"] = chainSettingTexts [ChainSetting.CHAIN_ALL, "全部连锁"],
.map((text, i) => ({ [ChainSetting.CHAIN_IGNORE, "忽略连锁"],
[ChainSetting.CHAIN_SMART, "智能连锁"],
] as const;
const chainSettingItems: MenuProps["items"] = chainSettingTexts.map(
([key, text]) => ({
label: text, label: text,
icon: <ChainIcon chainSetting={key} />,
key,
onClick: () => { onClick: () => {
matStore.chainSetting = i; matStore.chainSetting = key;
}, },
})) })
.map((item, i) => ({ key: i, ...item })); );
const surrenderMenuItems: MenuProps["items"] = [ const surrenderMenuItems: MenuProps["items"] = [
{ {
...@@ -148,14 +157,14 @@ export const Menu = () => { ...@@ -148,14 +157,14 @@ export const Menu = () => {
</Button> </Button>
</DropdownWithTitle> </DropdownWithTitle>
<DropdownWithTitle <DropdownWithTitle
title={chainSettingTexts[chainSetting]}
menu={{ menu={{
items: chainSettingItems, items: chainSettingItems,
selectable: true,
defaultSelectedKeys: ["3"],
}} }}
> >
<Button icon={<SettingOutlined />} type="text"></Button> <Button
icon={<ChainIcon chainSetting={chainSetting} />}
type="text"
></Button>
</DropdownWithTitle> </DropdownWithTitle>
<Tooltip title="聊天室"> <Tooltip title="聊天室">
<Button icon={<MessageFilled />} type="text"></Button> <Button icon={<MessageFilled />} type="text"></Button>
...@@ -170,7 +179,7 @@ export const Menu = () => { ...@@ -170,7 +179,7 @@ export const Menu = () => {
); );
}; };
const DropdownWithTitle: React.FC<DropdownProps & { title: string }> = ( const DropdownWithTitle: React.FC<DropdownProps & { title?: string }> = (
props props
) => { ) => {
const { token } = useToken(); const { token } = useToken();
...@@ -187,17 +196,37 @@ const DropdownWithTitle: React.FC<DropdownProps & { title: string }> = ( ...@@ -187,17 +196,37 @@ const DropdownWithTitle: React.FC<DropdownProps & { title: string }> = (
{...props} {...props}
dropdownRender={(menu) => ( dropdownRender={(menu) => (
<div style={contentStyle}> <div style={contentStyle}>
<Space style={{ padding: "12px 16px" }}>{props.title}</Space> {props.title && (
<Divider style={{ margin: 0 }} /> <>
<Space style={{ padding: "12px 16px", fontSize: 12 }}>
{props.title}
</Space>
<Divider style={{ margin: 0 }} />
</>
)}
{cloneElement(menu as React.ReactElement, { {cloneElement(menu as React.ReactElement, {
style: menuStyle, style: menuStyle,
})} })}
</div> </div>
)} )}
arrow arrow
trigger={["click", "hover"]} trigger={["click"]}
> >
{props.children} {props.children}
</Dropdown> </Dropdown>
); );
}; };
const ChainIcon: React.FC<{ chainSetting: ChainSetting }> = ({
chainSetting,
}) => {
switch (chainSetting) {
case ChainSetting.CHAIN_ALL:
return <IconFont type="icon-chain-all" />;
case ChainSetting.CHAIN_SMART:
return <IconFont type="icon-chain" />;
case ChainSetting.CHAIN_IGNORE:
default:
return <IconFont type="icon-chain-broken" />;
}
};
body { body {
background: #0f131e; background: #0f131e;
text-align: center;
position: relative; position: relative;
margin: 0; margin: 0;
padding: 0; padding: 0;
...@@ -13,6 +12,7 @@ body * { ...@@ -13,6 +12,7 @@ body * {
.wrapper { .wrapper {
position: relative; position: relative;
text-align: center;
} }
.wrapper > * { .wrapper > * {
......
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