Commit 15afe93f authored by timel's avatar timel

feat: new select card modal 10%

parent f87c4755
Pipeline #23269 failed with stages
in 11 minutes and 46 seconds
import { Button } from "antd";
import { useSnapshot } from "valtio";
import { CardType, matStore } from "@/stores";
import { Footer, genModal, ReactFcWithOnResult, Title } from "@/ui/Shared";
import { CardMeta, type ygopro } from "@/api";
interface Props {
min: number;
max: number;
single: boolean;
selecteds: Option[]; // 已经选择了的卡
selectables: Option[]; // 最多选择多少卡
mustSelects: Option[]; // 单选
cancelable: boolean; // 能否取消
finishable: boolean; // 选择足够了之后,能否确认
totalLevels: number; // 需要的总等级数(用于同调/仪式/...)
overflow: boolean; // 选择等级时候,是否可以溢出
}
interface Result {
result: Option[];
}
export interface Option {
// card id
meta: CardMeta;
location?: ygopro.CardLocation;
// 效果
effectDesc?: string;
// 作为素材的cost,比如同调召唤的星级
level1?: number;
level2?: number;
response?: number;
// 便于直接返回这个信息
card?: CardType;
}
const Content: ReactFcWithOnResult<Props, Result> = ({
min,
max,
single,
selecteds,
selectables,
mustSelects,
cancelable,
finishable,
totalLevels,
overflow,
onResult,
}) => {
const { hint } = useSnapshot(matStore);
const preHintMsg = hint?.esHint ?? "";
return <></>;
};
const showSelectCardsModal = genModal({ Content });
...@@ -4,7 +4,7 @@ import { MinusOutlined, UpOutlined } from "@ant-design/icons"; ...@@ -4,7 +4,7 @@ import { MinusOutlined, UpOutlined } from "@ant-design/icons";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import classNames from "classnames"; import classNames from "classnames";
import { proxy } from "valtio"; import { proxy } from "valtio";
import { cloneElement, createElement, useState } from "react";
/** 挂到某个节点去,在全局添加这几个静态方法 */ /** 挂到某个节点去,在全局添加这几个静态方法 */
export const ModalContext: React.FC = () => { export const ModalContext: React.FC = () => {
const { message, notification, modal } = App.useApp(); const { message, notification, modal } = App.useApp();
...@@ -44,7 +44,7 @@ export const genModal = <Props extends {}, Result extends {}>({ ...@@ -44,7 +44,7 @@ export const genModal = <Props extends {}, Result extends {}>({
Parameters<ModalFunc>[0], Parameters<ModalFunc>[0],
"content" | "onCancel" | "onOk" | "footer" | "title" "content" | "onCancel" | "onOk" | "footer" | "title"
>) => { >) => {
return (props: Props) => return (props: Props): Promise<Result> =>
new Promise<Result>((rs) => { new Promise<Result>((rs) => {
let isMini = proxy({ value: false }); let isMini = proxy({ value: false });
const getClassNames = () => const getClassNames = () =>
......
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