feat: one hour of progress

This commit is contained in:
Joshua Seigler 2020-02-18 16:05:59 -05:00
parent 5684ef36ec
commit 9242ce66ec
6 changed files with 88 additions and 47 deletions

19
components/addCard.js Normal file
View file

@ -0,0 +1,19 @@
import React from 'react';
import { useDispatch } from 'react-redux'
import { withRedux } from '../lib/redux';
const addCard = ({ columnIndex }) => {
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>;
}
export default withRedux(addCard);

7
components/card.js Normal file
View file

@ -0,0 +1,7 @@
import React from 'react'
export default ({ children }) => {
return <div className='card'>
I am a card
</div>
}

23
components/column.js Normal file
View file

@ -0,0 +1,23 @@
import React from 'react';
import { useSelector, shallowEqual } from 'react-redux';
import { withRedux } from '../lib/redux';
import Card from './card';
import AddCard from './addCard';
const column = ({ name, index, headerColor }) => {
const cards = useSelector(state => state.columns[index].cards);
return <div className='column'>
<h1 className='card-title' style={{ color: 'white', backgroundColor: headerColor }}>{name}</h1>
{ cards.map((c, cardIndex) => <Card key={`card-${index}-${cardIndex}`} />) }
<AddCard index={index} />
<style jsx>{`
.column {
margin: 12.5px;
}
`}</style>
</div>
}
export default withRedux(column);