Commit ad1a91ea authored by timel's avatar timel Committed by Chunchi Che

feat: card dropdown action:

parent d5a5441b
...@@ -40,12 +40,13 @@ section#mat { ...@@ -40,12 +40,13 @@ section#mat {
} }
} }
.card-shadow { .card-shadow {
// position: absolute; display: none;
// left: 0; position: absolute;
// top: 0; left: 0;
// width: 100%; top: 0;
// height: 100%; width: 100%;
// background-color: #0000005e; height: 100%;
background-color: transparent;
// filter: blur(2px); // filter: blur(2px);
} }
...@@ -97,8 +98,10 @@ section#mat { ...@@ -97,8 +98,10 @@ section#mat {
} }
} }
.mat-card .highlight { .mat-card.highlight .card-shadow {
box-shadow: 0 0 10px 2px #5db7ff; display: block !important;
background: linear-gradient(to right, #0079c6, #009cff) !important;
filter: blur(8px);
} }
@keyframes focus { @keyframes focus {
......
...@@ -22,15 +22,15 @@ import { ...@@ -22,15 +22,15 @@ import {
import type { SpringApiProps } from "./springs/types"; import type { SpringApiProps } from "./springs/types";
import { YgoCard } from "@/ui/Shared"; import { YgoCard } from "@/ui/Shared";
import { showCardModal } from "@/ui/Duel/Message/CardModal"; import { showCardModal, closeCardModal } from "@/ui/Duel/Message/CardModal";
import { Button, Dropdown } from "antd"; import { Button, Dropdown, type MenuProps } from "antd";
import { import {
UploadOutlined, UploadOutlined,
DownloadOutlined, DownloadOutlined,
UpOutlined, UpOutlined,
} from "@ant-design/icons"; } from "@ant-design/icons";
import { fetchStrings, sendSelectIdleCmdResponse, type CardMeta } from "@/api";
const NeosConfig = useConfig(); const NeosConfig = useConfig();
const { HAND, GRAVE, REMOVED, DECK, EXTRA, MZONE, SZONE, TZONE } = const { HAND, GRAVE, REMOVED, DECK, EXTRA, MZONE, SZONE, TZONE } =
...@@ -134,24 +134,58 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -134,24 +134,58 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => {
// <<< 动画 <<< // <<< 动画 <<<
// >>> 效果 >>>
const idleInteractivities = snap.idleInteractivities; const idleInteractivities = snap.idleInteractivities;
useEffect(() => { useEffect(() => {
setHighlight(!!idleInteractivities.length); setHighlight(!!idleInteractivities.length);
}, [idleInteractivities]); }, [idleInteractivities]);
const items = [
{ const interactivies = idleInteractivities.map((interactivity) => ({
key: "1", desc: interactTypeToString(interactivity.interactType),
label: "正面攻表召唤", response: interactivity.response,
}, effectCode: interactivity.activateIndex,
{ }));
key: "2", const EFFECT_ACTIVATION_DESC = "发动效果";
label: "反面守表召唤", const nonEffectInteractivies = interactivies.filter(
}, (item) => item.desc !== EFFECT_ACTIVATION_DESC
{ );
key: "3", const effectInteractivies = interactivies.filter(
label: "效果发动", (item) => item.desc === EFFECT_ACTIVATION_DESC
}, );
]; const menuItems: MenuProps["items"] = nonEffectInteractivies.map(
({ desc }, key) => ({
key,
label: desc,
})
);
if (effectInteractivies.length) {
menuItems.push({
key: menuItems.length,
label: EFFECT_ACTIVATION_DESC,
});
}
const onDropdownClick: MenuProps["onClick"] = ({ key }) => {
const index = Number(key);
if (index >= nonEffectInteractivies.length) {
// 是效果发动
handleEffectActivation();
} else {
// 非效果发动
sendSelectIdleCmdResponse(nonEffectInteractivies[index].response);
}
closeCardModal();
};
const handleEffectActivation = () => {
// 不用考虑为0的情况,因为已经判断了不可能为0
if (effectInteractivies.length === 1) {
// 如果只有一个效果,点击直接触发
sendSelectIdleCmdResponse(effectInteractivies[0].response);
} else {
// optionsModal
}
};
// <<< 效果 <<<
return ( return (
<animated.div <animated.div
className="mat-card" className="mat-card"
...@@ -182,10 +216,10 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -182,10 +216,10 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => {
<div className="card-focus" /> <div className="card-focus" />
<div className="card-shadow" /> <div className="card-shadow" />
<Dropdown <Dropdown
menu={{ items }} menu={{ items: menuItems, onClick: onDropdownClick }}
placement="bottom" placement="bottom"
overlayClassName="card-dropdown" overlayClassName="card-dropdown"
arrow={{ pointAtCenter: true }} arrow
trigger={["click"]} trigger={["click"]}
> >
<div className={classnames("card-img-wrap", { focus: classFocus })}> <div className={classnames("card-img-wrap", { focus: classFocus })}>
......
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