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-alwan

v1.1.2

Published

A simple lightweight, customizable touch friendly color picker

Downloads

15

Readme

react-alwan

A simple, lightweight, customizable, touch friendly color picker for react library.

   

   

Features

  • Touch friendly.
  • Support dark theme.
  • Alpha channel (opacity).
  • Support 3 color formats hsl, rgb and hex.
  • Keyboard accessible.
  • Simple easy to use interface (inspired by google chrome's color picker).
  • No dependencies.
  • Copy color to the clipboard.
  • Lightweight.

Demo

Click here to try it

Getting started

Install using package manager

npm install react-alwan

or

yarn add react-alwan

Direct Link

  • Jsdelivr CDN
<!-- Style -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/react-alwan/dist/alwan.css" />

<!-- Script -->
<script src="https://cdn.jsdelivr.net/npm/react-alwan/dist/umd/react-alwan.js"></script>
  • Unpkg CDN
<!-- Style -->
<link rel="stylesheet" href="https://unpkg.com/react-alwan/dist/alwan.css" />

<!-- Script -->
<script src="https://unpkg.com/react-alwan/dist/umd/react-alwan.js"></script>

Usage

// Import javascript.
import Alwan from 'react-alwan';
// Import css.
import 'react-alwan/dist/alwan.css';

function App() {
    return (
        <>
            <Alwan />
        </>
    );
}

Props

  • id (default '') — Set the color picker Id.

  • classname (default '') — Add classes to the reference button.

  • theme (default light) — Choose a theme, 'dark' or 'light'.

  • toggle (default true) — Toggle picker's visibility (Show/Hide), Setting this to false keeps the picker visible.

  • popover (default true) — Display the picker container as a pop-up (a box that floats on top of the page content), if it's false, picker container will be displayed as a block (embedded in the page's content).

  • position (default bottom-start) — Set the position of the popper (if popover is set to true) relative to the reference element, the position has two values separated by a dash (-), the first value is the direction (top, bottom, right, left), the second value is the alignment (start, center, end), omitting this value will default to center.

    e.g. 'bottom-start': 'bottom' places the picker below the reference element, and 'start' aligns the left side of the container with the left side of the reference element.

    Note: If the picker container has no space to be placed, it will auto-position itself. based on the available space.

  • margin (default 0) — Set the gap (in pixels) between the picker container and the reference element.

  • preview (default true) — Preview the color.

  • copy (default true) — Add/Remove a copy button.

  • opacity (default true) — Support alpha channel and display opacity slider.

  • disabled (default false) — Disable the picker, users won't be able to pick colors.

  • value (default #000) — Color picker value.

  • singleInput (default false) — For the formats 'hsl' and 'rgb', choose a single input to display the color string, or if false, display an input for each color component.

  • inputs (default true) — Input(s) field(s) for each color format. if this option is set to true then all formats are selected.

  • format (default rgb) — Initial color format.

  • swatches (default []) — Array of color swatches, invalid values will be displayed as rgb(0, 0, 0).

  • toggleSwatches (default false) — Make swatches container collapsible.

  • closeOnScroll (default false) — Close the color picker when scrolling.

  • onChange (default undefined) — On Change event fires whenever the color changes.

  • onOpen (default undefined) — On Open event fires whenever the color picker opens.

  • onClose (default undefined) — On Change event fired whenever the color picker closes.

Accessibility (v1.1)

Unlabeled interactive elements has a ARIA label attribute with a default values in english. You can change these labels in the options by modifying the i18n object prop.

  i18n: {
    palette: 'Color picker', // Label for the color picking area.
    copy: 'Copy color to clipboard', // Label & title for the copy button.
    changeFormat: 'Change color format', // Label & title for the change format button.
    swatch: 'Color swatch', // Label for swatch buttons.
    toggleSwatches: 'Toggle swatches', // Label & title for the toggle swatches button.
    hue: 'Change hue', // Label for the hue slider.
    alpha: 'Change opacity' // Label for the opacity slider.
}

Events

    <Alwan
        onOpen={(ev) => { /* ... */ }}
        onClose={(ev) => { /* ... */ }}
        onChange={(ev) => {
            ev.type // Event type `change`, `open` or `close`.

            // HSL color components.
            ev.h // Hue.
            ev.s // Saturation.
            ev.l // Lightness.

            // RGB color components.
            ev.r // Red.
            ev.g // Green.
            ev.b // Blue.

            ev.a // Alpha (opacity)

            // Color string values.
            ev.hex // Hex value.
            ev.rgb // RGB string.
            ev.hsl // HSL string.
        }}
    >