Skip to Content
BBRICKSv0.7.4
Recipes

Use the PR portal frame

PrPortalFrame draws the whole PR portal v3 frame from one component; the app's provider money, the PR theme import, the decision tags, phones, and how to build the same frame by hand.

PrPortalFrame is the PR portal v3 frame in one component: the dark sidebar with the v3 navigation, the "Open decisions" card, the signed-in person with sign-out, and a header with the screen's own tools, search, the bell and the raspberry "+ New" menu. It is made only of public exports, and you can use it or not: the second half of this page builds the same frame by hand.

The PR portal frame

One component for the whole PR portal v3 frame: the dark sidebar with the v3 nav, the Open decisions card, the signed-in person with sign-out, and the header with the screen's own tools, search, the bell and the raspberry "+ New". The card's "Show decision tags" switch drives a DecisionTagsProvider around the page, so the tag after "Shipments from brands" comes and goes. Pick another item in the sidebar to move.

Pinned to TRNDR presetPR theme
Code
import { useState } from 'react';
import { Button, Card, DecisionTag, Icon, PR_PORTAL_NAV, PrPortalFrame, type NavItem, type NotificationItem } from '@ergasti/bricks';

const OPEN = [
  { id: 'C3', question: 'Can a brand opt out of a TRNDR-wide challenge?' },
  { id: 'R10', question: 'What a tier gives creators' },
  { id: 'GS1', question: 'Damaged or extra units: brand collects within 14 days?' },
];

const NOTIFS: NotificationItem[] = [
  { id: 1, text: <><b>Sara Ali</b> has waited 8 days to join Glow Lab.</>, when: '1 hour ago', icon: 'approvals', tone: 'rasp', unread: true },
  { id: 2, text: <><b>Kemet Home</b> wallet is below zero (day 4 of 7).</>, when: 'Today', icon: 'wallet', tone: 'butter', unread: true },
  { id: 3, text: <><b>4 new creators</b> are waiting for approval.</>, when: 'Yesterday', icon: 'user', tone: 'sky', unread: false },
];

const COUNTS: Record<string, number> = { approvals: 9, programs: 3, gifts: 3 };

const nav = PR_PORTAL_NAV.map((group) => ({ ...group, items: group.items.map((item) => (COUNTS[item.id] ? { ...item, count: COUNTS[item.id] } : item)) }));

function Frame() {
  const [active, setActive] = useState('gifts');
  const [items, setItems] = useState(NOTIFS);
  return (
    <PrPortalFrame
      nav={nav} activeId={active} onNavigate={(item: NavItem) => setActive(item.id)}
      decisions={OPEN} user={{ name: 'Mona Adel', seed: 1 }} onSignOut={() => {}}
      title="Gift stock" subtitle="Brands send gifts to the warehouse and tell us what they sent. Nothing counts as gift stock until you confirm what arrived."
      tools={<Button><Icon name="plus" />Record gifts for a brand</Button>}
      search={{ fetcher: async () => [], onSelect: () => {} }}
      notifications={{ items, onOpenItem: (id) => setItems((all) => all.map((n) => (n.id === id ? { ...n, unread: false } : n))), onMarkAllRead: () => setItems((all) => all.map((n) => ({ ...n, unread: false }))), onSeeAll: () => setActive('activity') }}
      newMenu={[{ id: 'gift', label: 'Record gifts', sub: 'Boxes a brand sent without a claim', icon: 'gift' }]}
    >
      <Card title={<>Shipments from brands<DecisionTag id="GS1" question="Damaged or extra units: brand collects within 14 days?" /></>}>The screen goes here.</Card>
    </PrPortalFrame>
  );
}

Steps

  1. Set up the app once. Import @ergasti/bricks/styles.css and then @ergasti/bricks/themes/pr.css (see Stylesheets). Wrap the app in a BricksProvider with preset={trndrPreset} and money={{ decimals: 'auto' }}: the PR mock never shows ".00" on whole amounts ("EGP 412,300"), and amounts with cents keep them ("EGP 12.50"). The frame does not set money itself, so every screen inside it formats amounts the same way.
  2. Put the frame around each screen. Pass activeId and onNavigate for your router, title and subtitle for the page, and the screen as children. The frame puts data-bricks-theme="pr" on its own wrapper, so the PR look stays inside it.
  3. Fill the sidebar. decisions takes the open product decisions as { id, question }; the frame draws them in a DecisionsCard with tip="focus" (each code is a tab stop with its own tooltip). user takes the person (name, seed, detail, default "PR team"), drawn in a SidebarUser with a 34px avatar, and onSignOut (or signOutUrl with csrfToken for a form post) adds the sign-out button.
  4. Fill the header. tools holds the screen's own tools and draws them first, before the search (the scope switch on Home, "Record gifts for a brand" on Gift stock). search takes HeaderSearch props (the placeholder "Search brands, creators…" and the Brands / Creators groups are the defaults), notifications takes NotificationsMenu props, and newMenu takes the "+ New" items. Your app picks the items per page: only "Record gifts" on the gift pages. Any of the three can also be your own element.
  5. Use the decision tags. The frame wraps everything in a DecisionTagsProvider driven by the card's "Show decision tags" switch, so every inline DecisionTag on every screen shows or hides with it. The frame keeps the switch state itself; pass showTags and onShowTagsChange to keep it in your app (in the URL, say) or defaultShowTags to start with it on.
  6. A brand page. titleLead draws the brand's big square before its name in the h1 (BrandAvatar size="lg"), and breadcrumbs the crumb above it.

A brand page

titleLead puts the brand's big square before its name in the h1, breadcrumbs the crumb above it, and tools the page's own "View as brand" before the search. On brand pages the "+ New" menu offers both a challenge and gifts.

Pinned to TRNDR presetPR theme
Code
import { BrandAvatar, Button, Card, Icon, PR_PORTAL_NAV, PrPortalFrame } from '@ergasti/bricks';

const OPEN = [
  { id: 'C3', question: 'Can a brand opt out of a TRNDR-wide challenge?' },
  { id: 'R10', question: 'What a tier gives creators' },
  { id: 'GS1', question: 'Damaged or extra units: brand collects within 14 days?' },
];

const COUNTS: Record<string, number> = { approvals: 9, programs: 3, gifts: 3 };

const nav = PR_PORTAL_NAV.map((group) => ({ ...group, items: group.items.map((item) => (COUNTS[item.id] ? { ...item, count: COUNTS[item.id] } : item)) }));

function BrandPage() {
  return (
    <PrPortalFrame
      nav={nav} activeId="brands" decisions={OPEN} user={{ name: 'Mona Adel', seed: 1 }} onSignOut={() => {}}
      title="Glow Lab" titleLead={<BrandAvatar name="Glow Lab" color="#C7325C" size="lg" />} breadcrumbs={<><a href="#brands">Brands</a> / Glow Lab</>}
      tools={<Button><Icon name="eye" />View as brand</Button>}
      search={{ fetcher: async () => [], onSelect: () => {} }}
      newMenu={[{ id: 'ch', label: 'Challenge', sub: 'For one brand or all brands', icon: 'star' }, { id: 'gift', label: 'Record gifts', icon: 'gift' }]}
    >
      <Card title="Affiliate program">10% of sale</Card>
    </PrPortalFrame>
  );
}

The app setup

The app's setup and the frame

Your app root wraps everything once in a BricksProvider with money={{ decimals: 'auto' }} (the PR mock never shows ".00": "EGP 412,300", while "EGP 12.50" keeps its cents) and imports themes/pr.css; PrPortalFrame then sets data-bricks-theme="pr" on its own wrapper and holds the DecisionTagsProvider. Turn on "Show decision tags" in the sidebar to see the tag after "Sales".

Pinned to TRNDR presetPR theme
Code
import { useState } from 'react';
import { BricksProvider, Card, DecisionTag, Money, PrPortalFrame, trndrPreset, useLanguage, type NavItem, type ShellBrand } from '@ergasti/bricks';
import { notifications, openDecisions } from './recipes';

const brand: ShellBrand = { name: <>TRNDR<span className="kit-shell-accent">.</span></>, label: 'TRNDR', tagline: 'PR portal', mark: 'T' };

function AppSetup() {
  const language = useLanguage();
  const [active, setActive] = useState('brands');
  return (
    <BricksProvider preset={trndrPreset} language={language} money={{ decimals: 'auto' }}>
      <PrPortalFrame
        activeId={active} onNavigate={(item: NavItem) => setActive(item.id)}
        decisions={openDecisions} user={{ name: 'Mona Adel', seed: 1 }} onSignOut={() => {}}
        title="Brands" subtitle="Every brand on TRNDR, its wallet and its program."
        search={{ fetcher: async () => [], onSelect: () => {} }}
        notifications={{ items: notifications, onOpenItem: () => {}, onSeeAll: () => setActive('activity') }}
        newMenu={[{ id: 'ch', label: 'Challenge', sub: 'For one brand or all brands', icon: 'star' }]}
      >
        <Card title={<>Sales<DecisionTag id="R10" question="What a tier gives creators" /></>}>
          <Money value="412300.00" /> this month · <Money value="12.50" /> average fee
        </Card>
      </PrPortalFrame>
    </BricksProvider>
  );
}

On phones

The frame follows the shell's tiers. From 860 to 1024px the sidebar is a 72px icon rail that expands over the page. Under 860px it becomes a tab bar with a "More" button. The "More" sheet holds the whole nav, then the Open decisions card with its switch, then the person's row with sign-out, so none of them is lost on a phone. In the header the tools take a row of their own that scrolls sideways when it must. Under 600px the search folds into a button and "+ New" shows its icon only. The subtitle clamps to two lines (subtitleLines, default 2). The PR mock has no phone layout of its own; see Responsive layouts.

On a phone

Under 860px the sidebar becomes a tab bar and a "More" sheet; the sheet holds the whole nav, then the Open decisions card with its switch, then the person's row with sign-out. Open "More" to see them.

Pinned to ArabicTRNDR presetPR theme
Code
import { useState } from 'react';
import { Card, PR_PORTAL_NAV, PrPortalFrame, Segmented } from '@ergasti/bricks';

const OPEN = [
  { id: 'C3', question: 'Can a brand opt out of a TRNDR-wide challenge?' },
  { id: 'R10', question: 'What a tier gives creators' },
  { id: 'GS1', question: 'Damaged or extra units: brand collects within 14 days?' },
];

const COUNTS: Record<string, number> = { approvals: 9, programs: 3, gifts: 3 };

const nav = PR_PORTAL_NAV.map((group) => ({ ...group, items: group.items.map((item) => (COUNTS[item.id] ? { ...item, count: COUNTS[item.id] } : item)) }));

function Phone() {
  const [scope, setScope] = useState<'my' | 'all'>('my');
  return (
    <div style={{ maxWidth: 390 }}>
      <PrPortalFrame
        tier="mobile" nav={nav} activeId="home" decisions={OPEN} user={{ name: 'منى عادل', seed: 1 }} onSignOut={() => {}}
        title="صباح الخير يا منى" subtitle="13 حاجة مستنياك. الأهم الأول."
        tools={<Segmented label="البراندات اللي ظاهرة" size="sm" value={scope} onChange={setScope} options={[['my', 'براندات بتاعتي'], ['all', 'كل البراندات']]} />}
        search={{ fetcher: async () => [], onSelect: () => {} }}
      >
        <Card title="محتاجك">…</Card>
      </PrPortalFrame>
    </div>
  );
}

Build the frame by hand

When you need what the frame does not do (another sidebar card, a user menu in the header, your own routing links), build it from the same parts. This is the frame's markup, written out:

The same frame by hand

When you need what PrPortalFrame does not do, build it from the parts it is made of: DecisionTagsProvider driven by the card's switch, a data-bricks-theme="pr" wrapper, AppShell with PR_PORTAL_NAV, DecisionsCard tip="focus" in sidebarCard, SidebarUser avatarSize={34} with a LogoutButton className="kit-shell-me-out" in sidebarFooter, and AppHeader with leading tools, subtitleLines={2}, HeaderSearch, NotificationsMenu and the raspberry TopbarMenu. The phone sheet takes the card and the user row by itself.

Pinned to TRNDR presetPR theme
Code
import { useState } from 'react';
import { AppHeader, AppShell, Avatar, Card, DecisionTag, DecisionTagsProvider, DecisionsCard, HeaderSearch, Icon, LogoutButton, NotificationsMenu, PR_PORTAL_NAV, SidebarUser, TopbarMenu, type NavItem, type ShellBrand } from '@ergasti/bricks';
import { notifications, openDecisions } from './recipes';

const brand: ShellBrand = { name: <>TRNDR<span className="kit-shell-accent">.</span></>, label: 'TRNDR', tagline: 'PR portal', mark: 'T' };

function ByHand() {
  const [active, setActive] = useState('home');
  const [showTags, setShowTags] = useState(false);
  return (
    <DecisionTagsProvider visible={showTags}>
      <div data-bricks-theme="pr">
        <AppShell
          brand={brand} nav={PR_PORTAL_NAV} activeId={active} onNavigate={(item: NavItem) => setActive(item.id)}
          sidebarCard={<DecisionsCard decisions={openDecisions} tip="focus" showTags={showTags} onShowTagsChange={setShowTags} />}
          sidebarFooter={
            <SidebarUser avatar={<Avatar name="Mona Adel" seed={1} />} avatarSize={34} name="Mona Adel" detail="PR team"
              action={<LogoutButton className="kit-shell-me-out" onLogout={() => {}}><Icon name="logout" /><span className="kit-sr">Sign out</span></LogoutButton>} />
          }
          header={
            <AppHeader
              title="Good morning, Mona" subtitle="13 things need you. Most urgent first." subtitleLines={2}
              search={<HeaderSearch placeholder="Search brands, creators…" fetcher={async () => []} groupLabels={{ brands: 'Brands', creators: 'Creators' }} onSelect={() => {}} />}
              actions={<>
                <NotificationsMenu items={notifications} onOpenItem={() => {}} onSeeAll={() => setActive('activity')} />
                <TopbarMenu label="New" variant="pill" tone="rasp" trigger={<><Icon name="plus" />New</>} items={[{ id: 'ch', label: 'Challenge', icon: 'star' }, { id: 'gift', label: 'Record gifts', icon: 'gift' }]} />
              </>}
            />
          }
        >
          <Card title={<>Needs you<DecisionTag id="C3" question="Can a brand opt out of a TRNDR-wide challenge?" /></>}>The screen goes here.</Card>
        </AppShell>
      </div>
    </DecisionTagsProvider>
  );
}
  • Keep the order: the DecisionTagsProvider outside, then the data-bricks-theme="pr" wrapper, then AppShell.
  • Use PR_PORTAL_NAV as the nav, or copy it and add count to items.
  • Put the screen's tools in AppHeader leading, not in search, so they come before the search as in the mock. Put the bell and "+ New" in actions.
  • AppShell shows sidebarCard and sidebarFooter in the phone sheet as well. Pass sheetFooter only to show something else there; it then replaces both.

Notes

  • Every part is optional: leave out decisions, user, search, notifications or newMenu and that part is not drawn.
  • The frame's own words (the nav labels, "PR portal", "PR team", "New", the search placeholder) are in English and Arabic. Change them with labels, or for the whole app with the provider's labels.prPortalFrame.
  • The sign-in page sits outside the frame: LoginLayout with BrandMark as its brand. See Sign in.

Related: Compose a PR portal page, MobileNavSheet, Theming.

On this page