diff --git a/src/components/AddItem.tsx b/src/components/AddItem.tsx new file mode 100644 index 0000000..2399e7d --- /dev/null +++ b/src/components/AddItem.tsx @@ -0,0 +1,35 @@ +import React, { useState } from "react" +import ItemToDisplay from "../ItemToDisplay" +import Item from "../types/Item" +import Side from "../types/Side" + +interface Props { + side: Side + onChange?: (newItem: Item)=>void +} + +const AddItem: React.FC = ({side,onChange}) => { + const [selected,setSelected] = useState(Item.DEFAULT_PISTOL) + + return ( +
+ + onChange?.(selected)} + className="cursor-pointer" + > + Add + +
+ ) +} + +export default AddItem diff --git a/src/components/Card.tsx b/src/components/Card.tsx index 0190757..58426bd 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -3,6 +3,7 @@ import ItemToDisplay from "../ItemToDisplay" import Card from "../types/Card" import Item from "../types/Item" import Side from "../types/Side" +import AddItem from "./AddItem" import SwitchButton from "./SwitchButton" import TextEdit from "./TextEdit" @@ -31,12 +32,7 @@ const CardComp: React.FC = ({card,side,onChange}) => { }} className="float-right cursor-pointer" >X )} - -
{ - onChange?.(new Card(card.title,card.armor,card.helmet,...card.items,Item.HE)) - }} > - Add -
+ onChange?.(new Card(card.title,card.armor,card.helmet,...card.items,newItem))} /> )