Skip to content
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

Updated SinglePost.js #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Updated SinglePost.js #65

wants to merge 1 commit into from

Conversation

Slouis07
Copy link
Collaborator

@Slouis07 Slouis07 commented Feb 2, 2024

updated functionality such as:
+like button increase/decrease and color changed to green
+download post when click on save/download icon
+share feature with copy link
+dropdown for post options such as delete (red color now) , make public, and make private with pop-up alerts for each one
+teaser comments before full post comments and teaser comments are also displayed in full comment view
+can type in a new comment and that update will stay
+comment icon takes you to view all comments
Screen Shot 2024-02-02 at 10 07 52 AM
Screen Shot 2024-02-02 at 10 07 27 AM
Screen Shot 2024-02-02 at 10 06 07 AM

Copy link
Collaborator

@ItsJonasL ItsJonasL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good but likes should not be hardcoded, would it be possible for it to be fetched from else where?

@Slouis07
Copy link
Collaborator Author

Everything looks good but likes should not be hardcoded, would it be possible for it to be fetched from else where?

@Slouis07 Slouis07 closed this Feb 24, 2024
@Slouis07
Copy link
Collaborator Author

Slouis07 commented Feb 24, 2024

Everything looks good but likes should not be hardcoded, would it be possible for it to be fetched from else where?

it seems like the method to do that is to update my code to have it connect to backend? I'm not quite sure how to do that but it shouldn't be too hard, I would just have to know if there is someone in backend that did like count and their file name to link it i guess?

@Slouis07 Slouis07 reopened this Feb 24, 2024
@Slouis07 Slouis07 changed the title Update singlepost.jsx frontend/src/Components/Posts/SinglePost.js Feb 24, 2024
@Slouis07 Slouis07 changed the title frontend/src/Components/Posts/SinglePost.js Updated SinglePost.js Feb 24, 2024
Copy link
Collaborator

@v74c63t v74c63t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same changes as the change requested in the css PR (#64). Put your files inside the Components folder.

And like Jonas mentioned, you should be connecting to the backend to fetch all the post information and comments information instead of using static values.

Also, are you using any of the already created components for this? There should be components for comments and the view all comments popup that can be used included in the components folder.

Lastly, are you sure your styles are being applied correctly? When I was running the React app and calling this, none of the styles were actually getting applied. This is what I see when trying to use it on the example page.
Screenshot 2024-02-23 at 6 37 44 PM

const likeButton = document.querySelector('.like-button');
const shareButton = document.querySelector('.interaction-buttons.share');
const likesCountElement = document.querySelector('.likes-count');
const sharesCountElement = document.querySelector('.shares-count');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work so far! Just a couple of suggestions regarding React best practices.

  1. Same suggestions as everyone else in making sure nothing is hardcoded; Should be pulling the info from the backend (dm in the frontend chat if help is needed, seems like it might get complicated).
  2. It looks like all the functions and icons are wrapped in a huge useEffect. This will lead to a lot of performance issues later on as a useEffect often reloads the component multiple times depending on any change made to any of these buttons. If you wrap these icons in a tag, the button tag has special operator like onClick or onScroll etc. that you can attach the functions to so that they run as intended without the need of wrapping everything in a useEffect. My suggestion would be to wrap those icons in the button tag and move all of this logic outside of the useEffect.

Here's some resources:
https://react.dev/learn/responding-to-events
https://react.dev/reference/react/useEffect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants