RequestChallengeCard
The brand portal's Challenges card as the PR portal's View as brand shows it (the v3 mock's P.viewas): "Brands can ask TRNDR for a challenge." and a full-width "Request a challenge", disabled while PR only views (no onRequest), with why as its description.
import { RequestChallengeCard } from '@ergasti/bricks';Examples
View as brand
The brand's Challenges card with "Request a challenge" disabled while PR only views; the button's description says why. Pass onRequest in the brand portal itself.
Code
import { RequestChallengeCard } from '@ergasti/bricks';
function ViewAsBrand() {
return <div style={{ maxWidth: 360 }}><RequestChallengeCard /></div>;
}In Arabic
Code (not run)
import { RequestChallengeCard } from '@ergasti/bricks';
function Arabic() {
return <div style={{ maxWidth: 360 }}><RequestChallengeCard /></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 prRequestChallenge, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
title | Challenges | التحديات |
text | Brands can ask TRNDR for a challenge. | البراندات تقدر تطلب تحدي من TRNDR. |
request | Request a challenge | اطلب تحدي |
readOnly | Read only while you view as the brand. | للقراية بس وإنت بتتفرج كأنك البراند. |
Design guidance
How the BRICKS design system uses RequestChallengeCard. Written in docs/content/components/RequestChallengeCard.md; the props above are read from the code, which wins where the two disagree.
The brand's "Challenges" card as View as brand shows it: "Brands can ask TRNDR for a challenge." and a full-width "Request a challenge", disabled while PR only views; use it inside ReadOnlyFrame on the PR Portal's View as brand page.
It is the PR v3 mock's P.viewas side card (.card.s4 with <p class="muted"> and <button class="btn wide" disabled>). Before 0.7 the screen drew it as a Card with a disabled Button; use RequestChallengeCard instead, because it also says why the button cannot be used: with no onRequest the button is disabled and described by the card's text and a visually hidden "Read only while you view as the brand.".
Anatomy
- Card: title "Challenges".
- Text (muted, no margin): "Brands can ask TRNDR for a challenge." (
text), plus, when disabled, a visually hidden reason. - Button: full-width (
kit-pr-wide), default variant, "Request a challenge",aria-describedbythe text (and the reason when disabled).
Variants
| Prop | Look | When to use |
|---|---|---|
no onRequest (default) | Button disabled | View as brand: PR is only looking. |
onRequest | Button enabled | The brand's own portal, where the brand can ask. |
text | Your line | Different copy for the card. |
disabledReason | Your screen-reader reason | A reason other than viewing as the brand. |
States
| State | How |
|---|---|
| Disabled | No onRequest. Inside ReadOnlyFrame the whole panel is also inert. |
| Enabled | onRequest: hover, focus-visible and press as Button. |
Usage
// PR Portal › Brand detail › View as brand: the brand's creators beside its Challenges card, read only
import { Button, Card, PageGrid, ReadOnlyFrame, RequestChallengeCard, ViewAsBanner } from '@ergasti/bricks';
export function ViewAsGlowLab({ exit }: { exit: () => void }) {
return (
<>
<ViewAsBanner brandName="Glow Lab" onExit={exit} />
<ReadOnlyFrame>
<PageGrid split="8-4" align="start">
<Card title="Your creators" actions={<Button size="sm" disabled>Invite</Button>}>
<p style={{ margin: 0 }}>Sara Ali, Nour Hassan</p>
</Card>
<RequestChallengeCard />
</PageGrid>
</ReadOnlyFrame>
</>
);
}// Where the brand can act: the button opens the request form
import { RequestChallengeCard } from '@ergasti/bricks';
export function BrandChallengesCard({ openRequest }: { openRequest: () => void }) {
return <RequestChallengeCard onRequest={openRequest} />;
}Where it appears
- PR Portal › Brand detail › View as brand › the side column next to "Your creators" (PR · View as brand).
Guidelines
Do
- Leave
onRequestout in View as brand, so the button is disabled with its reason. - Keep it inside
ReadOnlyFramethere, withViewAsBannerabove.
Don't
- Don't hide the button in View as brand; PR should see what the brand sees.
- Don't make it raspberry here: the mock draws a plain wide button in this read-only view.
- Don't use it for the Brand dashboard's own request flow ("+ Request a challenge" on Motivation); that is a
Button variant="rasp"andChallengeRequestForm.
RTL and Arabic
- Mirrors with the card. Its words: "التحديات", "البراندات تقدر تطلب تحدي من TRNDR.", "اطلب تحدي", "للقراية بس وإنت بتتفرج كأنك البراند.".
Tokens
--ink-3 (text); card and button tokens.
Accessibility
- The button is described (
aria-describedby) by the card's text, and when disabled also by the hidden reason, so a screen reader hears what it does and why it is unavailable. - Inside
ReadOnlyFramethe card is inert and not read at all; the banner above explains the view. - A native disabled
<button>.
Found in the source
- ARIA attributes set:
aria-describedby.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
ReadOnlyFrame,ViewAsBanner: the View as brand page around it.ChallengeRequestForm: the brand's actual request form.BrandRequestCard: how PR sees the request once sent.
See also: Button · Card · useLanguage · AdjustWalletDialog · BrandAvatar · BrandCell · BrandDetailHeader
Source
src/pr/programs/RequestChallengeCard.tsx (line 42) on GitHub.