Commit 7b4082b8 authored by Chunchi Che's avatar Chunchi Che

add AnnounceModal

parent b9f6bee4
Pipeline #26757 failed with stages
in 9 minutes and 17 seconds
...@@ -18,6 +18,7 @@ import { ...@@ -18,6 +18,7 @@ import {
SortCardModal, SortCardModal,
YesNoModal, YesNoModal,
} from "./Message"; } from "./Message";
import { AnnounceModal } from "./Message/AnnounceModal";
import { LifeBar, Mat, Menu, Underlying } from "./PlayMat"; import { LifeBar, Mat, Menu, Underlying } from "./PlayMat";
import { ChatBox } from "./PlayMat/ChatBox"; import { ChatBox } from "./PlayMat/ChatBox";
import { HandChain } from "./PlayMat/HandChain"; import { HandChain } from "./PlayMat/HandChain";
...@@ -58,6 +59,7 @@ export const Component: React.FC = () => { ...@@ -58,6 +59,7 @@ export const Component: React.FC = () => {
<CheckCounterModal /> <CheckCounterModal />
<SortCardModal /> <SortCardModal />
<SimpleSelectCardsModal /> <SimpleSelectCardsModal />
<AnnounceModal />
<EndModal /> <EndModal />
<ChatBox /> <ChatBox />
<HandChain /> <HandChain />
......
.container {
display: flex;
flex-direction: column;
.input {
display: flex;
}
.list {
}
}
import { SearchOutlined } from "@ant-design/icons";
import { Avatar, Button, Input, List } from "antd";
import React, { useState } from "react";
import { proxy, useSnapshot } from "valtio";
import { CardMeta, sendSelectOptionResponse } from "@/api";
import { getCardImgUrl } from "@/ui/Shared";
import { NeosModal } from "../NeosModal";
import styles from "./index.module.scss";
interface Props {
isOpen: boolean;
opcodes: number[];
}
const defaultProps = {
isOpen: false,
opcodes: [],
};
const store = proxy<Props>(defaultProps);
export const AnnounceModal: React.FC = () => {
const { isOpen } = useSnapshot(store);
const [searchWord, setSearchWord] = useState("");
const [cardList, setCardList] = useState<CardMeta[]>([]);
const [selected, setSelected] = useState<number | undefined>(undefined);
const handleSearch = () => {};
const onSummit = () => {
if (selected !== undefined) {
sendSelectOptionResponse(selected);
rs();
setSearchWord("");
setCardList([]);
}
};
return (
<NeosModal
title="请输入关键字并选择宣言的卡"
open={isOpen}
footer={
<Button disabled={selected === undefined} onClick={onSummit}>
确定
</Button>
}
>
<div className={styles.container}>
<Input
className={styles.input}
placeholder="请输入宣言卡名(或关键字)"
bordered={false}
value={searchWord}
onChange={(e) => setSearchWord(e.target.value)}
suffix={
<Button
type="text"
icon={<SearchOutlined />}
onClick={() => handleSearch()}
/>
}
onKeyUp={(e) => e.key === "Enter" && handleSearch()}
allowClear
/>
<List
pagination={{ position: "bottom", align: "center" }}
dataSource={cardList}
renderItem={(item, index) => (
<List.Item key={index}>
<List.Item.Meta
avatar={<Avatar src={getCardImgUrl(item.id)} />}
title={<a>{item.text.name}</a>}
description={item.text.desc}
/>
</List.Item>
)}
/>
</div>
</NeosModal>
);
};
let rs: (v?: any) => void = () => {};
...@@ -53,6 +53,7 @@ export const YgoCard: React.FC<Props> = (props) => { ...@@ -53,6 +53,7 @@ export const YgoCard: React.FC<Props> = (props) => {
const NeosConfig = useConfig(); const NeosConfig = useConfig();
// TODO: 这个函数应该从这个文件抽离出来作为公共的函数使用
export function getCardImgUrl(code: number, back = false) { export function getCardImgUrl(code: number, back = false) {
const ASSETS_BASE = const ASSETS_BASE =
import.meta.env.BASE_URL === "/" import.meta.env.BASE_URL === "/"
......
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