Skip to Content
BBRICKSv0.7.4
PR PortalTiers

TierChangeDialog

The PR mock's "Change {name}'s tier" (v3 changeTier): what the tier is now and where it comes from (set by PR, or from the score with the score), a select of the tiers, led by "Follow the score (Established)" when PR set the tier by hand, and a required reason the creator sees. Save without a reason marks the field and says why (ReasonDialog's rule). On the kit Modal.

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

Examples

Change a tier

A tier set by hand stays until PR picks "Follow the score" again; the reason is required and the creator sees it.

Code
import { useState } from 'react';
import { Button, TierChangeDialog } from '@ergasti/bricks';

function ChangeTier() {
  const [open, setOpen] = useState(false);
  const [last, setLast] = useState('');
  return (
    <>
      <Button onClick={() => setOpen(true)}>Change Ali Tarek’s tier</Button> <small>{last}</small>
      <TierChangeDialog open={open} onClose={() => setOpen(false)} onSave={(r) => { setLast(`${r.tier}: ${r.reason}`); setOpen(false); }}
        name="Ali Tarek" tier="rising" source="manual" score={46} scoreTier="established" tiers={['rising', 'established', 'influential', 'elite']} />
    </>
  );
}

Props

Prop

Type

Labels

Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key prTierChange, or with the component's own prop where it has one. A {name} is a value the component fills in.

prTierChange
KeyEnglishArabic
titleChange {n}’s tierغيّر مستوى {n}
nowNowدلوقتي
manualSet by PR.حدده الـ PR.
fromScoreFrom the score ({s}).من التقييم ({s}).
staysA tier set by hand stays until you choose “Follow the score” again.المستوى اللي بيتحدد بالإيد بيفضل لحد ما تختار «امشي مع التقييم» تاني.
tierNew tierالمستوى الجديد
followFollow the score ({t})امشي مع التقييم ({t})
reasonReasonالسبب
reasonHintRequired · the creator sees itلازم · صانع المحتوى هيشوفه
reasonErrWrite a reason. The creator sees it.اكتب السبب. صانع المحتوى هيشوفه.
cancelCancelإلغاء
saveSaveاحفظ
savingSaving…بنحفظ…

Design guidance

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

The "Change {name}'s tier" modal: the tier now and where it comes from, a select of tiers led by "Follow the score" for a hand-set tier, and a required reason the creator sees; use it from the creator drawer or the Tiers screen.

TierChangeDialog is the v3 mock's changeTier (it replaces ReasonDialog mode="text" for tiers). A tier set by hand stays until PR picks "Follow the score (Established)" again, so the dialog says where the current tier comes from (set by PR, or from the score with the score). Saving without a reason marks the field and says why, as ReasonDialog does; choosing the tier the creator already has simply closes.

Anatomy

  1. Modal: kit Modal titled "Change Ali Tarek's tier".
  2. Now line: "Now Rising. Set by PR. A tier set by hand stays until you choose "Follow the score" again." (or "From the score (62).").
  3. New tier: a select of tiers (names from the provider), led by "Follow the score (Established)" when the tier is manual and a score tier exists.
  4. Reason: required input, placeholder "Required · the creator sees it", max 300.
  5. Footer: error alert, Cancel, ink Save ("Saving…").

Variants

sourceNow lineFirst option
manual (+ score, scoreTier)"Set by PR."Follow the score (Established)
manual, no score"Set by PR."tiers only
score"From the score (62)."tiers only

States

StateTrigger
Fresheach open: choice = current tier, empty reason
Same tierSave closes without onSave
Missing reason"Write a reason. The creator sees it."
Busybusy: Save disabled, "Saving…", aria-busy
Errorerror: footer alert

Types

TierChangeResult (onSave): { tier: key | 'follow_score', reason }.

Usage

import { useState } from 'react';
import { Button, TierChangeDialog } from '@ergasti/bricks';

export function ChangeTier() {
  const [open, setOpen] = useState(false);
  const [last, setLast] = useState('');
  return (
    <>
      <Button onClick={() => setOpen(true)}>Change Ali Tarek’s tier</Button> <small>{last}</small>
      <TierChangeDialog open={open} onClose={() => setOpen(false)} onSave={(r) => { setLast(`${r.tier}: ${r.reason}`); setOpen(false); }}
        name="Ali Tarek" tier="rising" source="manual" score={46} scoreTier="established" tiers={['rising', 'established', 'influential', 'elite']} />
    </>
  );
}
// From the creator drawer's "Change" link
<PrCreatorDrawer open creator={creator} onClose={close} onChangeTier={() => setChanging(true)} />
<TierChangeDialog open={changing} onClose={() => setChanging(false)} name={creator.name} tier={creator.tier!}
  source={creator.tierSource ?? 'score'} score={creator.score} scoreTier={scoreTierOf(creator.score)}
  tiers={['rising', 'established', 'influential', 'elite']} onSave={saveTier} busy={saving} error={saveError} />

Where it appears

  • PR Portal › Creators › creator drawer › Tier "Change".
  • PR Portal › Tiers › recent automatic moves › "Change".
  • Dashboard screens: PrCreators, PrTiers.

Guidelines

Do

  • Pass scoreTier so PR can return a hand-set creator to the score.
  • Write reasons the creator can understand; they see them.

Don't

RTL and Arabic

Mirrors. Arabic: "غيّر مستوى {name}", "امشي مع التقييم (…)", "لازم · صانع المحتوى هيشوفه".

Tokens

Modal and field tokens; --ink for the current tier name.

Accessibility

Kit Modal; labelled select and required reason (aria-required, error tied to the field); errors are alerts; Save carries aria-busy.

Found in the source

  • Roles in the markup: alert.
  • ARIA attributes set: aria-busy, aria-required.
  • Its tests cover: “busy disables Save; Escape closes; Arabic: the title and the follow option”.

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

See also: Button · FormField · Modal · useBricks · useLanguage

Source

src/pr/tiers/TierChangeDialog.tsx (line 69) on GitHub.

On this page