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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@select-org/palette

v0.1.0

Published

Framework-agnostic OKLCH color utilities and community-palette derivation for the Select design system.

Readme

@select/palette

Framework-agnostic OKLCH color utilities and community-palette derivation for the Select design system.

This package is runtime — it converts hex inputs to OKLCH, adjusts contrast, derives semantic palettes from a community brand+background hex pair, and returns OKLCH css strings ready to apply as scoped CSS variable overrides.

Pure TypeScript. No React. No CSS. No Tailwind. The only runtime dependency is Culori.

Why this exists

Backend ships per-community theming as hex (brandHex, bgHex). The web client today applies these inline with hand-tweaked contrast adjustments. This package centralizes the derivation rules: every consumer that derives a community palette gets the same algorithm and the same opinions about contrast, surface tints, and border generation.

See ADR 0012 for the architectural rationale.

Install

Workspace-internal during Phase 1 — consumed via file: dependency:

{
  "dependencies": {
    "@select/palette": "file:../select-design-system/packages/palette"
  }
}

Usage

import {
  hexToOklch,
  oklchToCss,
  ensureContrast,
  derivePaletteFromCommunity,
} from "@select/palette";

// One-shot palette for a community surface.
const palette = derivePaletteFromCommunity({
  brandHex: "#00d4dd",
  bgHex: "#ffffff",
});

// Apply as scoped CSS variable overrides:
const style = {
  "--color-surface": palette.surface,
  "--color-action-primary": palette.actionPrimary,
  "--color-text-primary": palette.textPrimary,
  // ... 21 more semantic tokens
};

API

Types

  • OklchColor{ l, c, h, alpha? } with all components in 0–1 (or 0–360 for h).
  • CommunityPalette — 24 semantic tokens as OKLCH css strings.

Conversion

  • hexToOklch(hex: string): OklchColor — accepts #rgb or #rrggbb. Throws on invalid input.
  • oklchToHex(c: OklchColor): string — outputs #rrggbb. Gamut-clamps to sRGB.
  • oklchToCss(c: OklchColor): string — outputs oklch(L C H) or oklch(L C H / alpha).

Transformation

  • lighten(c, amount) — increases L by amount, clamped at 1.
  • darken(c, amount) — decreases L by amount, clamped at 0.
  • mix(a, b, ratio) — interpolates L, C, alpha linearly; H along shortest path on the 0–360 circle.

Contrast

  • computeContrast(a, b): number — WCAG contrast ratio (1–21).
  • ensureContrast(fg, bg, targetRatio = 4.5): OklchColor — adjusts fg lightness until contrast meets target. Defaults to WCAG AA for normal text.

Palette derivation

  • derivePaletteFromCommunity({ brandHex, bgHex }): CommunityPalette — the load-bearing function. See src/derive.ts for the exact rules; see Plan 0002 for rationale per slot.

Testing

pnpm -F @select/palette test