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.
npm run build:tokens # tokens/affiliate.tokens.json → css/tokens.generated.css
npm test # behaviour tests and an automated accessibility scan per componentimport { 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.
- 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. - Status is colour plus words. Show a record’s state with
<StatusBadge status="…" />, which picks the tone withstatusTone(). Don’t choose a tone by hand, and never show a status by colour alone. - 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.tsbefore using it. - Numbers line up. Money and counts in tables are right-aligned (
is-num) and use equal-width digits, which.ds-tablealready sets, so a column can be compared at a glance. - 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. - Chart colours are for series, not status. Series take
--ads-viz-1to--ads-viz-5in order. Group anything past five into “Other” in viz-5. - Text tones have one job each.
--ads-text-mutedis for captions and metadata,--ads-text-disabledfor disabled controls only. - 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.
- 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
- 50
#FDF3F2 - 100
#FBE3E1 - 200
#F4C2BE - 300
#EA918D - 400
#E0605F - 500
#E0383A - 600
#CA0C0F - 700
#A30304 - 800
#7A0203 - 900
#520102
- 50
#F5F6F8 - 100
#EEF0F3 - 200
#E3E6EA - 300
#CDD2D9 - 400
#9AA1AB - 500
#636A75 - 600
#3D434D - 700
#2B3038 - 800
#1A1D23 - 900
#0B0D12
Semantic tokens
Surface
- gray.50
- own value
- gray.100
- gray.200
- gray.300
Text
- gray.900
- gray.600
- gray.500
- gray.400
Action
- brand.600
- brand.700
- brand.800
- brand.50
Selected & focus
- brand.500
- brand.700
- brand.800
- brand.200
- brand.100
App sidebar
- own value
- own value
- own value
- own value
- own value
- own value
Status
--ads-success#0E7A43 on #ECFAF1Approved, healthy--ads-warning#A15C00 on #FFF7E8Pending, locking, at risk--ads-danger#BE123C on #FFF1F3Reversed, failed, broken--ads-info#1F4FB8 on #EEF4FFPaid, scheduled, syncingData 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.
--ads-viz-1#CA0C0F--ads-viz-2#0B0D12--ads-viz-3#E59A13--ads-viz-4#2563EB--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
| Token | Sample | Size / line | Weight | Use for |
|---|---|---|---|---|
text-display | $128,430.52 | 28 / 36 | 700 | Page totals, empty states |
text-title-lg | Commissions | 20 / 28 | 600 | Page titles |
text-title | Top merchants this month | 16 / 24 | 600 | Card and dialog titles |
text-body | Payout batch will be sent on Oct 1. | 14 / 20 | 400 | Default UI text, table cells |
text-body-sm | Last synced 12 minutes ago | 13 / 18 | 400 | Dense tables, helper text |
text-label | Commission rate | 13 / 16 | 500 | Form labels, buttons |
text-caption | vs. previous 30 days | 12 / 16 | 400 | Metadata, axis labels |
text-overline | Network | 11 / 16 | 600 | Section labels, table headers |
text-mono | TXN-48213 · SUB_ID=gl-home | 12 / 16 | 400 | IDs, 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 labelspace-28pxInside compact controlsspace-312pxTable cell padding (compact)space-416pxCard padding, form rowsspace-520pxCard padding (default)space-624pxBetween cardsspace-832pxPage guttersspace-1248pxBetween page sections
Commission earned
$27,738.40
Radius & elevation
Corners get rounder as surfaces get bigger. Shadows are reserved for things that float; resting content is separated with borders.
radius-sm4pxBadges, checkboxesradius-md6pxButtons, inputsradius-lg10pxCards, tablesradius-xl12pxDialogs, drawersradius-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.
Button
- 3 tests
- 4 variants
- 3 sizes
- 6 states
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.
import { Button } from '@/design-system/components';primaryThe one action a screen exists for.secondarySupporting actions next to a primary.ghostLow-emphasis and toolbar actions.dangerDestructive actions, always confirmed.| Default | Hover | Focus | Loading | Disabled | |
|---|---|---|---|---|---|
primary | |||||
secondary | |||||
ghost | |||||
danger |
| Prop | Values | Default | Notes |
|---|---|---|---|
variant | primary | secondary | ghost | danger | primary | One primary per view or dialog. |
size | sm | md | lg | md | sm in table rows and toolbars; lg on touch-first flows. |
iconLeft / iconRight | IconName | — | 16px, or 14px at sm. |
loading | boolean | false | Keeps width, sets aria-busy, blocks repeat submits. |
disabled | boolean | false | Pair with a tooltip saying why. |
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.
import { TextField } from '@/design-system/components';Default
Focus
Filled
Error
Disabled
| Prop | Values | Default | Notes |
|---|---|---|---|
label | string | — | Required. Visually hidden only inside search bars. |
helperText | string | — | Replaced by the error message when invalid. |
error | string | — | Sets aria-invalid and links the message. |
prefix / suffix | string | — | Units and currency, never instructions. |
optional | boolean | false | Mark the minority: optional, not required. |
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.
import { Badge, StatusBadge } from '@/design-system/components';Commission lifecycle
- Pending
Tracked by the network, still inside the return window.
- Locking
Return window closed; network is finalising the amount.
- Approved
Confirmed by the merchant and owed to the publisher.
- Paid
Included in a payout batch that has been sent.
- Reversed
Cancelled after a return, fraud check or duplicate.
| Prop | Values | Default | Notes |
|---|---|---|---|
tone | neutral | info | success | warning | danger | neutral | Derive from status with statusTone(), never pick by hand. |
dot | boolean | true | Dot for states, no dot for tags. |
label | string | — | 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.
import { Alert } from '@/design-system/components';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.
3 links point to expired offers
Clicks still land on the merchant but will not earn commission.
Awin connection failed
The API token was revoked on Sep 22. Reconnect to resume syncing commissions.
Currency is shown in USD. Change it in Settings → Reporting.
| Prop | Values | Default | Notes |
|---|---|---|---|
variant | info | success | warning | danger | neutral | info | warning and danger use role="alert". |
title | string | — | States the situation in under eight words. |
action | string | — | One recovery action at most. |
dismissible | boolean | false | Only 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.
import { MerchantTable, Pagination } from '@/design-system/components';| Merchant | Clicks | Conv. | CVR | EPC | Status | Actions | ||
|---|---|---|---|---|---|---|---|---|
Backcountry | 16,420 | 371 | 2.26% | $0.30 | $4,986.24 | Active | ||
Crutchfield | 5,730 | 94 | 1.64% | $0.32 | $1,856.50 | Active | ||
Best Buy | 14,960 | 568 | 3.80% | $0.12 | $1,760.80 | Active | ||
Dyson | 6,845 | 58 | 0.85% | $0.24 | $1,670.40 | At risk | ||
Sephora | 9,310 | 262 | 2.81% | $0.10 | $969.40 | Active | ||
Trade Coffee | 3,120 | 88 | 2.82% | $0.11 | $334.40 | Active | ||
Wayfair | 1,564 | 12 | 0.77% | $0.11 | $174.00 | Paused |
Anatomy
- Toolbar Search, filter chips, density and export. Applied filters show their value and a clear action.
- Bulk bar Replaces nothing, pushes nothing: it appears above the header with a live total of what is selected.
- Entity cell Name plus one line of context (network · category), so the table rarely needs extra columns.
- Numeric columns Right-aligned, tabular, fixed decimals. The sorted column is marked and announced with aria-sort.
- 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.
import { Segmented } from '@/design-system/components';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.
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.
import { StatCard, Delta, Sparkline } from '@/design-system/components';Commission earned
$27,738.40
Earnings per click
$0.48
Reversal rate
4.2%
| Prop | Values | Default | Notes |
|---|---|---|---|
label | string | — | Name the metric, not the period. |
value | string | — | Pre-formatted; currency keeps two decimals. |
delta | string | — | Percent for totals, pts for rates. |
sentiment | auto | positive | negative | auto | Override when down is good. |
caption | string | vs. previous 30 days | Always 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.
import { AreaChart } from '@/design-system/components';- Impact
- Rakuten
- CJ
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.
- Add your sitegearlabreviews.example verified
- 2Connect networks2 of 4 connected
- 3Import linksScans existing affiliate links
- 4Set payout detailsBank or PayPal
In use
Reporting, merchant setup, commissions and network connections in the interactive prototype, built with these foundations and components. See the example screens →