-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Edit and Reply UI to DiscussionsCard #2375
Conversation
@HS-90 is attempting to deploy a commit to the c0d3-prod Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## master #2375 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 184 184
Lines 3270 3294 +24
Branches 861 868 +7
=========================================
+ Hits 3270 3294 +24
|
<CommentIcon /> Reply | ||
</div> | ||
<div className={styles.edit_delete}> | ||
<div onClick={editClick} data-testid="pencil"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to use a button instead of a div for clickable elements.
<div> | ||
<img src={userPic} className={styles.user_pic} /> | ||
<span className={styles.username}>{username}</span> | ||
<span> </span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this span for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used it to add a little space between elements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are adding span for the effect setting a specific amount of space between elements, then you need to do that with CSS instead instead of using span elements with whitespace values. It's more appropriate to do it with CSS since CSS is meant to be used for styling. Using CSS will make the styling choice more explicit as well, thus making the code more simple and understandable. From my side, I was confused about what this span was being used for because it wasn't very clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i ended up getting rid of it in my local, and didn't notice any difference visually actually. So it's removed now.
} | ||
> | ||
<div> | ||
<img src={userPic} className={styles.user_pic} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to add alt=""
here. (https://davidwalsh.name/accessibility-tip-empty-alt-attributes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use the <Image>
component by next.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use the
<Image>
component by next.js
When I use the Image component from next, for some reason it did not incorporate any of the styling, so I kept it as <img>
for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use the
<Image>
component by next.jsWhen I use the Image component from next, for some reason it did not incorporate any of the styling, so I kept it as
<img>
for now.
Does these help?
content: string | ||
likes?: number | ||
dislikes?: number | ||
replies?: Array<DiscussionReply> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the likes, dislikes, and replies optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided we aren't implementing likes in this version, but i just kept it in there as optional for now in case we change our minds or decide to put them in our backend data.
For replies, not every post will have replies, so I thought optional was the better way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a good idea to add these like/dislike
props now.
-
This PR is about adding edit/reply, not about adding likes/dislikes -- adding likes/dislikes seems specific
enough of a task that it should be its own PR. Being more organized with PRs will also make it easier for issue triaging when needed. -
I also have concerns about not fully completing the
likes/dislikes
feature in this component because I don't see a fleshed out plan or POC for the feature. Since its not completed in this PR(and shouldn't) and there's no fleshed out plan or POC, it makes me concerned that these props won't even be used -- when fully implementing thelikes/dislikes
feature, it could be decided that the like/dislike props should instead be replaced with prop X, which would mean the like/dislike props are potential tech debt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, why is the replies
prop added? It doesn't seem to be used yet either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please first finalize on the design and architecture of how to display replies to replies
(discussion replies) before adding all this code related to it. If this architecture isn't finalized, then it doesn't make sense to add all this logic relating to it because it'll just be potential tech debt
margin-right: 5px; | ||
font-size: 14px; | ||
border: 0px; | ||
padding: 5px 6px 5px 6px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A shorthand for this is padding: 5px 6px
border: 0px; | ||
padding: 5px 6px 5px 6px; | ||
background-color: transparent; | ||
&:hover, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nice to have a transition.
transition: background-color 0.3s ease
|
||
await userEvent.click(getByTestId('pencil')) | ||
|
||
waitFor(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you would need waitFor
if you used findBy*
instead of getBy*
.
</div> | ||
</div> | ||
{replyMode ? replyBox : <></>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can simplify this to {replyMode && replyBox}
)} | ||
|
||
<div className={styles.card_buttons}> | ||
{editMode ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{editMode && (
<div className={styles.card_content}>{content}</div> | ||
)} | ||
|
||
<div className={styles.card_buttons}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this div do anything if editMode is false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it doesnt do anything, we can simplify logic by removing an instance of checking for editMode
{editMode ? editBox : (
<>
<div className={styles.card_content}>{content}</div>
<div className={styles.card_buttons}>...</div>
</>
)}
const [replyMode, setReplyMode] = useState(false) | ||
const [editMode, setEditMode] = useState(false) | ||
const [replyText, setReplyText] = useState('') | ||
const [editText, setEditText] = useState('') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats the difference between replyText and editText? Why are both kinds of states needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we focus this PR on just implementing either the |
So should I prioritize some of the backend things first? That would be required for the save and reply feature to work as intended in production. Or should I create dummy objects for now to just save things on the frontend so we at least know what they look like once a user clicks 'save'(edit) or 'send'(replies). |
Working on back-end or front-end first is fine, at work it happens in parallel sometimes -- just be sure there is coordination between front-end changes and back-end changes. Frontend and backend should be following the same e2e architecture. Also, is there some design doc or POC in place? If there is none, then I have concerns that you are breaking up this feature of editing&saving into multiple PRs without a finalized architecture in place. If the architecture isn't finalized, then all the code in your PR is just going to be potential tech debt since everything will be subject to change. |
There is none right now. I can get one started though so we can get a better idea of the architecture. |
If the feature isn't complex enough you don't have to make a design doc, but just make sure you're organized in your PRs. Instead of implementing a bit of both |
After reading some of your comments, I think it would be a good idea to create a design doc for this project. I think having one will provide a better sense of direction for myself and the team while working on this. |
Here is an initial draft of the design doc. Welcome to any comments or suggestions for improvement! |
Closing due to inactivity. |
Description: relates to #2252
This PR adds the Edit and Reply UI for the DiscussionsCard. Please see screenshots below:
User clicks edit:
User clicks reply:
User clicks both reply and edit:
Test component here: https://deploy-preview-2375--youthful-thompson-448332.netlify.app/?path=/story/components-discussionscard--discussions-card-main