Skip to Content
BBRICKSv0.7.4
PR PortalGifts

GiftStatusFilter

The Gift stock list's status chips (the kit FilterChips radiogroup: one tab stop, arrows move and choose): All, Expected, Arrived, Problem reported, Confirmed with difference, Confirmed. Labels come from statusTables.pr. Filter rows with giftShipmentMatches.

import { GiftStatusFilter } from '@ergasti/bricks';

Examples

A shipment's status, and "Problem reported" beside it while the brand disputes PR's count

Code
import { GiftStatusPills } from '@ergasti/bricks';

function Pills() {
  return (
    <div style={{ display: 'grid', gap: 10, justifyItems: 'start' }}>
      <GiftStatusPills state="expected" />
      <GiftStatusPills state="arrived" />
      <GiftStatusPills state="confirmed_diff" problem />
      <GiftStatusPills state="confirmed" />
    </div>
  );
}

The Gift stock list: status chips over giftShipmentColumns (reference, brand, for, units claimed and confirmed, status)

giftShipmentMatches filters by a chip; "Problem reported" matches any state with an open report.

Code
import { useState } from 'react';
import { DataTable, GiftStatusFilter, giftShipmentColumns, giftShipmentMatches, type GiftShipmentFilter, type GiftShipmentRow } from '@ergasti/bricks';

const glow = { id: 'glow', name: 'Glow Lab', color: '#C7325C' };

const rows: GiftShipmentRow[] = [
  { id: 'GS-0017', sent: '17 Nov', brand: glow, for: 'December glow', claimed: 40, state: 'expected' },
  { id: 'GS-0013', sent: '15 Nov', brand: { id: 'kemet', name: 'Kemet Home', color: '#3D5A10' }, for: 'Weekend sprint', claimed: 40, state: 'arrived' },
  { id: 'GS-0014', sent: '9 Nov', brand: glow, for: 'Lip oil bundle push', claimed: 60, confirmed: 54, state: 'confirmed_diff', problem: true },
  { id: 'GS-0009', sent: '28 Oct', brand: glow, for: 'Winter glow launch', claimed: 115, confirmed: 115, state: 'confirmed' },
];

function GiftStockList() {
  const [chip, setChip] = useState<GiftShipmentFilter | 'all'>('all');
  return (
    <div style={{ display: 'grid', gap: 14 }}>
      <GiftStatusFilter value={chip} onChange={setChip} />
      <DataTable label="Gift shipments" columns={giftShipmentColumns('en')} rows={rows.filter((r) => giftShipmentMatches(chip, r))} rowKey={(r) => r.id} onRowClick={() => {}} />
    </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 prGiftStatusFilter, or with the component's own prop where it has one. A {name} is a value the component fills in.

prGiftStatusFilter
KeyEnglishArabic
labelShipment statusحالة الشحنة
allAllالكل

Design guidance

How the BRICKS design system uses GiftStatusFilter. Written in docs/content/components/GiftStatusFilter.md; the props above are read from the code, which wins where the two disagree.

The Gift stock list's status chips (All, Expected, Arrived, Problem reported, Confirmed with difference, Confirmed) as one radiogroup; use it in the list's toolbar to filter shipments by state.

It is the dashed chip row of the PR Portal's Gift stock list (mock P.gifts), passed to ListToolbar's filters slot. It wraps the kit FilterChips and takes its words from the provider's statusTables.pr, so the chips read exactly like the GiftStatusPills in the rows. problem is not a state: it matches any shipment with an open problem report. Filter rows with the exported giftShipmentMatches(filter, row).

Anatomy

  1. Group (.kit-chips, role="radiogroup", flex, wrap, gap 8): named "Shipment status".
  2. Chips (.kit-chipf, role="radio"): 7px × 14px pill, 1px dashed border, 13px semibold. "All" first, then each of filters in order.
  3. Selected chip (.kit-chipf.on): solid ink fill, white text.
  4. Count (optional, .kit-chipf-n, 11px, dir="ltr"): after the label when counts[filter] is a number.

Variants

Prop / valueLookUse when
filters default (GIFT_SHIPMENT_FILTERS)All · Expected · Arrived · Problem reported · Confirmed with difference · ConfirmedThe Gift stock list (the mock's order).
filters a subsetOnly those chips after AllA view that never shows some states (e.g. only in-transit).
counts omittedLabels onlyAs the mock.
counts given"Arrived 2"When the API returns per-state totals.

Chip labels per value (from TRNDR_PR_STATUSES): expected → Expected, arrived → Arrived, problem → Problem reported, confirmed_diff → Confirmed with difference, confirmed → Confirmed, cancelled → its status word if you add it to filters.

States

  • Unselected: dashed #C9CBD4 border on --card, --ink-2 text.
  • Selected: value equals the chip; solid --ink.
  • Active: a press scales the chip to 0.98 (off with reduced motion).
  • Focus-visible: focus ring on the chip; only the selected chip is in the tab order.
  • No match: a value that is neither 'all' nor one of filters selects no chip, and then no chip is in the tab order (FilterChips gives tabIndex={0} only to the selected chip), so keyboard users cannot reach the group. Always pass 'all' or one of filters; reset to 'all' when you narrow filters.
  • Touch: chips grow to a 44px minimum height at 859px and below; above that they keep the mock's 35–38px.
  • Overflow: the row wraps; Arabic labels are longer and wrap sooner.

Types

GiftShipmentFilter is GiftShipmentState | 'problem'; GiftShipmentState is 'expected' | 'arrived' | 'confirmed' | 'confirmed_diff' | 'cancelled'.

Usage

// PR Portal › Gift stock: in the list toolbar, filtering the table under it
function GiftShipmentsList({ rows }: { rows: GiftShipmentRow[] }) {
  const words = useGiftColumnsCopy('en');
  const [q, setQ] = useState('');
  const [scope, setScope] = useState('my');
  const [chip, setChip] = useState<GiftShipmentFilter | 'all'>('all');
  const shown = rows.filter((r) => giftShipmentMatches(chip, r));
  return (
    <>
      <ListToolbar
        search={{ value: q, onChange: setQ, placeholder: words.search, label: words.search }}
        filters={<GiftStatusFilter value={chip} onChange={setChip} />}
        actions={<Segmented label="Brands shown" options={[['my', 'My brands'], ['all', 'All brands']]} value={scope} onChange={setScope} />}
      />
      <DataTable label={words.label} columns={giftShipmentColumns('en', words)} rows={shown} rowKey={(r) => r.id}
        onClearFilters={() => { setQ(''); setChip('all'); }}
        footer={<Pager page={1} lastPage={1} total={shown.length} loading={false} label={words.label} onPage={() => {}} />} />
    </>
  );
}
// With counts from the API
<GiftStatusFilter value={chip} onChange={setChip}
  counts={{ all: 7, expected: 3, arrived: 2, problem: 1, confirmed_diff: 1, confirmed: 1 }} />
// Only the in-transit states
<GiftStatusFilter value={chip} onChange={setChip} filters={['expected', 'arrived']} />

Where it appears

  • PR Portal › Gift stock › list toolbar, under the stat tiles and above the shipments table (mock P.gifts: chips Expected, Arrived, Problem reported, Confirmed with difference, Confirmed). Screen: PR · Gift stock (gallery screen gifts). The group name "Shipment status" is the library's accessible name; the mock shows no label.

Guidelines

Do

  • Filter with giftShipmentMatches so "Problem reported" matches by the problem flag, not the state.
  • Reset to 'all' in the table's onClearFilters.
  • Keep value to 'all' or one of filters; otherwise no chip shows as selected.
  • Keep the mock's order; it follows a shipment's life.

Don't

  • Don't hard-code chip words: change them in statusTables.pr so pills and chips agree.
  • Don't use it for multi-select: one filter at a time.
  • Don't add counts that are only for the current page; give totals or none.

RTL and Arabic

  • Chips flow right to left; arrow keys follow the visual direction.
  • Arabic words from statusTables.pr ("الكل", "مستنيينه", "وصل", "في مشكلة متبلّغ عنها", "اتأكد بفرق", "اتأكد"); the group is named "حالة الشحنة".
  • Counts stay dir="ltr".

Tokens

--card, --ink, --ink-2, --focus-ring, --chipf-pad.

Accessibility

  • role="radiogroup" named "Shipment status"; each chip is role="radio" with aria-checked.
  • One tab stop (roving tabindex), as long as value matches a chip (see No match): Arrow keys (Left/Right follow the reading direction, Up/Down too) move and select at once, wrapping; Home and End jump to the first and last chip.
  • With a count the chip's name is "Arrived, 2" (aria-label), so the number is not read run-on.
  • Selection is shown by fill (solid --ink, white text) and border style (solid vs dashed), not by colour alone; aria-checked carries it to screen readers.

Found in the source

  • Its tests cover: “the mock’s chips in order, a radiogroup moved with the arrows”.

Read from the component's source and tests. See Accessibility for the patterns the library follows.

See also: useBricks · useLanguage · PrStatusPill · GiftStockList · BrandGiftStockCard · GiftAttentionList · GiftClaimCheck · GiftShipmentCard

Source

src/pr/gifts/GiftStatus.tsx (line 83) on GitHub.

On this page