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

@gwiyeomgo/activate-button-by-status

v0.2.22

Published

react button component that are enabled and disabled depending on their status

Downloads

5

Readme

activate-button-by-status install

  • npm install @gwiyeomgo/activate-button-by-status@latest
  • yarn add @gwiyeomgo/activate-button-by-status@latest

background

  • If the button is disabled, a specific status value is required.
  • For example, There is a button to modify the data.
  • This button should be disabled if the data is in the Cancel state.
  • I actually ended up using nested if statements while writing the code. The length of the code became longer, and the code became difficult to understand. To fix this, the repeated code was made into a component.

version release

  • 0.0.0 (2022-8-15)

    • first upload npm module
    • add currentStatus and activeStatus
  • 0.1.0 (2022-08-22)

    • add activeStatusWithPermissions and currentPermissions
  • 0.2.0 (2022-11-26)

    • add typescript
    • refactoring

version 0.0.0

  • If not included in the activeStatus, the button is disabled.
  • If you want to use activeStatus, please specify the currentStatus value
import ActivateButtonByStatus from "@gwiyeomgo/activate-button-by-status";

const STATUS = {
    Completed: "Completed",
    Cancelled: "Cancelled",
    Registered: "Registered",
    Accepted: "Accepted"
};

export default function App() {
    return (
        <div className="App">
            <ActivateButtonByStatus
                title={"Cancelled"}
                onClick={() => {
                    console.log("You can implement the situation by clicking the button");
                }}
                style={{ backgroundColor: "white" }}
                currentStatus={STATUS.Completed}
                activeStatus={["Registered", "Accepted"]}
            />
        </div>
    );
}

version 0.1.0

  • The manager can click the button even when it's complete status Employees can only click on the button in registration and accepted status
  • The activeStatusWithPermissions function is applied first even if the activeStatus function is set together
  • If you want to use activeStatusWithPermissions, please specify the currentStatus and currentPermissions values
<ActivateButtonByStatus
    title={"Cancelled"}
    onClick={() => {
        console.log("You can implement the situation by clicking the button");
    }}
    style={{ backgroundColor: "white" }}
    currentStatus={STATUS.Completed}
    currentPermissions={["Manager"]}
    activeStatusWithPermissions={{
        Completed: ["Manager"],
        Cancelled: [],
        Registered: ["Employee", "Manager"],
        Accepted: ["Employee", "Manager"]
    }}
/>

version 0.2.0

  • Add typescript
    <ActivateButtonByStatus
                title={"Cancelled Button(disabled)"} //required
                type={"status"} //required
                color={"danger"} //  "danger" | "primary" | "success"
                currentStatus={STATUS.Completed} //required
      ...
  • Add required type

    • title : string
    • currentStatus : string
    • type : string
      • status :if you specify type as 'status', please specify 'currentStatus' and 'activeStatus' together
      • statusWithPermission :if you specify type as 'statusWithPermission', please specify 'currentStatus' ,'currentPermissions' and 'activeStatusWithPermissions' together
  • Add css

    • color : "danger" , "primary" , "success"
    • html button => apply CSS to change to the button to look intuitive
  • v0.2.22 : When disabled props is true, the button must be disabled regardless of the status value

    • add error message :activeStatus not exsist,activeStatusWithPermissions not exsist

Example Link

active-buttons