Files
co-lite/solvway-admin-portal/docs/design/DASHBOARD-STANDARD.md
T
ngqileandClaude Opus 5.5 5ee51d1913 chore: copy kept Tastefully modules and portals into Co-Lite
Backend modules from tastefully 8bd93d15: core-libs, core-session,
api-gateway, mobile-api, services-auth, services-system,
services-counter, services-member, services-log, services-email.
solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal
from tastefully 8bd93d15. Copied as tracked files only.

Literal secrets replaced with environment placeholders:
- services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY,
  MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default)
- services-system: JUMIO_TOKEN, JUMIO_SECRET (optional)
- services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed
- core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default
  removed, ipgeolocation key read from IPGEOLOCATION_API_KEY
- services-system EkycAppConfig: commented Jumio credentials removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-11-26 15:55:45 +08:00

27 KiB
Raw Blame History

Dashboard Design Standard

Scope: every screen in backoffice-template and every client project forked from it. Status: authoritative. Where this document and a component disagree, the component is wrong. Basis: the ui-ux-pro-max design-intelligence skill, whose database matches an MLM back-office to its Data-Dense Dashboard style — multiple charts/widgets, data tables, KPI cards, minimal padding, grid layout, maximum data visibility, rated ⚡ excellent performance / ✓ WCAG AA.

Current client: babyboo.my — baby & maternity retail, competing against Medela, Momcozy, Kinderkraft and Hamilton. The audience is sleep-deprived, time-poor, highly selective parents, so every decision is ranked clarity → speed → trust, in that order. The register is warm and reassuring rather than clinical: a cream page instead of white, warm neutrals instead of grey, and a generous radius so nothing on screen has a sharp edge. Density stays — this is still an operator tool — but softened.

Two of the skill's raw recommendations are deliberately rejected, and must not be reintroduced:

Rejected Why
Dark-first palette (#020617 bg) CoLink PRODUCT.md lists "dark terminal aesthetic" as an anti-reference for admin staff working in daylit offices. We ship light-default with a full dark option.
Fira Code as heading font Monospace headings read as developer-tooling. Wrong register for non-technical association staff. Monospace is reserved for numerals.

1. Principles

  1. Clarity over cleverness. Every screen makes the next action obvious. Navigation, labels and hierarchy exist to guide, not to impress.
  2. Context awareness. Admins and members have different jobs. Orient each to what matters without making them hunt.
  3. Earned polish. Refinement comes from precision — consistent spacing, deliberate colour, purposeful motion — never from decoration piled on top.
  4. Progressive disclosure. Surface the common task immediately; keep advanced options reachable but out of the way. Not every edge case is a first-class element.
  5. Trustworthy by default. This software handles money and personal data. Communicate reliability through consistency, clear feedback, and explicit confirmation of destructive actions.

Anti-references — if a screen starts resembling these, stop: generic SaaS-blue admin template; cluttered legacy ERP (microscopic labels, toolbar overload, modal-on-modal); dark code-editor UI; anything that feels clinical, sterile or hard-edged.

Tone for babyboo.my. Warm, safe, calm. Rounded corners everywhere — --radius is 1rem and even the derived sm size is 12px. Badges are pills. Avatars and brand marks are circles. No square chips, no hairline-sharp dividers, no cold greys: neutrals are warm-tinted throughout. A tired parent scanning this at 3am should find it soft to look at and obvious to operate.


2. Tokens

All colour lives as plain CSS custom properties in app/globals.css — :root is light, .dark is dark — mapped into Tailwind by tailwind.config.ts (through color-mix, so opacity modifiers work). No component may contain a colour literal. Re-skinning a client = editing those two blocks, nothing else. Every colour token needs a value in both blocks. scripts/check-contrast.py reads the same file. (These tokens used to live in src/styles/_variables.scss; references to that file below are historical.)

The palette is CoLink's: indigo primary, pink accent.

Token Light Dark Use
--background #FDFBF7 #17120F Page canvas — warm cream, not white
--foreground #121212 #F8F4EF Body text (client-specified)
--card #FFFFFF #211A16 Widget/table surface
--primary #6E3E17 #D9A05B Brand, primary action, active nav
--primary-foreground #FFFFFF #241A10 Text on primary
--accent #F2BC57 #F2BC57 Brand gold — fill only, always with --accent-foreground
--accent-foreground #3A2410 #241A10 Text/glyphs sitting on an accent fill
--accent-strong #9A6212 #F2BC57 The accent family as text, icon or stroke
--muted #F7F2EA #2E251F Subtle fills, table stripes
--muted-foreground #6F5B48 #BCA994 Secondary text — floor value, never lighter
--positive #1B6E3E #6FCF97 Gains, paid, active
--negative #B3261E #F08A82 Losses, suspended, errors
--warning #8F5200 #F0B94A Pending, inactive
--border #EDE4D8 #332A23 Dividers only — decorative, deliberately subtle
--input #8D7761 #7A6A5C Form-control boundaries — must clear 3:1
--ring #6E3E17 #D9A05B Focus ring
--radius 1rem — lg; md = −2px, sm = −4px. Generous by brief
--table-head #F7D99A #4A3A1A Data-table header row (soft gold; full --accent is too low for dusty-blue text, 4.0:1)
--table-head-foreground #3E5C7A #DBE7F2 Header text, incl. sortable headers (5.1:1 / 8.8:1); sorted column = arrow + bold
--table-radius calc(var(--radius) - 4px) = 12px — Data-table frames (rounded-table), tighter than cards (20px) for dense data — added 2026-10-23
--contrast #4F7396 #9DB8D2 Dusty blue (added 2026-10-23): icon/stroke for kinds, never status or a primary action
--contrast-foreground #3E5C7A #DBE7F2 Text on a --contrast-soft pill (5.8:1 / 10.7:1)
--contrast-soft #E4ECF3 #22303D Fill of a category pill

Category pills (added 2026-10-23). A kind — order type, fulfilment mode — is not a state, so it never borrows the status tones. Badge has three category tones: contrast (dusty blue), teal (--chart-2) and violet (--chart-4), each a 10% tint with its own text colour (all ≥ 4.5:1, verified by check-contrast.py), plus neutral. Sales listing: Web / Delivery = contrast, Event = violet, Outlet / Pickup = teal, Counter / Take now = neutral (ORDER_TYPE_TONE, FULFILMENT_TONE). The pill always carries its label. The same tones colour each channel everywhere: dashboard Revenue-by-channel bars and the Reports Channel column use channelTone (NORMAL = contrast, EVENT = violet, OUTLET = teal) and CATEGORY_TONE_COLOR (--contrast, --chart-4, --chart-2, --muted-foreground). The dashboard revenue trend is drawn in --contrast, top-earner bars in --chart-2, and the Reports totals strip sits on --contrast-soft.

Brand pattern. .giraffe-spots (in app/globals.css, artwork --giraffe-motif) turns an element into the giraffe-coat pattern via a mask, coloured by --giraffe-patch (default --accent). Used on the login brand panel as a brown coat (--giraffe-patch: var(--primary)) at 14% over --accent — dark --accent-foreground text stays ≥ 7.0:1 on a patch. Decorative; elsewhere only where the owner specifies.

The brand gold is a fill, never a colour. #F2BC57 measures 1.73:1 against white, so on a light surface it can never carry text, a thin indicator line, or a chart series — it would be invisible. It is only ever a filled surface with --accent-foreground on top (8.41:1). Anything in the accent family that has to carry meaning — an icon glyph, a sparkline stroke, an active indicator bar — uses --accent-strong (5.08:1). This is why the accent is absent from the chart ramp, and why the contrast script checks accent-strong strictly while exempting accent itself.

Dark --primary is a lightened tint of the brand brown: #6E3E17 is too dark to read as a surface against an espresso background, so dark mode inverts the relationship and puts dark text on gold-brown.

Borders are two-tier, and this is deliberate. A divider between table rows is decoration and is exempt from contrast minimums, so --border stays light. The boundary of a control the user has to find and operate is a UI component under WCAG 1.4.11 and needs ≥3:1 — hence --input is visibly darker. Using --border on an input is a violation.

Every pair above is verified by python3 scripts/check-contrast.py, which reads the Sass maps directly and exits non-zero on any regression. Run it after touching the palette.

Chart series

Five categorical series, each ≥3:1 against its card surface. Assign by index, never by meaning — --chart-1 is not "revenue".

Token Light Dark
--chart-1 #6E3E17 #D9A05B
--chart-2 #1F6F6B #5FC9C0
--chart-3 #A15C00 #F0B94A
--chart-4 #7B5AC6 #B49BF0
--chart-5 #A63D5B #E88AA5

Adjacent hues can converge under colour-vision deficiency. Any chart relying on more than three series must carry value labels or a legend — colour is never the sole channel.

Typography

Loaded via next/font/google in app/layout.tsx (self-hosted at build, no runtime CSS @import).

Role Family Rules
Headings DM Sans 500/600/700 Owner decision 2026-09-29 (replaces Google Sans). Tight tracking, text-balance on multi-word titles
Body / UI Inter 400/500 ≥16px, line-height 1.5–1.75, max 65–75 chars per line
Numerals Inter + tnum Every currency figure, ID, percentage and table number, via .tabular. Inter's own tabular figures keep columns aligned and digits stable.
Code editors System monospace Code editors (email HTML) may use a monospace font. Owner-approved exception to the no-monospace rule.

Two families. Monospace only for code editors (the email-template HTML body); never for headings, labels or numerals. Numerals ride the body font because Inter ships true tabular figures, so columns still align — and monospace digits read technical, which is the wrong register for a parenting brand. It also removes a font request, which serves the speed priority.

src/styles/index.scss carries a commented @font-face block if Google Sans needs to be self-hosted (offline builds, or a licensed variant); drop the woff2 files into public/fonts/ and uncomment. DM Sans covers the gap if the family fails to load — do not substitute a lookalike and call it Google Sans.

Density & spacing

8pt scale (--space-1 = 4px … --space-10 = 40px). Data-dense means tight, not cramped:

Element Value
Table row height 36px
Card padding 16px (12px on ≤768px)
Grid gutter 16px
Section gap 24px
Control height 36px (touch target padded to ≥44×44px)

Z-index scale

Defined once, in the $z map in src/styles/_variables.scss:

10 sticky table header row · 30 app header · 40 sidebar + dropdown/popover · 45 mobile sidebar overlay · 50 dialog/toast. No other values, and no bare numbers in components.


3. Layout

12-column grid, max-w-[1600px], gutters 16px. One consistent container width across all screens — never mix.

┌──────────┬──────────────────────────────────────────────┐
│ SIDEBAR  │ HEADER  breadcrumbs · theme · user           │
│ 272px    ├──────────────────────────────────────────────┤
│ (76px    │ CONTENT  max-w-1600, p-16                    │
│ collapsed)│                                             │
└──────────┴──────────────────────────────────────────────┘

Breakpoints: 375 / 768 / 1024 / 1440. Sidebar becomes an off-canvas sheet below 1024px. Content must never scroll horizontally — wide tables scroll inside their own overflow-x-auto container.


4. Navigation

The renderer supports up to three levels (MAX_NAV_DEPTH), and refuses to render deeper rather than silently nesting forever.

Two levels remains the default for production IA. A third level buys grouping at the cost of hiding things behind two clicks, so it earns its place only when it groups filters over one collection — Members → By rank → Diamond — where the parent is a facet name and nothing is reachable only from there. It does not earn its place when it buries distinct destinations; those belong at level one or two, or on the page itself. If a third level is the only way to fit the nav in, the nav is too big.

The current tree exercises all three levels deliberately, so the pattern is proven rather than theoretical — see the backend contract note below.

  • Every second-level entry must resolve to a real view — a route, or a filter the target page already reads from the URL. No decorative parents, no dead links.
  • A group whose section contains the current route opens itself; it does not trap the user in whatever they last opened by hand.
  • Active state is carried by aria-current="page" plus a primary fill and an --accent indicator bar — three signals, not colour alone.
  • Second-level entries that differ only by query string must distinguish themselves by it. "All members" must not claim to be current when ?status=suspended is applied.
  • Collapsed rail: labels are hidden, title supplies the name, and clicking a group expands the rail and opens that group in one action rather than doing nothing.
  • Below lg: the rail becomes an overlay drawer — closes on navigation, on overlay click and on Escape, locks body scroll while open, and is aria-hidden when shut so its links stay out of the tab order.
  • Collapsed state persists per browser; it is a workspace preference, not app state.

Deeper levels inherit every rule above. Specifically: a group opens itself when anything at any depth beneath it is current (so the whole chain to the active entry unfolds), sibling groups stay shut, and an unfiltered "All …" entry stops being current as soon as any descendant's filter key appears in the URL — including keys introduced two levels down.

Backend contract

src/components/app/nav-config.ts is plain serialisable data — label, to, children, isDefault — with the icon as the only client-side concern. A menu endpoint can return this shape verbatim. nav-config.test.ts encodes the invariants such an endpoint must satisfy: every node is a leaf with a target or a group with children and never both, depth never exceeds the cap, every leaf resolves to a real route, targets are unique, and a group carries at most one isDefault entry.


5. KPI tile

The dashboard's top row. Each tile answers what is it, how big, which direction.

┌────────────────────────────────┐
│ TOTAL SALES            ▲ +12.4%│   label: 12px uppercase muted, tracking-wide
│ RM 486,250.00                  │   value: 28px Fira Code tabular, foreground
│ ╭─╮                            │   delta: arrow + explicit sign + %, positive/negative
│ ╰─╯╲╱╰──╱╰─  vs last month     │   sparkline: 12 pts, --chart-1, no axes
└────────────────────────────────┘

Rules:

  • Delta carries three redundant signals: colour, arrow glyph, and an explicit +/− sign. Colour alone fails colourblind users and fails WCAG 1.4.1.
  • Always state the comparison basis in words ("vs last month"). A bare percentage is unreadable.
  • A delta of exactly 0 renders neutral (--muted-foreground), not green.
  • Sparklines are decorative: no axes, no gridlines, no tooltip, aria-hidden="true". The number is the accessible content.
  • Never more than 6 tiles. Beyond that nothing is prominent.

6. Charts

Match the chart to the data question — from the skill's chart database:

Question Chart Notes
Trend over time Line Primary series --chart-1, 2px stroke. Optional 20%-opacity fill.
Compare categories Horizontal bar Sorted descending, value label on each bar. Highest-value insight per pixel.
Cumulative growth Area Single series, 20% fill, no stacking beyond 3 series.
Share of total Bar, not pie Pie only for ≤3 slices where the total genuinely matters.

Implementation — Recharts through shadcn's chart wrapper, so theming is automatic in both modes:

<ChartContainer config={chartConfig} className="h-[280px] w-full">
  <LineChart data={monthlyRevenue} margin={{ left: 12, right: 12 }}>
    <CartesianGrid vertical={false} stroke="var(--border)" />
    <XAxis dataKey="month" tickLine={false} axisLine={false} />
    <ChartTooltip content={<ChartTooltipContent />} />
    <Line
      dataKey="amount"
      stroke="var(--color-amount)"
      strokeWidth={2}
      dot={false}
    />
  </LineChart>
</ChartContainer>

Mandatory:

  • Every chart has a visual hierarchy. One dominant chart per screen; supporting charts are visibly smaller. A grid of same-size charts tells the reader nothing about what matters.
  • Y-axis on currency starts at zero. Truncated axes exaggerate change and erode trust.
  • Grid lines: horizontal only, --border. No vertical grid, no chart-junk borders.
  • Tooltips on hover, 150ms; never the only route to a value.
  • Accessible alternative required: each chart is paired with a <table class="sr-only"> of the same data, or the figures appear in adjacent visible text. (Skill rule data-table.)
  • Empty series renders the empty state — not an axis framing nothing.

7. Tables & trees

Tables are the primary workspace of a back office, so they get the most care.

  • Sticky header (z-10), --card background, semibold 12px uppercase labels.
  • Sortable columns show direction; the sorted column stays visually marked at rest.
  • Filterable is mandatory for any table that paginates. A paging list view without filtering is an explicit skill anti-pattern (no-filtering). Status/rank use faceted filters with result counts. This applies to primary list views (Members, Reports); a bounded sub-list — one member's own sales history, their direct downline — is exempt, because the enclosing record already scopes it and adding controls there is noise, not progressive disclosure.
  • Row hover uses --muted background only. Never a transform — hover must not shift layout.
  • Clickable rows: cursor-pointer, a real focusable link inside for keyboard and middle-click.
  • Numeric columns right-aligned, Fira Code tabular.
  • Filter state lives in the URL query string so a filtered view is shareable and survives reload.
  • Pagination shows total and range ("11–20 of 60"), never bare page numbers.
  • Export acts on the entire filtered result set, not the visible page.

Trees (genealogy): role="tree"/treeitem with aria-expanded; connector lines drawn with borders, not box-drawing characters; search auto-expands only the ancestors of matches and highlights the match with <mark>; expand/collapse controls are ≥44×44px hit areas.

Alternate views of one hierarchy share one expansion state. The indented tree and the top-down chart read the same expandedIds, so switching view keeps the same branch open. A view that ignores it renders the entire hierarchy, which on a real network means an unnavigably wide canvas — and it makes the collapse controls in that view meaningless.

Any canvas that can outgrow its viewport owes the user an anchor. Scroll position is centred on the root on mount and whenever the canvas can have resized, and an explicit Recenter control is always present. Opening on an arbitrary slice with no cue about which way to scroll is a defect, not a detail.


8. Required states

Every data-bound view implements four states. A screen missing one is incomplete.

State Requirement
Loading Skeleton matching the real layout's shape, per widget. Never one page-wide spinner — that hides already-available data and causes layout jump. Reserve final dimensions (skill rule content-jumping).
Empty Icon + one-line cause + the corrective action ("No members match these filters" + Clear filters). Never a bare "No data".
Error Human sentence, role="alert", and a Retry control. Never a raw exception string.
Partial Non-critical failures degrade silently and locally — a failed filter-options fetch must not blank the table.

9. Accessibility — WCAG 2.1 AA, non-negotiable

  • Contrast ≥4.5:1 body text, ≥3:1 large text and UI boundaries — verified in both modes.
  • Visible focus ring on every interactive element: ring-2 ring-ring ring-offset-2. Never outline: none without a replacement.
  • Touch targets ≥44×44px, including icon buttons and tree togglers.
  • Icon-only buttons carry aria-label. Decorative glyphs get aria-hidden.
  • Tab order matches visual order. Dialogs trap focus and restore it to the trigger on close.
  • Every input has a real <label for>. Placeholders are not labels.
  • Colour is never the only carrier of meaning — pair with glyph, text, or shape.
  • All motion respects prefers-reduced-motion: reduce.
  • Charts have a table or text equivalent (§6).

10. Motion

150–300ms, transform/opacity only (never width/height/top — they trigger layout).

Interaction Duration
Hover / focus colour 150ms
Dropdown, popover, tooltip 200ms
Dialog, sheet 250ms
Skeleton → content 200ms fade

Nothing loops. Nothing animates on page load beyond a single content fade. No parallax, no gradient-shifting backgrounds, no scroll-jacking. All of it gated:

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

11. Anti-patterns

Rejected outright — these are the specific things that make an admin UI look amateur:

  • Emoji as icons. Lucide SVG only, consistent 24×24 viewBox, rendered size-4/size-5.
  • Scale-transform hovers (hover:scale-105) — they shift neighbouring layout. Use colour, border or shadow.
  • bg-white/10 glass in light mode — invisible. bg-card or ≥80% opacity.
  • gray-400 body text — fails contrast. --muted-foreground is the floor.
  • border-white/10 — invisible in light mode. Use --border.
  • Filterless or unsortable data tables (skill anti-pattern).
  • Decorative gradients, glows, animated backgrounds (skill anti-pattern for this style). Two narrow exceptions, and only these two: a fill under a data line in a chart or sparkline, which is data visualisation rather than ornament; and the brand wordmark, which is identity. Both go through @include brand-gradient-text or a chart <linearGradient> — never an ad-hoc page background.
  • Mixed container widths across screens.
  • Modal-on-modal, and toolbars of more than 5 controls.
  • var() wrappers in class names where a theme utility exists — bg-primary, not bg-[var(--primary)].
  • Fabricated data. No placeholder deltas, sparklines or totals that aren't computed from the service layer. A number on screen must be real or absent.

Pre-delivery checklist

Run before any screen is called done:

Visual — no emoji icons · one icon set · hover causes no layout shift · theme utilities not var() wrappers · one dominant chart per screen Interaction — cursor-pointer on everything clickable · visible hover feedback · transitions 150–300ms · async buttons disable while pending Modes — light contrast ≥4.5:1 · dark contrast ≥4.5:1 · borders visible in both · no transparent surface unreadable in light Layout — no horizontal scroll at 375/768/1024/1440 · nothing hidden behind sticky elements · consistent max-width A11y — labels on all inputs · aria-label on icon buttons · keyboard-only pass completes every task · focus visible throughout · colour never the sole signal · prefers-reduced-motion honoured Data — loading, empty, error and partial states all implemented · every figure traceable to src/services/*


Re-skinning for a client

  1. Edit $palettes in src/styles/_variables.scss — primary, accent, chart ramp, radius.
  2. Swap the font <link> in index.html and the --font-* tokens in src/styles/tailwind.css.
  3. Replace the wordmark in the sidebar header.
  4. Run python3 scripts/check-contrast.py and fix anything it flags.

Nothing else should require changes. If a client re-skin forces you into component source, that component has a hardcoded value and is in violation of §2.