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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-colorblind-filter

v1.0.0

Published

Module React pour simuler différents types de daltonisme avec des filtres visuels

Readme

🕶️ react-colorblind-filter

npm version License: MIT

Module React/TypeScript pour simuler différents types de daltonisme sur votre application web. Fonctionne comme des "lunettes virtuelles" sans modifier le CSS existant.

✨ Fonctionnalités

  • 🎨 5 types de filtres (vision normale + 4 types de daltonisme)
  • 🚀 Installation simple via npm
  • 💡 API intuitive avec Context API
  • 🎯 TypeScript support complet
  • 🪶 Léger et sans dépendances externes
  • ♿ Améliore l'accessibilité de vos tests

📦 Installation

npm install react-colorblind-filter
# ou
yarn add react-colorblind-filter
# ou
pnpm add react-colorblind-filter

🚀 Utilisation Rapide

1. Wrapper votre app avec le Provider

import { ColorBlindFilterProvider } from 'react-colorblind-filter';

function App() {
  return (
    <ColorBlindFilterProvider>
      <YourApp />
    </ColorBlindFilterProvider>
  );
}

2. Utiliser le composant Select

import { ColorBlindFilterSelect } from 'react-colorblind-filter';

function Navbar() {
  return (
    <nav>
      <label>Mode d'accessibilité :</label>
      <ColorBlindFilterSelect />
    </nav>
  );
}

3. Ou créer votre propre contrôle

import { useColorBlindFilter } from 'react-colorblind-filter';

function CustomControl() {
  const { filterType, setFilterType } = useColorBlindFilter();

  return (
    <select 
      value={filterType} 
      onChange={(e) => setFilterType(e.target.value)}
    >
      <option value="none">Normal</option>
      <option value="protanopia">Protanopie</option>
      <option value="deuteranopia">Deutéranopie</option>
      <option value="tritanopia">Tritanopie</option>
      <option value="achromatopsia">Achromatopsie</option>
    </select>
  );
}

📚 API

<ColorBlindFilterProvider>

Composant Provider à placer à la racine de votre app.

<ColorBlindFilterProvider>
  {children}
</ColorBlindFilterProvider>

useColorBlindFilter()

Hook React pour accéder au filtre.

const { filterType, setFilterType } = useColorBlindFilter();

// filterType: 'none' | 'protanopia' | 'deuteranopia' | 'tritanopia' | 'achromatopsia'
// setFilterType: (type: ColorBlindType) => void

<ColorBlindFilterSelect>

Composant Select prêt à l'emploi.

Props :

  • className?: string - Classes CSS
  • style?: React.CSSProperties - Styles inline
<ColorBlindFilterSelect 
  className="my-select" 
  style={{ fontSize: '16px' }} 
/>

🎨 Types de Daltonisme

| Type | Description | |------|-------------| | none | Vision normale | | protanopia | Difficulté à percevoir le rouge | | deuteranopia | Difficulté à percevoir le vert | | tritanopia | Difficulté à percevoir le bleu | | achromatopsia | Vision en noir et blanc uniquement |

💡 Exemples

Avec des boutons radio

import { useColorBlindFilter, ColorBlindType } from 'react-colorblind-filter';

function FilterSettings() {
  const { filterType, setFilterType } = useColorBlindFilter();

  return (
    <>
      {['none', 'protanopia', 'deuteranopia', 'tritanopia', 'achromatopsia'].map((type) => (
        <label key={type}>
          <input
            type="radio"
            value={type}
            checked={filterType === type}
            onChange={(e) => setFilterType(e.target.value as ColorBlindType)}
          />
          {type}
        </label>
      ))}
    </>
  );
}

Avec des boutons

function FilterButtons() {
  const { setFilterType } = useColorBlindFilter();

  return (
    <>
      <button onClick={() => setFilterType('none')}>Normal</button>
      <button onClick={() => setFilterType('protanopia')}>Protanopie</button>
      <button onClick={() => setFilterType('deuteranopia')}>Deutéranopie</button>
    </>
  );
}

🔧 Comment ça marche ?

Le module utilise des filtres SVG appliqués dynamiquement sur l'élément <html> via la propriété CSS filter. Les matrices de couleurs simulent les différents types de daltonisme de manière non-invasive, sans modifier le CSS existant de votre application.

🤝 Contribution

Les contributions sont les bienvenues ! N'hésitez pas à ouvrir une issue ou une pull request sur GitHub.

📄 Licence

MIT © [Ton Nom]

🙏 Crédits

Les matrices de couleurs sont basées sur des recherches scientifiques sur le daltonisme.