Table of contents
- The common pieces
- Modal
- Tabs
- Expanders (More / Less)
- Collapsible sections
- Section tabs (the sub-nav)
- Search boxes
- Quick jump
- Buttons and forms
- Pending names (live regions)
- Countdowns
- Tables with a filter box
- Home widgets
- Character selector
- Auto-refresh pages
- Tables
- Phone sheets
- Phone and touch styles
- Geometry through data attributes
- Tooltips
The common pieces
Everything below already exists. Use these; don't build a second one. Markup contracts are the whole API: if you change one side, the other side and its tests change in the same commit.
Modal
One implementation behind every pop-up (add-module, fit picker,
planner dialogs, quick jump). Markup: a .modal-backdrop
wrapping a .modal, rendered hidden. Drive it through
EveSynapseModal:
open(el, {onClose, focus}): shows the backdrop in the browser's top layer (manual popover, so the blur covers top bar and sidebar), captures focus and moves it in.focus: falseopts out.close(el),isOpen(el): close returns focus to whatever had it;onCloseruns on every close, however it came.- Backdrop click, any
[data-close-modal]inside, or Escape closes the topmost. Dialogs inside swapped-out content close with the swap.
Tabs
A strategy/tabbed block is a [data-tabs] container whose
tablist renders hidden and whose panels (role="tabpanel",
each with an id, each tab a role="tab" button with
aria-controls naming its panel and id="<panel>-tab") all
render stacked under their own headings. That's the no-JS page.
JS unhides the list, shows one panel at a time, and adds
.tabs-on to the container so CSS can drop the per-panel
headings. Arrow keys move along the list; a URL hash naming a
panel opens it. The trade-ideas page and home module are the
worked example.
Expanders (More / Less)
One mechanism for every summary/detail pair: the detail block
carries data-wmore, its control carries data-expand naming
the block's id. Home modules get their control injected into
the heading automatically (below); table rows that own a
detail row render their control server-side and use the same
switch. Without JS every detail block renders open. Open state
is a per-browser convenience in localStorage
(evesynapse.home.expanded).
Collapsible sections
A section marked data-fold="closed" starts folded; fold
buttons are added per node by app.js, so fresh swapped content
folds the same way. Fold at the smallest sensible unit on the
page, not around whole pages.
Section tabs (the sub-nav)
A page's section tabs are {{template "sectiontabs" .}} in its
pagetabs block. base.html renders that block inside the sub-nav
bar (.subnav), first in main, so it docks under the top bar and
rides with it. The bar carries the section's category navigation
on one row: the groups as inverted folder tabs hanging from the top
bar's edge, then the active group's pages. It renders the current
section's links from sectionNav (nav.go), the same list the
sidebar menus render from, and appears only on the section's own
pages. Never hand-write a tab strip in a page body. When tabs stop
fitting their row, app.js folds the ones that don't fit into the
strip's More disclosure: the fit is measured, the active tab never
folds, and widening restores.
In the phone band (max-width: 45rem) the shell navigates from a
fixed bottom bar instead: Home, the bottomBarSlots sections
(nav.go) and a Sections button opening a sheet with every section,
its groups, the character switcher and the account actions, all
derived from the same sectionNav. The sub-nav keeps one row
there: the group tabs step aside and the page tabs swipe sideways.
The bar and sheet live in the shell (base.html); app.js re-marks
their active section after each swap.
Search boxes
Every search box is the same autocomplete widget over one
suggestion endpoint. Markup: a form whose input carries
role="combobox", aria-controls naming a
<ul class="suggest" role="listbox" hidden> beside it. The
surface's JS calls attachSuggest(input, list, endpoint, onPick): the box names its feed (items, pilots, types, and so on; a
pool of the one endpoint) and what a pick does (navigate, fill
a hidden id, add a row). Without JS, or without a feed, the
plain form submits exactly as before.
Quick jump
Ctrl+K opens the palette, a modal over two sources: pages,
from quickJumpPages in app.js (which must mirror sectionNav
exactly; TestQuickJumpPagesMatchNav enforces it), and
entities (Pages / Characters / Items / Corporations /
Alliances / Pilots) from the search endpoint, each kind with
its own target URL. Adding a page to the palette is the nav
recipe under "Adding things".
Buttons and forms
.btnis the button;.btn-quietis the low-key variant,.btn-dangerthe destructive one. Disabled is the native attribute /aria-disabled.- A button that navigates carries
data-href="/path"(same- site paths only). CSP allows no inline handlers, so there is noonclick, ever. - A form that needs a confirm carries
data-confirm="…"; the ask happens before submit, and the form still works without JS as a plain submit. - A filter control that should apply immediately carries
data-autosubmit; its form keeps its submit button for no-JS readers.
Pending names (live regions)
Pages render cache-only, so a name the app hasn't resolved yet
renders as a live region that fills itself in: the view sets a
Pending flag, and the template renders
<span data-live-region data-poll-url="/labels/corporation-fragment?id={{.ID}}"
data-poll-state="pending"><span class="loading-pulse"></span> Loading name…</span>
instead of the name. The fragment endpoints exist per kind
(character / corporation / alliance / place); a settled miss
stops polling and leaves the plain #<id> text. A whole page
still loading uses the same mechanism on a wrapper with the
page's own fragment URL. Once resolved, names render through
the link helpers (charLink, corpLink, and so on). A resolved name
is a link to its page, never bare text.
Countdowns
Any element with data-finish="<RFC3339>" counts down to that
moment. The server renders the static remainder as the text (that's the
no-JS fallback and the pre-JS paint) and one shared
ticker updates all of them, stopping on will-swap and starting
on content-ready.
Tables with a filter box
An <input data-table-filter="<table id>" data-row-class="<row class>" data-header-class="<header class>"> filters its table
client-side: rows carry a data-search attribute, rows whose
text misses hide, and category headers with no visible rows
hide with them (data-header-class is optional). The industry
pages are the worked example. This is a convenience over an
already-rendered table, never a substitute for the bounded-
read rule on big data.
Home widgets
A widget is three registrations and a body:
- the module manifest (module_manifest.go): id, title, layer;
- the overview registry (home_overview.go): default size and grid bounds (W/H, MinW/MinH);
- a block in home.html keyed by widget id.
home.html renders the shell for every widget (<section class="card" data-widget data-gw data-gh …> with an
<h3> title and a .card-body), and the block fills
.card-body from stored data only. Long lists render in full
and mark rows beyond the widget's cap with data-wmore; the
expander machinery (above) supplies the More/Less toggle and
the "all of it on the X page" link is part of the block.
Customize (drag, resize, remove, add) is layered over the
plain customize forms, never a replacement for them; a widget
that renders its shell honestly gets all of it for free.
Character selector
Pages scoped to one pilot render the charselector partial
(templates/charselector.html) with the viewer's character
list: a filterable dropdown of ?character= links. Picking
one reloads the page under that character, and the page's
section links carry the parameter from there. Character-
scoped pages take the selected character from the shared page
data: don't parse the parameter or build a second picker.
Auto-refresh pages
A page that refreshes itself sets data-autorefresh on the
body (the page data's AutoRefresh flag) and ships a
<noscript> meta-refresh doing the same. The JS reload waits
out typing in a field and hidden tabs, never runs for
reduced-motion readers, and dies on swap-away: swaps onto
an auto-refresh page fall back to a full load, so the chain
only ever starts on first paint. Sync is the worked example.
Tables
A data table with a header row fits its box at every width with
nothing extra. app.js measures each one, and re-measures whenever
its box changes width (the window, the sidebar, a pane beside it):
a table whose columns fit stays a table, and a table that would
scroll sideways reads as cards. Each row becomes a card, its first
cell the title and every other cell a figure under its column's
label. The labels are copied from the header row (data-label), so
no template carries them twice, and a sortable table keeps a Sort
picker that drives the header-click sort. A table's wrapper never
grows past its container, so the measure is always honest. Levers
on the markup:
class="opt"on a header cell keeps that column off the cards (the same low-priority mark the home modules use).class="card-title"on a header cell makes that column the card's title in place of the first cell (Killmails titles each card with the victim's ship, not the time). A cell with nothing in it stays off its card.data-cards="on"forces cards;data-cards="off"keeps a table that scrolls sideways inside its own wrapper (on phones its text columns wrap). Use "off" only for grids whose point is comparing columns: order books, price history, the calendar.- Key/value tables (
th+tdrows, no header row) wrap their values on phones on their own. - A highlighted row (
tr.yours) takes the theme's selection paint, the pinned first cell included; as a card the highlight is the card's own.
Phone sheets
A block of secondary controls (filters, options) that should
step aside on a phone carries data-sheet (with an id and a
data-sheet-title), and its trigger is a button with
data-sheet-open="<id>" rendered hidden. Off the phone band
the block renders inline and the trigger stays hidden. In the
band, app.js turns the block into a bottom sheet in the top
layer (an auto popover). It stays in place in the DOM, so a
sheet of form fields still submits with its form. JS adds the
sheet's head and close button. Anything inside marked
.sheet-only shows only in sheet mode, and a .sheet-foot
rides the sheet's bottom edge: put the submit there. Contract
search's filters are the worked example.
Phone and touch styles
phone.css is the touch and phone layer. base.html links it
last behind a media attribute, so mouse desktops never block on
it. It is split into bands (touch, phone, short landscape),
each with its own query. Shared phone treatment goes there, in
the band it belongs to. A page with substantial phone styles
keeps them in its own sheet inside the same 45rem query.
Sticky in-page bars offset from --l-top (or --sticky-top on a
page without a sub-nav), never a literal header height. On short landscape screens the top bar scrolls
away, and the token follows it.
Geometry through data attributes
CSP forbids inline style, so per-element numbers ride
attributes and app.js applies them through the CSSOM:
data-w (bar fill width, %), data-left / data-top
(position, %), data-rot (rotation, deg; the element is also
centered on its point), data-pad-left (indent, px). Applied
at load and again for injected markup. If a number describes
an element, it goes in one of these, never in a style
attribute.
Tooltips
Shell controls (nav, top bar) use data-tip="…", CSS-only,
positioned by the shell's styles. Rich content tooltips (fit
modules, market chart points) are surface code (fit.js, the
chart code in app.js) with their own anchoring rules; don't
stretch data-tip into one of those.