-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[what] implement comment details, restruct provider to enable context…
… api [how] - implement CommentThread, CommentStarter - adopt moment.js to display timestamp - complete remove comment and update comment thread actions - extract canvas component - replace prop drilling with context [reference] According to the following discussion, react-konva <Stage> will influence the Context API: konvajs/react-konva#188 Redux is based on Context API, so it is influenced too konvajs/react-konva#311
- Loading branch information
Showing
11 changed files
with
428 additions
and
77 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import {useContext, useEffect} from 'react'; | ||
import {Layer} from 'react-konva'; | ||
import {CanvasStatusContext} from '../../contexts/CanvasStatusProvider'; | ||
import Picture from '../picture/Picture'; | ||
import Comment from '../comment/Comment'; | ||
import {ID_PREFIX} from '../../constants'; | ||
|
||
const Canvas = ({mode, currentUser, selectID, newComment}) => { | ||
const { | ||
pictures, | ||
comments, | ||
addComment, | ||
} = useContext(CanvasStatusContext); | ||
|
||
useEffect(() => { | ||
if (!newComment) return; | ||
addComment(newComment); | ||
}, [newComment]); | ||
|
||
return ( | ||
<Layer> | ||
{pictures.map((picture) => | ||
<Picture key={picture.id} | ||
mode={mode} | ||
currentUser={currentUser} | ||
isSelecting={picture.id === selectID} | ||
comments={comments.filter((comment) => comment.parentId === picture.id)} | ||
{...picture} | ||
/> | ||
)} | ||
{comments | ||
.filter((comment) => comment.parentId === ID_PREFIX.CANVAS) | ||
.map((comment) => | ||
<Comment | ||
key={comment.id} | ||
comment={comment} | ||
mode={mode} | ||
currentUser={currentUser} | ||
/> | ||
)} | ||
</Layer> | ||
); | ||
} | ||
|
||
export default Canvas; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.