feat: sync redux to localstorage

This commit is contained in:
Joshua Seigler 2020-02-19 02:00:21 -05:00
parent 9242ce66ec
commit ff4a941dd8
10 changed files with 230 additions and 149 deletions

View file

@ -1,19 +1,38 @@
import React from 'react';
import { useDispatch } from 'react-redux'
import { withRedux } from '../lib/redux';
import { withRedux } from 'lib/redux';
const addCard = ({ columnIndex }) => {
const addCard = ({ column }) => {
const dispatch = useDispatch();
return <a onClick={
() => {
const userText = window.prompt('New card text:', '(no text)');
dispatch({ type: 'ADD_CARD', payload: {
column: columnIndex,
text: userText
} });
}
}>+ Add a card</a>;
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);