Commit 535b3e8b authored by Chunchi Che's avatar Chunchi Che

add CardListModal component

parent 6a1f6c80
import React from "react";
import { useAppSelector } from "../../hook";
import { store } from "../../store";
import {
selectCardListModalIsOpen,
selectCardListModalInfo,
} from "../../reducers/duel/modalSlice";
import { setCardListModalIsOpen } from "../../reducers/duel/mod";
import { Modal, List, Popover, Card } from "antd";
const { Meta } = Card;
const CARD_WIDTH = 100;
const CardListModal = () => {
const dispatch = store.dispatch;
const isOpen = useAppSelector(selectCardListModalIsOpen);
const list = useAppSelector(selectCardListModalInfo);
const handleOkOrCancel = () => {
dispatch(setCardListModalIsOpen(false));
};
return (
<Modal open={isOpen} onOk={handleOkOrCancel} onCancel={handleOkOrCancel}>
<List
itemLayout="horizontal"
dataSource={list}
renderItem={(item) => (
<Popover
content={
<Card
hoverable
style={{ width: CARD_WIDTH }}
cover={<img alt={item.name} src={item.imgUrl} />}
>
<Meta title={item.name} />
<p>{item.desc}</p>
</Card>
}
>
<List.Item>
<List.Item.Meta title={item.name} description={item.desc} />
</List.Item>
</Popover>
)}
></List>
</Modal>
);
};
export default CardListModal;
...@@ -31,32 +31,30 @@ const CardModal = () => { ...@@ -31,32 +31,30 @@ const CardModal = () => {
}; };
return ( return (
<> <Modal open={isOpen} onOk={handleOkOrCancel} onCancel={handleOkOrCancel}>
<Modal open={isOpen} onOk={handleOkOrCancel} onCancel={handleOkOrCancel}> <Card
<Card hoverable
hoverable style={{ width: CARD_WIDTH }}
style={{ width: CARD_WIDTH }} cover={<img alt={name} src={imgUrl} />}
cover={<img alt={name} src={imgUrl} />} >
> <Meta title={name} />
<Meta title={name} /> <p>{desc}</p>
<p>{desc}</p> </Card>
</Card> {interactivies.map((interactive, idx) => {
{interactivies.map((interactive, idx) => { return (
return ( <Button
<Button key={idx}
key={idx} onClick={() => {
onClick={() => { sendSelectIdleCmdResponse(interactive.response);
sendSelectIdleCmdResponse(interactive.response); dispatch(setCardModalIsOpen(false));
dispatch(setCardModalIsOpen(false)); dispatch(clearHandsInteractivity(0));
dispatch(clearHandsInteractivity(0)); }}
}} >
> {interactive.desc}
{interactive.desc} </Button>
</Button> );
); })}
})} </Modal>
</Modal>
</>
); );
}; };
......
...@@ -12,6 +12,7 @@ import Field from "./field"; ...@@ -12,6 +12,7 @@ import Field from "./field";
import Deck from "./deck"; import Deck from "./deck";
import Exclusion from "./exclusion"; import Exclusion from "./exclusion";
import Cemeteries from "./cemetery"; import Cemeteries from "./cemetery";
import CardListModal from "./cardListModal";
// Ref: https://github.com/brianzinn/react-babylonjs/issues/126 // Ref: https://github.com/brianzinn/react-babylonjs/issues/126
const NeosDuel = () => ( const NeosDuel = () => (
...@@ -37,6 +38,7 @@ const NeosDuel = () => ( ...@@ -37,6 +38,7 @@ const NeosDuel = () => (
)} )}
</ReactReduxContext.Consumer> </ReactReduxContext.Consumer>
<CardModal /> <CardModal />
<CardListModal />
<HintNotification /> <HintNotification />
</> </>
); );
......
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