@molecule/app-achievement-card-svelte

Feature · achievement-card · App (browser) · v1.1.3 · Apache-2.0

Badge / achievement unlock card with icon + name + description + earned-at

npm install @molecule/app-achievement-card-svelte

npm · Source on GitHub

How it works

@molecule/app-achievement-card-svelte is a ready-made achievement-card feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

<script lang="ts">
  import { AchievementCard } from '@molecule/app-achievement-card-svelte'
</script>

<AchievementCard
  name="First Login"
  description="Signed in for the first time."
  earned
  earnedAt="Jan 3, 2025"
  tier="Common"
>
  {#snippet icon()}<span>🏆</span>{/snippet}
</AchievementCard>

Works with: @molecule/app-i18n, @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte

Reference

Svelte badge / achievement unlock card — the Svelte counterpart of @molecule/app-achievement-card-react, with the same props and the same DOM for the same input.

Exports AchievementCard — icon + name + description + earned state. Locked achievements render greyed-out; in-progress ones show a progress bar.

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

<script lang="ts">
  import { AchievementCard } from '@molecule/app-achievement-card-svelte'
</script>

<AchievementCard
  name="First Login"
  description="Signed in for the first time."
  earned
  earnedAt="Jan 3, 2025"
  tier="Common"
>
  {#snippet icon()}<span>🏆</span>{/snippet}
</AchievementCard>

Type

feature

Installation

npm install @molecule/app-achievement-card-svelte @molecule/app-i18n @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte

API

Interfaces

AchievementCardProps

Props accepted by the AchievementCard component.

interface AchievementCardProps {
  /** Achievement name: a snippet, or a plain string. */
  name: Snippet | string
  /** Description / what it took to earn: a snippet, or a plain string. */
  description?: Snippet | string
  /** Icon / illustration slot: a snippet, or a plain string. */
  icon: Snippet | string
  /** Whether the user has earned this achievement. */
  earned?: boolean
  /** Earned-at display: a snippet, or a plain string. */
  earnedAt?: Snippet | string
  /**
   * Label shown before `earnedAt` on earned achievements. Overrides the
   * translated / `defaultValue` `'Earned'` (prop > `t()` > default).
   */
  earnedLabel?: string
  /**
   * Label shown on locked achievements (not earned, no progress). Overrides
   * the translated / `defaultValue` `'Locked'` (prop > `t()` > default).
   */
  lockedLabel?: string
  /** Optional progress data (for in-progress achievements): the earned count out of a maximum. */
  progress?: { value: number; max: number }
  /** Optional rarity / tier label ("Legendary", "Common"): a snippet, or a plain string. */
  tier?: Snippet | string
  /** Extra classes. */
  className?: string
}

Constants

AchievementCard

const AchievementCard: LegacyComponentType

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-i18n ^1.0.1
  • @molecule/app-svelte ^3.13.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-svelte ^1.1.0
  • svelte ^5.0.0

Runtime Dependencies

  • @molecule/app-i18n
  • @molecule/app-svelte
  • @molecule/app-ui
  • @molecule/app-ui-svelte
  • svelte

The "Earned"/"Locked" state labels flow through t() with English defaultValue fallbacks under the achievementCard.* keys, so the @molecule/app-locales-achievement-card companion bond (or the host app's own locale) can translate them. Each is also overridable per-instance via the earnedLabel / lockedLabel props (prop > t() > default). The labels are read through useTranslation(), so they follow a locale switch. Node-valued props (name, description, icon, earnedAt, tier) are snippet props.

Translations

Translation strings are provided by @molecule/app-locales-achievement-card.