Skip to Content
BBRICKSv0.7.4
BlocksMotivation

GiftStockList

The Gifts tab's stock card: picked of total, "Choose gift products", and one row per product (picture, how many are left, progress, In stock / No gifts left). A row opens the gift drawer.

import { GiftStockList } from '@ergasti/bricks';

Examples

Gift stock

Each gift with how many are picked of how many, a progress bar and an "out" state at 100%. Loading, error and empty come with their own props.

Code
import { GiftStockList } from '@ergasti/bricks';
import { blocksData } from './sample-data';

function Stock() {
  return (
    <div style={{ display: 'grid', gap: 16, maxWidth: 560 }}>
      <GiftStockList title="Winter glow launch" items={blocksData.GIFT_STOCK} onOpen={() => {}} onChoose={() => {}} />
      <GiftStockList title="Loading" items={[]} status="loading" />
      <GiftStockList title="Error" items={[]} status="error" error="We could not load the gifts." onRetry={() => {}} />
      <GiftStockList title="Empty" items={[]} onChoose={() => {}} />
    </div>
  );
}

Thumbnail tones from the catalogue

seed on an item picks its thumbnail's tone (use the product's own index so the same product keeps its colour across screens); without it the row's position is used.

Code
import { GiftStockList } from '@ergasti/bricks';
import { blocksData } from './sample-data';

function Seeded() {
  return (
    <div style={{ maxWidth: 560 }}>
      <GiftStockList title="Winter glow launch" items={blocksData.GIFT_STOCK.map((g, i) => ({ ...g, seed: i + 1 }))} onOpen={() => {}} />
    </div>
  );
}

Props

Prop

Type

Labels

Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key giftStockList, or with the component's own prop where it has one. A {name} is a value the component fills in.

giftStockList
KeyEnglishArabic
picked{p} / {t} pickedاتاخد {p} من {t}
left{l} of {t} leftفاضل {l} من {t}
inStockIn stockمتوفر
noneLeftNo gifts leftالهدايا خلصت
chooseChoose gift productsاختار منتجات الهدايا
listGift stockمخزون الهدايا
emptyNo gift products chosen yet.لسه مختارتش منتجات هدايا.

Design guidance

How the BRICKS design system uses GiftStockList. Written in docs/content/components/GiftStockList.md; the props above are read from the code, which wins where the two disagree.

The Gifts tab's stock card: "Gift stock · <challenge>" with picked of total, "Choose gift products", and one row per product (picture, how many are left, progress, In stock / No gifts left); a row opens the gift drawer.

It is the mock's gift stock .rows card on Brand › Motivation › Gifts. Stock is kept by TRNDR; the brand sees what creators picked and can change which products are offered. It has the block states (loading, error + Try again, "No gift products chosen yet.").

Anatomy

  1. Card: Card with header title, sub "83 / 115 picked" (ready and non-empty) and ink "Choose gift products" (with onChoose).
  2. List: ul named "Gift stock"; each row (.kit-blk-rowi, a button when onOpen):
    1. ProductThumb 44px (tone from seed or index);
    2. ProgressRow: bold name + muted "· 16 of 50 left", picked of total;
    3. Pill: ok "In stock" or bad "No gifts left".
  3. States: skeleton rows, error box, empty line.

Variants

SetupWhen
onChooseBrand may edit the gift list.
onOpenRows open the gift drawer.

States

StateTrigger
In stock / none lefttotal - picked > 0 or 0.
Loadingstatus="loading".
Errorstatus="error".
Emptyitems=[].

Types

GiftStockItem (items): { id, name, imageUrl?, picked, total, seed? }.

Usage

// Brand › Motivation › Gifts
<Banner tone="info" icon="gift">Gift stock is kept by TRNDR. You choose which products creators can pick; we ship them. Delivery addresses are never shown here.</Banner>
<StatGrid columns={5}>{giftKpis.map((k) => <KpiCard key={k.key} tone={k.tone} icon={k.icon} label={k.label} value={k.value} />)}</StatGrid>
<div style={{ display: 'grid', gap: 16, gridTemplateColumns: '1fr 1fr' }}>
  <GiftStockList title="Gift stock · Winter glow" onChoose={() => setModal('gifts')} onOpen={openGift}
    items={[
      { id: 1, name: 'Red lipstick', picked: 34, total: 50 },
      { id: 2, name: 'Lash mascara', picked: 22, total: 30 },
      { id: 4, name: 'Face powder', picked: 15, total: 15 },
    ]} />
  <GiftRulesCard readOnly value={rules} />
</div>

Where it appears

  • Brand › Motivation › Gifts › gift stock card (BrandMotivation).

Guidelines

Do

  • Keep the server's order (most picked first works well).

Don't

  • Don't compute stock on the client beyond total - picked; send both.

RTL and Arabic

  • Mirrors; progress fills from the right. Arabic: "فاضل 16 من 50", "متوفر", "الهدايا خلصت", "اختار منتجات الهدايا".

Tokens

Card tokens, ProgressRow pips (--rasp on --track), Pill ok / bad, --line, --ink-3.

Accessibility

  • A named list; openable rows are buttons; status is in words ("No gifts left"), not only colour.

Found in the source

  • ARIA attributes set: aria-label.

Read from the component's source and tests. See Accessibility for the patterns the library follows.

See also: Card · Button · Pill · ProductThumb · ProgressRow · useLanguage · BonusCard · BonusDetail · ChallengeCard · ChallengeDetail

Source

src/blocks/motivation/GiftStockList.tsx (line 57) on GitHub.

On this page