Skip to Content
BBRICKSv0.7.4
BlocksMotivation

BonusDetail

The bonus drawer's body: the tinted head, everyone's progress (each row opens the creator), "Open the challenge".

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

Examples

Bonus cards

A threshold bonus ("reach 20 orders → EGP 500") with the creators closest to it; the whole card opens the detail.

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

function Cards() {
  const language = useLanguage();
  return (
    <div style={{ display: 'grid', gap: 16, gridTemplateColumns: 'repeat(auto-fit, minmax(320px, 1fr))' }}>
      {blocksData.BONUSES.map((b) => <BonusCard key={b.title} title={b.title} rule={b.rule[language]} tone={b.tone} progress={b.progress} onOpen={() => {}} />)}
    </div>
  );
}

Bonus detail

Everyone's progress toward the goal, with links to the creator and to the challenge.

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

function Detail() {
  const language = useLanguage();
  const b = blocksData.BONUSES[0];
  return <div style={{ maxWidth: 400 }}><BonusDetail title={b.title} rule={b.rule[language]} tone="rasp" progress={b.progress} onOpenCreator={() => {}} onOpenChallenge={() => {}} /></div>;
}

Fewer rows, and nobody started

rows sets how many of the closest creators the card shows (default 4); with an empty progress the card says nobody has started yet.

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

function RowsAndEmpty() {
  const language = useLanguage();
  const b = blocksData.BONUSES[0];
  return (
    <div style={{ display: 'grid', gap: 16, gridTemplateColumns: 'repeat(auto-fit, minmax(320px, 1fr))' }}>
      <BonusCard title={b.title} rule={b.rule[language]} tone={b.tone} progress={b.progress} rows={2} onOpen={() => {}} />
      <BonusCard title="Back to campus · 30 orders" rule={b.rule[language]} tone="lime" progress={[]} onOpen={() => {}} />
    </div>
  );
}

A money goal, done by the server

For a sales bonus, display on each progress row shows formatted money in place of "value / goal", and done (from the server) adds "· Done" even when the rounded value is under the goal. Leave both out for a count goal: the card then shows "9 / 20" and works out Done itself.

Code
import { BonusCard, Money, useLanguage } from '@ergasti/bricks';

function MoneyGoal() {
  const language = useLanguage();
  const goal = '5000.00';
  const rows = [
    { id: 9, name: 'Tarek Fathy', sales: '5000.00', done: true },
    { id: 2, name: 'Salma Hosny', sales: '3420.50', done: false },
    { id: 4, name: 'Karim Hosny', sales: '1234.00', done: false },
  ];
  const progress = rows.map((r) => ({ id: r.id, name: r.name, value: Math.floor(Number(r.sales)), goal: Number(goal), done: r.done,
    display: <><Money value={r.sales} /> / <Money value={goal} /></> }));
  return (
    <div style={{ maxWidth: 420 }}>
      <BonusCard title={language === 'ar' ? 'جلو الشتا · مبيعات 5,000 ج.م' : 'Winter glow · EGP 5,000 in sales'} rule={language === 'ar' ? 'بيع بـ 5,000 ج.م في التحدي ← مكافأة 500 ج.م' : 'Sell EGP 5,000 in the challenge → EGP 500 bonus'}
        tone="lime" progress={progress} 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 bonusCard, or with the component's own prop where it has one. A {name} is a value the component fills in.

bonusCard
KeyEnglishArabic
openOpen for everyone’s progress →افتح عشان تشوف تقدّم الكل ←
everyoneEveryone’s progressتقدّم الكل
openChallengeOpen the challengeافتح التحدي
emptyNobody has started yet.لسه محدش بدأ.

Design guidance

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

The bonus drawer's body: the tinted head with the bonus and its rule, everyone's progress (each row opens the creator) and "Open the challenge"; open it from a BonusCard.

It is the mock's openBonus() drawer on Brand › Motivation › Bonuses. Unlike the card it lists every creator, not only the closest few.

Anatomy

  1. Head: DrawerHead in tone, title and rule.
  2. Heading: h3 "Everyone's progress".
  3. List: ul named "Everyone's progress", a ProgressRow (lime pips) per creator, wrapped in a button when onOpenCreator.
  4. Empty: "Nobody has started yet."
  5. Action: "Open the challenge" (when onOpenChallenge).

Variants

PropValuesWhen
toneBlockToneMatch the card.
onOpenCreatorset / unsetRows as buttons or plain.

States

StateTrigger
With creatorsprogress non-empty.
No creatorsprogress=[]: empty line.
Done rowsdone or value ≥ goal.

Usage

<Drawer open={!!bonus} onClose={close} title={bonus.title} hideTitle>
  <BonusDetail title={bonus.title} rule={bonus.rule[language]} tone={bonus.tone} progress={bonus.progress}
    onOpenCreator={openCreator} onOpenChallenge={() => openChallenge(bonus.challengeId)} />
</Drawer>

Where it appears

  • Brand › Motivation › Bonuses › bonus drawer (openBonus()) (BrandMotivation).

Guidelines

Do

  • Keep the order the server sends (closest first).

Don't

  • Don't page it inside the drawer for small programs; long lists scroll in the drawer.

RTL and Arabic

  • Mirrors. Arabic: "تقدّم الكل", "افتح التحدي", "لسه محدش بدأ."

Tokens

DrawerHead tone pairs, --ink-3 (empty line), ProgressRow lime pips (--chart-lime on --track).

Accessibility

  • Structure: the DrawerHead title, an h3 "Everyone's progress", then a <ul> named "Everyone's progress".
  • With onOpenCreator, each row is a <button> whose name is the row's text: "Tarek Fathy", then the pips read as one image ("Tarek Fathy: 9 of 20"), then "9 / 20" and "· Done" when reached. Without it the rows are plain list items.
  • Keyboard: Tab moves through the creator buttons in list order, then "Open the challenge"; Enter or Space opens. Focus shows the kit ring (--focus-ring) on the row.
  • Empty: "Nobody has started yet." as text.
  • Nothing is announced when the list changes; it lives in a drawer, which moves focus in on open and back on close (Drawer).
  • Contrast: lime pips (--chart-lime on --track, 1.7:1) are below 3:1, which is why the figure is always repeated as text next to them.

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: Button · DrawerHead · ProgressRow · useLanguage · Money · ChallengeCard · ChallengeRequestForm

Source

src/blocks/motivation/BonusDetail.tsx (line 25) on GitHub.

On this page