This is a solution to the Interactive comments section challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
- View the optimal layout for the app depending on their device's screen size
- See hover states for all interactive elements on the page
- Create, Read, Update, and Delete comments and replies
- Upvote and downvote comments
- Bonus: If you're building a purely front-end project, use
localStorage
to save the current state in the browser that persists when the browser is refreshed. - Bonus: Instead of using the
createdAt
strings from thedata.json
file, try using timestamps and dynamically track the time since the comment or reply was posted.
- Solution URL: Project Repo
- Live Site URL: Web Page
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- localStorage - to save states in the browser
- Mobile-first workflow
- immerjs - A tiny package that allows you to work with immutable state in a more convenient way
- React Timestamp - A React Component for displaying a datetime in local timezone
- React - JS library
- TailwindCSS - CSS framework
I gained experience working with react's useReducer hook and immer.js combined I also learnt how to use the react-timestamp component.
const findComment = (comments, commentId, nestKey) => {
for(const key in comments) {
const comment = comments[key];
if(comment.id === commentId) {
return comment;
}
if(comment[nestKey] && comment[nestKey].length !== 0) {
const foundReply = findComment(comment[nestKey], commentId, nestKey);
if(foundReply) {
return foundReply;
}
}
}
return null;
}
I would like to improve my problem solving skills and build more complex components in the future!
- React Documentation - I worked with the react documentation while building, it helped better my understanding of some concepts.
- Tailwind Documentation - I used it in learning styling based on variables or conditional tailwind styling, if you will.
- Website - Goodness Okanlawon
- Frontend Mentor - @CodeEvolver
- Twitter - @goody_dev
Thanks to God!