OpenRate
The mock's .opn: an olive bar and the percentage. The bar is decorative; the figure is text, one text node ("62%", not "62" + "%"). percent is clamped to 0–100 and rounded.
import { OpenRate } from '@ergasti/bricks';Examples
Message table cells
Who a message went to, who sent it (a brand, or TRNDR when null) and the open rate; the building blocks of the messages table preset.
Code
import { AudienceLabel, OpenRate, SenderCell } from '@ergasti/bricks';
import { brands } from './pr';
function Cells() {
return (
<div style={{ display: 'grid', gap: 12 }}>
<AudienceLabel audience={{ kind: 'all' }} />
<AudienceLabel audience={{ kind: 'brand', brand: brands.glow }} />
<AudienceLabel audience={{ kind: 'tier', tier: 'elite' }} />
<AudienceLabel audience={{ kind: 'group', name: 'Top sellers' }} />
<AudienceLabel audience={{ kind: 'picked', creators: [{ name: 'Nour Hassan', seed: 2 }, { name: 'Hana Rami', seed: 6 }] }} />
<div style={{ display: 'flex', gap: 24 }}><SenderCell brand={brands.mira} /><SenderCell brand={null} /><OpenRate percent={71} /></div>
</div>
);
}The mock's history table cells
SenderCell draws the mock's 28px square for brands and TRNDR (avatarSize="md" for the 38px one); OpenRate writes "62%" as one figure beside its bar.
Code
import { OpenRate, SenderCell } from '@ergasti/bricks';
import { brands } from './pr';
function SenderAndOpenRate() {
return (
<div style={{ display: 'grid', gap: 12 }}>
<div style={{ display: 'flex', gap: 24, alignItems: 'center' }}><SenderCell brand={brands.glow} /><SenderCell brand={null} /><SenderCell brand={brands.glow} avatarSize="md" /></div>
<div style={{ display: 'flex', gap: 24, maxWidth: 360 }}><OpenRate percent={62} /><OpenRate percent={100} /></div>
</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 prMessageCells, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
all | All TRNDR creators | كل صنّاع المحتوى على TRNDR |
brand | Brand | براند |
group | Group | مجموعة |
tier | Tier | مستوى |
more | +{n} | +{n} |
opened | {p}% opened | اتفتحت {p}% |
trndr | TRNDR | TRNDR |
Design guidance
How the BRICKS design system uses OpenRate. Written in docs/content/components/OpenRate.md; the props above are read from the code, which wins where the two disagree.
A small olive bar with the percentage of creators who opened a message; use it in the Messages history table's "Opened" column.
OpenRate is the PR mock's .opn. The bar is decoration; the figure is one text node ("62%"), and the tooltip reads "62% opened". percent is clamped to 0-100 and rounded. UsageBar draws the same bar for a count of a total.
Anatomy
- Wrapper:
<span class="kit-pr-opn" title="62% opened">, flex, 8px gap, at least 110px wide. - Track: 6px,
--track, radius 99px; olive fill to the percentage.aria-hidden. - Figure: "62%", 12px
--ink-3,dir="ltr", at least 34px.
Variants
None: the fill follows percent.
States
| State | Trigger |
|---|---|
| None opened | percent={0}: empty bar, "0%" |
| All opened | percent={100}: full bar |
| Out of range | clamped to 0-100 |
Usage
import { OpenRate } from '@ergasti/bricks';
<OpenRate percent={71} />// A custom history column (messageColumns already includes it)
const opened: DataColumn<MessageRow> = { key: 'opened', label: 'Opened', sortKey: 'opened', render: (m) => <OpenRate percent={m.openPercent} /> };The mock's history table cells. SenderCell draws the mock's 28px square for brands and TRNDR (avatarSize="md" for the 38px one); OpenRate writes "62%" as one figure beside its bar. (docs example SenderAndOpenRate)
import { AudienceLabel, OpenRate, SenderCell } 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 SenderAndOpenRate() {
return (
<div style={{ display: 'grid', gap: 12 }}>
<div style={{ display: 'flex', gap: 24, alignItems: 'center' }}><SenderCell brand={brands.glow} /><SenderCell brand={null} /><SenderCell brand={brands.glow} avatarSize="md" /></div>
<div style={{ display: 'flex', gap: 24, maxWidth: 360 }}><OpenRate percent={62} /><OpenRate percent={100} /></div>
</div>
);
}Where it appears
- PR Portal › Messages › history table, "Opened" column; the message drawer's stats.
Guidelines
Do
- Pass the rate the server computed; don't round before passing.
- Use it for rates only; use
UsageBarfor "58 of 100".
Don't
- Don't colour the bar by performance.
- Don't show it before a message has been delivered (show "—" in the cell instead).
RTL and Arabic
The bar fills from the inline start; the figure stays dir="ltr". Arabic tooltip comes from labels.prMessageCells.opened.
Tokens
--track, --olive, --ink-3.
Accessibility
The bar is aria-hidden; the figure is text and reads "71%". The tooltip repeats it for pointer users.
Found in the source
- ARIA attributes set:
aria-hidden.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
UsageBar: used of total.AudienceLabel,SenderCell: the other history cells.
See also: Avatar · BrandAvatar · PrIcon · useBricks · useLanguage · AnnouncementComposer · AudiencePicker · ChannelPicker
Source
src/pr/MessageCells.tsx (line 80) on GitHub.