Skip to content

As it's name, this is an interactive comment section that i built for my submission challenge in Frontend Mentor

Notifications You must be signed in to change notification settings

Kurniakun17/Interactive-Comment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frontend Mentor - Interactive comments section solution

This is a solution to the Interactive comments section challenge on Frontend Mentor.

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

Links

  • Solution URL:
  • Live Site URL:

My process

Built with

  • React - JS library
  • TypeScript
  • TailwindCSS

What I learned

From this project, i learned a lot about how does TypeScripts work and it's making me get used to it. But the most important lesson that i learnt is how does a reference type variable works such and built a recursive function to manipulate the origin object.

export function deleteComment(comments: Comment[], id: number) {
  for (let i = 0; i < comments.length; i++) {
    const comment = comments[i];
    if (comment.id === id) {
      comments.splice(i, 1);
      return true;
    }
    if (comment.replies && comment.replies.length > 0) {
      if (deleteComment(comment.replies, id)) {
        return true;
      }
    }
  }
  return false;
}

Continued development

In the future, i would like to improve this project by making a backend for this project using MongoDB, ExpressJS, and NodeJS so it can store the comment that has been published.

Author

About

As it's name, this is an interactive comment section that i built for my submission challenge in Frontend Mentor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published