Skip to content

Instantly share code, notes, and snippets.

@nickredmark
Last active November 16, 2019 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickredmark/81cd9bfc35752a1c8422c48e646b43a0 to your computer and use it in GitHub Desktop.
Save nickredmark/81cd9bfc35752a1c8422c48e646b43a0 to your computer and use it in GitHub Desktop.
Card.ts
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