npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

emirkucukosman-feedbacky

v1.0.6

Published

Feedbacky is a fully customizable, lightweight (37 kB) Modal component which enables customers to give feedback about your e-commerce website.

Downloads

11

Readme

Feedbacky

Feedbacky is a fully customizable, lightweight (37 kB) Modal component which enables customers to give feedback about your e-commerce website.

Feedbacky is built using React & TypeScript and it has only one dependency which is clsx library

How it works?

Customers writes their feedback into a text box, clicks submit and that's it! By default feedbacks are saved into a Google Sheet via SheetDB API. But this default behaviour can be changed via providing a custom onSubmit prop to the Modal. See more below.

How to use?

First install the package by running:

npm install emirkucukosman-feedbacky

There are two ways to manage the modal:

  1. Managing the Modal state by-yourself and rendering conditionally
import { useState } from "react";
import { Modal } from "emirkucukosman-feedbacky";

const App = () => {
  const [isOpen, setIsOpen] = useState(false);

  const handleOpen = () => {
    setIsOpen(true);
  };

  const handleClose = () => {
    setIsOpen(false);
  };

  return (
    <div>
      <Modal.Trigger onClick={handleOpen} />
      {isOpen && <Modal onClose={handleClose} {...otherProps} />}
    </div>
  );
};
  1. Using the ModalProvider and useModalContext hook
import {
  Modal,
  ModalProvider,
  useModalContext,
} from "emirkucukosman-feedbacky";

const Example = () => {
  const { openModal } = useModalContext();

  const handleOpen = () => {
    openModal({
      header: {
        title: "Modal Title",
      },
      ...otherProps,
    });
  };

  return (
    <div>
      <Modal.Trigger onClick={handleOpen}>Open Modal</Modal.Trigger>
    </div>
  );
};

const App = () => {
  return (
    <ModalProvider>
      <Example />
    </ModalProvider>
  );
};

Customization

Modal component has 4 sub-components as it's children which are Header, Body, Footer and Success. By default these components are used if you don't provide any custom children. If any children is provided inside Modal component than only those elements will be rendered

import { Modal } from "emirkucukosman-feedbacky";

<Modal />
// so this is actually rendered as:
<Modal>
  <Modal.Header />
  <Modal.Body />
  <Modal.Footer />
  <Modal.Success />
</Modal>
// note that Modal.Success is only rendered when submit is successful or showSuccess prop is true

Each of this child components can also be customizable by props like:

import { Modal } from "emirkucukosman-feedbacky";

<Modal
  header={{ title: 'Modal Title' }}
  body={{
    textAreaPlaceholder: 'Feedback placeholder...'
  }}
  ...otherProps
/>

It is also possible to both use the default components and your custom components ones like:

import { Modal } from "emirkucukosman-feedbacky";

<Modal>
  <Modal.Header />
  <Modal.Body />
  <Modal.Footer>
    <CustomFooter />
  </Modal.Footer>
  <Modal.Success />
</Modal>;

Props List

Modal Props

| Property | Description | Types | Required | | --------------------- | --------------------------------------------------------------------- | ------------ | -------- | | overlayClassName | classes to apply to overlay element | string | optional | | modalClassName | classes to apply to modal element | string | optional | | modalContentClassName | classes to apply to modal content element | string | optional | | formClassName | classes to apply to form element | string | optional | | header | header props | HeaderProps | optional | | body | body props | BodyProps | optional | | footer | footer props | FooterProps | optional | | success | success props | SuccessProps | optional | | children | children to render inside modal | ReactNode | optional | | sheetDbApiUrl | SheetDB API URL to save the feedback response | string | optional | | showSuccess | shows or hides the Modal.Success component | boolean | optional | | onSubmit | custom onSubmit function which will get called when submit is clicked | function | optional | | onClose | function which will be called when modal is closed | function | required |

Modal.Trigger Props

| Property | Description | Types | Required | | ------------------------- | ----------------------------------------------------- | --------- | -------- | | triggerContainerClassName | classes to apply to trigger container element | string | optional | | triggerButtonClassName | classes to apply to trigger button element | string | optional | | children | children to render inside trigger | ReactNode | optional | | onClick | function which will be called when trigger is clicked | function | optional |

Modal.Header Props

| Property | Description | Types | Required | | ----------------------- | --------------------------------------------------- | --------- | -------- | | title | title to be display on the modal | string | optional | | headerClassName | classes to apply to header element | string | optional | | titleClassName | classes to apply to title element | string | optional | | closeButtonRowClassName | classes to apply to close button row element | string | optional | | closeButtonClassName | classes to apply to close button element | string | optional | | children | children to render inside header | ReactNode | optional | | onClose | function which will be called when close is clicked | function | optional |

Modal.Body Props

| Property | Description | Types | Required | | -------------------- | ------------------------------------------------------ | --------- | -------- | | description | description to be display on the modal | string | optional | | bodyClassName | classes to apply to body element | string | optional | | descriptionClassName | classes to apply to description element | string | optional | | textAreaClassName | classes to apply to text area element | string | optional | | textAreaPlaceholder | placeholder to show on text area | string | optional | | textAreaRows | row count for text area | number | optional | | feedbackValue | string value for the feedback text area element | string | optional | | children | children to render inside body | ReactNode | optional | | onFeedbackChange | function which will be called when feedback is changed | function | optional |

Modal.Footer Props

| Property | Description | Types | Required | | --------------------- | ---------------------------------------------------- | --------- | -------- | | submitLabel | text to display inside submit button | string | optional | | submittingLabel | text to display inside submit button when submitting | string | optional | | isSubmitting | submit status of the button | boolean | optional | | submitButtonClassName | classes to apply to submit button element | string | optional | | footerClassName | classes to apply to footrr element | string | optional | | children | children to render inside footer | ReactNode | optional |

Modal.Success Props

| Property | Description | Types | Required | | ---------------- | ----------------------------------- | --------- | -------- | | message | text to display for success message | string | optional | | messageClassName | classes to apply to message element | string | optional | | children | children to render inside success | ReactNode | optional |