diff --git a/docs/STYLE-GUIDE.md b/docs/STYLE-GUIDE.md index ae023ff..f38f771 100644 --- a/docs/STYLE-GUIDE.md +++ b/docs/STYLE-GUIDE.md @@ -1,16 +1,205 @@ -# Writing for the iPX interface +# The iPX style guide -How the words in iPX read: the page (`web/`), the admin page, sign-in, the iOS app's own alerts -(`ios/`) and the directory's and ipx-play's pages. It applies to every string a person sees: -buttons, tooltips, toasts, hints, placeholders, empty lists, errors. +How iPX looks, behaves and reads: the page (`web/`), the admin page, sign-in, the iOS app's own +alerts (`ios/`) and the directory's and ipx-play's pages. The first half is design: principles, +layout, controls, dialogs, keyboard, feedback, safety and accessibility. The second half is +writing: every string a person sees. -iPX is a web page in English, used on a desktop browser, a phone's home screen and inside the iOS -app, by people who run their own server or were given an account on one. They know what a podcast -and a feed are; they do not know what a guid, a scan job or a 304 is. +iPX is a web page in English, used with a mouse and keyboard in a desktop browser, by touch on a +phone's home screen, and inside the iOS app, by people who run their own server or were given an +account on one. They know what a podcast and a feed are; they do not know what a guid, a scan job +or a 304 is. Where a browser or iOS has a convention of its own, it wins over this guide. -The rules below were chosen against forty years of interface guides (Apple 1987-2014, Windows -1995 and 2010, GNOME, KDE, Android and others); the reasons for the disputed ones are in the -decision log at the end. +The rules were chosen against forty years of interface guides (Apple 1987-2014, Windows 1995 and +2010, NeXTSTEP, GNOME, KDE, Android and others); the reasons for the disputed ones are in the two +decision logs. + +# Design + +## Principles + +| Principle | For iPX | ✅ | ❌ | +|---|---|---|---| +| The person is in control | iPX acts on its own only where it was asked to (downloads by a feed's settings, checks on the schedule), and each can be turned off | A feed downloads its newest five because its settings say so | Marking an item read because it scrolled past | +| See and point | Every action is on screen somewhere; a key or a swipe is a quicker way to it, never the only one | On a phone a swipe goes to the next item; so do the reader's arrow and `j` | An action only on a long-press | +| Consistency | The same thing looks and works the same on every screen, on a phone and a desktop, as it did in the last release | Every dialog has Cancel on the left and its action on the right | A Save at the top of one dialog and the bottom of the next | +| Stability | Things stay where they were: the list keeps its place, a dialog closes back to the control that opened it, a reader keeps its scroll when it redraws | A button that cannot act now is dimmed in place | A toolbar whose buttons come and go with the selection | +| Feedback | Every action shows a result where it happened, within a tenth of a second | The row's dot empties as it is marked read | A spinner in the corner for a change to one row | +| Forgiveness | What can be taken back is taken back easily; what cannot is asked about first | Unsubscribe asks, and says what goes | Delete a file at one tap | +| Accessible from the start | A screen reader, a keyboard alone, zoom, reduced motion and high contrast all work, in every theme | An icon button with a tooltip and a matching `aria-label` | An icon button with only its icon | + +## Layout and visual system + +**Two layouts, one breakpoint.** Wider than 820 px: the feed list, the item list and the reader +side by side. 820 px or narrower: one column, the feed list as a drawer, the reader as a sheet. No +third layout for a tablet; a breakpoint is added only with a test that fails without it. (The +admin page wraps its tabs at 600 px, its one exception.) + +**Spacing** comes from one scale: 2, 4, 6, 8, 10, 12, 14 px, the gaps the stylesheet already uses. +✅ `gap:8px` · ❌ `gap:9px`. Within a group the smaller steps, between groups the larger. + +**Corners**: 6-10 px on controls and rows, 14 px on cards and sheets, round (`999px`) on pills and +chips, `50%` on round buttons and art. Not a new radius for one component. + +**Type**: 13 px is the body of the interface; 11-12.5 px for secondary lines (dates, counts), 14-17 +px for headings and the reader's text, 26 px only for a sheet's title. The fonts are the person's +choice in Settings (interface and reading separately), so a component never names a font: it uses +`--f-*` through the theme. Numbers that are compared (times, counts, sizes) use tabular figures and +line up on the right. + +**Colour** is by role, never by value: `--bg`, `--panel`, `--panel2`, `--raise` for surfaces; +`--fg`, `--dim`, `--faint` for text by importance; `--accent`, `--accent2` for the selection and +the primary action; `--good`, `--warn`, `--bad` for state; `--line` for rules. ✅ +`color:var(--bad)` · ❌ `color:#d33`. Each of the 25 palettes defines every role, and +`node tests/contrast.ts` checks each against WCAG AA; a new role needs a value in all 25 and a +contrast check. Working on a component never changes a theme's colours. + +**Colour is never the only signal.** An unread item has its dot and its weight; a failing feed has +its icon and its label; a pressed toggle has its shape and `aria-pressed`. ✅ the pin's outline +fills in · ❌ the pin turns green. + +**Icons** are Font Awesome Free, embedded as SVG through `ICON`, only those used; nothing is +fetched from another site. One icon means one thing everywhere: the plus adds, the check saves, +the cross cancels or closes. An icon that toggles changes shape (pin, pin-on), not colour. + +**Touch targets** are at least 44 by 44 px on a phone, 40 px where a row is dense, as the player's +and toolbar's buttons are. Hover effects sit inside `@media (hover:hover)`, so a phone never keeps +one stuck after a tap. + +**The phone's edges**: the page is `viewport-fit=cover` and pads itself by the safe-area insets +(`--safe-*`), on the home screen and in the app alike. + +## Controls + +| Control | Use for | Not for | +|---|---|---| +| Button | An action now | A setting that stays: that is a toggle or a select | +| Icon button | A frequent action whose icon is unambiguous: play, close, add, delete | Anything needing a word to tell it apart; give it a label | +| Toggle button (`aria-pressed`) | A state of the thing in view: pinned, DeadAir on, read | A choice among three or more | +| Checkbox | An on-or-off setting in a form | An action | +| Select | One of four or more fixed choices | Two choices (a toggle), or a list to search (a filter box) | +| Tabs (Unread, All, In progress) | Views of the same list | Steps of a task | +| Chips | Words someone types: keywords, hidden words | A fixed set of choices | +| Search box | A list longer than a screen; it gets a clear button once something is typed | A list of five | + +Every control has hover (only where there is hover), focus, pressed and disabled states, drawn +from the theme's roles. Focus is always visible: ✅ the theme's focus ring · ❌ `outline:none` +with nothing in its place. + +A control that cannot act now is **dimmed in place**, with a tooltip saying why, not removed: +✅ Play, dimmed, "Nothing to play in this item" · ❌ Play missing from items without a file. Remove +it only where it can never apply, as the file buttons on an item with no file. + +## Dialogs and sheets + +* **Modal only when iPX needs an answer first**: adding a feed, a feed's settings, a confirmation. + Everything else is in place: the reader, the player, Now Playing. +* **One purpose, short.** A dialog that scrolls on a desktop is two dialogs, or a page. +* **Buttons** go at the bottom right: Cancel on the left, the action on the right, as `cardacts` + draws them. ✅ *Cancel* *Unsubscribe* · ❌ *Unsubscribe* *Cancel*. Two buttons is the norm; three + at most. +* **The action is named**, not OK: ✅ *Add feed*, *Download*, *Make playlist*. An icon button + names it in its tooltip and `aria-label`. +* **A destructive action is red** (`danger`) and is never the default: Enter in a box does not + unsubscribe. +* **Escape, a tap outside, and Cancel all close** without changing anything. Focus goes back to + the control that opened the dialog. +* **A confirmation is the page's own dialog**: `ask()`, or a dialog of its own when it has more + than a sentence to say, as Unsubscribe does. Never `confirm()`, which the iOS app answered + Cancel without showing (#453). +* **When changes apply**: how iPX looks (theme, fonts, light or dark) applies as it is chosen; what + changes what the server does (a feed's settings, a signal, a playlist) applies on Save, since + it costs a check or a download. +* **On a phone** a dialog is a sheet from the bottom edge, its buttons within reach of a thumb. + +## Commands and menus + +* **No menu bar.** Commands are in the toolbar of what they act on: the feed's header for the + feed, the reader's bar for the item, the player for what plays. A row's less frequent commands + are in its More menu. +* **Every command has one visible home**; a key, a swipe or a context menu is a quicker way to it. +* **Toggles change their name**: ✅ Pin, Unpin · ❌ two buttons, one always dimmed. +* **Frequent first**: within a menu, the commands used most at the top, the destructive ones last, + after a separator. + +## Keyboard + +The page uses single keys, like Feedly's, and `?` lists them all. The list in `keysModal()` is +the table; a new key goes there in the same change. + +| Rule | ✅ | ❌ | +|---|---|---| +| Never take a key the browser or the system has: anything with Ctrl, Cmd or Alt | `r` reloads the lists | Ctrl+R reloads the lists | +| A key does nothing while typing in a box, except Escape | `j` in the search box types a j | `j` in the search box moves the selection | +| Escape always closes the top thing: a confirmation, then a dialog, then the drawer, then Now Playing | | | +| One key, one meaning, in every view | `s` pins the selected item | `s` saving settings in one view | +| Pairs go by `g` + a letter, within a second and a half | `g u` Up Next | | +| Every key's action has a button too | | A key with no button | + +**Focus order** follows reading order: the toolbar, the feed list, the item list, the reader, the +player. A row in a list is reached with Tab and opened with Enter or Space. Opening a dialog puts +focus in it; closing it puts focus back. + +## Feedback and timing + +| Wait | What shows | +|---|---| +| Under 0.1 s | The result, in place: the row changes, the button presses | +| 0.1-1 s | Nothing extra; the result arrives | +| Over 1 s | A spinner where the result will appear, not over the whole page | +| Over 5 s, or a download | Progress with an amount: "Downloading *file*: 52%", a bar on the row | +| Over 10 s | Progress and a way to stop it | + +* **Motion** is short: 120-250 ms for a press, a fade or a sheet, never over 450 ms, starting at + once. With reduced motion asked for, nothing moves; spinners pulse instead of turning, sheets + and toasts fade instead of sliding. +* **Toasts** confirm what just happened, at the bottom, for 3.2 s. An error toast stays until it is + dismissed, and a run of them does not stack up the screen. +* **Sound and haptics** are never the only feedback; on the phone an error toast also gives a + warning tap. + +## Errors, undo and safety + +* **Prevent before reporting**: Save is dimmed until the form can be saved; a number box has its + limits (`min`, `max`); an address is checked when it is added, not on every key. +* **Validate on Save**, not on each keystroke and not on leaving a field. +* **Ask only before what cannot be taken back**: unsubscribing, marking a whole list read, + deleting a playlist or a signal, removing an account. Not before marking one item read, pinning + or queueing, which a second tap undoes. +* **Offline is not an error**: what was kept still opens, and reads, pins and places are sent when + the connection is back. +* **A failure keeps what the person typed**: a dialog whose Save fails stays open with the message + in it. + +## Accessibility checklist + +* Every icon-only control has a tooltip and an `aria-label` saying the same thing. +* Every toggle has `aria-pressed`; every dialog `aria-labelledby` its title; a dialog makes the + page behind it `inert`. +* Every pointer action has a keyboard path, and every swipe a button. +* Contrast passes WCAG AA in all 25 palettes (`node tests/contrast.ts`), for text and for icons. +* Nothing relies on colour alone, on hover alone, or on sound alone. +* Reduced motion, reduced transparency and more contrast are honoured + (`prefers-reduced-motion`, `prefers-reduced-transparency`, `prefers-contrast`). +* Text zooms to 200% without a horizontal scroll at 320 px wide. +* Touch targets are at least 44 px, 40 in a dense row. +* The page's language is set (`lang="en"`). + +## Design decision log + +| Decision | Choice | Why | +|---|---|---| +| Dialog button order | Cancel left, action right, bottom right | What every iPX dialog already does, and Apple's order since 1987, which the iOS app's users see in every other app; Windows 2010 has the reverse. One order, never mixed | +| Default button | None for a destructive action; otherwise the action, never Cancel | Mac 1992, Windows 1995 and 2010 agree a dangerous action is never the default | +| Menus | No menu bar; toolbars on what they act on, a More menu per row | A web page in a browser and an app on a phone have no menu bar of their own; Windows 2010 drops one with three categories or fewer | +| Modal or in place | In place by default; modal only for an answer iPX needs first | Mac 1992 and Windows 1995: modal only when the program cannot go on without it | +| Dim or hide | Dim in place, with the reason as a tooltip; hide only what can never apply | Apple 1987-2009 and Windows 1995: dimming keeps the screen stable | +| When a change applies | Appearance at once; what the server does on Save | Windows 2010's live preview for what is cheap to try; Save for what costs a check or a download | +| Shortcuts | Single keys and `g` pairs, as Feedly's, never a modifier | A reader's keys are used a hundred times a session; Apple 2009 and Windows 1995 say not to take the system's keys, which any modifier risks in a browser | +| Confirm or undo | Ask before what cannot be taken back; what a second tap undoes is not asked | Apple 1987: alerts should be rare. iPX has no undo, so what cannot be reversed is asked about instead | +| Breakpoints | One, at 820 px | Two layouts are tested; a third doubles the testing for a tablet that does well with either | + +# Writing ## Voice and tone @@ -161,7 +350,7 @@ play offline: ${title}` keeps the variable at the end), plurals handled as a who with "(s)", dates and numbers through `toLocaleString` and the page's date helpers, and room for half again as much text in every label. -## Decision log +## Writing decision log | Decision | Choice | Why | |---|---|---|