Item stats
componentThe Destiny stat block: an aligned grid of right-labeled stat rows.
Install
npx shadcn@latest add @engram/item-statsRegistry item: /r/item-stats.json — the machine-readable definition agents install from.
Example
Blast Radius
100Velocity
95Stability
28Handling
90Reload Speed
75Rounds Per Minute72Magazine1
Bungie API
source the propsFetch the data with @engram/api (a typed bungie-api-ts client) and map it to this component's props with @engram/core. This is the exact code the docs' live examples run.
/** Resolve a Bungie name → membership, then fetch that profile. Returns a
* bungie-api-ts DestinyProfileResponse. */
export async function fetchProfile(
client: BungieClient,
bungieName: string,
components: DestinyComponentType[] = PROFILE_COMPONENTS,
): Promise<DestinyProfileResponse> {
const memberships = await client.searchByBungieName(bungieName);
const membership = memberships.find((m) => m.membershipId) ?? memberships[0];
if (!membership) throw new Error(`No Destiny profile for "${bungieName}"`);
return client.getProfile(
membership.membershipType,
membership.membershipId,
components,
);
}
export function resolveEquipped(
profile: DestinyProfileResponse,
characterId: string,
getDef: GetDefinition,
): ResolvedItem[] {
const equip = profile.characterEquipment?.data?.[characterId]?.items ?? [];
const instances = profile.itemComponents?.instances?.data ?? {};
const stats = profile.itemComponents?.stats?.data ?? {};
const sockets = profile.itemComponents?.sockets?.data ?? {};
const reusable = profile.itemComponents?.reusablePlugs?.data ?? {};
return equip
.map((it) => {
const id = it.itemInstanceId;
return resolveItem(
it,
{
instance: id ? instances[id] : undefined,
stats: id ? stats[id]?.stats : undefined,
sockets: id ? sockets[id]?.sockets : undefined,
reusablePlugs: id ? reusable[id]?.plugs : undefined,
},
getDef,
);
})
.filter((r): r is ResolvedItem => r !== null);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | — |
color | string | BAR_COLOR | Bar fill color (any CSS color / token var). |
stats* | StatProps[] | — | — |
total | number | — | Show a summed "Total" row beneath the stats (armor). |
Composition
pulled in on install- item-statscomponent
- segmented-baratom
Dependencies
npm@engram/core
Own the code: shadcn add copies this component's source into your repo to read and edit directly. Extend without forking — edit the source, use asChild to swap the element, or pass the typed annotations prop for curated data.