@molecule/app-achievement-card-vue
Feature · achievement-card · App (browser) · v1.1.2 · Apache-2.0
Badge / achievement unlock card with icon + name + description + earned-at
npm install @molecule/app-achievement-card-vueHow it works
@molecule/app-achievement-card-vue 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.
import { createApp, defineComponent, h } from 'vue'
import { AchievementCard } from '@molecule/app-achievement-card-vue'
const App = defineComponent({
setup() {
return () =>
h(
AchievementCard,
{
name: 'First Login',
description: 'Signed in for the first time.',
earned: true,
earnedAt: 'Jan 3, 2025',
tier: 'Common',
},
{ icon: () => [h('span', null, '🏆')] },
)
},
})
createApp(App).mount('#app')Works with: @molecule/app-i18n, @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue
Reference
Vue badge / achievement unlock card.
Exports <AchievementCard> — the Vue counterpart of
@molecule/app-achievement-card-react with the same props (React names),
the same ClassMap tokens and the same DOM for the same input. 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.tsJSDoc, not this file.
Quick Start
import { createApp, defineComponent, h } from 'vue'
import { AchievementCard } from '@molecule/app-achievement-card-vue'
const App = defineComponent({
setup() {
return () =>
h(
AchievementCard,
{
name: 'First Login',
description: 'Signed in for the first time.',
earned: true,
earnedAt: 'Jan 3, 2025',
tier: 'Common',
},
{ icon: () => [h('span', null, '🏆')] },
)
},
})
createApp(App).mount('#app')
Type
feature
Installation
npm install @molecule/app-achievement-card-vue @molecule/app-i18n @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
API
Interfaces
AchievementCardProps
Props accepted by the AchievementCard component.
interface AchievementCardProps {
/**
* Achievement name (a node, also accepted as the same-named slot). Required
* by the component: one of the prop and the slot must carry it.
*/
name?: VNodeChild
/** Description / what it took to earn (a node, or its same-named slot). */
description?: VNodeChild
/**
* Icon / illustration slot (a node, or its same-named slot). Required by the
* component: one of the prop and the slot must carry it.
*/
icon?: VNodeChild
/** Whether the user has earned this achievement. */
earned?: boolean
/** Earned-at display (a node, or its same-named slot). */
earnedAt?: VNodeChild
/**
* 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 node or its same-named slot. */
tier?: VNodeChild
/** Extra classes. */
className?: string
}
Constants
AchievementCard
Badge / achievement unlock card — icon + name + description + earned state. Locked achievements render greyed-out.
const AchievementCard: DefineComponent<
ExtractPropTypes<{
name: null
description: null
icon: null
earned: { type: BooleanConstructor; default: boolean }
earnedAt: null
earnedLabel: StringConstructor
lockedLabel: StringConstructor
progress: { type: PropType<AchievementCardProps['progress']> }
tier: null
className: StringConstructor
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
name: null
description: null
icon: null
earned: { type: BooleanConstructor; default: boolean }
earnedAt: null
earnedLabel: StringConstructor
lockedLabel: StringConstructor
progress: { type: PropType<AchievementCardProps['progress']> }
tier: null
className: StringConstructor
}>
> &
Readonly<{}>,
{ earned: boolean },
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeAchievementCardProps).
Returns: The achievement card component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-i18n^1.0.1@molecule/app-ui^1.0.1@molecule/app-ui-vue^1.1.0@molecule/app-vue^3.13.0 || ^4.0.0vue^3.4.0
Runtime Dependencies
@molecule/app-i18n@molecule/app-ui@molecule/app-ui-vue@molecule/app-vuevue
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) arrive
as a prop AND a same-named slot; components accept either.
Translations
Translation strings are provided by @molecule/app-locales-achievement-card.