Skip to Content
BBRICKSv0.7.4
BlocksMotivation

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.

giftRulesCard
KeyEnglishArabic
titleGift rulesقواعد الهدايا
subWhat creators can pick, and how often.صنّاع المحتوى يختاروا إيه، وكل قد إيه.
subLockedSet by the TRNDR team. Contact TRNDR to change them.فريق TRNDR هو اللي بيحددها. كلّم TRNDR لو عايز تغيّرها.
locked🔒 Set by TRNDR🔒 بيحددها TRNDR
pickCreators can pick giftsصنّاع المحتوى يقدروا يختاروا هدايا
pickHintOff: no new product credits are sent and TRNDR assigns the gift; credits creators already hold can still be picked.لو مقفولة، مفيش رصيد هدايا منتجات جديد بيتبعت و TRNDR بيحدد الهدية؛ صنّاع المحتوى يقدروا يختاروا بالرصيد اللي معاهم.
oneOne gift per challengeهدية واحدة في كل تحدي
oneHintA creator gets and picks at most one gift in each challenge.صانع المحتوى ياخد ويختار هدية واحدة بس في كل تحدي.
cooldownGift cooldownفترة الانتظار بين الهدايا
cooldownTipDays a creator waits after using one of your gifts before getting another. Applies only while “Only the best gift per creator” is on.عدد الأيام اللي صانع المحتوى بيستناها بعد ما يستخدم هدية منك قبل ما ياخد غيرها. بتسري بس لما «أحسن هدية بس لكل صانع محتوى» تكون شغالة.
defaultDaysDefault {n} daysالافتراضي {n} يوماً
daysLabelCooldown in daysفترة الانتظار بالأيام
daysUnitdaysيوم
resetReset to {n}رجّعها {n}
errorCooldown must be 1 to {max} daysفترة الانتظار لازم تكون من 1 لـ {max} يوم
followingFollowing the TRNDR defaultماشي على الافتراضي بتاع TRNDR
useDefaultUse the defaultارجع للافتراضي
cooldownNeedsBestTurn 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

  1. Card: Card titled "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.
  2. Rule rows (.kit-blk-rule): bold title, muted hint, optional default note, iOS Switch at the end:
    1. "Creators can pick gifts";
    2. "One gift per challenge";
    3. "Gift cooldown" (dotted term with its tip): "Default 90 days", days input + "days" + "Reset to 90" when different, error line.

Variants

PropValueLook / when
readOnly (or no onChange)lockedPill, locked switches and days: the v3 mock.
editableonChange setConsole with editable rules.
inheritedper rule"Following the TRNDR default".
onUseDefaultset"Use the default" link on overridden rules.
bestGiftOnly={false}cooldown locked"Turn on “Only the best gift per creator” to use a cooldown."
defaultDays / maxDays90 / 365House cooldown and limit.

States

StateTrigger
Cooldown offcooldown: false: row dimmed, days disabled.
Days ≠ default"Reset to 90" link.
Invalid days"Cooldown must be 1 to 365 days" (giftCooldownError).
Read-onlyevery 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 SaveBar or 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.

See also: Card · Pill · useLanguage · BonusCard · BonusDetail · ChallengeCard · ChallengeDetail

Source

src/blocks/motivation/GiftRulesCard.tsx (line 101) on GitHub.

On this page