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

@jvhaile/luna

v1.0.1

Published

Luna is a flexible React and Tailwind CSS theming library, enabling dynamic and customizable theme management for a seamless design experience.

Downloads

25

Readme

@jvhaile/luna

@jvhaile/luna is a flexible theming library for React and Tailwind CSS, enabling dynamic theme customization with user-defined color schemes, theme variants, and easy integration with Tailwind's utility classes.

Features

  • Dynamic Theming: Create and switch between custom themes with light and dark mode support.
  • Tailwind Integration: Extend Tailwind CSS with theme-specific utility classes.
  • React Context API: Manage themes globally across your application.
  • TypeScript Support: Type-safe theming for robust and predictable development.

Installation

Install the package using npm or pnpm:

npm install @jvhaile/luna
# or
pnpm add @jvhaile/luna

Setup

1. Define Your Theme System

Create your theme configurations and set up your theme system:

// src/theme.ts
import { createThemeSystem } from "@jvhaile/luna";

export const themeSystem = createThemeSystem(
    ['primary', 'secondary', 'background', 'text', 'accent', 'card'],
    [
        {
            name: 'Modern Elegance',
            light: {
                primary: '#0D47A1',  // Deep Blue
                secondary: '#8E24AA',  // Purple
                background: '#FAFAFA',  // Off White
                text: '#212121',  // Dark Gray
                accent: '#FF5722',  // Vibrant Orange
                card: '#FFFFFF',  // Pure White
            },
            dark: {
                primary: '#42A5F5',  // Soft Blue
                secondary: '#BA68C8',  // Light Purple
                background: '#121212',  // Almost Black
                text: '#E0E0E0',  // Light Gray
                accent: '#FF7043',  // Soft Orange
                card: '#1C1C1C',  // Dark Gray
            },
        },
        {
            name: 'Forest Retreat',
            light: {
                primary: '#2E7D32',  // Forest Green
                secondary: '#FFB300',  // Amber
                background: '#F1F8E9',  // Light Green
                text: '#3E2723',  // Dark Brown
                accent: '#FF8F00',  // Deep Orange
                card: '#FFFFFF',  // Pure White
            },
            dark: {
                primary: '#66BB6A',  // Light Green
                secondary: '#FFC107',  // Bright Amber
                background: '#1B5E20',  // Dark Green
                text: '#E8F5E9',  // Pale Green
                accent: '#FFA000',  // Orange
                card: '#263238',  // Blue Gray
            },
        }
    ]
);

2. Wrap Your Application with ThemeProvider

Use the ThemeProvider to wrap your application components:

import { ThemeProvider } from "@jvhaile/luna";
import { themeSystem } from "./src/theme";

export default function App() {
  return (
    <ThemeProvider {...themeSystem}>
      <div className="bg-background text-primary">
        <h1 className="text-secondary">Welcome to Luna</h1>
        <p className="bg-card p-4">This is a card with accent color.</p>
      </div>
    </ThemeProvider>
  );
}

3. Configure Tailwind CSS

Extend your Tailwind CSS configuration to include the theme variables:

// tailwind.config.ts
import { generateTailwindColorExtension } from "@jvhaile/luna";
import { themeSystem } from "./src/theme";

const config = {
  content: [
    "./src/**/*.{js,ts,jsx,tsx,mdx}",
  ],
  theme: {
    extend: {
      colors: generateTailwindColorExtension(themeSystem.variables),
    },
  },
  plugins: [],
};

export default config;

Usage

With the setup complete, you can now use your theme variables in Tailwind utility classes like bg-primary, text-secondary, bg-card, and more. The theme will dynamically switch between light and dark modes based on user preference.

Example

<div className="bg-background text-primary">
  <h1 className="text-secondary">Welcome to Luna</h1>
  <p className="bg-card p-4">This is a card with card color.</p>
</div>