GiftRulesCard
The Gifts tab's "Gift rules" card: three iOS switch rows (creators can pick gifts, one gift per challenge, the gift cooldown) with their hints; the cooldown's days (1–365, "Default 90 days", "Reset to 90" when different) dim and lock while it is off. Read-only shows "🔒 Set by TRNDR" and locks every control. Changes go out through onChange.
import { GiftRulesCard } from '@ergasti/bricks';Examples
Gift rules, read-only and editable
Read-only draws the rules as facts; editable draws switches and the cooldown days, and inherited marks a rule that follows the platform default with a "Use default" button.
Code
import { useState } from 'react';
import { GiftRulesCard, type GiftRules } from '@ergasti/bricks';
function Rules() {
const [rules, setRules] = useState<GiftRules>({ pick: true, one: true, cooldown: true, days: '90' });
return (
<div style={{ display: 'grid', gap: 16, gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))' }}>
<GiftRulesCard readOnly value={{ pick: true, one: true, cooldown: true, days: '90' }} />
<GiftRulesCard value={rules} onChange={setRules} inherited={{ one: true }} onUseDefault={() => {}} />
</div>
);
}Your own house cooldown
defaultDays is the cooldown the card calls the default ("Default 30 days", "Reset to 30"); maxDays caps the days field.
Code
import { useState } from 'react';
import { GiftRulesCard, type GiftRules } from '@ergasti/bricks';
function Cooldown() {
const [rules, setRules] = useState<GiftRules>({ pick: true, one: false, cooldown: true, days: '45' });
return <div style={{ maxWidth: 420 }}><GiftRulesCard value={rules} onChange={setRules} defaultDays={30} maxDays={120} /></div>;
}The cooldown applies only while "Only the best gift per creator" is on
With bestGiftOnly={false} it is locked and says why.
Code
import { useState } from 'react';
import { GiftRulesCard, type GiftRules } from '@ergasti/bricks';
function BestGiftOff() {
const [rules, setRules] = useState<GiftRules>({ pick: true, one: true, cooldown: true, days: '90' });
return (
<div style={{ maxWidth: 420 }}>
<GiftRulesCard value={rules} onChange={setRules} bestGiftOnly={false} />
</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 giftRulesCard, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
title | Gift rules | قواعد الهدايا |
sub | What creators can pick, and how often. | صنّاع المحتوى يختاروا إيه، وكل قد إيه. |
subLocked | Set by the TRNDR team. Contact TRNDR to change them. | فريق TRNDR هو اللي بيحددها. كلّم TRNDR لو عايز تغيّرها. |
locked | 🔒 Set by TRNDR | 🔒 بيحددها TRNDR |
pick | Creators can pick gifts | صنّاع المحتوى يقدروا يختاروا هدايا |
pickHint | Off: no new product credits are sent and TRNDR assigns the gift; credits creators already hold can still be picked. | لو مقفولة، مفيش رصيد هدايا منتجات جديد بيتبعت و TRNDR بيحدد الهدية؛ صنّاع المحتوى يقدروا يختاروا بالرصيد اللي معاهم. |
one | One gift per challenge | هدية واحدة في كل تحدي |
oneHint | A creator gets and picks at most one gift in each challenge. | صانع المحتوى ياخد ويختار هدية واحدة بس في كل تحدي. |
cooldown | Gift cooldown | فترة الانتظار بين الهدايا |
cooldownTip | Days a creator waits after using one of your gifts before getting another. Applies only while “Only the best gift per creator” is on. | عدد الأيام اللي صانع المحتوى بيستناها بعد ما يستخدم هدية منك قبل ما ياخد غيرها. بتسري بس لما «أحسن هدية بس لكل صانع محتوى» تكون شغالة. |
defaultDays | Default {n} days | الافتراضي {n} يوماً |
daysLabel | Cooldown in days | فترة الانتظار بالأيام |
daysUnit | days | يوم |
reset | Reset to {n} | رجّعها {n} |
error | Cooldown must be 1 to {max} days | فترة الانتظار لازم تكون من 1 لـ {max} يوم |
following | Following the TRNDR default | ماشي على الافتراضي بتاع TRNDR |
useDefault | Use the default | ارجع للافتراضي |
cooldownNeedsBest | Turn on “Only the best gift per creator” to use a cooldown. | شغّل «أحسن هدية بس لكل صانع محتوى» عشان تستخدم فترة الانتظار. |
Design guidance
How the BRICKS design system uses GiftRulesCard. Written in docs/content/components/GiftRulesCard.md; the props above are read from the code, which wins where the two disagree.
The Gifts tab's "Gift rules" card: three iOS switch rows (creators can pick gifts, one gift per challenge, the gift cooldown with its days), read-only "Set by TRNDR" or editable; changes go out through onChange.
It is the mock's .card.ro on Brand › Motivation › Gifts, where the rules are owned by TRNDR ("🔒 Set by TRNDR", "Default 90 days", "Reset to 90"). The mock never saves them (its saveGift() is never called); this block reports every change and leaves saving to you (e.g. with a SaveBar). The console's extras: per-rule "Following the TRNDR default" / "Use the default", and bestGiftOnly={false} locking the cooldown with the reason.
Anatomy
- Card:
Cardtitled "Gift rules", sub "What creators can pick, and how often." (or "Set by the TRNDR team. Contact TRNDR to change them."); read-only adds a mute "🔒 Set by TRNDR" pill. - Rule rows (
.kit-blk-rule): bold title, muted hint, optional default note, iOSSwitchat the end:- "Creators can pick gifts";
- "One gift per challenge";
- "Gift cooldown" (dotted term with its tip): "Default 90 days", days input + "days" + "Reset to 90" when different, error line.
Variants
| Prop | Value | Look / when |
|---|---|---|
readOnly (or no onChange) | locked | Pill, locked switches and days: the v3 mock. |
| editable | onChange set | Console with editable rules. |
inherited | per rule | "Following the TRNDR default". |
onUseDefault | set | "Use the default" link on overridden rules. |
bestGiftOnly={false} | cooldown locked | "Turn on “Only the best gift per creator” to use a cooldown." |
defaultDays / maxDays | 90 / 365 | House cooldown and limit. |
States
| State | Trigger |
|---|---|
| Cooldown off | cooldown: false: row dimmed, days disabled. |
| Days ≠ default | "Reset to 90" link. |
| Invalid days | "Cooldown must be 1 to 365 days" (giftCooldownError). |
| Read-only | every control locked. |
Types
giftCooldownError(rules, language, max?, labels?) returns the error or null; validate with it before saving.
GiftRules (value): { pick, one, cooldown: boolean; days: string }.
Usage
// Brand › Motivation › Gifts (TRNDR-owned, as the mock)
<GiftRulesCard readOnly value={{ pick: true, one: true, cooldown: true, days: '90' }} />// Editable, with a save bar
const [draft, setDraft] = useState(saved);
<SaveBar dirty={!isEqual(draft, saved)} saveDisabled={giftCooldownError(draft, 'en') !== null}
onSave={() => save(draft)} onDiscard={() => setDraft(saved)} />
<GiftRulesCard value={draft} onChange={setDraft} inherited={{ one: true }} onUseDefault={useDefault} />Where it appears
- Brand › Motivation › Gifts › Gift rules card (BrandMotivation).
Guidelines
Do
- Keep it read-only where TRNDR owns the rules; say who to contact.
Don't
- Don't save on every toggle without telling the user; use a
SaveBaror a toast.
RTL and Arabic
- Mirrors; switch knobs travel the other way; days LTR. Arabic: "قواعد الهدايا", "🔒 بيحددها TRNDR", "رجّعها 90".
Tokens
Card tokens, Switch iOS tokens (--ok), --ink-3, --bad, --line.
Accessibility
- Switches are named by their row titles; the cooldown tip is read as the days field's description; errors are tied to the field.
Found in the source
- ARIA attributes set:
aria-label,aria-describedby,aria-invalid.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
See also: Card · Pill · useLanguage · BonusCard · BonusDetail · ChallengeCard · ChallengeDetail
Source
src/blocks/motivation/GiftRulesCard.tsx (line 101) on GitHub.