SenderPicker
The composer's "From": TRNDR itself or a brand the PR sends on behalf of (the mock's #mf select: TRNDR, then the PR's brands). A native select (one tab stop, the platform's own list); the line under it says what the choice means, with the chosen brand's square. value null is TRNDR.
import { SenderPicker } from '@ergasti/bricks';Examples
The composer's "From"
A native select: TRNDR first (value null), then the brands the PR sends on behalf of. The line under it says what the choice means, with the brand's square.
Code
import { useState } from 'react';
import { SenderPicker } from '@ergasti/bricks';
import { brands } from './pr';
function From() {
const [value, setValue] = useState<string | number | null>(null);
return (
<div style={{ maxWidth: 420 }}>
<SenderPicker brands={[brands.glow, brands.nile, brands.mira]} value={value} onChange={setValue} />
<p className="kit-muted" style={{ marginTop: 12 }}>value: <code>{JSON.stringify(value)}</code></p>
</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 prSenderPicker, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
label | From | من |
trndr | TRNDR | TRNDR |
hint | Messages from a brand go only to creators who joined it. | رسايل البراند بتوصل بس لصنّاع المحتوى اللي اشتركوا فيه. |
behalf | Sent on behalf of {b}. Creators see {b} as the sender; the log records you. | هتتبعت بالنيابة عن {b}. صنّاع المحتوى هيشوفوا {b} هو اللي باعت، والسجل هيكتب اسمك إنت. |
platform | Sent by TRNDR to any creator on the platform. | هتتبعت من TRNDR لأي صانع محتوى على المنصة. |
Design guidance
How the BRICKS design system uses SenderPicker. Written in docs/content/components/SenderPicker.md; the props above are read from the code, which wins where the two disagree.
The composer's "From" field: TRNDR itself or a brand PR sends on behalf of, with a line explaining what the choice means; use it at the top of the announcement composer.
SenderPicker is the mock's #mf select: TRNDR first, then PR's brands. It is a native select (one tab stop, the platform's own list). Under it a note with the sender's square says what happens: "Sent by TRNDR to any creator on the platform." or "Sent on behalf of Glow Lab. Creators see Glow Lab as the sender; the log records you.", followed by "Messages from a brand go only to creators who joined it." The sender limits the audiences the composer allows.
Anatomy
- Field:
kit-fieldwith the label "From". - Select: TRNDR, then each brand by name.
- Note (described-by): an
xsBrandAvatar(ink "T" for TRNDR) and the explanation, 12px--ink-3.
Variants
value | Note |
|---|---|
null | TRNDR square; "Sent by TRNDR to any creator on the platform. Messages from a brand go only to creators who joined it." |
| a brand id | Brand square; "Sent on behalf of {brand}. Creators see {brand} as the sender; the log records you. …" |
States
Default, focus (native select), and an unknown id falls back to TRNDR.
Usage
import { SenderPicker } from '@ergasti/bricks';
<SenderPicker
brands={[{ id: 'glow', name: 'Glow Lab', color: '#C7325C' }, { id: 'nile', name: 'Nile Threads' }]}
value={senderId}
onChange={setSenderId}
/>// Sender first, then an audience the sender allows
<SenderPicker brands={myBrands} value={senderId} onChange={(id) => { setSenderId(id); setAudience({ kind: id ? 'brand' : 'all', picked: [] }); }} />
<AudiencePicker
value={audience}
onChange={setAudience}
modes={senderId ? ['brand', 'tier', 'picked'] : ['all', 'brand', 'tier', 'picked']}
fixedBrand={senderId ? brandById(senderId) : null}
brands={myBrands} tiers={tierCounts} creators={creators}
recipients={reach}
/>The composer's "From". A native select: TRNDR first (value null), then the brands the PR sends on behalf of. The line under it says what the choice means, with the brand's square. (docs example From)
import { useState } from 'react';
import { SenderPicker } from '@ergasti/bricks';
// brands: the docs' sample rows (docs/examples/_pr.ts), e.g. brands.glow = { id: 'glow', name: 'Glow Lab', color: '#C7325C' }
export function From() {
const [value, setValue] = useState<string | number | null>(null);
return (
<div style={{ maxWidth: 420 }}>
<SenderPicker brands={[brands.glow, brands.nile, brands.mira]} value={value} onChange={setValue} />
<p className="kit-muted" style={{ marginTop: 12 }}>value: <code>{JSON.stringify(value)}</code></p>
</div>
);
}Where it appears
- PR Portal › Messages › New message › From.
AnnouncementComposerdraws it for you.
Guidelines
Do
- List only the brands this PR manages (My brands).
- Keep TRNDR first: it is the default sender.
Don't
- Don't let a brand sender reach "All TRNDR creators": a brand reaches only its own creators.
- Don't replace the native select with a custom menu.
RTL and Arabic
Mirrors. Arabic: "من", "هتتبعت من TRNDR لأي صانع محتوى على المنصة.", "هتتبعت بالنيابة عن {b}. …".
Tokens
--ink-3 (note), field tokens, BrandAvatar colours.
Accessibility
A labelled native <select>, described by the note, so the consequence is read with the choice.
Found in the source
- ARIA attributes set:
aria-describedby. - Its tests cover: “Arabic + RTL: the label and the on-behalf line in Arabic”.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
SenderCell: the sender in the history table.AudiencePicker: who receives it.AnnouncementComposer: the whole composer.
See also: BrandAvatar · useLanguage · AudienceLabel · ChannelPicker
Source
src/pr/SenderPicker.tsx (line 33) on GitHub.