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 🙏

© 2025 – Pkg Stats / Ryan Hefner

kreeda

v1.1.1

Published

Kreeda: a small React game library

Readme

Kreeda

Kreeda — a small, behavior-first React UI library for card-deck style games.
This library focuses on game behaviour (draw, reveal, accept, penalty) while providing simple, themeable UI primitives.
You can use it to build your own games — from learning flashcards to fun two-player prompts.

Storybook


Table of contents


Install

# install from npm
npm install kreeda

# or with yarn
yarn add kreeda

react and react-dom are peer dependencies. Make sure they are installed in your app.


Quick start

Minimal example:

// App.tsx
import React from "react";
import { CardDeck } from "kreeda";

// import base styles once
import "kreeda/dist/styles.css";

export default function App() {
  const cards = [
    {
      id: "c1",
      title: "Say something kind",
      body: "Tell your partner one thing you love about them.",
      genericFace: {
        kind: "media",
        media: { type: "image", src: "https://picsum.photos/400/260", alt: "scenery" }
      }
    },
    {
      id: "c2",
      title: "Breathe",
      body: "Try a 4-4-8 breathing exercise together.",
      genericFace: {
        kind: "html",
        html: `<div style="text-align:center"><p>Inhale 4s, hold 4s, exhale 8s</p></div>`
      }
    }
  ];

  return <CardDeck initialCards={cards} />;
}

API

Card props

type CardProps = {
  card: GenericCard;
  onReveal?: () => void;
  className?: string;
  initiallyFlipped?: boolean;
  sanitizeHtml?: (html: string) => string;
  renderGenericFace?: (
    face: GenericCard["genericFace"],
    card: GenericCard
  ) => React.ReactNode;
};
  • sanitizeHtml → optional sanitizer when rendering genericFace.kind = "html".
  • renderGenericFace → lets you override how the generic/back face is drawn.

CardDeck props

type CardDeckProps = {
  initialCards?: GenericCard[];
  includeSensitive?: boolean;
  onPenalty?: (
    revealed: GenericCard
  ) => void | Promise<GenericCard | null | undefined>;
  className?: string;
};
  • Accept flow: puts revealed card back at bottom.
  • Penalty flow: calls onPenalty.
    You can return void, null, or a GenericCard. void is normalized to null.

useCardDeck hook

const {
  deck,
  revealed,
  history,
  draw,
  reveal,
  accept,
  penalty,
  discardTop,
  shuffle,
  reset,
  peek
} = useCardDeck(initialCards, options);

Types

export type Media = {
  type: "image" | "gif" | "video" | "svg" | "other";
  src: string;
  alt?: string;
  width?: number;
  height?: number;
  loading?: "lazy" | "eager";
};

export type GenericFace =
  | { kind: "media"; media: Media }
  | { kind: "html"; html: string }
  | { kind: "node"; node: unknown }
  | { kind: "gif"; media: Media }
  | { kind: "none" };

export type GenericCard = {
  id: string;
  title?: string;
  subtitle?: string;
  body?: string;
  tags?: string[];
  sensitive?: boolean;
  genericFace?: GenericFace | null;
  meta?: Record<string, unknown>;
};

Theming & CSS overrides

Kreeda ships minimal CSS with variables that you can override.

Import CSS

// index.tsx
import "kreeda/dist/styles.css";

Override with variables

:root {
  --kreeda-primary: #1db954;
  --kreeda-primary-contrast: #fff;
  --kreeda-card-width: 380px;
  --kreeda-radius: 16px;
}

Scope to a theme

.app--dark {
  --kreeda-surface: #0f172a;
  --kreeda-primary: #ff5a5f;
}

Inline override

<div style={{ ['--kreeda-primary' as any]: '#3b82f6' }}>
  <CardDeck initialCards={cards} />
</div>

Storybook & Demos

Run locally:

npm run storybook

Build static:

npm run build-storybook

👉 Live Storybook

Contains:

  • Welcome → guided usage
  • ComponentsCard, CardDeck
  • Demos → e.g. Sexual wellness two-player demo (shows sensitive content handling)

Publishing & Release

We ship a helper script ./scripts/release.sh:

# default patch bump + publish
./scripts/release.sh

# minor bump
./scripts/release.sh minor

# skip npm publish
./scripts/release.sh patch --no-publish

# skip storybook build
./scripts/release.sh patch --no-storybook

It:

  1. checks repo state,
  2. builds library,
  3. builds storybook (optional),
  4. bumps version,
  5. commits + tags,
  6. pushes to git,
  7. publishes to npm.

Troubleshooting & tips

  • Chunk size warnings → Already handled in .storybook/main.ts with chunkSizeWarningLimit.
  • Duplicate story id → Ensure each story file uses a unique title.
  • Missing sanitizeHtml → Provide DOMPurify or sanitize manually if you use genericFace.kind = "html".
  • Penalty handler → Safe to return nothing; hook treats it as null.

Contributing & development

# install deps
npm install

# run storybook
npm run storybook

# build lib
npm run build
  • Follow conventional commits (feat:, fix:, chore:).
  • Story files should default export meta and ensure unique titles.

License

MIT © 2025 Ashish Kirodian