Skip to content

goody-dev/interactive-comment-section

Repository files navigation

Frontend Mentor - Interactive comments section solution

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.

Table of contents

Overview

The challenge

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 the data.json file, try using timestamps and dynamically track the time since the comment or reply was posted.

Screenshot

Webpage Screenshot

Links

My process

Built with

  • 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

What I learned

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;
}

Continued development

I would like to improve my problem solving skills and build more complex components in the future!

Useful resources

  • 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.

Author

Acknowledgments

Thanks to God!

About

A Comment Section Application built with ReactJS and TailwindCSS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published