webview for social and dev helpers social-toolkit.frytg.workers.dev
social-toolkit DESIGN.md
12 kB · 186 lines
Markdown
at main

Design system #

Visual and structural conventions for the toolkit UI. The tokens and shared classes live in src/style.css, the app shell in src/App.vue, and the shared controls in src/components/. Setup and task commands are in the README.

The look follows frytg.digital and the dashy dashboard: a dark green ground, hairlines instead of filled cards, flush corners, and yellow for interaction.

Palette #

Colours are Tailwind theme tokens in the @theme block, so each one works as a utility (bg-dark-greeny, text-off-white/70). Use opacity modifiers instead of new hex values.

  • dark-greeny (#181d16): header and control panels. The darkest surface; never use black.
  • mid-dark-greeny (#293126): page ground and the canvas area behind a tool's output.
  • greeny (#3e4939): text on a yellow fill, and selected text.
  • yellow (#ffff11): hover, active and focus states.
  • orange (#f09139): warnings and error notices.
  • off-white (#ecebe3): primary text. Prefer it over white.
  • fake-gray (#d7e2cc): the base that the line and muted tokens mix from. Don't use it directly.

Derived tokens #

A :root block mixes the palette into a small line and surface scale. Prefer these over a new color-mix().

  • --line (fake-gray at 20%): default hairline border.
  • --line-strong (fake-gray at 36%): emphasis border, slider tracks, axis lines.
  • --muted (fake-gray at 72%): labels and secondary text.
  • --faint (fake-gray at 55%): tertiary text, hints, units.
  • --surface-1 (dark-greeny): panel fill.
  • --surface-2 (off-white at 4.5%): inset fields, row hover.
  • --surface-3 (off-white at 8%): raised control fill.
  • --radius (0): corner radius of every control.
  • --safe-top, --safe-right, --safe-bottom, --safe-left: iOS safe-area insets.
  • --panel-width (min(20rem, 100%)): width of an open control panel.

The line, muted, faint and surface percentages match dashy's. Change them in both projects, or the two apps drift apart.

Reference a token with an arbitrary value (border-[var(--line)], text-[var(--muted)]). That is the spelling the codebase uses throughout.

Shapes and type #

  • Corners are flush. Every control reads --radius, so change corners there and never per component. Only round things that are round by nature, such as a legend dot.
  • Geist Sans is the default face. Geist Mono is for data: coordinates, counts, hex values, IPs, timestamps. Add tabular-nums wherever numbers line up in a column.
  • Fonts are not in the repo. just fonts downloads them into src/style/, which is gitignored. Without that step just dev uses a locally installed Geist if there is one, and the system font otherwise. just build runs the download itself.
  • Type scale. Sizes are fixed pixel values, written as arbitrary utilities (text-[13px]).
    • 13px: control rows and body text in a panel.
    • 12px: .ui-label, detail rows, notices.
    • 11px: hints, units and mono readouts beside a slider.
    • 10px: micro labels only, such as a stat label or a table header. Never running text.
    • 15px semibold: the title of the loaded item, such as an activity name.
    • 22px mono semibold: a headline number in a stat tile.
    • 14px: header tabs and the wordmark.
  • Case. The header is lowercase: the tabs get it from .ui-tab. Text inside a tool stays as written, in sentence case. Don't add text-transform to .ui-label, .ui-btn, .ui-chip or .ui-seg-btn: row labels inside the panels are plain text without a shared class, so only half the panel would change case.

App shell #

The header has two rows on --surface-1, with a hairline under each.

■ FRYTG SOCIALS  blurb of the active tool            frytg.digital ↗  repo ↗
0 overview  1 halftone  2 gpx overlay  3 gpx viewer  4 elevation lines  5 dmarc viewer
  • Top row. The wordmark, the active tool's blurb in muted lowercase (hidden below sm), and the external links. The wordmark links to the overview.
  • Tab row. An overview tab, then one .ui-tab per tool, inside a .ui-tab-row. The active tab is a solid yellow block (is-active); hover is a --surface-2 fill. Don't give tabs a border.
  • Routes. The URL hash names the open tool: #gpx-viewer opens the tool with that id. No hash, or a hash that matches no tool, shows the overview. Tabs and overview tiles are plain links, so the back button, a reload and open-in-new-tab all work. Switching tools unmounts the previous one, so its unsaved state is lost.
  • Shortcuts. 0 opens the overview and 1…9 open the first nine tools. A tenth tool gets a tab without a number. The handler ignores keys typed into an input, textarea or select, and keys pressed with a modifier.
  • Order. Tabs follow the order of FLEET_TOOLS in src/tools/registry.ts, so reordering that array also changes which number opens which tool.
  • Narrow screens. Below lg the tab row scrolls sideways with faded edges, and the active tab scrolls itself into view. From lg up the row wraps. The row's padding is set in .ui-tab-row and equals the fade width, so the first tab is not dimmed. Don't add padding utilities to the row.
  • Fixed height. body has overflow: hidden and the app fills the viewport. The page itself never scrolls, so each tool must scroll its own regions.
  • Safe areas. The header pads --safe-top. Each tool pads its own left, right and bottom edges.

Overview page #

ToolOverview is the start page. It lists every entry of FLEET_TOOLS, so a new tool appears without an edit here.

  • Ground. dark-greeny, in a centred max-w-5xl column. Unlike a tool, this page scrolls as a whole.
  • Tiles. One link per tool in a gap-px grid: the shortcut number in muted mono, the label at 18px semibold, the summary sentence at 13px, and an "Open …" button-look at the bottom. The whole tile is the link.
  • Outlines. A tile draws its 1px outline as a box-shadow, and the grid has p-px. Neighbours then share one hairline, and an empty cell in the last row stays empty. Don't space tiles with gap-2 or give them a border.
  • Hover and focus. The tile fills yellow with dark-greeny text, and the button inverts to dark-greeny with yellow text.

Tool layout #

A tool fills the area under the header with a control panel on the left and its output on the right.

┌ panel ──────┬ output ─────────────────────────┐
│          ‹  │                                 │
│ section     │   canvas, map, chart or table   │
│ controls    │                                 │
│ ─────────── │                                 │
│ actions     │                                 │
└─────────────┴─────────────────────────────────┘
  • Root. relative flex h-full bg-mid-dark-greeny.
  • Panel. An aside.ui-panel-shell holding a .ui-panel-toggle-row with the shared PanelToggle, then a .ui-panel-body with the controls. Adding is-collapsed shrinks the shell to a 2.75rem strip and hides the body.
  • Initial state. Use initialPanelOpen() from src/tools/panel-state.ts. The panel starts open from 768px and closed below it. The value is read once, so resizing the window later does not reopen or close the panel.
  • Panel sections. A .ui-label heading, then the controls. Pin export or destructive actions to the bottom of the panel, above a --line top border.
  • Stat tiles. Headline numbers sit in a two-column grid (grid-cols-2 gap-4): a 10px uppercase label in --faint with tracking-[0.08em], then the value in 22px mono semibold with tabular-nums. See HeroStats. There is no shared class for this yet, so copy the classes from there instead of inventing a variant.
  • Output. min-w-0 flex-1. Overlays on the output, such as notices and map controls, sit on bg-dark-greeny/90 with a --line border.

Controls #

Shared classes carry the ui- prefix and take their state from an is- class. Hover and active states are yellow: a yellow fill with greeny text on buttons, chips, segments and toggles, and yellow text on .ui-link. Header tabs are the exception (see App shell).

  • .ui-label: section heading or field caption, 12px in --muted.
  • .ui-btn: standard button. Add .ui-btn-primary for the one main action of a panel.
  • .ui-btn-ghost: secondary action without a border.
  • .ui-link: text-only action, such as reset.
  • .ui-chip: one of several exclusive options when the labels vary in length. is-active marks the choice.
  • .ui-seg with .ui-seg-btn: equal-width segmented choice. Use SegmentedControl instead of writing the markup.
  • .ui-toggle with .ui-toggle-knob: rectangular on/off switch. is-on marks the on state.
  • .ui-field: bordered box around an input or select. The border turns yellow on focus.
  • input[type='range']: styled globally. Use SliderControl for a labelled slider with a value readout.
  • input[type='color']: styled globally. Use ColorField for a swatch with a hex field.

Controls are sized for touch first. Below 768px they have a minimum height between 2rem and 2.75rem. From 768px up the minimum height is removed and the padding tightens. Add a new control to the @media (min-width: 768px) block at the end of the stylesheet instead of shipping one size for both.

Class naming and overrides #

  • Prefixes are enforced. The lint rule tailwindcss/no-unknown-classes in .oxlintrc.json fails on any class that is not a Tailwind utility, unless it starts with ui- or is-. Name a new shared class ui-* and its states is-*.
  • A utility cannot override a ui- class. The shared classes are written outside a cascade layer, and Tailwind puts utilities inside one, so the shared class wins whatever the order in the class attribute. ui-field min-h-0 keeps the field's own minimum height, and nothing reports it. To vary a property that a ui- class sets, change the class or add an is- modifier in the stylesheet.
  • Utilities still add. A utility works for any property the class does not set, such as width, margin or text colour on .ui-field.
  • Keep element rules narrow. The same cascade applies to any unlayered rule on a bare element. A global button, input, select { font: inherit } once sat in the stylesheet and silently cancelled every text-[…], font-mono and font-medium utility on those elements. Tailwind's preflight already does that reset inside a layer, so don't add it back. The remaining element rules only target input[type='range'] and input[type='color'].
  • Lint does not check that a ui-* class exists. The prefix exemption lets a misspelled or never-defined class through, and the element renders unstyled. After adding one, check that the stylesheet defines it.

Adding a tool #

  1. Create src/tools/<id>/<Name>Tool.vue, with components/ for its Vue parts and engine/ for logic that has no DOM.
  2. Follow the tool layout: panel shell on the left, output on the right.
  3. Add an entry to FLEET_TOOLS in src/tools/registry.ts. id becomes the URL hash, label the tab and the tile title, blurb the line next to the wordmark, and summary the sentence on the overview tile. Keep the label to one or two words. The position in the array sets the number shortcut.
  4. Add the tool to the list in the README.
  5. Run just lint.