Last active
November 16, 2019 22:10
-
-
Save nickredmark/81cd9bfc35752a1c8422c48e646b43a0 to your computer and use it in GitHub Desktop.
Card.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Card = ({ getId, index, id, data, onSetTitle }) => { | |
const card = data[id]; | |
const [editing, setEditing] = useState(); | |
const [cardTitle, setCardTitle] = useState(card.title); | |
return ( | |
<div className="card"> | |
{editing ? ( | |
<form | |
onSubmit={e => { | |
e.preventDefault(); | |
onSetTitle(id, cardTitle); | |
setEditing(false); | |
}} | |
> | |
<input | |
autoFocus | |
value={cardTitle} | |
onChange={e => setCardTitle(e.target.value)} | |
placeholder="card title" | |
/> | |
</form> | |
) : ( | |
<div | |
onDoubleClick={e => { | |
setCardTitle(card.title); | |
setEditing(true); | |
}} | |
className="card-title" | |
> | |
{card.title || "No title"}{" "} | |
<a href={`/?board=${id}`} target="_blank" className="card-link"> | |
# | |
</a> | |
</div> | |
)} | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment