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

@molecule/app-loyalty-tier-badge-angular

v1.1.1

Published

Bronze/Silver/Gold/Platinum loyalty tier badge with progress to next tier — hotels, airlines, retail rewards

Readme

@molecule/app-loyalty-tier-badge-angular

Angular Bronze/Silver/Gold/Platinum loyalty tier badge with optional progress bar to the next tier.

Angular counterpart of @molecule/app-loyalty-tier-badge-react: the same props (React names), the same DOM for the same input.

Exports:

  • <div mol-loyalty-tier-badge> — colored tier glyph + label; when BOTH points and nextTierThreshold are set (and a next tier exists) it also renders a progress bar plus an "X to next tier" readout; platinum shows "Top tier reached" instead. Inputs: tier, points?, nextTierThreshold?, tierLabel? / nextTierLabel? (override the translated names for branded programs, e.g. "Member" / "Elite"), size? ('sm' | 'md' | 'lg'), dataMolId?, className?.
  • LoyaltyTier, LoyaltyTierBadgeProps types; computeProgress() and nextTierOf() helpers.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { Component } from '@angular/core'
import { LoyaltyTierBadge } from '@molecule/app-loyalty-tier-badge-angular'

@Component({
  selector: 'app-account-tier',
  standalone: true,
  imports: [LoyaltyTierBadge],
  template: `
    <div mol-loyalty-tier-badge [tier]="'gold'" [points]="42000" [nextTierThreshold]="75000"></div>
  `,
})
export class AccountTier {}

Type

feature

Installation

npm install @molecule/app-loyalty-tier-badge-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-i18n @molecule/app-ui @molecule/app-ui-angular

API

Interfaces

LoyaltyTierBadgeProps

Props accepted by {@link LoyaltyTierBadge} — the same props @molecule/app-loyalty-tier-badge-react accepts, bound as inputs on div[mol-loyalty-tier-badge].

interface LoyaltyTierBadgeProps {
  /** Current tier. */
  tier: LoyaltyTier
  /**
   * Member's current points / nights / qualifying activity in the tier
   * unit. Optional; when present and `nextTierThreshold` is also given the
   * badge renders a progress bar and "X to next tier" readout.
   */
  points?: number
  /**
   * Threshold (in the same unit as `points`) at which the next tier is
   * earned. Combined with `points` to compute progress.
   */
  nextTierThreshold?: number
  /** Override the auto-derived next-tier label (e.g. "Diamond"). */
  nextTierLabel?: string
  /** Override the displayed tier label (defaults to translated tier name). */
  tierLabel?: string
  /** Display size. */
  size?: 'sm' | 'md' | 'lg'
  /** `data-mol-id` attribute for AI-agent selectors. */
  dataMolId?: string
  /** Extra classes appended via the ClassMap `cn()` helper. */
  className?: string
}

Types

LoyaltyTier

Standard loyalty tier rungs.

type LoyaltyTier = 'bronze' | 'silver' | 'gold' | 'platinum'

Classes

LoyaltyTierBadge

LoyaltyTierBadge component.

Bronze/Silver/Gold/Platinum tier badge: a colored glyph holding the label's first letter, the tier label, and — when points and nextTierThreshold are both given and a next tier exists — a progress bar plus an "X to next tier" readout; platinum shows "Top tier reached" instead. The host IS the outer <div> (div[mol-loyalty-tier-badge]), matching React's root exactly: same classes, same attributes, same inline styles.

This is the Angular counterpart of @molecule/app-loyalty-tier-badge-react.

@Component({
  selector: 'div[mol-loyalty-tier-badge]',
  standalone: true,
  inputs: [
    'tier',
    'points',
    'nextTierThreshold',
    'nextTierLabel',
    'tierLabel',
    'size',
    'dataMolId',
    'className',
  ],
  host: {
    role: 'group',
    '[class]': 'classes()',
    '[attr.data-mol-id]': 'dataMolId ?? "loyalty-tier-badge"',
    '[attr.data-tier]': 'tier',
    '[attr.aria-label]': 'groupLabel()',
  },
  // prettier-ignore
  template: `<span aria-hidden="true" [class]="glyphClasses()" [style]="glyphStyle()" data-mol-id="loyalty-tier-glyph">{{ tierInitial() }}</span><div [class]="bodyClasses()" style="flex: 1 1 0%"><span [class]="tierNameClasses()">{{ tierName() }}</span>@if (showProgress()) {<div role="progressbar" aria-valuemin="0" aria-valuemax="100" [attr.aria-valuenow]="percent()" [attr.aria-label]="progressLabel()" data-mol-id="loyalty-tier-progress" [class]="trackClasses()" [style]="progressOuterStyle()"><div [style]="progressInnerStyle()"></div></div><span [class]="subTextClasses()" data-mol-id="loyalty-tier-progress-label">{{ remainingLabel() }}</span>} @else if (isTopTier()) {<span [class]="subTextClasses()" data-mol-id="loyalty-tier-top">{{ topTierLabel() }}</span>}</div>`,
})
export class LoyaltyTierBadge {
  /** Current tier. */
  tier!: LoyaltyTier
  /** Member's current points / nights / qualifying activity. */
  points?: number
  /** Threshold at which the next tier is earned (same unit as `points`). */
  nextTierThreshold?: number
  /** Override the auto-derived next-tier label (e.g. "Diamond"). */
  nextTierLabel?: string
  /** Override the displayed tier label (defaults to the translated name). */
  tierLabel?: string
  /** Display size (defaults to `'md'` at read time). */
  size?: 'sm' | 'md' | 'lg'
  /** `data-mol-id` for AI-agent selectors (defaults to `'loyalty-tier-badge'`). */
  dataMolId?: string
  /** Extra classes appended via the ClassMap `cn()` helper. */
  className?: string

  /** The i18n handle (locale-reactive), read in an injection context. */
  private readonly i18n = useTranslation()

  /** The current class map. */
  cm(): UIClassMap {
    return getClassMap()
  }

  /** The glyph's pixel size (React's `size` default parameter). */
  px(): number {
    return SIZE_PX[this.size ?? 'md']
  }

  /** The glyph's accent color for the current tier. */
  accent(): string {
    return TIER_COLOR[this.tier]
  }

  /** The next tier, or null at the top of the ladder. */
  next(): LoyaltyTier | null {
    return nextTierOf(this.tier)
  }

  /** Progress toward the next tier, clamped to 0–1. */
  progress(): number {
    return computeProgress(this.points, this.nextTierThreshold)
  }

  /** Whether the progress bar and its readout render (React's `showProgress`). */
  showProgress(): boolean {
    return (
      typeof this.points === 'number' &&
      typeof this.nextTierThreshold === 'number' &&
      this.nextTierThreshold > 0 &&
      this.next() !== null
    )
  }

  /** Whether the member is at the highest tier (React's `next === null`). */
  isTopTier(): boolean {
    return this.next() === null
  }

  /** The progress percentage, rounded (React's `Math.round(progress * 100)`). */
  percent(): number {
    return Math.round(this.progress() * 100)
  }

  /** The translated name of a tier rung. */
  translatedTierName(rung: LoyaltyTier): string {
    switch (rung) {
      case 'bronze':
        return this.i18n.t('loyaltyTierBadge.tier.bronze', {}, { defaultValue: 'Bronze' })
      case 'silver':
        return this.i18n.t('loyaltyTierBadge.tier.silver', {}, { defaultValue: 'Silver' })
      case 'gold':
        return this.i18n.t('loyaltyTierBadge.tier.gold', {}, { defaultValue: 'Gold' })
      case 'platinum':
        return this.i18n.t('loyaltyTierBadge.tier.platinum', {}, { defaultValue: 'Platinum' })
    }
  }

  /** The displayed tier label: `tierLabel` when given, else the translated tier name (prop > `t()` > `defaultValue`). */
  tierName(): string {
    return this.tierLabel ?? this.translatedTierName(this.tier)
  }

  /** The glyph's single-letter initial (React's `tierName.charAt(0)`). */
  tierInitial(): string {
    return this.tierName().charAt(0)
  }

  nextName(): string {
    if (this.nextTierLabel !== undefined && this.nextTierLabel !== null) return this.nextTierLabel
    const upcoming = this.next()
    if (!upcoming) return ''
    return this.translatedTierName(upcoming)
  }

  /** Points still needed for the next tier, never negative. */
  remaining(): number {
    if (!this.showProgress()) return 0
    return Math.max(0, (this.nextTierThreshold ?? 0) - (this.points ?? 0))
  }

  /** The wrapper's accessible name (`{{tier}} tier`). */
  groupLabel(): string {
    return this.i18n.t(
      'loyaltyTierBadge.group',
      { tier: this.tierName() },
      { defaultValue: '{{tier}} tier' },
    )
  }

  /** The progress bar's accessible name (`Progress to {{next}}`). */
  progressLabel(): string {
    return this.i18n.t(
      'loyaltyTierBadge.progress',
      { next: this.nextName() },
      { defaultValue: 'Progress to {{next}}' },
    )
  }

  /** The remaining-points readout (`{{remaining}} to {{next}}`). */
  remainingLabel(): string {
    return this.i18n.t(
      'loyaltyTierBadge.remaining',
      { remaining: this.remaining(), next: this.nextName() },
      { defaultValue: '{{remaining}} to {{next}}' },
    )
  }

  /** The top-tier message (`Top tier reached`). */
  topTierLabel(): string {
    return this.i18n.t('loyaltyTierBadge.topTier', {}, { defaultValue: 'Top tier reached' })
  }

  /** The inline style of the glyph (React's `glyphStyle`). */
  glyphStyle(): string | null {
    const size = this.px()
    const accent = this.accent()
    return styleText({
      width: `${size}px`,
      height: `${size}px`,
      borderRadius: '50%',
      // The tier's metallic accent is data (the tier's identity), not a theme tone.
      background: `radial-gradient(circle at 30% 30%, ${accent} 0%, ${accent}99 60%, ${accent}66 100%)`,
      display: 'inline-flex',
      alignItems: 'center',
      justifyContent: 'center',
      flexShrink: 0,
      fontWeight: 700,
      fontSize: `${Math.round(size * 0.45)}px`,
    })
  }

  /** The glyph's class (React's `cm.borderAll` — the theme's border color), routed through `cn()` like every token read. */
  glyphClasses(): string {
    return this.cm().cn(this.cm().borderAll)
  }

  /** The inline style of the progress track (React's `progressOuter`). */
  progressOuterStyle(): string | null {
    return styleText({
      position: 'relative',
      height: '6px',
      borderRadius: '3px',
      overflow: 'hidden',
      width: '100%',
    })
  }

  trackClasses(): string {
    return this.cm().cn(this.cm().surfaceSecondary)
  }

  /** The inline style of the progress fill (React's `progressInner`). */
  progressInnerStyle(): string | null {
    return styleText({
      width: `${this.percent()}%`,
      height: '100%',
      // The fill carries the tier's accent (data).
      background: this.accent(),
      transition: 'width 200ms ease',
    })
  }

  /** The wrapper's class list (React's `cm.flex(...)` + `className`). */
  classes(): string {
    const cm = this.cm()
    return cm.cn(cm.flex({ align: 'center', gap: 'sm' }), this.className)
  }

  /** The body column's class list (React's `cm.flex({ direction: 'col', gap: 'xs' })`). */
  bodyClasses(): string {
    return this.cm().flex({ direction: 'col', gap: 'xs' })
  }

  /** The tier label's class list (React's `cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))`). */
  tierNameClasses(): string {
    const cm = this.cm()
    return cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))
  }

  /** The secondary lines' class list (React's `cm.cn(cm.textSize('xs'), cm.textMuted)`). */
  subTextClasses(): string {
    const cm = this.cm()
    return cm.cn(cm.textSize('xs'), cm.textMuted)
  }
}

(Member comments are shortened to their first sentence, and the 2 longest are left out to fit; the full declaration is in node_modules/@molecule/app-loyalty-tier-badge-angular/dist/loyalty-tier-badge.component.d.ts.)

Functions

computeProgress(points, threshold)

Compute progress (0–1) toward the next tier given current points + threshold.

function computeProgress(points?: number, threshold?: number): number
  • points — Current points balance.
  • threshold — Points needed to reach the next tier.

Returns: Clamped 0–1 progress ratio.

nextTierOf(tier)

Resolve the next tier name (lowercase) given the current tier. Returns null when the member is already at the highest tier.

function nextTierOf(tier: LoyaltyTier): LoyaltyTier | null
  • tier — Current tier.

Returns: The next-tier name or null if at the top.

Injection Notes

Requirements

Peer dependencies:

  • @angular/common ^22.0.0
  • @angular/core ^22.0.0
  • @angular/platform-browser ^22.0.0
  • @molecule/app-angular ^3.5.0 || ^4.0.0
  • @molecule/app-i18n ^1.0.1
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-angular ^1.1.0

Runtime Dependencies

  • @angular/common

  • @angular/core

  • @angular/platform-browser

  • @molecule/app-angular

  • @molecule/app-i18n

  • @molecule/app-ui

  • @molecule/app-ui-angular

  • The tier glyph accent is ALWAYS a fixed metallic hex per tier (bronze / silver / gold / platinum) — it does not read theme tokens; only the border and secondary text use --mol-color- variables (with light-theme fallbacks).

  • Labels route through t() under the loyaltyTierBadge. prefix, read through useTranslation(), so they follow a locale switch. The companion @molecule/app-locales-loyalty-tier-badge bond currently ships only group and progress — the tier names, remaining, and topTier strings fall back to English everywhere until the bond gains those keys (or pass tierLabel / nextTierLabel yourself).

  • points / nextTierThreshold must share a unit (points, nights, spend); progress is clamped to 0–1.

Translations

Translation strings are provided by @molecule/app-locales-loyalty-tier-badge.