@molecule/app-loyalty-tier-badge-svelte
v1.1.0
Published
Bronze/Silver/Gold/Platinum loyalty tier badge with progress to next tier — hotels, airlines, retail rewards
Maintainers
Readme
@molecule/app-loyalty-tier-badge-svelte
Svelte Bronze/Silver/Gold/Platinum loyalty tier badge with optional progress bar to the next tier.
Svelte counterpart of @molecule/app-loyalty-tier-badge-react: the same
props (React names), the same DOM for the same input.
Exports:
<LoyaltyTierBadge>— colored tier glyph + label; when BOTHpointsandnextTierThresholdare 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. Props:tier,points?,nextTierThreshold?,tierLabel?/nextTierLabel?(override the translated names for branded programs, e.g. "Member" / "Elite"),size?('sm' | 'md' | 'lg'),dataMolId?,className?.LoyaltyTier,LoyaltyTierBadgePropstypes;computeProgress()andnextTierOf()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.tsJSDoc, not this file.
Quick Start
<script lang="ts">
import { LoyaltyTierBadge } from '@molecule/app-loyalty-tier-badge-svelte'
</script>
<LoyaltyTierBadge tier="gold" points={42000} nextTierThreshold={75000} />Type
feature
Installation
npm install @molecule/app-loyalty-tier-badge-svelte @molecule/app-i18n @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelteAPI
Interfaces
LoyaltyTierBadgeProps
Props for {@link LoyaltyTierBadge}.
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'Functions
computeProgress(points, threshold)
Compute progress (0–1) toward the next tier given current points + threshold.
function computeProgress(points?: number, threshold?: number): numberpoints— 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 | nulltier— Current tier.
Returns: The next-tier name or null if at the top.
Constants
LoyaltyTierBadge
const LoyaltyTierBadge: LegacyComponentTypeInjection Notes
Requirements
Peer dependencies:
@molecule/app-i18n^1.0.1@molecule/app-svelte^3.5.0@molecule/app-ui^1.0.1@molecule/app-ui-svelte^1.1.0svelte^5.0.0
Runtime Dependencies
@molecule/app-i18n@molecule/app-svelte@molecule/app-ui@molecule/app-ui-sveltesvelteThe 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 theloyaltyTierBadge.prefix, read throughuseTranslation(), so they follow a locale switch. The companion@molecule/app-locales-loyalty-tier-badgebond currently ships onlygroupandprogress— the tier names,remaining, andtopTierstrings fall back to English everywhere until the bond gains those keys (or passtierLabel/nextTierLabelyourself).points/nextTierThresholdmust share a unit (points, nights, spend); progress is clamped to 0–1.
Translations
Translation strings are provided by @molecule/app-locales-loyalty-tier-badge.
