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

@parssa/universal-ui

v0.2.21

Published

Note: This project is very much a work in progress.

Downloads

23

Readme

Universal UI

Note: This project is very much a work in progress.

See the docs here: https://universal-ui.vercel.app

What is this library?

A customizable Tailwind React UI library, utilizing data-attributes and TW3.2 functionality to have extremely flexible components.

Tenets

  1. All components should be easily themeable project-wide, and per-instance overrideable.
  2. No components should ever require !important selectors of any kind to override any defaults.
  3. Many different custom theme styles should be achieveable through the tailwind.config.js and the UniversalUIThemeProvider
  4. Refs are always forwarded
  5. Composition is king
  6. Full light/dark mode support, with ability to override defaults

Getting Started

This library assumes your project is configured with Tailwind 3.2+.

First install the library with your package manager of choice:

npm install @universal-ui/react

Then, import the UniversalUIThemeProvider and wrap your app in it:

import { UniversalUIThemeProvider } from '@universal-ui/react';

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

Lastly, add the following to your tailwind.config.js:


content: [
  ...,
  "./node_modules/@parssa/universal-ui/src/components/**/*.{ts,tsx,js,jsx}",
  ...
],
plugins: [
  ...
    require("@parssa/universal-ui/src/plugin"),
  ...
  ]

Theming / Configuration

There are two main ways to theme this library: through the tailwind.config.js and through the UniversalUIThemeProvider.

Tailwind Config

Here is where you can apply overrides for the semantic colors, and things such as the spacing scale.

Example theme replacing the brand color with some green hues.

theme: {
   universalUI: {
    themes: [
      {
          name: "brand",
          colors: {
            50: "#f1f8f4",
            100: "#ddeee3",
            200: "#bdddc9",
            300: "#9ac8af",
            400: "#63a482",
            500: "#428766",
            600: "#306b50",
            700: "#265641",
            800: "#204536",
            900: "#1b392d"
          }
        },
    ]
  }
}

One thing to note is it's ideal to provide a color scale from 50-900, as these colors are all used when determining the light/dark variants for the components.

UniversalUIThemeProvider

The UniversalUIThemeProvider is a React Context Provider that allows you to override the theme on a per-instance basis. This is useful for changing the feel of all components on a page, or for a specific component.

Per component, you can pass in a string, or a function which returns the instance's props, to apply styles conditionally.

import { UniversalUIThemeProvider } from '@universal-ui/react';

const config = {
  components: {
    button: ({ theme }: ButtonProps) => {
      if (theme === 'error') {
        return 'cursor-not-allowed';
      }
      return '';
    },
    text: ({ variant }: TextProps) => {
      if (variant === 'h1') {
        return 'underline'
      }

      return '';
    },
  }
}

function App() {
  return (
    <UniversalUIThemeContext.Provider value={config}>
      <YourApp />
    </UniversalUIThemeContext.Provider>
  );
}

SSR

To ensure components respond to the user's OS theme preference, you'll need to wrap your app in the UniversalUIThemeProvider and pass in the ssr prop.

const config = {
  components: { ... },
  ssr: true
}