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

react-opium-button

v0.0.4

Published

A light-weight react button with inline state indicator.

Downloads

25

Readme

react-opium-button

A light-weight react button with inline state indicator.

Codepen demo

Features

  • Automatically generates a darker color from a given solid or gradient color for the hover/focus effect
  • Hover color can also be provided manually
  • Loading indicators with SVG animations
  • Optional different text while loading
  • Success indicator

Installation

npm i react-opium-button

Usage

Basic example

import React, { Component } from 'react';
import Button from 'react-opium-button';
import 'react-opium-button/style.css';

class App extends Component {
  contructor(props) {
    super(props);
    this.state = { buttonState: 'normal' };
  }

  handleClick() {
    console.log('button clicked');
  }

  render() {
    return (
      <div style={{ margin: '200px auto', maxWidth: '400px' }}>
        <Button
          text="Save"
          padding="10px 50px"
          background="#ee0979"
          color="#ffffff"
          state={this.state.buttonState}
          onClick={this.handleClick} />
      </div>
    );
  }
}

export default App;

Advanced usage

Extend the plugin to make your own settings as default.

// ./myModifiedButton.js
import Button from 'react-opium-button';

class myModifiedButton extends Button {
  static defaultProps = {
    background: '#ff0000',
    color: '#2e2e2e',
    dimensions: '100px 40px',
    border: '2px solid #ff0000',
    rounded: true
  }
}

export default myModifiedButton;

Customizations

| Prop | Type | Default | Description | |---|---|---|---| | text | String | Click me! | Button text | | background | String | #e8eaeb | Background color of the button. It can be solid or gradient color with hex values. It automatically calculates a darker color for hover effect, however, you can also specify a hover color with a '|' separator, e.g. '#ff0000|#000000' | | color | String | #2e2e2e | Text color, should be a hex value, optionally specify hover color as '#ff0000|#000000' | | dimensions | String | auto auto | If the button needs to be of specific width or height, e.g. 150px 30px | | padding | String | 5px | CSS padding e.g. 10px 50px | | border | String | none | CSS border e.g. 2px solid #e2e3e5 | | radius | Number | 0 | Border radius | | full | Boolean | false | Occupies full width if set true | | rounded | Boolean | false | Makes the button corners rounded | | state | String | normal | Button state: normal, loading or success | | loaderType | String | circle | Loading animation type, it can be set as circle, dots, ripple, disk or gooey | | loadingText | String | null | If set, it will show this text in place of loading animation | | onClick | Function | - | onClick handler |