The provider and presets
BricksProvider, trndrPreset, CORE_PRESET, statuses, tiers, currency and statusTables.
BricksProvider gives every component below it (kit, shell, blocks and PR blocks, and the data hooks' DataProvider) one resolved configuration. The component page, with its props table and examples, is BricksProvider.
What it holds
| Prop | What it does |
|---|---|
preset | The starting point: the generic core with this preset laid over it. Without one, the provider extends the config above it (another provider's, or the built-in default). |
language | 'en' or 'ar' for every component without its own language. |
statuses | { key: { tone, en, ar } }, added to or replacing the preset's. StatusPill reads it. |
tiers, defaultTier | { key: { en, ar, bg?, ink? } }. TierChip and TierBadge read it; without bg and ink the --tier-<key>-bg and --tier-<key>-ink tokens colour the chip. defaultTier is shown for a creator with no tier. |
currency | { code, label: { en, ar }, format? }. Money, MoneyFigure, MoneyNote amounts and HeroCard read it. format replaces the formatter. |
money, moneyFor | How money figures are shown: money for every figure, moneyFor for single slots ({ 'walletLedger.entry': { showCurrency: true } }). A component's own money prop wins. See Money display. |
moneyNoteStyle | How a MoneyNote that wraps a label is drawn for the subtree: 'term' (default), 'plain' or 'icon'. |
moneyNotes | The money "?" dictionary. A MoneyNotesProvider below it still wins. |
labels | Words per component and language, for kit and package components alike. See Words and labels. |
platforms | The platforms the app works with (default all three: ['instagram', 'tiktok', 'youtube']; they are always drawn in that order). Follower totals and glyphs (FollowersCell, PlatformFollowers, the creator cards and drawers) and ChallengeRequestForm's platform options use only these, so platforms={['instagram', 'tiktok']} takes YouTube out of every component below; a request form opened on an old YouTube request shows and sends "Any platform". Replaces the parent's list. followerTotal(followers, platforms) sums the same way. |
statusTables | Named status tables a package reads apart from statuses: pr (PrStatusPill) and prAudit (AuditAreaPill). |
The other props override the preset: statuses and tiers add or replace keys, currency and moneyNotes replace, labels merge per component and language, money and moneyFor merge field by field. A component's own language prop still wins over the provider's.
No provider
With no provider, every component draws the TRNDR preset in English (DEFAULT_CONFIG). This is what 0.1.0 drew, so code written for it keeps its output. <BricksProvider preset={trndrPreset}> draws the same markup.
CORE_PRESET and trndrPreset
CORE_PRESET is the generic core: English, no statuses, no tiers, no currency word, the kit's words. trndrPreset is the TRNDR brand console: its status words and tones, its creator tiers, the Egyptian pound, its coupon and score wording, and the PR portal's status tables. A preset is a plain object (BricksPreset); build your own the same way:
One preset or another
The same components under the TRNDR preset and under a preset of your own: no component has a language, currency or labels prop here, the provider supplies them. Nested providers extend the one above; a preset starts again from the generic core.
Code
import { BricksProvider, Money, ScoreRing, StatusPill, TierChip, trndrPreset, type BricksPreset } from '@ergasti/bricks';
const acme: BricksPreset = {
statuses: { open: { tone: 'sky', en: 'Open', ar: 'مفتوح' }, closed: { tone: 'mute', en: 'Closed', ar: 'مقفول' } },
tiers: { gold: { en: 'Gold', ar: 'ذهبي', bg: '#FFF0C9', ink: '#8A5A00' }, silver: { en: 'Silver', ar: 'فضي', bg: '#E6E8EE', ink: '#4A4D57' } },
defaultTier: 'silver',
currency: { code: 'SAR', label: { en: 'SAR', ar: 'ر.س' } },
labels: { scoreRing: { en: { label: 'Acme score', title: (n) => `Acme score ${n} / 100` }, ar: { label: 'تقييم أكمي', title: (n) => `تقييم أكمي: ${n} من 100` } } },
};
function Presets() {
return (
<div style={{ display: 'grid', gap: 16 }}>
<BricksProvider preset={trndrPreset}>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 12, alignItems: 'center' }}>
<b>trndrPreset</b>
<StatusPill status="paid" />
<TierChip tier="elite" />
<Money value="1500.50" />
<ScoreRing value={74} />
</div>
</BricksProvider>
<BricksProvider preset={acme}>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 12, alignItems: 'center' }}>
<b>Acme</b>
<StatusPill status="open" />
<TierChip tier="gold" />
<Money value="1500.50" />
<ScoreRing value={74} />
</div>
</BricksProvider>
</div>
);
}CORE_PRESET
constant
The generic core: English, no statuses or tiers, no currency word, the kit's words, each money slot's default.
const CORE_PRESET: Required<Omit<BricksPreset, "labels">>Source: src/lib/config.ts (line 107)
trndrPreset
constant
<BricksProvider preset={trndrPreset}>: the brand console as 0.1.0 drew it, plus the PR portal's status tables (statusTables.pr, statusTables.prAudit; their keys mean other states than the console's statuses, so they are separate tables, not merged into statuses).
const trndrPreset: BricksPresetSource: src/preset/trndr.ts (line 153)
TRNDR_STATUSES
constant
Every status word a console list shows, with the mock's own tone (its pillFor map) and EN / AR label. One table, so the same state reads the same on every screen.
const TRNDR_STATUSES: { readonly active: { readonly tone: "ok"; readonly en: "Active"; readonly ar: "نشط"; }; readonly live: { readonly tone: "ok"; readonly en: "Live"; readonly ar: "شغّال"; }; readonly accepted: { readonly tone: "ok"; readonly en: "Accepted"; readonly ar: "اتقبلت"; }; readonly approved: { readonly tone: "ok"; readonly en: "Approved"; readonly ar: "اتوافق عليه"; }; readonly paid: { readonly tone: "ok"; readonly en: "Paid"; readonly ar: "اتدفع"; }; readonly delivered: { readonly tone: "ok"; readonly en: "Delivered"; readonly ar: "اتسلّم"; }; readonly paused: { readonly tone: "warn"; readonly en: "Pa …Source: src/preset/trndr.ts (line 15)
TRNDR_TIERS
constant
CreatorPulseScore::TIERS, named as affiliate.pulse.tier.* names them. Colours are the theme's --tier-<key>-* tokens (tokens.css: Rising lime, Established sky, Elite gold, Influential teal).
const TRNDR_TIERS: { readonly rising: { readonly en: "Rising"; readonly ar: "صاعد"; }; readonly established: { readonly en: "Established"; readonly ar: "متمكن"; }; readonly influential: { readonly en: "Influential"; readonly ar: "مؤثر"; }; readonly elite: { readonly en: "Elite"; readonly ar: "نخبة"; }; }Source: src/preset/trndr.ts (line 44)
TRNDR_CURRENCY
constant
The Egyptian pound: "EGP 1,234.50" in English, "1,234.50 ج.م" in Arabic.
const TRNDR_CURRENCY: { readonly code: "EGP"; readonly label: { readonly en: "EGP"; readonly ar: "ج.م"; }; }Source: src/preset/trndr.ts (line 52)
TRNDR_LABELS
constant
TRNDR's own words in the kit: the coupon chip, the TRNDR score ring, settings TRNDR manages.
const TRNDR_LABELS: { readonly couponChip: { readonly en: { readonly copy: (code: string) => string; readonly done: "Copied"; readonly failed: "Couldn't copy"; }; readonly ar: { readonly copy: (code: string) => string; readonly done: "اتنسخ"; readonly failed: "معرفناش ننسخ"; }; }; readonly scoreRing: { readonly en: { readonly label: "TRNDR score"; readonly title: (n: number) => string; }; readonly ar: { readonly label: "تقييم TRNDR"; readonly title: (n: number) => string; }; }; readonly keyValue: { readonly en: { readonly locked: "🔒 Managed by TRNDR"; }; readonly ar: { readonly locked: "🔒 بيديرها فريق TRNDR"; } …Source: src/preset/trndr.ts (line 55)
Statuses and tiers
StatusPill shows one word with a tone for a status key. A key the table does not have is drawn as the raw key in the mute tone, and one console warning is logged for it, so extend the table before you use a new key:
Add your own statuses
statuses adds to or replaces the preset's table.
Code
import { BricksProvider, StatusPill, trndrPreset } from '@ergasti/bricks';
function Statuses() {
return (
<BricksProvider preset={trndrPreset} statuses={{ scheduled: { tone: 'lilac', en: 'Scheduled', ar: 'متجدول' }, paid: { tone: 'lime', en: 'Settled', ar: 'اتسوّى' } }}>
<div style={{ display: 'flex', gap: 8 }}>
<StatusPill status="scheduled" />
<StatusPill status="paid" />
<StatusPill status="live" />
</div>
</BricksProvider>
);
}The PR portal keeps its own tables, because its keys mean other states than the console's (paused, live and paid appear in both):
TRNDR_PR_STATUSES
constant
The PR portal's status words (PrStatusPill reads them as statusTables.pr): every status word the PR portal shows, with the PR mock's tone and EN / AR label: programs, challenges, requests, creators, join sources, payouts, receipts and wallet top-ups. One table, so a state reads the same on every screen.
const TRNDR_PR_STATUSES: { readonly active: { readonly tone: "ok"; readonly en: "Active"; readonly ar: "شغّال"; }; readonly paused: { readonly tone: "mute"; readonly en: "Paused"; readonly ar: "متوقف"; }; readonly live: { readonly tone: "ok"; readonly en: "Live"; readonly ar: "شغّال دلوقتي"; }; readonly upcoming: { readonly tone: "sky"; readonly en: "Upcoming"; readonly ar: "جاي"; }; readonly settling: { readonly tone: "warn"; readonly en: "Settling"; readonly ar: "بيتقفل"; }; readonly ended: { readonly tone: "mute"; readonly en: "Ended"; readonly ar: "خلص"; }; readonly needs_review: { readonly tone: "warn"; readonly …Source: src/preset/trndr.ts (line 74)
TRNDR_AUDIT_AREAS
constant
The PR portal's audit areas (the PR mock's Activity log AREA) with their pill tones: AuditAreaPill reads them as statusTables.prAudit; an app adds its own there.
const TRNDR_AUDIT_AREAS: { readonly approvals: { readonly tone: "ok"; readonly en: "Approvals"; readonly ar: "الموافقات"; }; readonly programs: { readonly tone: "bad"; readonly en: "Programs"; readonly ar: "البرامج"; }; readonly challenges: { readonly tone: "warn"; readonly en: "Challenges"; readonly ar: "التحديات"; }; readonly tiers: { readonly tone: "lilac"; readonly en: "Tiers"; readonly ar: "المستويات"; }; readonly messages: { readonly tone: "lilac"; readonly en: "Messages"; readonly ar: "الرسايل"; }; readonly owners: { readonly tone: "sky"; readonly en: "Owners"; readonly ar: "المسؤولين"; }; readonly payouts: { r …Source: src/preset/trndr.ts (line 135)
Currency
The currency word is placed before the figure in English and after it in Arabic ("EGP 1,234.50", "1,234.50 ج.م"). Money, formatMoney and amountInText take the provider's currency; formatMoney(value, { language, currency }) takes a one-off word.
CURRENCY is deprecated since 0.2.0 and removed in 1.0: read TRNDR_CURRENCY.label, or set the provider's currency.
CURRENCY
constant
deprecated
Deprecated
Since 0.2.0: use TRNDR_CURRENCY.label or the BricksProvider's currency. Removed in 1.0.
The currency word: before the figure in English, after it in Arabic (formatMoney's order). The TRNDR preset's (EGP); a BricksProvider currency gives components another one.
const CURRENCY: Readonly<Record<Lang, string>>Source: src/lib/format.ts (line 16)
Reading the configuration
useBricks() returns the resolved configuration (language, statuses, tiers, defaultTier, currency, moneyNotes, labels, packageLabels, statusTables, money, moneyFor and formatMoney); useLanguage() returns the language alone.
Read the resolved configuration
useBricks() returns what the nearest BricksProvider resolved (the built-in TRNDR default without one); useLanguage() is the language alone, and takes a component's own prop first. The two probes below are under the docs frame's preset and under a plain trndrPreset in Arabic.
Code
import { BricksProvider, trndrPreset, useBricks, useLanguage } from '@ergasti/bricks';
function Probe() {
const config = useBricks();
const language = useLanguage();
return (
<ul>
<li>language: <b>{language}</b></li>
<li>currency: <b>{config.currency.code || '(none)'}</b></li>
<li>statuses: <b>{Object.keys(config.statuses).length}</b>, tiers: <b>{Object.keys(config.tiers).length}</b></li>
<li>formatMoney: <b>{config.formatMoney('1234.5', { language })}</b></li>
</ul>
);
}
function Config() {
return (
<div style={{ display: 'grid', gap: 12 }}>
<Probe />
<BricksProvider preset={trndrPreset} language="ar"><Probe /></BricksProvider>
</div>
);
}