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

tailwind-easy-theme

v2.0.2

Published

```bash pnpm i -D tailwind-easy-theme colord ```

Downloads

199

Readme

Installation

pnpm i -D tailwind-easy-theme colord

Usage

const { Theme } = require('tailwind-easy-theme');

const theme = new Theme({
  colors: {
    somecolor: '#e9e6ff',
    primary: {
      DEFAULT: '#ffcccc',
      100: '#ffcccc',
      200: '#ff9999',
      300: '#ff6666',
      400: '#ff3333',
    },
  },
});

const darkMode = theme.variant(
  {
    colors: {
      primary: {
        DEFAULT: '#0f172a',
        400: '#475569',
        300: '#334155',
        200: '#1e293b',
        100: '#0f172a',
      },
    },
  },
  {
    mediaQuery: '@media (prefers-color-scheme: dark)',
  }
);

const coolTheme = theme.variant(
  {
    colors: {
      somecolor: '#555',
    },
  },
  {
    selector: '[data-theme="cool-theme"]',
  }
);

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [],
  theme: {
    extend: {},
  },
  plugins: [
    theme.create({
      '[data-theme="dark"]': darkMode,
    }),
  ],
};

This config create the tailwind classes and generate the necessary css and inject it. The color is converted to hsl values, so that opacity works as expected.

Generated CSS for this example:

:root {
  --color-somecolor: 247 100% 95%;
  --color-primary: 0 100% 90%;
  --color-primary-100: 0 100% 90%;
  --color-primary-200: 0 100% 80%;
  --color-primary-300: 0 100% 70%;
  --color-primary-400: 0 100% 60%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-primary: 222 47% 11%;
    --color-primary-100: 222 47% 11%;
    --color-primary-200: 217 33% 17%;
    --color-primary-300: 215 25% 27%;
    --color-primary-400: 215 19% 35%;
  }
}

[data-theme='cool-theme'] {
  --color-somecolor: 0 0% 33%;
}

[data-theme='dark'] {
  --color-primary: 222 47% 11%;
  --color-primary-100: 222 47% 11%;
  --color-primary-200: 217 33% 17%;
  --color-primary-300: 215 25% 27%;
  --color-primary-400: 215 19% 35%;
}

The hex value is given as the fallback value to the tailwind variable config. This means the vscode autocomplete shows the color correctly, despite being a css variable!

Showcase

Options

export type Options = {
  /** The prefix added to the key of a color. Defaults to `--color-` */
  prefix?: string;
  /** The selector to add the css variables to. Defaults to `:root` */
  selector?: string;
};
type VariantOptions = {
  /** The selector to add the css variables to. If not specified will use main theme's selector. */
  selector?: string;
  /** @example `@media (prefers-color-scheme: dark)` */
  mediaQuery?: string;
};