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

@test-party/contrast-color-picker

v1.0.0

Published

🎨 @test-party/contrast-color-picker is a lightweight, customizable color contrast picker designed for React applications. Built with accessibility in mind, it helps developers ensure compliance with WCAG color contrast standards by offering real-time fee

Downloads

333

Readme

Contrast Color Picker

Watch the demo video clip

License Version

A fork of react-colorful enhanced with built-in color contrast detection to ensure accessibility compliance according to WCAG guidelines.

Table of Contents

Introduction

Color accessibility is crucial for creating inclusive web applications. The Contrast Color Picker extends the popular react-colorful library by adding color contrast detection functionality. This ensures that selected color combinations meet the WCAG guidelines for color contrast. Specifically, we follow a minimum contrast ratio of 4.5:1 to ensure compliance with WCAG AA level standards, enhancing the readability and usability of your applications.

Features

  • Multiple Color Formats: Supports Hex, RGB, RGBA, HSL, HSLA, HSV, HSVA, and their string equivalents.
  • Built-in Contrast Analysis: Automatically calculates the contrast ratio between foreground and background colors to determine compliance with WCAG guidelines.
  • Easy Integration: Simple API to integrate color pickers into your React applications with minimal setup.
  • Customizable: Pass in background colors and handle color changes seamlessly.

Installation

Using npm

npm install @test-party/contrast-color-picker

Using Yarn

yarn add @test-party/contrast-color-picker

Note: Ensure that you have the necessary peer dependencies installed (react and react-dom).

Usage

To utilize the Contrast Color Picker in your React application, follow the example below. This demonstrates how to integrate various color picker components with contrast analysis.

Basic Example

import { useState } from 'react';
import { HexColorPicker } from '@test-party/contrast-color-picker';

function App() {
  const [hexForegroundColor, setHexForegroundColor] = useState("#000000");
  const [hexBackgroundColor, setHexBackgroundColor] = useState("#ffffff");

  return (
    <div>
      <h1>Testing @test-party/contrast-color-picker</h1>

      <h2>Hex</h2>
      <HexColorPicker 
        color={hexForegroundColor} 
        onChange={setHexForegroundColor} 
        backgroundColor={hexBackgroundColor}
      />

    </div>
  );
}

export default App;

Components

The Contrast Color Picker offers a variety of components tailored to different color formats. Each component requires the following props:

  • color: The current color value.
  • onChange: Function to handle color changes.
  • backgroundColor: The background color against which contrast is calculated.

Available Components

  • HexColorPicker
  • HexAlphaColorPicker
  • RgbColorPicker
  • RgbaColorPicker
  • HslColorPicker
  • HslaColorPicker
  • HsvColorPicker
  • HsvaColorPicker
  • RgbStringColorPicker
  • RgbaStringColorPicker
  • HslStringColorPicker
  • HslaStringColorPicker
  • HsvStringColorPicker
  • HsvaStringColorPicker

API

Props

Each color picker component accepts the following props:

  • color (string | object): The current color value. The type depends on the color format (e.g., hex string, RGB object).
  • onChange (function): Callback function that receives the updated color value.
  • backgroundColor (string | object): The background color used for contrast analysis.

Example

<HexColorPicker 
  color="#ff0000" 
  onChange={(newColor) => setColor(newColor)} 
  backgroundColor="#ffffff"
/>

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/YourFeature.
  3. Make your changes and commit them: git commit -m 'Add some feature'.
  4. Push to the branch: git push origin feature/YourFeature.
  5. Open a pull request.

Please ensure your code follows the existing style and passes all tests.

License

This project is licensed under the MIT License.

Getting Started

To get started with the Contrast Color Picker, follow the installation instructions above and integrate the desired color picker components into your React application as demonstrated in the usage example.

For more detailed information, refer to the React Colorful documentation, as this package builds upon its foundation with added accessibility features.

Support

If you encounter any issues or have questions, feel free to open an issue in the repository or reach out to the maintainer.