triplebyte-react-spa/components/addCard.js
2020-02-19 02:00:21 -05:00

38 lines
824 B
JavaScript

import React from 'react';
import { useDispatch } from 'react-redux'
import { withRedux } from 'lib/redux';
const addCard = ({ column }) => {
const dispatch = useDispatch();
return <>
<a className='addCard' onClick={
() => {
const userText = window.prompt('New card text:', '');
if (userText !== null) {
dispatch({ type: 'ADD_CARD', payload: {
column,
text: userText
}});
}
}
}><span>+</span> Add a card</a>
<style jsx>{`
.addCard {
margin-top: 12px;
cursor: pointer;
opacity: 0.4;
display: block;
padding: 0 8px;
}
.addCard:hover {
opacity: 1;
}
span {
font-size: 1.5em;
}
`}</style>
</>;
}
export default withRedux(addCard);