WalletHealthCard
The Wallet tab's "Wallet health" card: a warning while the wallet is low or below zero, how much of the last top-up is left (pips of 25), and the three thresholds in words.
import { WalletHealthCard } from '@ergasti/bricks';Examples
Wallet health
Four states from the same data: ok and low are worked out from leftPercent (low at or under lowPercent; pass the program's own line, as there is no default); negative and paused come from the server and are passed as health.
Code
import { WalletHealthCard } from '@ergasti/bricks';
function States() {
return (
<div style={{ display: 'grid', gap: 16, gridTemplateColumns: 'repeat(auto-fit, minmax(280px, 1fr))' }}>
<WalletHealthCard lowPercent={20} pauseDays={7} leftPercent={62} lastTopup="250000.00" onOpenSettings={() => {}} />
<WalletHealthCard lowPercent={20} pauseDays={7} leftPercent={17} lastTopup="250000.00" onOpenSettings={() => {}} />
<WalletHealthCard lowPercent={20} leftPercent={0} lastTopup="250000.00" health="negative" pauseDays={7} />
<WalletHealthCard lowPercent={20} pauseDays={7} leftPercent={null} lastTopup={null} health="paused" />
</div>
);
}Your own low line
lowPercent moves the line at which the wallet counts as low (here 30%, so 25% left is low).
Code
import { WalletHealthCard } from '@ergasti/bricks';
function LowLine() {
return <div style={{ maxWidth: 320 }}><WalletHealthCard leftPercent={25} lastTopup="100000.00" lowPercent={30} /></div>;
}Without the thresholds, and settings as a link
Since 0.5.0, a card without lowPercent and pauseDays draws no legend for them, no day count in the banners, and never calls the wallet low by itself: pass health from the server. settingsHref makes "Wallet settings" a link to that page (through safeHref); use onOpenSettings instead when settings open in a drawer.
Code
import { WalletHealthCard } from '@ergasti/bricks';
function NoThresholdsAndLink() {
return (
<div style={{ display: 'grid', gap: 16, gridTemplateColumns: 'repeat(auto-fit, minmax(280px, 1fr))' }}>
<WalletHealthCard leftPercent={17} lastTopup="250000.00" health="low" settingsHref="/wallet/settings" />
<WalletHealthCard leftPercent={0} lastTopup="250000.00" health="negative" settingsHref="/wallet/settings" />
</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 walletHealthCard, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
title | Wallet health | صحة المحفظة |
settings | Wallet settings | إعدادات المحفظة |
lowLead | Low: | قليل: |
low | {p}% of your last top-up is left. If it stays below zero for {d} days, your coupons pause until you top up. | فاضل {p}% من آخر شحنة. لو الرصيد فضل تحت الصفر {d} يوماً، الكوبونات هتقف لحد ما تشحن. |
negativeLead | Below zero: | تحت الصفر: |
negative | Your wallet is below zero. If it stays there for {d} days, your coupons pause until you top up. | محفظتك تحت الصفر. لو فضلت كده {d} يوماً، الكوبونات هتقف لحد ما تشحن. |
pausedLead | Paused: | متوقفة: |
paused | Your wallet stayed below zero, so your coupons are paused until you top up. | محفظتك فضلت تحت الصفر، فالكوبونات واقفة لحد ما تشحن. |
leftOf | Left of your last top-up | الفاضل من آخر شحنة |
percentOf | {p}% of | {p}% من |
noTopup | No top-up yet | لسه مفيش شحن |
legendOk | OK above {l}% | تمام فوق {l}% |
legendLow | Low ≤ {l}% | قليل ≤ {l}% |
legendPaused | Paused after {d} days below zero | بتقف بعد {d} يوماً تحت الصفر |
Design guidance
How the BRICKS design system uses WalletHealthCard. Written in docs/content/components/WalletHealthCard.md; the props above are read from the code, which wins where the two disagree.
The Wallet tab's "Wallet health" card: a warning while the wallet is low, below zero or paused, how much of the last top-up is left as 25 pips, and the program's thresholds in words; use it beside the wallet balance hero on the Payments › Wallet tab.
It is the mock's wallet-tab .card.s5. The server computes the figures (share left, last top-up, and ideally the verdict); the card only words them. Without health it calls the wallet low when leftPercent is at or under lowPercent; it never guesses "below zero" or "paused".
Anatomy
- Card header: "Wallet health" and, on the end side, a small "Wallet settings" button (
onOpenSettings) or link (settingsHref). - Banner (only when not OK): kit
Bannerwith a bold lead ("Low:", "Below zero:", "Paused:") and the consequence sentence. - Progress head (
.kit-blk-prog-h): "Left of your last top-up" and, on the end side, "17% of EGP 250,000.00" (a plainMoneyNoteon figurewallet_left_percent), or "No top-up yet". - Pips: 25 cells, each 4%, filled to the share left; named "Left of your last top-up: 17%".
- Legend (
.kit-legend, optional): "OK above 20%", "Low ≤ 20%", "Paused after 7 days below zero".
Variants
health (or derived) | Banner | Use when |
|---|---|---|
'ok' | none | Share left above the low line (or no lowPercent). |
'low' | warn (amber), alert icon: "Low: 17% of your last top-up is left. If it stays below zero for 7 days, your coupons pause until you top up." | Share at or under the low line. Derived when lowPercent is passed. |
'negative' | bad (red), alert icon: "Below zero: Your wallet is below zero…" | Server says the balance is negative. Pass it. |
'paused' | bad (red), pause icon: "Paused: Your wallet stayed below zero, so your coupons are paused until you top up." | Server paused coupons. Pass it. |
| Prop | Effect |
|---|---|
lowPercent | Adds the OK / Low legend items and enables the derived low verdict. |
pauseDays | Adds the Paused legend item and the day count in the low / below-zero sentences. |
settingsHref vs onOpenSettings | Link (navigation) vs button (opens a drawer). Neither: no header action. |
States
| State | How |
|---|---|
| Healthy | leftPercent above lowPercent (story Healthy). |
| Low | leftPercent ≤ lowPercent, or health="low" (story Low, the mock: 17%). |
| Below zero | health="negative" (story BelowZero). |
| Paused | health="paused". |
| No top-up yet | leftPercent={null} and lastTopup={null}: "No top-up yet", empty pips (story NoTopUp). |
| Out-of-range input | leftPercent is clamped to 0–100 and rounded for display; the low comparison uses the unrounded value (20.4 is not low at 20). |
Types
WalletHealth (health): 'ok' | 'low' | 'negative' | 'paused'.
WalletHealthCopy (labels): title, settings, the leads and sentences (lowLead, low(percent, pauseDays), negativeLead, negative(pauseDays), pausedLead, paused), leftOf, percentOf, noTopup, and the legend functions (legendOk, legendLow, legendPaused).
Usage
<WalletHealthCard
leftPercent={17}
lastTopup="250000.00"
lowPercent={20}
pauseDays={7}
onOpenSettings={() => setDrawer('wallet-settings')}
/>// Payments › Wallet tab: the balance hero and the health card side by side (`scr-grid--75` is the gallery's 7/5 grid), the ledger below
<PillTabs label="Payments" idPrefix="pay" value={tab} onChange={setTab}>…</PillTabs>
<div className="scr-grid scr-grid--75">
<HeroCard deco={false} figures={wallet} actions={<>
<Button variant="white">Top up</Button>
<Button variant="on-dark">Pay by bank transfer</Button>
</>} />
<WalletHealthCard
leftPercent={wallet.leftPercent}
lastTopup={wallet.lastTopup}
health={wallet.health} // the server's verdict: 'ok' | 'low' | 'negative' | 'paused'
lowPercent={20}
pauseDays={7}
onOpenSettings={openWalletSettings}
/>
</div>
<WalletLedger groups={groups} balance={wallet.balance} />// Before the first top-up
<WalletHealthCard leftPercent={null} lastTopup={null} lowPercent={20} pauseDays={7} />Where it appears
- Brand › Payments › Wallet tab › "Wallet health" card (
.card.s5), beside the dark balance hero, above "Where your money went". - Dashboard screen: Payments › Wallet (
gallery/screens/PaymentsWalletScreen.tsx). - The PR Portal shows a brand's wallet with
BrandWalletCardinstead.
Guidelines
Do
- Pass
healthfrom the server whenever it knows the balance is negative or coupons are paused. - Pass
lowPercentandpauseDaysfrom the program's rules so the legend and sentences say real numbers. - Use
settingsHrefwhen Wallet settings is a page,onOpenSettingswhen it is a drawer.
Don't
- Don't compute
leftPercentin the client from rounded figures. - Don't add a second warning banner above the card for the same condition.
- Don't hide the legend in the low state: it explains why the warning shows.
RTL and Arabic
- Header action, progress head and pips mirror; pips fill from the start side.
- Arabic copy: "صحة المحفظة", leads "قليل:", "تحت الصفر:", "متوقفة:"; day counts use the Arabic plural helper.
- Money follows the provider's Arabic format ("250,000.00 ج.م").
Tokens
.kit-blk-prog-h (13px), .kit-blk-prog-v (--ink-3, 12px), .kit-legend (--ink-2, 12px), plus Card, Banner (--warn*, --bad*) and Pips tokens. .kit-blk-health .kit-banner + * pulls the next row up 4px.
Accessibility
- The banner is a kit
Banner(text with a decorative icon); the lead word ("Low:") is bold so the state is said in words, not colour. - The pips have an accessible name with the value ("Left of your last top-up: 17%").
- The header action is a real
<button>or<a>, focusable, with the visible name "Wallet settings". - The legend is a
<ul>.
Found in the source
- No roles, ARIA attributes or key handling are set in this component's own source; it renders native elements and the components it composes.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
BrandWalletCard: the PR Portal's view of a brand's wallet (balance, held, top-ups).WalletLedger: where the money went.TopUpAmountPicker/TopUpResultBanner: the top-up flow the low banner leads to.UsageMeter: a plain used-of-limit meter, not money health.
See also: Card · Banner · Button · ButtonLink · MoneyNote · Money · Pips · useLanguage · useMoneyDisplay · PayoutBatchDetail · PayoutWindowCard · ReceiptCard
Source
src/blocks/payments/WalletHealthCard.tsx (line 77) on GitHub.