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

rg-dst

v1.2.22

Published

A scalable, reusable React + TypeScript component library with Vite, Tailwind CSS, Storybook, ESLint, and Vitest. This README helps new contributors understand the structure, conventions, and workflows to confidently add or update code and resolve issues.

Readme

RG Design System Template – Developer Guide

A scalable, reusable React + TypeScript component library with Vite, Tailwind CSS, Storybook, ESLint, and Vitest. This README helps new contributors understand the structure, conventions, and workflows to confidently add or update code and resolve issues.

Stack

  • React 19, TypeScript 5, Vite 6
  • Tailwind CSS 4 (with @tailwindcss/vite); PostCSS for CSS build
  • Storybook 8 (React + Vite)
  • Vitest 3 + Testing Library + JSDOM
  • ESLint 9 (typescript-eslint, react-hooks, react-refresh)
  • Rollup for library bundling (ESM + CJS + DTS)

Project Structure

.
├─ src/
│  ├─ assets/
│  │  └─ style/                 # Base CSS tokens and utilities (compiled into dist/style.css)
│  ├─ components/
│  │  ├─ <ComponentName>/       # One folder per public component
│  │  │  ├─ index.tsx           # Component implementation (export default/named)
│  │  │  ├─ _.style.ts          # Styles (e.g., cva, class composition)
│  │  │  ├─ _.types.ts|type.ts  # Component props/types
│  │  │  ├─ _.stories.tsx       # Storybook stories
│  │  │  └─ _.test.tsx          # Unit tests (Vitest + Testing Library)
│  │  ├─ developers/            # Showcase profiles (excluded from coverage)
│  │  └─ ui/                    # Internal building blocks (not public API)
│  ├─ hooks/                    # Reusable hooks
│  ├─ icons/                    # Icon components + types (excluded from coverage)
│  ├─ lib/                      # Utilities shared by components
│  ├─ index.ts                  # Library public exports
│  ├─ index.css                 # Tailwind entry (built via PostCSS)
│  └─ main.tsx                  # Local playground entry (not part of build output)
├─ tests/setup.ts               # Vitest setup (jsdom, matchers)
├─ vite.config.ts               # Vite + Vitest base config (alias '@' → './src')
├─ vitest.config.ts             # Test include/exclude and coverage rules
├─ eslint.config.js             # ESLint rules and TS integration
├─ postcss.config.mjs           # PostCSS pipeline (imports, autoprefixer)
├─ rollup.config.mjs            # Library bundle (esm/cjs/dts) for publish
├─ package.json                 # Scripts, exports, deps, peer deps
├─ dist/                        # Build output (ignored in dev)
└─ public/                      # Static assets used by Storybook/demo

Naming and File Conventions

  • Component folders are PascalCase and contain the standard set: index.tsx, _.style.ts, _.types.ts (or type.ts), _.stories.tsx, _.test.tsx.
  • Internal-only primitives live under src/components/ui and should not be exported from the library root.
  • The alias @ resolves to ./src (import like import { cn } from '@/lib/utils').
  • CSS tokens live in src/assets/style/*.css; the library bundles dist/style.css (see exports in package.json).

Getting Started

Prereqs: Node 18+ (or 20+), PNPM recommended.

Install dependencies:

pnpm install

Run the dev playground (Vite):

pnpm dev

Open Storybook for component docs:

pnpm story

Run tests:

pnpm test

Run tests with coverage:

pnpm coverage

Lint the repo:

pnpm lint

Build the library (types + CSS + bundles):

pnpm build

Full release build (test → vite build → rollup):

pnpm rollup

Exports and Consumers

package.json exposes:

  • ESM: dist/index.mjs
  • CJS: dist/index.js
  • Types: dist/index.d.ts
  • CSS: dist/style.css (via subpath export)

Consumers can:

import { Button } from 'rg-dst';
import 'rg-dst/dist/style.css';

Adding a New Component

  1. Scaffold folder: src/components/<ComponentName>/ with files:
  • index.tsx – component implementation
  • _.types.ts – define prop types; export ComponentNameProps
  • _.style.ts – class builders (e.g., with class-variance-authority) and helpers
  • _.stories.tsx – at least default and variants stories
  • _.test.tsx – render, states, a11y basics
  1. Implement component:
  • Keep public API small and typed. Prefer controlled props where appropriate.
  • Compose classes using clsx/cva. Do not inline large style strings.
  • Avoid leaking internal implementation details through props.
  1. Export from library:
  • Re-export from src/components/index.ts or src/index.ts according to the existing pattern.
  1. Document in Storybook:
  • Include controls for all public props.
  • Add usage notes and edge cases in stories or MDX docs.
  1. Tests:
  • Use @testing-library/react with JSDOM.
  • Cover critical behaviors, keyboard interactions, and edge states.
  • Place snapshots only for minimal structural assurance (avoid brittle snapshots).
  1. Styles and Tokens:
  • Reuse tokens from src/assets/style/* when possible.
  • If adding new primitive tokens, update CSS files with clear, scoped variables.

Updating an Existing Component

  1. Search for usages across stories, tests, and src/components/ui primitives before changing prop names or behavior.

  2. Maintain backward compatibility when feasible. If a breaking change is necessary:

  • Adjust stories and tests.
  • Update release notes and communicate migration steps in the PR description.
  1. Keep _.types.ts as the single source of truth for props and update stories/tests accordingly.

  2. Performance and a11y:

  • Use React.memo/useMemo only when it removes real work; avoid premature optimization.
  • Ensure focus management and ARIA attributes are correct (especially for interactive components).

Testing & Coverage

Vitest is configured with JSDOM and global test APIs. Defaults:

  • Includes: src/**/*.test.{ts,tsx}, src/**/*.spec.{ts,tsx}
  • Excludes: node_modules, dist, **/*.stories.tsx, **/*.style.ts, **/*.types.ts, src/icons/**/*.{ts,tsx}

Coverage includes src/**/*.{ts,tsx} with further excludes:

  • Stories, styles, types, icons
  • src/components/developers/**
  • tests/**, dist/**, src/main.tsx, src/vite-env.d.ts

Command hints:

pnpm test            # run unit tests
pnpm coverage        # generate text/json/html coverage

Linting & Code Style

ESLint rules are defined in eslint.config.js:

  • Typescript-eslint recommended rules
  • React hooks rules enforced
  • @typescript-eslint/no-explicit-any is disabled where pragmatic
  • react-refresh/only-export-components warned to keep HMR-friendly exports

Guidelines:

  • Prefer clear, descriptive names over abbreviations.
  • Keep components focused; extract internal UI into src/components/ui.
  • Minimal comments; only for non-obvious rationale or caveats.
  • Early returns over deep nesting; avoid broad try/catch.

Styles & Theming

  • Tailwind via Vite plugin; utility composition preferred.
  • Shared tokens and utilities live in src/assets/style/*.css.
  • Library CSS is built with pnpm build:css to dist/style.css. Consumers must import it.

Icons

  • Add icons to src/icons/general as React components.
  • Keep icon types in src/icons/icons.type.ts.
  • Icons are excluded from test coverage; still add basic validation where necessary.

Aliases

@./src (configured in both vite.config.ts and vitest.config.ts). Example:

import { cn } from '@/lib/utils'

Scripts (from package.json)

  • pnpm dev – Start Vite dev server (with --host for LAN testing)
  • pnpm build:css – Build src/index.css to dist/style.css via PostCSS
  • pnpm build – TypeScript build + CSS build + Vite build
  • pnpm rollup – Run tests, Vite build, and Rollup bundle (esm/cjs/dts)
  • pnpm story – Run Storybook on port 6006
  • pnpm build-storybook – Generate static Storybook
  • pnpm test – Run Vitest
  • pnpm coverage – Vitest with coverage
  • pnpm lint – Run ESLint

Publishing Notes

  • Ensure peerDependencies for react and react-dom are correct.
  • Verify exports map and types in package.json.
  • Run pnpm rollup and verify dist/ contains .mjs, .js, .d.ts, and style.css.

Troubleshooting

  • Dev server fails to start

    • Delete node_modules and lockfile, then pnpm install.
    • Ensure Node version ≥ 18.
  • Storybook cannot resolve @ alias

    • Restart Storybook after changes to vite.config.ts.
    • Confirm alias is set in both vite.config.ts and Storybook config (React-Vite preset handles this).
  • Tests fail with DOM-related errors

    • Ensure jsdom environment is set (it is in config). Check tests/setup.ts path.
  • Coverage missing for new files

    • Confirm files are within src/ and not in an excluded pattern.
  • Styles not applied in consumer app

    • Remind consumers to import 'rg-dst/dist/style.css'.

Contribution Workflow

  1. Create a feature branch: git checkout -b feat/<short-name>
  2. Implement changes with stories and tests.
  3. Run pnpm lint && pnpm test && pnpm build locally.
  4. Open a PR with:
    • Summary of changes
    • Screenshots (stories) if visual
    • Breaking changes and migration notes
  5. Request review; address feedback; squash and merge.

Questions or issues? Open an issue with context, repro steps, and environment details.