Affiliate design system

Shared foundations for dense tables, money states and setup flows in the Affiliate Revenue Dashboard. Examples use fictional figures and publisher sites alongside real retailer and network names; no real partner data is shown.

React 19.3.0
Component markup
TypeScript 5.9.3
Typed props
CSS custom properties
Styling from the token file
Next.js 16.4.5
This docs site
Vitest 3.2.7
Test runner
Testing Library 16.3.3
Behaviour tests
axe-core 4.14.0
Automated accessibility scan
Shiki 3.23.0
Code highlighting

Setup

Tokens live in one file, src/design-system/tokens/affiliate.tokens.json: two colour ramps (brand red and gray) and semantic tokens named for their job, which point at the ramps. The build writes them as CSS custom properties and fails if a component uses a ramp value directly. Components are React for markup and plain CSS for styling; their interactions (row selection, segmented controls, chart tooltips) come from design-system.js, a DOM script carried over from the WordPress version.

Terminal
npm run build:tokens   # tokens/affiliate.tokens.json → css/tokens.generated.css
npm test               # behaviour tests and an automated accessibility scan per component
Page.tsx
import { MerchantTable, StatusBadge } from '@/design-system/components';
import { sampleMerchants } from '@/design-system/lib';
import '@/design-system/css/index.css';

export function Merchants() {
  return (
    <div className="ds-scope">
      <MerchantTable rows={sampleMerchants} />
    </div>
  );
}

Rules for using this system

    Written to be followed without asking, by a designer, an engineer or an AI model building a new screen. Each rule points to the token, component or function that enforces it.

    1. Colour comes from semantic tokens. Use --ads-text-*, --ads-bg-*, --ads-border*, --ads-action-*, --ads-selected-*, --ads-focus-* and the status tokens. Never use the brand or gray ramps, or a hex value, inside a component.
    2. Status is colour plus words. Show a record’s state with <StatusBadge status="…" />, which picks the tone with statusTone(). Don’t choose a tone by hand, and never show a status by colour alone.
    3. Each status keeps one tone everywhere. Pending and Locking are warning, Approved is success, Paid is info, Reversed and Sync failed are danger, Paused is neutral. Add a new status to the map in src/design-system/lib.ts before using it.
    4. Numbers line up. Money and counts in tables are right-aligned (is-num) and use equal-width digits, which .ds-table already sets, so a column can be compared at a glance.
    5. Alerts last as long as the problem. An alert stays until its condition changes; a toast confirms something the user just did and leaves after four seconds. Warning and danger alerts use role="alert" and offer one recovery action at most.
    6. Chart colours are for series, not status. Series take --ads-viz-1 to --ads-viz-5 in order. Group anything past five into “Other” in viz-5.
    7. Text tones have one job each. --ads-text-muted is for captions and metadata, --ads-text-disabled for disabled controls only.
    8. Extend before adding. If a documented component can do the job with a new variant or prop, extend it. Add a component only when the job is different, not just the look.
    9. Every state is designed. Loading, empty and error states ship with the component, not after it.

    Testing

    Every React component has tests in src/design-system/components/components.test.tsx, run with npm test. The list below is read from that file when this page is built.

    • Markup and behaviour: Testing Library renders each component and checks it the way a reader would meet it: by role and accessible name.
    • Accessibility scan: each test also runs axe-core against WCAG rules such as names for buttons and images, valid ARIA and labelled form fields.
    • Not covered: interactions added by design-system.js, colour contrast (the test environment doesn’t render styles), testing with a real screen reader, and the CSS-only components (date range picker, stepper).

    Button

    • never submits a form and shows its label
    • names an icon-only button by its label
    • marks a loading button as busy

    TextField

    • ties the label to the field
    • marks the field invalid and ties the error message to it

    Alert

    • announces warnings and errors immediately, other alerts politely
    • labels the dismiss button

    Badge

    • pairs the tone with visible text, never colour alone

    StatusBadge

    • takes its tone from the status, so every screen agrees

    Delta

    • shows the change as text

    StatCard

    • shows label, value and change, and hides the decorative sparkline

    Segmented

    • is a labelled group of toggle buttons with one pressed

    MerchantTable

    • labels every checkbox by its merchant
    • marks the sorted column for screen readers
    • shows each status as a badge with text

    Pagination

    • is labelled navigation that marks the current page

    AreaChart

    • is a labelled figure; the drawing and axes are hidden from screen readers

    EntityLogo

    • is decorative: the name beside it is the label

    Icon

    • is hidden from screen readers

    Color

    • 2 ramps
    • 28 semantic tokens
    • WCAG AA text contrast

    Two primitive ramps feed a small set of semantic tokens. Components only ever reference semantic tokens, so a rebrand or dark theme is a token swap, not a redesign.

    Primitive ramps

    brand
    1. 50#FDF3F2
    2. 100#FBE3E1
    3. 200#F4C2BE
    4. 300#EA918D
    5. 400#E0605F
    6. 500#E0383A
    7. 600#CA0C0F
    8. 700#A30304
    9. 800#7A0203
    10. 900#520102
    gray
    1. 50#F5F6F8
    2. 100#EEF0F3
    3. 200#E3E6EA
    4. 300#CDD2D9
    5. 400#9AA1AB
    6. 500#636A75
    7. 600#3D434D
    8. 700#2B3038
    9. 800#1A1D23
    10. 900#0B0D12

    Semantic tokens

    Surface

    • --ads-bg-canvasApp background behind cards
      gray.50
    • --ads-bg-surfaceCards, tables, popovers
      own value
    • --ads-bg-subtleTable headers, hover rows
      gray.100
    • --ads-borderDividers and card edges
      gray.200
    • --ads-border-strongInputs and stronger dividers
      gray.300

    Text

    • --ads-text-primaryHeadings, values
      gray.900
    • --ads-text-secondaryBody copy, labels
      gray.600
    • --ads-text-mutedCaptions and metadata
      gray.500
    • --ads-text-disabledDisabled controls only
      gray.400

    Action

    • --ads-action-primaryPrimary buttons and links
      brand.600
    • --ads-action-hoverHover on primary
      brand.700
    • --ads-action-pressedActive and pressed
      brand.800
    • --ads-action-subtleSelected rows, subtle highlights
      brand.50

    Selected & focus

    • --ads-focus-outlineFocus outlines and open triggers
      brand.500
    • --ads-selected-textActive preset, tab count, applied filter
      brand.700
    • --ads-selected-text-strongBulk-action bar, dates in a range
      brand.800
    • --ads-selected-borderApplied filter chips
      brand.200
    • --ads-selected-dividerEdge of the bulk-action bar
      brand.100

    App sidebar

    • --ads-side-bgApp sidebar background
      own value
    • --ads-side-raised
      own value
    • --ads-side-hover
      own value
    • --ads-side-border
      own value
    • --ads-side-text
      own value
    • --ads-side-muted
      own value

    Status

    Success
    --ads-success#0E7A43 on #ECFAF1Approved, healthy
    Warning
    --ads-warning#A15C00 on #FFF7E8Pending, locking, at risk
    Danger
    --ads-danger#BE123C on #FFF1F3Reversed, failed, broken
    Info
    --ads-info#1F4FB8 on #EEF4FFPaid, scheduled, syncing

    Data visualisation

    Series colours are assigned in order and never reused for status. Five is the ceiling; group anything beyond that into “Other” in viz-5.

    1. --ads-viz-1#CA0C0F
    2. --ads-viz-2#0B0D12
    3. --ads-viz-3#E59A13
    4. --ads-viz-4#2563EB
    5. --ads-viz-5#A3AAB4

    Typography

    • Google Sans
    • JetBrains Mono
    • 14px base

    One family at nine sizes. Google Sans stays legible at 12px in dense tables, and every number uses tabular figures so columns of money line up.

    Google Sans

    Regular 400 · Medium 500 · SemiBold 600 · Bold 700

    $1,284.50$311.08$42.00 Tabular figures keep decimals aligned

    TokenSampleSize / lineWeightUse for
    text-display$128,430.5228 / 36700Page totals, empty states
    text-title-lgCommissions20 / 28600Page titles
    text-titleTop merchants this month16 / 24600Card and dialog titles
    text-bodyPayout batch will be sent on Oct 1.14 / 20400Default UI text, table cells
    text-body-smLast synced 12 minutes ago13 / 18400Dense tables, helper text
    text-labelCommission rate13 / 16500Form labels, buttons
    text-captionvs. previous 30 days12 / 16400Metadata, axis labels
    text-overlineNetwork11 / 16600Section labels, table headers
    text-monoTXN-48213 · SUB_ID=gl-home12 / 16400IDs, codes, tracking params

    Spacing & layout

    • 4px base unit
    • 216px sidebar

    Everything sits on a 4px grid. Density is a spacing decision: compact tables drop one step of padding rather than shrinking type.

    • space-14pxIcon to label
    • space-28pxInside compact controls
    • space-312pxTable cell padding (compact)
    • space-416pxCard padding, form rows
    • space-520pxCard padding (default)
    • space-624pxBetween cards
    • space-832pxPage gutters
    • space-1248pxBetween page sections

    Commission earned

    $27,738.40

    12.5%vs. previous 30 days
    202016
    Stat card: space-5 padding on all sides, space-4 between label and value.

    Radius & elevation

      Corners get rounder as surfaces get bigger. Shadows are reserved for things that float; resting content is separated with borders.

      • radius-sm4pxBadges, checkboxes
      • radius-md6pxButtons, inputs
      • radius-lg10pxCards, tables
      • radius-xl12pxDialogs, drawers
      • radius-full999pxAvatars, pills
      • elevation-0FlatBorder only. Inline panels, table rows.
      • elevation-1RaisedCards resting on the canvas.
      • elevation-2OverlayMenus, popovers, date pickers.
      • elevation-3ModalDialogs, drawers, toasts.

      Iconography

      • Lucide
      • 16 / 20px
      • currentColor

      Lucide at a 2px stroke, drawn at 16px inside controls and 20px in navigation. Icons support a label; they only stand alone when the action is universal and has an accessible name.

      Navigation

      • Overview
      • Performance
      • Commissions
      • Merchants
      • Networks
      • Links
      • Content
      • Sites
      • Team
      • Settings

      Actions

      • Add
      • Edit
      • Copy
      • Export
      • Filter
      • Search
      • Sync
      • Open
      • More
      • Close

      Data & status

      • Clicks
      • Rate
      • Revenue
      • Coupon
      • Card
      • Date
      • Success
      • Warning
      • Error
      • Info

      Button

      Buttons commit an action. Labels are a verb plus the thing it acts on, so a queue full of buttons still reads as a list of outcomes.

      src/design-system/components
      import { Button } from '@/design-system/components';
      Variants
      primaryThe one action a screen exists for.
      secondarySupporting actions next to a primary.
      ghostLow-emphasis and toolbar actions.
      dangerDestructive actions, always confirmed.
      States
      DefaultHoverFocusLoadingDisabled
      primary
      secondary
      ghost
      danger
      Sizes & icons
      PropValuesDefaultNotes
      variantprimary | secondary | ghost | dangerprimaryOne primary per view or dialog.
      sizesm | md | lgmdsm in table rows and toolbars; lg on touch-first flows.
      iconLeft / iconRightIconName—16px, or 14px at sm.
      loadingbooleanfalseKeeps width, sets aria-busy, blocks repeat submits.
      disabledbooleanfalsePair with a tooltip saying why.
      Do Lead with one primary action and let the rest step down in emphasis.
      Don’t Stack primaries side by side or use vague labels like “OK” and “Submit”.

      Text field

      • 2 tests
      • 5 states
      • Prefix / suffix
      • 36px height

      Labels always sit above the field and never disappear into placeholders. Errors say what went wrong and how to fix it, in that order.

      src/design-system/components
      import { TextField } from '@/design-system/components';
      States

      Default

      Shown on reports and invoices.

      Focus

      Shown on reports and invoices.

      Filled

      Shown on reports and invoices.

      Error

      Add https:// so the network can track clicks.

      Disabled

      Set by the network connection.
      Configurations
      %
      $USD
      PropValuesDefaultNotes
      labelstring—Required. Visually hidden only inside search bars.
      helperTextstring—Replaced by the error message when invalid.
      errorstring—Sets aria-invalid and links the message.
      prefix / suffixstring—Units and currency, never instructions.
      optionalbooleanfalseMark the minority: optional, not required.
      Add https:// so the network can track clicks.
      Do Write errors that name the fix: “Add https:// so the network can track clicks.”
      Invalid input!
      Don’t Blame the user or leave them guessing with “Invalid input”.

      Status badge

      • 2 tests
      • 5 tones
      • Dot + label
      • Never colour alone

      Badges label the state of a record. Five tones cover every status in the product, and each status maps to exactly one tone, everywhere.

      src/design-system/components
      import { Badge, StatusBadge } from '@/design-system/components';
      Tones
      NeutralInfoSuccessWarningDanger
      ExclusiveCPACoupon Without a dot: attributes and tags, not states.

      Commission lifecycle

      1. Pending

        Tracked by the network, still inside the return window.

      2. Locking

        Return window closed; network is finalising the amount.

      3. Approved

        Confirmed by the merchant and owed to the publisher.

      4. Paid

        Included in a payout batch that has been sent.

      5. Reversed

        Cancelled after a return, fraud check or duplicate.

      PropValuesDefaultNotes
      toneneutral | info | success | warning | dangerneutralDerive from status with statusTone(), never pick by hand.
      dotbooleantrueDot for states, no dot for tags.
      labelstring—One or two words, sentence case.

      Alert & toast

      • 2 tests
      • 5 variants
      • Optional action
      • Toast: 4s

      Alerts stay on the page until the condition changes. Toasts confirm something the user just did and leave on their own after four seconds.

      src/design-system/components
      import { Alert } from '@/design-system/components';
      Inline alerts

      Impact syncs every 4 hours

      Commissions from the last sync (12 minutes ago) are included. Newer sales will appear after 2:00 PM.

      Payout batch #2291 sent

      $18,402.16 across 41 publishers. Funds usually arrive in 2–3 business days.

      Currency is shown in USD. Change it in Settings → Reporting.

      Toast
      Tracking link copied
      PropValuesDefaultNotes
      variantinfo | success | warning | danger | neutralinfowarning and danger use role="alert".
      titlestring—States the situation in under eight words.
      actionstring—One recovery action at most.
      dismissiblebooleanfalseOnly for alerts that do not block work.

      Data table

      • 4 tests
      • Sortable
      • Selectable
      • 2 densities

      The workhorse. Tables pair a toolbar for search, filters and density with a body tuned for scanning: numbers right-aligned in tabular figures, one sorted column, and row actions that stay out of the way until needed.

      src/design-system/components
      import { MerchantTable, Pagination } from '@/design-system/components';
      Merchant performance
      2 selected · $15,796.40 in commission
      MerchantClicksConv.CVREPCStatusActions
      Backcountry
      Impact · Outdoor
      16,4203712.26%$0.30$4,986.24Active
      Crutchfield
      CJ · Electronics
      5,730941.64%$0.32$1,856.50Active
      Best Buy
      Impact · Electronics
      14,9605683.80%$0.12$1,760.80Active
      Dyson
      Awin · Home
      6,845580.85%$0.24$1,670.40At risk
      Sephora
      Rakuten · Beauty
      9,3102622.81%$0.10$969.40Active
      Trade Coffee
      ShareASale · Food & drink
      3,120882.82%$0.11$334.40Active
      Wayfair
      Impact · Home
      1,564120.77%$0.11$174.00Paused
      Showing 1–6 of 48

      Anatomy

      1. Toolbar Search, filter chips, density and export. Applied filters show their value and a clear action.
      2. Bulk bar Replaces nothing, pushes nothing: it appears above the header with a live total of what is selected.
      3. Entity cell Name plus one line of context (network · category), so the table rarely needs extra columns.
      4. Numeric columns Right-aligned, tabular, fixed decimals. The sorted column is marked and announced with aria-sort.
      5. Footer Range and total first, then pagination. Totals never change when paging.

      Density

      Comfortable
      48px rows · space-4 cell padding
      Compact
      36px rows · space-3 cell padding · context line hidden
      Default
      Comfortable

      Try the density toggle above; it is the same control operators use.

      Tabs & segmented control

      Tabs switch between views of the same records and carry counts so people know where work is waiting. Segmented controls change how the current view is shown: range, unit or density.

      src/design-system/components
      import { Segmented } from '@/design-system/components';
      Tabs with counts
      Segmented control
      Do Use tabs for the same records filtered by status, with counts that match the rows below.
      Don’t Use tabs to navigate between unrelated pages. That is what the sidebar is for.

      Date range picker

      • CSS and markup, no React component
      • Presets
      • 2-month view
      • Keyboard: arrows, Enter

      Reporting runs on ranges, so presets come first and the calendar second. Future dates are disabled because commissions cannot be earned tomorrow.

      Open state
      August 2026
      12345678910111213141516171819202122232425262728293031
      September 2026
      123456789101112131415161718192021222324252627282930
      Aug 26, 2026 – Sep 24, 2026 · 30 days

      Stat card

      • 2 tests
      • Label · value · delta
      • Optional sparkline

      A single number with its comparison. The delta is coloured by whether the change is good, not by its direction, so a falling reversal rate reads green.

      src/design-system/components
      import { StatCard, Delta, Sparkline } from '@/design-system/components';
      Examples

      Commission earned

      $27,738.40

      12.5%vs. previous 30 days

      Earnings per click

      $0.48

      3.1%vs. previous 30 days

      Reversal rate

      4.2%

      0.8 ptsvs. previous 30 days
      PropValuesDefaultNotes
      labelstring—Name the metric, not the period.
      valuestring—Pre-formatted; currency keeps two decimals.
      deltastring—Percent for totals, pts for rates.
      sentimentauto | positive | negativeautoOverride when down is good.
      captionstringvs. previous 30 daysAlways state the comparison.

      Area chart

      • 1 test
      • Max 5 series
      • Y-axis from zero
      • Hover + keyboard tooltip

      For one metric over time, stacked when the parts add up to a meaningful total. Hover shows every series at that point with its change from the previous period.

      src/design-system/components
      import { AreaChart } from '@/design-system/components';
      Stacked · commission by network
      • Impact
      • Rakuten
      • CJ
      Do Put the largest series at the bottom of the stack so the baseline everyone reads from stays steady.
      Don’t Stack rates or averages. EPC and conversion rate do not add up, so use a line chart.

      Stepper

      • CSS and markup, no React component
      • Done · current · upcoming
      • aria-current="step"

      Shows progress through a setup flow that spans sessions. Each step says what is left, not just its name, so people can pick up where they stopped.

      Publisher onboarding
      1. Add your sitegearlabreviews.example verified
      2. 2Connect networks2 of 4 connected
      3. 3Import linksScans existing affiliate links
      4. 4Set payout detailsBank or PayPal

      App navigation

      • 216px sidebar
      • Site switcher
      • ⌘K search

      A fixed sidebar holds the product areas and the site switcher; the top bar holds where you are and global search. Every screen in the examples uses this shell unchanged.

      src/design-system/components
      import { ShellChrome } from '@/design-system/components';
      App shell
      1. Gearlab Reviews
      2. Commissions

      Commissions

      Page header: title, one-line context, and page-level actions on the right.

      Page content
      PropValuesDefaultNotes
      activeNavItem—Sets aria-current="page" and the subtle action fill.
      countnumber—Only for items with work waiting, like pending commissions.
      siteSite—Switcher scopes every screen to one site or “All sites”.

      In use

      Reporting, merchant setup, commissions and network connections in the interactive prototype, built with these foundations and components. See the example screens →