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

@pcampus/reward-widget

v0.2.4

Published

Public UI components and theme types for Pcampus Reward Widget integrations.

Readme

@pcampus/reward-widget

Public UI components and theme types for Pcampus Reward Widget integrations.

Relationship to the Reward Widget service

Pcampus-reward-widget is the private runtime and source of truth for campaign configuration, eligibility, server draw, inventory, claims, webhooks, and the hosted Player/Embed experience.

Pcampus-reward-widget-library is the public UI layer: reusable components, theme tokens, and TypeScript types that consumer apps can render and style. It does not contain API clients, draw or eligibility logic, campaign state, secrets, claims, webhooks, or coupon data.

This package is UI-only. It never contains draw/eligibility clients, campaign secrets, coupon codes, or authoritative server logic.

Status

Public UI catalog for spin, scratch, pick-card, mystery-box, and quiz. Presentation matches the Merchant Portal preview package. This package is still UI-only: no draw, claims, or campaign APIs.

Public support matrix

The UI catalog targets spin, scratch, pick-card, mystery-box, and quiz. This package exports presentation primitives, theme configuration, and public types only. Reward service APIs, server-side authority, claims, webhooks, secrets, and coupon data remain outside the package.

Installation & Usage

npm install @pcampus/reward-widget

SSR / String Markup

import { renderRewardWidgetMarkup } from '@pcampus/reward-widget';

const html = renderRewardWidgetMarkup({
  widgetType: 'spin',
  state: 'eligible',
  title: 'Daily Wheel of Fortune',
  message: 'Spin now to win exclusive points!',
  actionLabel: 'Spin Now',
  theme: { brandPrimaryColor: '#2952a3' },
});

Interactive widgets (player chrome)

import { mountInteractiveWidget } from '@pcampus/reward-widget';

const root = document.getElementById('widget-root');
mountInteractiveWidget(root, {
  widgetType: 'pick-card',
  rewards: [
    { name: 'ส่วนลด 100 บาท', weight: 40 },
    { name: 'Lucky Bonus', weight: 30 },
    { name: '100 Points', weight: 20 },
  ],
  theme: { brandPrimaryColor: '#4b7fd4' },
});

SSR equivalent: renderInteractiveWidgetMarkup({ widgetType, rewards, theme }). Per-type helpers: renderSpinWheelMarkup / mountSpinWheel, and the same pattern for scratch, pick-card, mystery-box, and quiz.

Open examples/interactive-catalog.html via a local static server to view all five types.

Client DOM Mount (chrome shell)

import { mountRewardWidget } from '@pcampus/reward-widget';

const container = document.getElementById('widget-root');
mountRewardWidget(container, {
  widgetType: 'mystery-box',
  state: 'eligible',
  title: 'Special Mystery Box',
  onAction: () => {
    console.log('Action clicked');
  },
});

Theme Tokens & Customization

Consumers can customize widget styling using typed tokens and CSS custom properties:

import { createRewardWidgetTheme, rewardWidgetThemeCss } from '@pcampus/reward-widget';

// Create custom theme with fallbacks to defaults
const theme = createRewardWidgetTheme({
  primary: '#2952a3',
  background: '#0f172a',
  radius: '0.5rem',
});

// Generate scoped CSS variables
const css = rewardWidgetThemeCss({ primary: '#2952a3' });

Supported Tokens

| Token | Default | Purpose | |---|---|---| | primary | #2952a3 | Primary brand color | | primaryHover | #1e3a8a | Interactive hover state | | surface | #ffffff | Component card/surface | | background | #0f172a | Container background | | border | #cbd5e1 | Border and outline | | focus | #f59e0b | Focus ring indicator | | disabled | #64748b | Disabled control state | | warning | #f59e0b | Warning message/badge | | blocked | #9f1239 | Ineligible / limit reached | | success | #047857 | Reward won / success | | radius | 0.75rem | Border radius | | spacing | 1rem | Component padding | | motion | 160ms | Transition duration |

Build

npm install
npm run build
npm test

The package build emits JavaScript and TypeScript declarations under dist/.

Public release policy

Releases use the public npm registry only after human review. Before publishing, run npm test, npm pack --dry-run, and npm audit --omit=dev. The published artifact is limited to dist/, this README, and the MIT license.