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

@lokkotara/custom-modal

v1.1.14

Published

A simple, generic, and customizable modal component for React

Downloads

30

Readme

Important information about this package

This package is meant to be used for educational purpose. It is not intended to be maintained and could be deleted in the future.

About this package

It's a simple, lightweight, and customizable modal component for React. It is built using Storybook and fortawesome as dependencies.

-> Storybook allows us to isolate the package from the business logic and context of our application.

-> Fortawesome is a package developed by Font Awesome and provides an easy way to use icons in our component.

Installation

To install this package, type

 npm install @lokkotara/custom-modal

Usage

First, import the component with

import { Modal } from "@lokkotara/custom-modal";

Then, you can use it like this :

import React,{ useState } from "react";
import { Modal } from "@lokkotara/custom-modal";

const SomeComponent = () => {

  const [isModal, setIsModal] = useState(false);

  const customModalBody = (
    <span>An interesting text</span>
  );

  return (
    <div>
      <Modal
        closeButton={false} // Display the close button
        closeButtonStyle={{color: purple}} // Style for the close button
        icon="success" // The icon to display
        iconStyle={{color: purple}} // Style for the icon
        isOpen={isModal} // Whether the modal is open or closed
        message={customModalBody} //The content inside the body of the modal
        messageStyle={{fontSize: 1.2rem}} //Style applied to the message
        modalContainerStyle={{ backgroundColor: "rgba(164, 137, 178, 0.9)" }} // Style applied to the container behind the modal
        modalStyle={{backgroundColor: #f1f2f3, maxWidth: 500px, minHeight: 250px}} // Style for the modal window
        modalMode={true} // If true, it can't be closed by clicking on the background behind the modal
        onClose={() => setIsModal(false)} // Called when the modal is closed
        title="An awesome title" // The title of the modal
        titleStyle={{color: grey, fontSize: 1.5rem}} // Style applied to the title
      />
    </div>
  )
};

PropTypes

There is a couple of props that we can pass to our component to customise its appearance. Below is an explanation of what we can do :

| Name | Type | Required | Example | | :--------------: | :----------------: | :------: | :--------------: | | closeButton | void or Boolean | no | Nothing if you want the close button and closeButton={false} if you want to remove it | | closeButtonStyle | void or Object | no | closeButtonStyle={{color: purple, fontSize: 1.5rem}} | | icon | void or String | no | Nothing if you don't want any icon. Else, one of these : success, error, info, danger | | iconStyle | void or Object | no | Icons have a size and their own color by default. However, you can change it by passing an object of properties iconStyle={{color: purple, fontSize: 1.5rem}} | | isOpen | Boolean | yes | isOpen should be linked to a useState with false as default value ans set to true to open the modal | | message | String/JSX.element | yes | message="My first message" or an element like message={<span>My first message in a span</span>} | | messageStyle | void or Object | no | messageStyle={{fontSize: 1.2rem, color:grey, fontWeight: bold}} | | | modalStyle | void or Object | no | modalStyle={{backgroundColor: #f1f2f3, maxWidth: 500px, minHeight: 250px}} | | modalMode | void or Boolean | no | Nothing if you want to close by clicking outside. Else modalMode={true} | | onClose | Function | yes | Should set the useState to false like this : onClose={() => setIsModal(false)} | | title | void or String | no | title="An awesome title" | | titleStyle | void or Object | no | titleStyle={{color: grey, fontSize: 1.5rem}} |

Examples

Here are a few screenshots of what we can do with customisation :

| Type | Example | | :--------------: | :----------------: | | Success message | Successful example | | Error message | error example | | Info message | info example | | Danger message | danger example | | Long message | long example | | Custom modal colors | custom colors example | | Custom background color | custom background example |