1.1.4 • Published 5 months ago

comments-react v1.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Comments-React Module (using Firebase)

Comments module Comments module

Effortlessly add a robust comment system to your blog or website! 🚀
The Comments-React Module is a lightweight, feature-packed library built with modern tools like React, TypeScript, and Tailwind CSS.
Designed for flexibility and ease of use, it offers a seamless way to manage comments while maintaining control over customization and moderation.

Démonstration GIF


✨ Features

  • Firebase Integration: All comments are stored securely in Firebase, ensuring scalability and reliability.
  • Full CRUD Support: Add, edit, or delete your comment with ease.
  • Smart Moderation: Built-in profanity filtering using the powerful leo-profanity module.
  • Customizable:
    • Support for changing languages and text.
    • Change color for button, text(and svg) and background !
    • Adjustable character limits to suit your needs.
    • Prevent spamming with anti-multi-post protection.
  • Modern Tech Stack: Built with React, TypeScript, and styled using Tailwind CSS for a clean and responsive UI.

🚀 Quick Start

Installation

Install the package via npm or yarn:

npm install comments-react

Firebase config

this module use firebase config so you have to create an account.(it's free, choose Firestore Database)

const firebaseConfig = {
    apiKey: process.env.NEXT_PUBLIC_FIREBASE_APIKEY,
    authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTHDOMAIN,
    projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECTID,
    storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGEBUCKET,
    messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGINGSENDERID,
    appId: process.env.NEXT_PUBLIC_FIREBASE_APPID,
    measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENTID
  };

1. Add Google Authentication

Google Auth

2. Create collection named "comments" (empty, this module will hydrate it)

Create collection

3. Protect with rules

Rules

Exemple of your component

"use client";

import { Comments } from "comments-react";

const Comment = ({ pageUid, lang }: { pageUid: string, lang: string }) => {
  const firebaseConfig = {
    apiKey: process.env.NEXT_PUBLIC_FIREBASE_APIKEY,
    authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTHDOMAIN,
    projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECTID,
    storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGEBUCKET,
    messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGINGSENDERID,
    appId: process.env.NEXT_PUBLIC_FIREBASE_APPID,
    measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENTID
  };

  return <Comments firebaseConfig={firebaseConfig} pageUid={pageUid} />;
};

export default Comment;

Props

Settings

PropertyTypesDefault
firebaseConfigobjectfirebaseConfig
pageUidstringpageUid
profanityLanguagestring"en" (only "en", "fr", "ru")
preventMultiPostsbooleantrue (the user have to wait other comment to post again)
maxCharsnumber1000
langstringlang (date only)

Style

PropertyTypesDefault
backgroundColorstring"#FFFFFF"
textColorstring"#10172A" (surcharge svg color too)
buttonColorstring"#232d47"
buttonHoverColorstring"#10172A"
fontPrimstring""(override tailwind font)
fontSecstring"" (override tailwind font)

Texts

texts={{
    placeholder=""
    btnAdd=""
    ....
}}
PropertyTypesDefault
placeholderstring"Your comment"
btnAddstring"Add a comment"
btnEditstring"Edit"
btnCancelstring"Cancel"
errorCharacstring"Please do not exceed 1000 characters"
errorAddstring"You need to wait for another user to add a comment"
errorUrlAndMailstring"Please do not include URLs or email addresses"
characLeftstring"Characters left"
dateAtstring"at"
dateThestring"on"
dateEditstring"Edited on"
dateThestring"on"
btnModalConfirmstring"Confirm"
titleModalDeletestring"Delete this comment"
connexionTitlestring"Log in to add a comment"
connexionButtonstring"Log in with Google"

Contact

If you have any question feel free to contact me on my website 😉 www.meetguillaume.dev

1.1.4

5 months ago

1.1.3

5 months ago

1.1.2

5 months ago

1.1.1

5 months ago

1.1.0

5 months ago

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago