Skip to content

Commit

Permalink
removed static board data, added zustand persist store
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-Web3 committed Apr 30, 2023
1 parent d0c8f72 commit 078b250
Show file tree
Hide file tree
Showing 7 changed files with 454 additions and 409 deletions.
36 changes: 19 additions & 17 deletions src/components/shared/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,25 @@ const Body: React.FC<{

return (
<motion.main layout className="body">
{!currentBoard.status.every(el => !el.tasks.length) && (
<motion.div layout className="body__boards">
{currentBoard.status
.filter(el => el.tasks.length)
.map(el => (
<Board key={nanoid()} {...el} />
))}
<motion.div
layout
onClick={() =>
setModalType({ modalType: 'new-column', showModal: true })
}
className="body__add-board"
>
<motion.p layout>+ new column</motion.p>
{currentBoard?.status &&
!currentBoard.status.every(el => el.tasks.length === 0) && (
<motion.div layout className="body__boards">
{currentBoard.status
.filter(el => el.tasks.length)
.map(el => (
<Board key={nanoid()} {...el} />
))}
<motion.div
layout
onClick={() =>
setModalType({ modalType: 'new-column', showModal: true })
}
className="body__add-board"
>
<motion.p layout>+ new column</motion.p>
</motion.div>
</motion.div>
</motion.div>
)}
)}
<div className="empty">
<p className="empty__message">
This board is empty. Create a new column to get started.
Expand All @@ -50,6 +51,7 @@ const Body: React.FC<{
onClick={() =>
setModalType({ modalType: 'new-column', showModal: true })
}
disabled={!currentBoard}
>
<img src={plus} alt="add" />
Add New Column
Expand Down
5 changes: 2 additions & 3 deletions src/components/shared/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const Header: React.FC<{
className="header"
>
<motion.div
// layout
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
className="header__sidebar-hidden"
Expand All @@ -60,7 +59,7 @@ const Header: React.FC<{
<p>kanban</p>
</motion.div>
<img className="header__logo" src={logo} alt="logo" />
<p className="header__title">{currentBoard.name}</p>
<p className="header__title">{currentBoard?.name}</p>
<motion.img
onClick={() => setIsNavOpened(prev => !prev)}
variants={variants}
Expand All @@ -73,7 +72,7 @@ const Header: React.FC<{
<Button
onClick={() => setModalType({ modalType: 'add-task', showModal: true })}
className="header__add-task btn--on"
disabled={currentBoard.status.length === 0}
disabled={!Boolean(currentBoard?.status.length)}
>
<img src={add} alt="add board" />
<p>add new task</p>
Expand Down
3 changes: 1 addition & 2 deletions src/components/shared/ModifyBoards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const ModifyBoards: React.FC<{
}> = function ({ title, button, editBoard = false, newColumn = false }) {
const id = useId()

const modalType = useStore(state => state.modalType)
const currentBoard = useStore(state => state.currentBoard)
const theme = useStore(state => state.theme())
const [createBoard, editBoardHandler] = useStore(state => [
Expand Down Expand Up @@ -70,7 +69,7 @@ const ModifyBoards: React.FC<{
animate={{ scaleY: 1, opacity: 1 }}
exit={{ x: '-100%', opacity: 0 }}
layout
key={el[1]}
key={idx}
htmlFor={`subtask${id}${idx}`}
className="columns__input"
>
Expand Down
28 changes: 15 additions & 13 deletions src/components/shared/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,21 @@ const NavBar: React.FC<{
</motion.div>
<p className="navbar__title">All boards({boards.length})</p>
<div className="navbar__boards">
{boards.map((board, idx) => (
<motion.div
variants={boardVariants}
key={idx}
className={`navbar__board ${
board.id === currentBoard.id ? 'active' : ''
}`}
onClick={() => setCurrentBoard(board.id)}
>
<img src={boardIcon} alt="board" />
<p>{board.name}</p>
</motion.div>
))}
{boards.length
? boards.map((board, idx) => (
<motion.div
variants={boardVariants}
key={idx}
className={`navbar__board ${
board.id === currentBoard.id ? 'active' : ''
}`}
onClick={() => setCurrentBoard(board.id)}
>
<img src={boardIcon} alt="board" />
<p title={board.name}>{board.name}</p>
</motion.div>
))
: []}
<div className="navbar__add-board navbar__board">
<img src={boardIconP} alt="board" />
<img src={plusP} alt="add board" />
Expand Down
Loading

0 comments on commit 078b250

Please sign in to comment.