Fishies 0.8.1

This commit is contained in:
CRTkafa 2026-10-01 05:41:30 +00:00
commit faaba9b2f3
76 changed files with 2198 additions and 0 deletions

26
LICENSE Normal file
View file

@ -0,0 +1,26 @@
The code in this package (everything under src/ and dist/) is under the MIT License:
MIT License
Copyright (c) 2026 Fishies
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The icons (everything under icons/) and the Fishies name and marks are
© 2026 Fishies. All rights reserved.

44
README.md Normal file
View file

@ -0,0 +1,44 @@
# @fishies/ui
The kit the social aquarium game [Fishies](https://fishies.lol) is drawn with: reef-toy React
components, design tokens as CSS variables and as data, and the painted system icon set. See every
piece live, with the Fishies Handbook, at **https://fishies.lol/ui**.
```sh
npm i @fishies/ui
```
## Use it
```tsx
import '@fishies/ui/tokens.css' // the --fx-* custom properties
import '@fishies/ui/kit.css' // the components
import { Button, Panel, configureIcons } from '@fishies/ui'
// The icons ship in this package under icons/. Serve that folder, or point at a CDN copy:
configureIcons({ url: icon => `https://cdn.jsdelivr.net/npm/@fishies/ui@0.8.1/icons/${icon.name}.png` })
export function Shop() {
return <Panel title="Shop" icon="shop">
<Button tone="gold" icon="coin">Buy for 120</Button>
</Panel>
}
```
React 18 or newer is a peer dependency. Each component is its own module, so a bundler keeps only
what you import. `Select` and the loader carry their own stylesheets (`@fishies/ui/select.css`,
`@fishies/ui/loader.css`).
The motion tokens (`--m-quick`, `--m-ease-spring` and the rest) are slots: set them, or load a
stylesheet that does, and every component animates with them; leave them out and nothing moves.
## What is in it
| Folder | Holds |
| --- | --- |
| `dist/` | ES modules with type declarations, and the stylesheets |
| `src/` | the same components and tokens as TypeScript source |
| `icons/` | the painted icon set, one PNG per name, each twice its largest display size |
| `handbook/` | the Fishies Handbook as Markdown |
Version 0.8.1 matches the Fishies release it was taken from.

266
handbook/README.md Normal file
View file

@ -0,0 +1,266 @@
# The Fishies Handbook
How Fishies looks, reads, sounds and what its world holds, generated from the game's own sources. The living version, with every component drawn, is at https://fishies.lol/ui.
## Brand
- Brand palette is fixed to the site's five existing tokens (#071a24 ground, #edf5ed ink, #ffc46b accent, #83cfbd sea, #adc3c7 muted); no new blue/purple/gradient brand colour and no novel illustrated background per platform · Steam capsules, Play feature graphics and social banners all sit on #071a24 with the fish as the subject.
- Nothing in the game UI renders below 12px, weight 700 minimum, ink not grey; the display face (Baloo 2) carries every number/label/button while Nunito is reserved for sentences; text over live water is stroked (paint-order: stroke fill), never shadowed, because a shadow disappears over coral.
### Brand
The five colours every store page, capsule, banner, the site and the Field Guide sit on.
| Token | Value | Use |
| --- | --- | --- |
| `--fx-ground` | `#071a24` | The night-water ground behind the site, the Field Guide and every brand picture. |
| `--fx-ground-ink` | `#edf5ed` | Words on the ground: headings and links on the site. |
| `--fx-gold` | `#ffc46b` | The one warm accent: the thing to press, the coin, the playhead, a focus ring. |
| `--fx-sea` | `#83cfbd` | Sea-green for links and quiet highlights on the ground. |
| `--fx-muted` | `#adc3c7` | Body copy on the ground, a step quieter than the headings. |
### Gold
The toy gold of the HUD: a face, a rim and a darker foot that makes a button sit up.
| Token | Value | Use |
| --- | --- | --- |
| `--fx-gold-light` | `#ffe2a6` | Gold words on glass: window titles, the clock, numbers that matter. |
| `--fx-gold-face` | `#ffe4a8` | The lit top of a gold button. |
| `--fx-gold-deep` | `#e59a3e` | The far end of a gold fill: a progress bar, the played part of a video. |
| `--fx-gold-foot` | `#c88a3d` | The solid edge under a gold button, its toy thickness. |
| `--fx-gold-warm` | `#ff9a6b` | Gold leaning to coral, where a fill runs warm (sunrise, a streak). |
| `--fx-amber` | `#f4c656` | The landing’s amber: the wordmark’s gleam and the reel’s titles. |
### Type
Baloo 2 for the game’s voice (numbers, labels, buttons, titles), Nunito for sentences; nothing under 12px.
| Token | Value | Use |
| --- | --- | --- |
| `--fx-font-display` | `var(--font-display), "Baloo 2", ui-rounded, sans-serif` | Titles, numbers, buttons, labels. |
| `--fx-font-ui` | `var(--font-ui), Nunito, ui-rounded, sans-serif` | Sentences and anything read as text. |
| `--fx-t-xs` | `12px` | The floor: units, captions, a badge’s count. |
| `--fx-t-sm` | `13px` | Chips, list details, helper lines. |
| `--fx-t-md` | `15px` | Buttons, list titles, body copy in the game. |
| `--fx-t-lg` | `19px` | A panel’s title. |
| `--fx-t-xl` | `24px` | A stat’s value, a window’s hero number. |
| `--fx-t-2xl` | `31px` | A page heading. |
| `--fx-t-3xl` | `40px` | A moment’s headline (level up, a new fish). |
| `--fx-track-tight` | `-.015em` | Display type at size. |
| `--fx-track-label` | `.14em` | Upper-case eyebrows above a group. |
## UI
- One source per fact, no redundancy (owner, 1 October 2026: 'no complexity, disconnection, inconsistency, gaps, especially in the wiki, and above all no redundancy'): decisions live in the Atlas, player knowledge in the Field Guide (generated from the catalogue where it can be), visual and component truth in fishies-ui's tokens and components. The bibles are not new texts: they are one Fishies Handbook in fishies-ui whose sections are generated from those sources (Brand and UI from the tokens and components, Art and Writing from the Atlas canon, World from the Field Guide); anything that cannot be generated is merged into an existing source instead of copied.
### Water
The deep blues under the glass; each one is the water a few metres further down.
| Token | Value | Use |
| --- | --- | --- |
| `--fx-abyss` | `#04101b` | The deepest water: behind full-screen moments and the video frame. |
| `--fx-deep` | `#08202f` | A sunken well inside a panel: inputs, tracks, empty slots. |
| `--fx-deep-2` | `#0d2c3f` | A raised well: a hovered row, a chosen tab’s ground. |
| `--fx-deep-3` | `#14435c` | The lightest deep: dividers that need to show on glass. |
| `--fx-navy` | `#173d63` | The body of a round toy button (window controls, the player’s buttons). |
### Ink
Words on glass, in three weights; the quietest still reads at 6.7:1 on a panel.
| Token | Value | Use |
| --- | --- | --- |
| `--fx-ink` | `#eef6ff` | Everything a player reads on glass: titles, values, labels. |
| `--fx-ink-2` | `rgb(238 246 255 / 80%)` | Sentences under a title. |
| `--fx-ink-3` | `rgb(238 246 255 / 62%)` | Captions, units and hints; never anything a player must act on. |
| `--fx-ink-blue` | `#a9c9ea` | Labels that name a value beside it (Level, Coins, Fish). |
| `--fx-ink-on-gold` | `#12304a` | Words on a gold button or a gold chip. |
### Tones
Six hues that tell kinds apart (an app tile, a chip, a chart line) and two that mean good and bad.
| Token | Value | Use |
| --- | --- | --- |
| `--fx-tone-sky` | `#6cc8ff` | Sky blue: water, visits, anything about other keepers. |
| `--fx-tone-coral` | `#ff8f87` | Coral: reports, a count that wants you, the close button. |
| `--fx-tone-kelp` | `#7fdc8f` | Kelp green: live, online, growing. |
| `--fx-tone-violet` | `#b8a2ff` | Violet: rare things and night. |
| `--fx-tone-lagoon` | `#5cd8c6` | Lagoon: the landing’s shallow water. |
| `--fx-tone-mute` | `#8fa7b5` | Grey-blue: off, empty, not yet. |
| `--fx-good` | `#6fe3b0` | Done, fed, clean, saved. |
| `--fx-alarm` | `#ff8478` | Hungry, dirty, failed: what needs a hand now. |
| `--fx-pearl` | `#fff4d6` | Pearl: the warm white of a badge rim and the landing’s cream. |
| `--fx-cream` | `#f3dfb2` | Cream: the shaded side of a pearl knob, warm sand. |
| `--fx-plum` | `#36203f` | Plum: the landing’s deep warm shadow under cream. |
### Glass
The one material everything floats on: tinted water glass with a sheen across its top.
| Token | Value | Use |
| --- | --- | --- |
| `--fx-glass-top` | `rgb(22 58 120 / 70%)` | The upper tint of glass. |
| `--fx-glass-bottom` | `rgb(8 26 66 / 88%)` | The lower tint of glass, darker so words sit on it. |
| `--fx-glass-quiet-top` | `rgb(22 58 120 / 62%)` | Glass over the live tank, a little thinner so the fish show through. |
| `--fx-glass-quiet-bottom` | `rgb(8 26 66 / 82%)` | The lower tint of quiet glass. |
| `--fx-glass-sheen` | `rgb(255 255 255 / 16%)` | The light across the top half of a pane. |
| `--fx-glass` | `linear-gradient(180deg, var(--fx-glass-sheen), transparent 46%), linear-gradient(180deg, var(--fx-glass-top), var(--fx-glass-bottom))` | A pane: windows, panels, menus, the dock. |
| `--fx-glass-quiet` | `linear-gradient(180deg, var(--fx-glass-sheen), transparent 46%), linear-gradient(180deg, var(--fx-glass-quiet-top), var(--fx-glass-quiet-bottom))` | A pane over the tank: HUD capsules, the fish card. |
| `--fx-glass-well` | `rgb(4 16 30 / 55%)` | The darker water inside a window, under its title bar. |
| `--fx-glass-blur` | `blur(14px) saturate(1.2)` | What glass does to the reef behind it (backdrop-filter). |
### Rims
A hairline of light round every pane; gold marks the panes that are yours to use.
| Token | Value | Use |
| --- | --- | --- |
| `--fx-rim` | `rgb(140 200 255 / 34%)` | The blue hairline round glass. |
| `--fx-rim-bright` | `rgb(140 200 255 / 55%)` | The hairline on hover. |
| `--fx-gold-rim` | `rgb(255 196 107 / 58%)` | The gold hairline round windows, the dock, tiles and the chosen tab. |
| `--fx-gold-rim-quiet` | `rgb(255 196 107 / 26%)` | Gold dividers: under a title bar, between dock groups. |
| `--fx-rim-light` | `inset 0 1px rgb(255 240 210 / 30%)` | The lit inner top edge of a gold-rimmed pane. |
| `--fx-ground-rim` | `#9ebfbe26` | Hairlines on the ground: card edges and rules between sections of the site. |
### Depth
Soft lifts for panes over water, and the solid foot that makes a toy control look pressable.
| Token | Value | Use |
| --- | --- | --- |
| `--fx-lift-1` | `0 2px 10px rgb(2 10 18 / 34%)` | A chip or a small button just off the water. |
| `--fx-lift-2` | `0 10px 30px rgb(2 8 20 / 45%)` | A panel, the dock, a menu. |
| `--fx-lift-3` | `0 24px 60px rgb(2 8 20 / 60%)` | A window or a moment that takes the screen. |
| `--fx-foot` | `0 4px 0 rgb(4 18 34 / 55%)` | The toy foot under a glass button or tile; pressing sinks into it. |
| `--fx-foot-deep` | `0 6px 0 rgb(4 18 34 / 55%)` | The foot under a desktop tile, which stands taller. |
| `--fx-plump` | `inset 0 2px rgb(255 255 255 / 40%), inset 0 -6px 12px rgb(0 0 0 / 28%)` | The lit top and shaded belly that make a tile round. |
| `--fx-on-water` | `0 1px 2px #020c1a, 0 4px 16px rgb(2 12 26 / 80%)` | The shadow under words that sit straight on the water. |
### Radii
Round, never sharp: the smaller the thing, the rounder it reads.
| Token | Value | Use |
| --- | --- | --- |
| `--fx-r-sm` | `10px` | Rows, inputs, keys. |
| `--fx-r-md` | `14px` | Cards, menus, tooltips. |
| `--fx-r-lg` | `20px` | Panels and windows. |
| `--fx-r-xl` | `28px` | Desktop tiles and the dock. |
| `--fx-r-full` | `999px` | Buttons, chips, tabs, badges, tracks. |
### Spacing
A 4px grid: every gap, padding and margin is one of these.
| Token | Value | Use |
| --- | --- | --- |
| `--fx-s-1` | `4px` | Inside a chip, between a value and its unit. |
| `--fx-s-2` | `8px` | Between an icon and its label, between chips. |
| `--fx-s-3` | `12px` | Inside a button, between rows. |
| `--fx-s-4` | `16px` | A card’s inset. |
| `--fx-s-5` | `24px` | A panel’s inset, between groups. |
| `--fx-s-6` | `32px` | Between sections of a page. |
| `--fx-s-7` | `48px` | Around a page’s hero. |
### Layers
Named heights, so a toast never slides under a window and a tooltip never under a toast.
| Token | Value | Use |
| --- | --- | --- |
| `--fx-z-raised` | `10` | A card lifted above its siblings (a dragged tile). |
| `--fx-z-sticky` | `100` | Headers and rails that stay as the page scrolls. |
| `--fx-z-dock` | `900` | The menu bar and the dock. |
| `--fx-z-modal` | `1000` | A window or sheet that holds the screen, with its backdrop. |
| `--fx-z-toast` | `1100` | Toasts, above any window. |
| `--fx-z-tooltip` | `1200` | Tooltips and open menus, above everything. |
### Motion
Named slots the motion system fills (apps/web/app/motion/motion.css, where each one is described): arrivals overshoot a little and settle, presses squash, exits get out of the way.
| Token | Value | Use |
| --- | --- | --- |
| `--m-quick` | `120ms` | A press, a hover, a check. |
| `--m-base` | `180ms` | A fade, a chip changing. |
| `--m-move` | `260ms` | Something travelling: a panel arriving, a row sliding. |
| `--m-show` | `400ms` | A moment: a window unfolding, a reward landing. |
| `--m-ease-out` | `cubic-bezier(.2, .8, .2, 1)` | Answers the hand: decelerates hard. |
| `--m-ease-spring` | `cubic-bezier(.34, 1.5, .64, 1)` | The reef-toy arrival: overshoots a little and settles. |
| `--m-ease-calm` | `cubic-bezier(.45, 0, .25, 1)` | Calm, symmetric: crossfades, drift. |
| `--m-ease-in` | `cubic-bezier(.4, 0, 1, 1)` | Leaving: accelerates away. |
| `--m-stagger` | `40ms` | Stagger step for lists. |
### Components
- **SystemIcon** · A painted icon from the system set, by name, at one of the set's sizes.
- **Button** · A plump toy button: glass for everyday actions, gold for the one thing to press, ghost for a quiet third choice, danger for what cannot be undone.
- **ButtonLink** · The same button as a link, for an action that goes somewhere.
- **RoundButton** · A round toy button for window controls, the video player and close; `label` is what it says to a screen reader.
- **Chip** · A small reading or choice: a dot of colour for a kind, an icon, or gold when chosen.
- **Badge** · A coral count bubble that sits on a tile, a dock item or a bell; a dot when the number does not matter.
- **Tag** · A gold-rimmed capsule for a small upper-case word beside a name (Beta, New, Admin).
- **Card** · A glass card: an optional eyebrow, a title and a few lines.
- **Panel** · A gold-rimmed glass panel with a title row (icon, title, actions) and a body.
- **Window** · A Keeper OS window frame: a title bar with round minimise and close buttons over a darker well.
- **Tabs** · A row of pill tabs in a sunken track; the chosen one is gold.
- **List** · A list of rows; each row has an icon, a title, a detail line and a value at its end.
- **ListRow** · One row of a list; a button when it does something, a link when it goes somewhere.
- **Field** · A labelled text field in a sunken pill, with an optional hint under it.
- **Toggle** · An on and off switch with a pearl knob; gold when on.
- **Tooltip** · A designed tooltip, never plain text: an icon and title, a line, and labelled values; it opens on hover and on keyboard focus.
- **Toast** · A notice that slides in at the edge: an icon in a coloured bubble, a title, a line and a close.
- **Stat** · A number a keeper reads at a glance: an icon, the value in gold with its unit, and what it counts.
- **DockTile** · A desktop tile: a plump glass square in its own hue holding an icon, a title under it, a badge and an open mark.
- **Dock** · A dock: a gold-rimmed glass shelf of icons; the app in front wears a gold bar, open ones a dot.
- **DockItem** · One icon on a dock.
- **Spinner** · The Fishies spinner for anything on its way: a glass porthole with a gold arc going round and bubbles rising.
- **Progress** · A progress bar: a glass channel filling with gold, a bubble riding its leading edge; with no value the gold sweeps.
- **Select** · A dropdown that opens a dark panel with a gold check, driven from the keyboard like a native one and never clipped by its panel.
- **Image** · The one way Fishies puts a picture on screen: a drop-in `<img>` that shows the Fishies spinner on a glass placeholder in its own box until the file is fully downloaded and decoded, then fades it in.
## Art
Authored target-size sprite art, layered sources, deterministic exports.
- Definitive-remaster non-negotiable checks for every species: the profile is recognisable at 1x before its colour is read; a mouth belongs to a head; the eye sits inside an implied skull and stays stable through a tail stroke; fins grow from opaque roots into visible rays with a restrained translucent edge; the body has a front, belly and peduncle beyond a colour ramp; the species stays legible over the real reef backdrop, the shop and the Field Guide.
- Approved eye language: a warm socket, pale sclera, a deep pupil shifted toward the snout and one hard catchlight · a plain black bead is not an approved default for any Fishies species, including nocturnal ones.
- Fish keep their painted mouths.
- The floor has depth: decorations can sit at different depths rather than all standing on one line, which is what makes a reef read as a place instead of a shelf.
## Writing
- Middle dot "·", never an em dash.
- Owner, 30 September 2026: "rename Blue Glass to Lapis Lazuli. I want relatable names overall, not silly ones." Floor names are plain and recognisable: White Sand (was White Aragonite), Mossy Soil (was Planted Soil), Lapis Lazuli (was Blue Glass, repainted to match), Pearl Pebbles (was Black & White Pearl). Ids follow the names; nothing had shipped, so no migration.
- Fishies' lore direction (decision 78, owner decided 11 September 2026): Option B · a light fictional keeper-culture framing on top of real biology (an unnamed shared tradition like 'the Keeping', in-fiction framing for the level titles, an optional second 'Keeper's Note' paragraph beside each species' existing real-biology text), not real-world-only and not a full invented setting/faction/plot.
## Sound
Sound effects and the soundtrack.
- Fishies OST (owner, 13 September 2026): six original tracks released as an album; the album and in-game versions are the same recording. Tracks share one room (samples, mix chain, loudness) and must differ in key, meter, tempo, lead instrument and groove; no variations of an earlier track. A seventh waits until a place or moment in the game needs its own music.
- Home Tank (first shipped as Kelp Lullaby) is the main music (owner, 13 September 2026): it plays from its intro when the player enters the game, after the loading screen lifts, and Visitors follows it in the default rotation. Reef Room stays in the jukebox but only joins the rotation if the player ticks it.
- Every OST album master begins from 0.6 s of silence and a 1.8 s swell, and intros bring their layers in one at a time; the game fades a track in over 2 s on arrival (owner, 13 September 2026: the intros came in too fast).
- Places with their own music: on Auto, Open Water plays Open Water whether or not it is ticked; a track the player holds by hand still plays there; leaving hands back to the rotation (owner, 13 September 2026).
- Credit music to CRTkafa; the OST is free to use.
## World
### Field Guide
- [Open Water](https://fishies.lol/wiki/mechanics/open-water) · Swim out as one of your fish and meet other keepers.
- [Swimming in a friend's aquarium](https://fishies.lol/wiki/mechanics/swim-visits) · Join another keeper's aquarium as one of your own fish.
### Places
- [Kelp Garden](https://fishies.lol/open-water/kelp-garden) · A coral garden that runs into a kelp forest. Room to roam.
- [Shipwreck](https://fishies.lol/open-water/shipwreck) · An old ship asleep on the sand, lanterns still lit. Swim through its ribs.
### Catalogues
- [Species catalogue](https://fishies.lol/wiki/species) (102) · Every fish in the game with its growth time, unlock level, egg price and sale value.
- [Decorations catalogue](https://fishies.lol/wiki/decorations) (74) · Every plant and ornament, what it costs and how long it keeps algae away.
- [Equipment catalogue](https://fishies.lol/wiki/equipment) (9) · Every filter, auto-feeder and heater with its price, unlock level and what it does.

BIN
icons/announce.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
icons/arrange.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
icons/bell.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
icons/book.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
icons/bug.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
icons/camera.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
icons/cart-add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
icons/cart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
icons/chat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
icons/clean.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
icons/coin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
icons/coral.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
icons/decorate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
icons/edit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
icons/egg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
icons/emote-food.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
icons/emote-heart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
icons/emote-hello.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
icons/emote-music.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
icons/emote-question.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

BIN
icons/emote-sleep.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
icons/emote-sparkle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

BIN
icons/emote-surprise.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

BIN
icons/explore.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
icons/feed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

BIN
icons/fish.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
icons/follow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
icons/fullscreen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
icons/gear.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
icons/growth.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
icons/heart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
icons/help.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
icons/home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
icons/idea.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
icons/inspect.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
icons/inventory.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

BIN
icons/kelp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
icons/lock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
icons/map.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
icons/menu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
icons/music.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

BIN
icons/mute.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
icons/net.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
icons/people.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
icons/pin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
icons/remedy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
icons/report.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
icons/share.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
icons/shell.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
icons/shop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
icons/solved.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
icons/sound.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
icons/staff.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
icons/star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
icons/updates.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
icons/upvote.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
icons/views.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

66
package.json Normal file
View file

@ -0,0 +1,66 @@
{
"name": "@fishies/ui",
"version": "0.8.1",
"description": "The Fishies UI kit: reef-toy components, design tokens and the painted system icon set from the social aquarium game Fishies.",
"keywords": [
"fishies",
"ui-kit",
"design-tokens",
"react",
"components",
"icons",
"game-ui"
],
"homepage": "https://fishies.lol/ui",
"repository": {
"type": "git",
"url": "https://git.crt.fyi/PlayFishies/fishies-ui.git"
},
"bugs": {
"url": "https://fishies.lol/community"
},
"license": "SEE LICENSE IN LICENSE",
"author": "Fishies <hi@crt.fyi>",
"type": "module",
"sideEffects": [
"**/*.css"
],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./tokens": {
"types": "./dist/tokens.d.ts",
"import": "./dist/tokens.js"
},
"./icons": {
"types": "./dist/icons.d.ts",
"import": "./dist/icons.js"
},
"./tokens.css": "./dist/tokens.generated.css",
"./kit.css": "./dist/kit.css",
"./loader.css": "./dist/loader.css",
"./select.css": "./dist/select.css",
"./icons/*": "./icons/*",
"./src/*": "./src/*",
"./package.json": "./package.json"
},
"files": [
"dist",
"src",
"icons",
"handbook",
"README.md",
"LICENSE"
],
"peerDependencies": {
"react": ">=18",
"react-dom": ">=18"
},
"publishConfig": {
"access": "public"
}
}

71
src/FishiesImg.tsx Normal file
View file

@ -0,0 +1,71 @@
'use client'
import { useCallback, useEffect, useLayoutEffect, useRef, useState, type ImgHTMLAttributes, type Ref } from 'react'
import { reveal } from './fx-image'
import './loader.css'
const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect
/** The one way Fishies puts a picture on screen: a drop-in `<img>` that shows the Fishies
* spinner on a glass placeholder in its own box until the file is fully downloaded and
* decoded, then fades it in. Same element, same attributes, same box as the bare `<img>` it
* replaces, so no surface's selectors or layout move. See fx-image.ts for the states.
*
* Give it a size (width/height, or a CSS box) wherever you can: that box is the placeholder,
* and it is what keeps the layout still while the picture is on its way. */
export default function FishiesImg({ ref, decoding, ...props }: ImgHTMLAttributes<HTMLImageElement> & { ref?: Ref<HTMLImageElement> }) {
const own = useRef<HTMLImageElement | null>(null)
const mounted = useRef(false)
const setRef = useCallback((node: HTMLImageElement | null) => {
own.current = node
if (typeof ref === 'function') ref(node)
else if (ref) ref.current = node
}, [ref])
useIsomorphicLayoutEffect(() => {
const img = own.current
if (!img) return
// A new address waits again; the document's listener (FX_IMAGE_SCRIPT) or this effect
// reveals it. A picture already complete at first mount was in memory: no fade.
if (mounted.current) img.setAttribute('data-fx', 'wait')
const first = !mounted.current
mounted.current = true
reveal(img, first && img.complete)
const settle = () => reveal(img)
img.addEventListener('load', settle)
img.addEventListener('error', settle)
return () => { img.removeEventListener('load', settle); img.removeEventListener('error', settle) }
}, [props.src, props.srcSet])
return <img {...props} ref={setRef} decoding={decoding ?? 'async'} data-fx="wait" suppressHydrationWarning/>
}
/** A `<video>` with a poster: render it with `data-fx={poster ? 'wait' : undefined}` and
* `suppressHydrationWarning`, and pass its ref here. The same placeholder as FishiesImg holds
* its box until the poster is decoded (or the first frame arrives, whichever is first). */
export function useFxPoster(video: { current: HTMLVideoElement | null }, poster: string | null | undefined) {
const decoded = useDecodedUrl(poster)
useIsomorphicLayoutEffect(() => {
const element = video.current
if (!element || !poster) return
const show = () => { if (element.getAttribute('data-fx') === 'wait') element.setAttribute('data-fx', 'fade') }
if (decoded || element.readyState >= 2) { show(); return }
element.addEventListener('loadeddata', show)
return () => element.removeEventListener('loadeddata', show)
}, [video, poster, decoded])
}
/** For a picture drawn as a CSS background: the address once it is downloaded and decoded,
* `null` until then (show a FishiesSpinner meanwhile). */
export function useDecodedUrl(url: string | null | undefined): string | null {
const [ready, setReady] = useState<string | null>(null)
useEffect(() => {
if (!url) return
let live = true
const probe = new Image()
probe.decoding = 'async'
probe.src = url
const done = () => { if (live) setReady(url) }
;(typeof probe.decode === 'function' ? probe.decode() : new Promise(resolve => { probe.onload = resolve })).then(done, done)
return () => { live = false }
}, [url])
return url && ready === url ? url : null
}

122
src/Select.tsx Normal file
View file

@ -0,0 +1,122 @@
'use client'
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react'
import { createPortal } from 'react-dom'
import { placePopup, selectedIndex, selectKey } from './select-state'
import './select.css'
export type SelectOption = { value: string; label: string; disabled?: boolean; icon?: ReactNode }
type Props = {
value: string
onChange: (value: string) => void
options: readonly SelectOption[]
'aria-label'?: string
'aria-labelledby'?: string
disabled?: boolean
/** Renders a hidden input so an enclosing form still submits the value. */
name?: string
className?: string
size?: 'regular' | 'compact'
autoFocus?: boolean
}
/* The popup is portalled to <body> so no scrolling panel, backdrop-filter or overflow can clip
it. It leaves its surface's CSS scope behind, so the surface's tokens are read off the trigger
and carried over inline: one component that looks native to the site, the tank and admin. */
const TOKENS = ['--fs-select-ink', '--fs-select-muted', '--fs-select-line', '--fs-select-panel', '--fs-select-hover', '--fs-select-accent', '--fs-select-radius', '--fs-select-shadow', '--fs-select-font']
/** A dropdown that opens a dark panel with a gold check, driven from the keyboard like a native one and never clipped by its panel. */
export default function Select({ value, onChange, options, disabled, name, className, size = 'regular', autoFocus, ...aria }: Props) {
const id = useId()
const trigger = useRef<HTMLButtonElement>(null), list = useRef<HTMLUListElement>(null)
const [open, setOpen] = useState(false)
const [active, setActive] = useState(-1)
const [style, setStyle] = useState<CSSProperties>({})
const [up, setUp] = useState(false)
const current = options.find(option => option.value === value)
const place = useCallback(() => {
const button = trigger.current
if (!button) return
const rect = button.getBoundingClientRect()
const spot = placePopup(rect, { width: window.innerWidth, height: window.innerHeight }, 320)
const computed = getComputedStyle(button)
const tokens: Record<string, string> = {}
for (const token of TOKENS) { const resolved = computed.getPropertyValue(token).trim(); if (resolved) tokens[token] = resolved }
setUp(spot.up)
setStyle({ ...tokens, fontFamily: computed.fontFamily, left: spot.left, minWidth: spot.width, maxWidth: Math.min(360, window.innerWidth - 16), top: spot.top, bottom: spot.bottom, maxHeight: spot.maxHeight } as CSSProperties)
}, [])
const show = (index: number) => { place(); setActive(index); setOpen(true) }
const close = (focus: boolean) => { setOpen(false); if (focus) trigger.current?.focus() }
const choose = (next: string) => { if (next !== value) onChange(next) }
useLayoutEffect(() => { if (open) place() }, [open, place])
// The popup grows to its longest label; keep that wider box inside the viewport too.
useLayoutEffect(() => {
const popup = list.current
if (!popup || typeof style.left !== 'number') return
const left = Math.max(8, Math.min(style.left, window.innerWidth - 8 - popup.offsetWidth))
if (left !== style.left) setStyle(previous => ({ ...previous, left }))
}, [style])
useEffect(() => {
if (!open) return
const outside = (event: PointerEvent) => {
const target = event.target as Node
if (!trigger.current?.contains(target) && !list.current?.contains(target)) setOpen(false)
}
window.addEventListener('pointerdown', outside, true)
window.addEventListener('resize', place)
const scrolled = (event: Event) => { if (!list.current?.contains(event.target as Node)) place() }
window.addEventListener('scroll', scrolled, true)
return () => { window.removeEventListener('pointerdown', outside, true); window.removeEventListener('resize', place); window.removeEventListener('scroll', scrolled, true) }
}, [open, place])
useEffect(() => {
if (open && active >= 0) list.current?.querySelector<HTMLElement>(`[data-index="${active}"]`)?.scrollIntoView({ block: 'nearest' })
}, [open, active])
useEffect(() => { if (disabled) setOpen(false) }, [disabled])
const keydown = (event: React.KeyboardEvent<HTMLButtonElement>) => {
if (event.altKey || event.ctrlKey || event.metaKey) return
const result = selectKey({ open, active }, event.key, options, value)
if (!result.handled && result.close !== 'blur') return
if (result.handled) { event.preventDefault(); event.stopPropagation() }
if (result.open && !open) { show(result.active); return }
setActive(result.active)
if (!result.open) close(result.close === 'focus')
if (result.choose !== undefined) choose(result.choose)
}
const labelId = `${id}-label`, valueId = `${id}-value`, listId = `${id}-list`
const labelledby = aria['aria-labelledby'] ?? (aria['aria-label'] ? labelId : undefined)
const classes = ['fs-select', size === 'compact' ? 'fs-select-compact' : '', open ? 'is-open' : '', className ?? ''].filter(Boolean).join(' ')
return <>
{aria['aria-label'] && !aria['aria-labelledby'] && <span id={labelId} hidden>{aria['aria-label']}</span>}
<button ref={trigger} type="button" className={classes} disabled={disabled} autoFocus={autoFocus}
aria-haspopup="listbox" aria-expanded={open} aria-controls={open ? listId : undefined}
aria-labelledby={labelledby ? `${labelledby} ${valueId}` : undefined}
aria-activedescendant={open && active >= 0 ? `${id}-option-${active}` : undefined}
onClick={() => open ? close(false) : show(selectedIndex(options, value))} onKeyDown={keydown}>
{current?.icon && <span className="fs-select-icon" aria-hidden="true">{current.icon}</span>}
<span id={valueId} className="fs-select-value">{current?.label ?? ''}</span>
<i aria-hidden="true">▾</i>
</button>
{name && <input type="hidden" name={name} value={value} />}
{open && typeof document !== 'undefined' && createPortal(
<ul ref={list} id={listId} role="listbox" aria-labelledby={labelledby} tabIndex={-1}
className={`fs-select-popover${up ? ' is-up' : ''}${size === 'compact' ? ' fs-select-compact' : ''}`} style={style}
onPointerDown={event => event.preventDefault()}>
{options.map((option, index) => <li key={option.value} id={`${id}-option-${index}`} data-index={index} role="option"
aria-selected={option.value === value} aria-disabled={option.disabled || undefined}
className={index === active ? 'is-active' : undefined}
onPointerEnter={() => { if (!option.disabled) setActive(index) }}
onClick={() => { if (option.disabled) return; close(true); choose(option.value) }}>
{option.icon && <span className="fs-select-icon" aria-hidden="true">{option.icon}</span>}
<span>{option.label}</span>
{option.value === value && <b aria-hidden="true">✓</b>}
</li>)}
</ul>, document.body)}
</>
}

2
src/css.d.ts vendored Normal file
View file

@ -0,0 +1,2 @@
// The components import their own stylesheets; a bundler brings them in.
declare module '*.css'

38
src/fx-image.ts Normal file
View file

@ -0,0 +1,38 @@
/** Pictures that never paint half-loaded (owner, 1 October 2026: "never, ever should I see an
* image while it is loading").
*
* Every picture the site, the game and the launcher show is an `<img data-fx="wait">`
* (FishiesImg). loader.css keeps its pixels out of its own box while it waits, and shows the
* Fishies spinner on a glass placeholder of the same size in their place, so nothing moves.
* Once the file is complete *and* decoded (`img.decode()`), the state becomes `fade` (a short
* fade in) or, for a picture that was already in memory when it mounted, `ready` (no fade:
* a cached picture asking to fade in is theatre). A broken picture becomes `error`: the
* placeholder stays, the spinner stops.
*
* The same `reveal` runs twice over: as an inline script in the document head, listening for
* every image `load` in the capture phase, so a server-rendered picture appears as soon as it
* is decoded rather than when the page's JavaScript hydrates; and from FishiesImg's effect,
* for a picture that was already complete before anything was listening. Both are
* idempotent: only a picture still in `wait` for its current address changes state. */
export type FxState = 'wait' | 'fade' | 'ready' | 'error'
/** Self-contained on purpose: `FX_IMAGE_SCRIPT` inlines its source, so it may reference
* nothing outside its own body. */
export function reveal(img: HTMLImageElement, instant?: boolean): void {
if (img.getAttribute('data-fx') !== 'wait' || !img.complete) return
const src = img.currentSrc || img.src
const set = (state: string) => {
if (img.getAttribute('data-fx') === 'wait' && (img.currentSrc || img.src) === src) img.setAttribute('data-fx', state)
}
if (!img.naturalWidth) { set('error'); return }
if (instant) { set('ready'); return }
if (typeof img.decode !== 'function') { set('fade'); return }
img.decode().then(() => set('fade'), () => set(img.naturalWidth ? 'fade' : 'error'))
}
/** The document-head half: catches `load`/`error` of every waiting picture, including the
* server-rendered ones that finish before hydration. */
export const FX_IMAGE_SCRIPT = `(function(){var r=${reveal.toString()};` +
`function h(e){var t=e.target;if(t&&t.tagName==='IMG'&&t.hasAttribute('data-fx'))r(t)}` +
`document.addEventListener('load',h,true);document.addEventListener('error',h,true)})()`

446
src/icons.generated.ts Normal file
View file

@ -0,0 +1,446 @@
// GENERATED by tools/fishies-ui/build.ts from apps/web/app/ui/icons.ts and the picture files it names. Do not edit: change the source and run `bun tools/fishies-ui/build.ts`.
// px: the file's width in pixels. sharpTo: the largest CSS size it stays sharp at. usedBy: the parts of Fishies that draw it.
export const ICON_FACTS: Readonly<Record<string, { readonly px: number; readonly sharpTo: number; readonly usedBy: readonly string[] }>> = {
"feed": {
"px": 56,
"sharpTo": 28,
"usedBy": [
"Field Guide",
"Game"
]
},
"net": {
"px": 56,
"sharpTo": 28,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"clean": {
"px": 56,
"sharpTo": 28,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"decorate": {
"px": 56,
"sharpTo": 28,
"usedBy": [
"Field Guide",
"Game"
]
},
"arrange": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Game"
]
},
"remedy": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"inspect": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Game",
"Keeper OS"
]
},
"home": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"explore": {
"px": 56,
"sharpTo": 28,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"map": {
"px": 320,
"sharpTo": 160,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"shop": {
"px": 56,
"sharpTo": 28,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"cart": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"cart-add": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Game",
"Keeper OS"
]
},
"inventory": {
"px": 56,
"sharpTo": 28,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"book": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Game",
"Keeper OS"
]
},
"people": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"share": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Game",
"Keeper OS"
]
},
"pin": {
"px": 40,
"sharpTo": 20,
"usedBy": [
"Game",
"Keeper OS"
]
},
"menu": {
"px": 52,
"sharpTo": 26,
"usedBy": [
"Game",
"Keeper OS"
]
},
"bell": {
"px": 52,
"sharpTo": 26,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"gear": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS",
"Video player"
]
},
"help": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"sound": {
"px": 52,
"sharpTo": 26,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS",
"Video player"
]
},
"mute": {
"px": 52,
"sharpTo": 26,
"usedBy": [
"Game",
"Keeper OS",
"Video player"
]
},
"music": {
"px": 52,
"sharpTo": 26,
"usedBy": [
"Game"
]
},
"fullscreen": {
"px": 52,
"sharpTo": 26,
"usedBy": [
"Game",
"Video player"
]
},
"camera": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Game",
"Keeper OS"
]
},
"coin": {
"px": 80,
"sharpTo": 40,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"fish": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS",
"Video player"
]
},
"egg": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"growth": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"heart": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"star": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game",
"Keeper OS"
]
},
"shell": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Game",
"Keeper OS"
]
},
"kelp": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Game",
"Keeper OS"
]
},
"coral": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Game",
"Keeper OS"
]
},
"lock": {
"px": 168,
"sharpTo": 84,
"usedBy": []
},
"solved": {
"px": 168,
"sharpTo": 84,
"usedBy": []
},
"staff": {
"px": 168,
"sharpTo": 84,
"usedBy": []
},
"edit": {
"px": 168,
"sharpTo": 84,
"usedBy": []
},
"upvote": {
"px": 168,
"sharpTo": 84,
"usedBy": []
},
"report": {
"px": 168,
"sharpTo": 84,
"usedBy": []
},
"follow": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game"
]
},
"views": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Game"
]
},
"chat": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game"
]
},
"announce": {
"px": 168,
"sharpTo": 84,
"usedBy": []
},
"updates": {
"px": 168,
"sharpTo": 84,
"usedBy": [
"Field Guide",
"Game"
]
},
"bug": {
"px": 168,
"sharpTo": 84,
"usedBy": []
},
"idea": {
"px": 168,
"sharpTo": 84,
"usedBy": []
},
"emote-hello": {
"px": 128,
"sharpTo": 64,
"usedBy": [
"Game"
]
},
"emote-heart": {
"px": 128,
"sharpTo": 64,
"usedBy": [
"Game"
]
},
"emote-question": {
"px": 128,
"sharpTo": 64,
"usedBy": [
"Game"
]
},
"emote-surprise": {
"px": 128,
"sharpTo": 64,
"usedBy": [
"Game"
]
},
"emote-food": {
"px": 128,
"sharpTo": 64,
"usedBy": [
"Game"
]
},
"emote-sleep": {
"px": 128,
"sharpTo": 64,
"usedBy": [
"Game"
]
},
"emote-music": {
"px": 128,
"sharpTo": 64,
"usedBy": [
"Game"
]
},
"emote-sparkle": {
"px": 128,
"sharpTo": 64,
"usedBy": [
"Game"
]
}
}

69
src/icons.ts Normal file
View file

@ -0,0 +1,69 @@
/** The Fishies system icon set: the painted icons the game's dock and HUD, the Keeper OS desktop,
* the video player and the Field Guide share, named and grouped like an operating system's icon
* set (owner, 1 October 2026; Atlas landing-site jzxy3e).
*
* Data only. Each picture is painted once (public/game/ui-icons, public/game/emotes, provenance in
* their PROVENANCE files) and exported at twice its largest display size. What each file measures
* and where the code uses it are not written here: `bun tools/fishies-ui/build.ts` reads them into
* icons.generated.ts, so this list cannot drift from the files. */
export type IconGroup = 'care' | 'places' | 'system' | 'things' | 'expressions'
export const ICON_GROUPS: readonly { readonly id: IconGroup; readonly title: string; readonly use: string }[] = [
{ id: 'care', title: 'Care tools', use: 'The verbs of keeping fish: the dock’s tools and the cursors they become.' },
{ id: 'places', title: 'Places and lists', use: 'Where you can go and what you can open: rooms, shop, stash, map, people.' },
{ id: 'system', title: 'System', use: 'Settings, sound, notices and the frame: the same in the game, the OS and the player.' },
{ id: 'things', title: 'Things', use: 'Nouns of the reef: coins, fish, eggs, plants, rewards.' },
{ id: 'expressions', title: 'Expressions', use: 'The emotes keepers send in Open Water and the chat.' },
]
export type SystemIcon = {
readonly name: string
readonly file: string
readonly label: string
/** What it stands for, everywhere it appears. One meaning per icon, one icon per meaning. */
readonly meaning: string
readonly group: IconGroup
}
const ui = (name: string, label: string, group: IconGroup, meaning: string): SystemIcon => ({ name, file: `/game/ui-icons/${name}.png`, label, group, meaning })
const emote = (name: string, label: string, meaning: string): SystemIcon => ({ name: `emote-${name}`, file: `/game/emotes/${name}.png`, label, group: 'expressions', meaning })
export const SYSTEM_ICONS = [
ui('feed', 'Feed', 'care', 'give fish food'), ui('net', 'Net', 'care', 'catch a fish to sell or move'), ui('clean', 'Clean', 'care', 'wipe the glass'),
ui('decorate', 'Decorate', 'care', 'place a new decoration'), ui('arrange', 'Arrange', 'care', 'move what is already placed'),
ui('remedy', 'Remedy', 'care', 'heal a sick fish'), ui('inspect', 'Inspect', 'care', 'look closer, search'),
ui('home', 'Home', 'places', 'your own aquarium'), ui('explore', 'Explore', 'places', 'find other keepers'), ui('map', 'Map', 'places', 'the ocean map and its places'),
ui('shop', 'Shop', 'places', 'buy fish, decor and care'), ui('cart', 'Cart', 'places', 'open the basket'), ui('cart-add', 'Add to cart', 'places', 'put something in the basket'),
ui('inventory', 'Stash', 'places', 'what you own but have not placed'), ui('book', 'Book', 'places', 'the Field Guide and guides'),
ui('people', 'People', 'places', 'keepers, friends, followers'), ui('share', 'Share', 'places', 'send a link elsewhere'), ui('pin', 'Pin', 'places', 'keep it on top'),
ui('menu', 'Menu', 'system', 'more choices'), ui('bell', 'Notices', 'system', 'what happened while you were away'), ui('gear', 'Settings', 'system', 'change how it works'),
ui('help', 'Help', 'system', 'ask or learn how'), ui('sound', 'Sound', 'system', 'sound is on'), ui('mute', 'Muted', 'system', 'sound is off'),
ui('music', 'Music', 'system', 'the soundtrack'), ui('fullscreen', 'Full screen', 'system', 'fill the screen'), ui('camera', 'Camera', 'system', 'take a picture or a video'),
ui('coin', 'Coin', 'things', 'money in the game'), ui('fish', 'Fish', 'things', 'a fish, the game itself'), ui('egg', 'Egg', 'things', 'an egg, something hatching'),
ui('growth', 'Growth', 'things', 'growing up, rising numbers'), ui('heart', 'Heart', 'things', 'a like, kindness'), ui('star', 'Star', 'things', 'level, favourite, reward'),
ui('shell', 'Shell', 'things', 'a shell, reef chat'), ui('kelp', 'Kelp', 'things', 'plants'), ui('coral', 'Coral', 'things', 'coral and ornaments'),
ui('lock', 'Locked', 'system', 'closed, cannot be changed or answered'), ui('solved', 'Solved', 'things', 'answered, done, approved'),
ui('staff', 'Staff', 'things', 'someone from the Fishies team'), ui('edit', 'Edit', 'system', 'change words, or was changed'),
ui('upvote', 'Upvote', 'things', 'this is useful, raise it'), ui('report', 'Report', 'system', 'tell the team something is wrong'),
ui('follow', 'Follow', 'system', 'get notices about it'), ui('views', 'Views', 'things', 'how many looked, who can see it'),
ui('chat', 'Chat', 'places', 'a conversation, replies, general talk'),
ui('announce', 'Announcements', 'places', 'news from the team'), ui('updates', 'Updates', 'places', 'patch notes and what changed'),
ui('bug', 'Bugs', 'places', 'something broken'), ui('idea', 'Ideas', 'places', 'a suggestion'),
emote('hello', 'Hello', 'wave hello'), emote('heart', 'Love', 'send love'), emote('question', 'Question', 'wonder aloud'), emote('surprise', 'Surprise', 'be surprised'),
emote('food', 'Food', 'ask for food'), emote('sleep', 'Sleepy', 'feel sleepy'), emote('music', 'Music', 'enjoy the music'), emote('sparkle', 'Sparkle', 'something wonderful'),
] as const satisfies readonly SystemIcon[]
export type SystemIconName = (typeof SYSTEM_ICONS)[number]['name']
/** The sizes the set is drawn at, in CSS pixels. A file stays sharp up to half its pixel width. */
export const ICON_SIZES = { xs: 16, sm: 20, md: 28, lg: 46, xl: 84 } as const
export type IconSize = keyof typeof ICON_SIZES
export const iconByName = (name: string): SystemIcon | undefined => SYSTEM_ICONS.find(icon => icon.name === name)
let resolveUrl = (icon: SystemIcon): string => icon.file
/** Where the pictures are served from. In the game they sit at their `file` path; anywhere else,
* point this at a copy of the package's `icons/` folder (`icons/<name>.png`). */
export function configureIcons(options: { url: (icon: SystemIcon) => string }): void { resolveUrl = options.url }
export const iconUrl = (icon: SystemIcon): string => resolveUrl(icon)

8
src/index.ts Normal file
View file

@ -0,0 +1,8 @@
'use client'
export * from './kit'
export { TOKEN_GROUPS, TOKENS, fx, tokensCss, type Token, type TokenGroup } from './tokens'
export { SYSTEM_ICONS, ICON_GROUPS, ICON_SIZES, iconByName, iconUrl, configureIcons, type SystemIcon as SystemIconEntry, type SystemIconName, type IconGroup, type IconSize } from './icons'
export { ICON_FACTS } from './icons.generated'
export { SPINNER_SVG, svgDataUri } from './loader'
export { FX_IMAGE_SCRIPT, reveal } from './fx-image'
export type { SelectOption } from './Select'

275
src/kit.css Normal file
View file

@ -0,0 +1,275 @@
/* fishies-ui components (kit.tsx). Reef toy (Atlas landing-site 3mk66d): round, plump, slightly 3D
controls on water glass with a gold rim, a bubble here and there. Every value is a token from
tokens.generated.css or a motion slot the motion system fills; nothing here picks its own colour.
In its own cascade layer, last of the layers, so a component beats the game's older layered
skins without !important, and a surface's own unlayered rules can still place it. The order is
restated here because whichever stylesheet the browser meets first fixes it. */
@layer base, skin, system, responsive, kit;
@layer kit {
/* ── icon ────────────────────────────────────────────────────────────── */
.fx-icon { display: inline-grid; place-items: center; flex: none; line-height: 0; }
.fx-icon img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; -webkit-user-drag: none; }
/* ── button ──────────────────────────────────────────────────────────── */
.fx-button {
position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; gap: var(--fx-s-2);
min-height: 46px; padding: 0 var(--fx-s-5); border: 1px solid var(--fx-rim); border-radius: var(--fx-r-full);
font: 800 var(--fx-t-md)/1 var(--fx-font-display); letter-spacing: var(--fx-track-tight); white-space: nowrap; text-decoration: none;
cursor: pointer; -webkit-tap-highlight-color: transparent;
transition: transform var(--m-quick) var(--m-ease-spring), box-shadow var(--m-quick) var(--m-ease-out), filter var(--m-quick) var(--m-ease-out);
}
.fx-button.is-sm { min-height: 36px; padding: 0 var(--fx-s-4); font-size: var(--fx-t-sm); gap: var(--fx-s-1); }
.fx-button.is-lg { min-height: 56px; padding: 0 var(--fx-s-6); font-size: var(--fx-t-lg); }
.fx-button:focus-visible { outline: 3px solid var(--fx-gold); outline-offset: 3px; }
.fx-button:disabled, .fx-button[aria-disabled='true'] { cursor: not-allowed; filter: saturate(.35) brightness(.85); transform: none; }
.fx-button:hover:not(:disabled) { transform: translateY(-2px); }
.fx-button:active:not(:disabled) { transform: translateY(2px) scale(.98); }
/* Glass: the everyday button. */
.fx-button, .fx-button.is-glass {
background: var(--fx-glass); color: var(--fx-ink);
box-shadow: var(--fx-rim-light), var(--fx-foot);
}
.fx-button.is-glass:hover:not(:disabled), .fx-button:not([class*='is-']):hover:not(:disabled) { border-color: var(--fx-rim-bright); }
.fx-button:active:not(:disabled) { box-shadow: var(--fx-rim-light), 0 1px 0 rgb(4 18 34 / 55%); }
/* Gold: the one thing to press. `.gold-button` is the game's name for it, painted here so the
game has one gold button (the panels used to have a pearl one and the HUD a glowing one). */
:is(.fx-button.is-gold, .gold-button) {
border-color: var(--fx-pearl);
background: radial-gradient(60% 46% at 30% 10%, rgb(255 255 255 / 55%), transparent 70%), linear-gradient(180deg, var(--fx-gold-face), var(--fx-gold));
box-shadow: inset 0 1px rgb(255 255 255 / 55%), inset 0 -3px 6px rgb(200 138 61 / 30%), 0 3px 0 var(--fx-gold-foot), var(--fx-lift-1);
color: var(--fx-ink-on-gold); text-shadow: none; -webkit-text-stroke: 0;
}
:is(.fx-button.is-gold, .gold-button):hover:not(:disabled) { filter: brightness(1.05) saturate(1.05); }
:is(.fx-button.is-gold, .gold-button):active:not(:disabled) { box-shadow: inset 0 1px rgb(255 255 255 / 55%), inset 0 -2px 4px rgb(200 138 61 / 30%), 0 1px 0 var(--fx-gold-foot); }
/* Ghost: a third choice that should not compete. */
.fx-button.is-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--fx-ink-2); }
.fx-button.is-ghost:hover:not(:disabled) { background: rgb(255 255 255 / 8%); color: var(--fx-ink); transform: none; }
.fx-button.is-ghost:active:not(:disabled) { box-shadow: none; }
/* Danger: undo-less things (sell all, delete). */
.fx-button.is-danger {
border-color: color-mix(in oklab, var(--fx-tone-coral), white 30%);
background: radial-gradient(60% 46% at 30% 10%, rgb(255 255 255 / 34%), transparent 70%), linear-gradient(180deg, var(--fx-tone-coral), color-mix(in oklab, var(--fx-alarm), black 28%));
box-shadow: inset 0 1px rgb(255 255 255 / 40%), 0 3px 0 color-mix(in oklab, var(--fx-alarm), black 55%), var(--fx-lift-1);
color: white;
}
.fx-button > .fx-icon { margin-left: calc(var(--fx-s-2) * -1); }
/* ── round button: window controls, the player, a close ──────────────── */
.fx-round {
display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; padding: 0;
border: 1px solid var(--fx-rim); border-radius: 50%; color: var(--fx-ink); cursor: pointer;
background: radial-gradient(circle at 35% 28%, rgb(255 255 255 / 26%), transparent 52%), var(--fx-navy);
box-shadow: inset 0 -2px 4px rgb(0 0 0 / 25%), 0 2px 0 rgb(2 10 24 / 50%);
transition: transform var(--m-quick) var(--m-ease-spring), filter var(--m-quick) var(--m-ease-out);
}
.fx-round.is-sm { width: 30px; height: 30px; }
.fx-round.is-lg { width: 48px; height: 48px; }
.fx-round svg { width: 55%; height: 55%; }
.fx-round .fx-icon { width: 70%; height: 70%; }
.fx-round:hover:not(:disabled) { transform: translateY(-1px) scale(1.06); filter: brightness(1.1); }
.fx-round:active:not(:disabled) { transform: translateY(1px) scale(.94); }
.fx-round:focus-visible { outline: 3px solid var(--fx-gold); outline-offset: 2px; }
.fx-round.is-coral { border-color: color-mix(in oklab, var(--fx-tone-coral), white 30%); background: radial-gradient(circle at 35% 28%, rgb(255 255 255 / 30%), transparent 52%), color-mix(in oklab, var(--fx-alarm), black 25%); }
.fx-round.is-gold { border-color: var(--fx-pearl); color: var(--fx-ink-on-gold); background: radial-gradient(circle at 35% 28%, rgb(255 255 255 / 60%), transparent 52%), linear-gradient(180deg, var(--fx-gold-face), var(--fx-gold)); box-shadow: inset 0 -2px 4px rgb(200 138 61 / 35%), 0 2px 0 var(--fx-gold-foot); }
.fx-round[aria-pressed='true'] { border-color: var(--fx-gold-rim); box-shadow: inset 0 0 0 2px rgb(255 196 107 / 40%), 0 2px 0 rgb(2 10 24 / 50%); }
/* ── chip ────────────────────────────────────────────────────────────── */
.fx-chip {
display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 var(--fx-s-3);
border: 1px solid var(--fx-rim); border-radius: var(--fx-r-full); background: rgb(255 255 255 / 6%); color: var(--fx-ink);
font: 800 var(--fx-t-sm)/1 var(--fx-font-display); font-variant-numeric: tabular-nums; white-space: nowrap;
transition: background var(--m-quick) var(--m-ease-out), transform var(--m-quick) var(--m-ease-spring);
}
button.fx-chip { cursor: pointer; }
button.fx-chip:hover { background: rgb(255 255 255 / 13%); }
button.fx-chip:active { transform: scale(.95); }
.fx-chip:focus-visible { outline: 3px solid var(--fx-gold); outline-offset: 2px; }
.fx-chip > i { width: 8px; height: 8px; border-radius: 50%; background: var(--tone, var(--fx-tone-mute)); box-shadow: 0 0 0 3px color-mix(in oklab, var(--tone, var(--fx-tone-mute)), transparent 75%); }
.fx-chip .fx-icon { width: 18px; height: 18px; margin-left: -4px; }
.fx-chip[aria-pressed='true'], .fx-chip[aria-checked='true'], .fx-chip.is-on {
border-color: var(--fx-pearl); color: var(--fx-ink-on-gold);
background: linear-gradient(180deg, var(--fx-gold-face), var(--fx-gold)); box-shadow: inset 0 1px rgb(255 255 255 / 55%), 0 2px 0 var(--fx-gold-foot);
}
/* ── badge and tag ───────────────────────────────────────────────────── */
.fx-badge {
display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; border: 2px solid var(--fx-pearl); border-radius: var(--fx-r-full);
background: linear-gradient(180deg, var(--fx-tone-coral), color-mix(in oklab, var(--fx-alarm), black 22%));
color: white; font: 900 var(--fx-t-xs)/1 var(--fx-font-ui); font-variant-numeric: tabular-nums; box-shadow: 0 3px 8px rgb(0 0 0 / 35%);
}
.fx-badge.is-dot { min-width: 14px; width: 14px; height: 14px; padding: 0; }
.fx-tag {
display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--fx-gold-rim); border-radius: var(--fx-r-full);
color: var(--fx-gold); font: 900 var(--fx-t-xs)/1.2 var(--fx-font-ui); letter-spacing: var(--fx-track-label); text-transform: uppercase;
}
.fx-eyebrow { display: block; color: var(--fx-gold); font: 900 var(--fx-t-xs)/1 var(--fx-font-ui); letter-spacing: var(--fx-track-label); text-transform: uppercase; }
/* ── surfaces: card, panel, window ───────────────────────────────────── */
.fx-card, .fx-panel, .fx-window, .fx-dock, .fx-toast, .fx-tooltip, .fx-stat {
border: 1px solid var(--fx-rim); background: var(--fx-glass); color: var(--fx-ink);
-webkit-backdrop-filter: var(--fx-glass-blur); backdrop-filter: var(--fx-glass-blur);
}
.fx-card { display: grid; gap: var(--fx-s-2); padding: var(--fx-s-4); border-radius: var(--fx-r-md); box-shadow: var(--fx-rim-light), var(--fx-lift-2); }
.fx-card > h3 { margin: 0; font: 800 var(--fx-t-lg)/1.15 var(--fx-font-display); letter-spacing: var(--fx-track-tight); }
.fx-card > p { margin: 0; color: var(--fx-ink-2); font: 600 var(--fx-t-md)/1.5 var(--fx-font-ui); }
.fx-panel { display: flex; flex-direction: column; min-width: 0; border-color: var(--fx-gold-rim); border-radius: var(--fx-r-lg); box-shadow: var(--fx-rim-light), var(--fx-lift-2); overflow: hidden; }
.fx-panel-head { display: flex; align-items: center; gap: var(--fx-s-3); min-height: 56px; padding: var(--fx-s-2) var(--fx-s-3) var(--fx-s-2) var(--fx-s-4); border-bottom: 1px solid var(--fx-gold-rim-quiet); }
.fx-panel-head > .fx-icon { width: 30px; height: 30px; filter: drop-shadow(0 3px 3px rgb(0 0 0 / 35%)); }
.fx-panel-head h2 { flex: 1; min-width: 0; margin: 0; overflow: hidden; color: var(--fx-gold-light); font: 800 var(--fx-t-lg)/1.1 var(--fx-font-display); text-overflow: ellipsis; white-space: nowrap; }
.fx-panel-body { padding: var(--fx-s-4); }
.fx-window { display: flex; flex-direction: column; min-width: 0; border-color: var(--fx-gold-rim); border-radius: 22px; overflow: hidden; box-shadow: var(--fx-rim-light), 0 4px 0 rgb(4 18 34 / 50%), var(--fx-lift-3); }
.fx-window-bar { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 6px 8px 6px 14px; background: linear-gradient(180deg, rgb(255 255 255 / 12%), rgb(255 255 255 / 2%)); border-bottom: 1px solid var(--fx-gold-rim-quiet); }
.fx-window-bar > .fx-icon { width: 26px; height: 26px; }
.fx-window-bar h2 { flex: 1; min-width: 0; margin: 0; overflow: hidden; color: var(--fx-gold-light); font: 800 17px/1 var(--fx-font-display); text-overflow: ellipsis; white-space: nowrap; }
.fx-window-buttons { display: flex; gap: 6px; }
.fx-window-body { flex: 1; min-height: 0; overflow: auto; padding: var(--fx-s-4); background: var(--fx-glass-well); scrollbar-width: thin; }
/* ── tabs ────────────────────────────────────────────────────────────── */
.fx-tabs { display: inline-flex; gap: 4px; max-width: 100%; padding: 4px; overflow-x: auto; border: 1px solid var(--fx-rim); border-radius: var(--fx-r-full); background: var(--fx-deep); box-shadow: inset 0 2px 6px rgb(0 0 0 / 40%); scrollbar-width: none; }
.fx-tab {
display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 var(--fx-s-4); border: 1px solid transparent; border-radius: var(--fx-r-full);
background: none; color: var(--fx-ink-2); font: 800 var(--fx-t-sm)/1 var(--fx-font-display); white-space: nowrap; cursor: pointer;
transition: background var(--m-base) var(--m-ease-out), color var(--m-base) var(--m-ease-out), transform var(--m-quick) var(--m-ease-spring);
}
.fx-tab .fx-icon { width: 22px; height: 22px; }
.fx-tab:hover { color: var(--fx-ink); background: rgb(255 255 255 / 7%); }
.fx-tab:active { transform: scale(.96); }
.fx-tab:focus-visible { outline: 3px solid var(--fx-gold); outline-offset: 1px; }
.fx-tab[aria-selected='true'] {
border-color: var(--fx-pearl); color: var(--fx-ink-on-gold);
background: linear-gradient(180deg, var(--fx-gold-face), var(--fx-gold)); box-shadow: inset 0 1px rgb(255 255 255 / 55%), 0 2px 0 var(--fx-gold-foot);
}
/* ── list ────────────────────────────────────────────────────────────── */
.fx-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.fx-row {
display: flex; align-items: center; gap: var(--fx-s-3); width: 100%; min-height: 56px; padding: var(--fx-s-2) var(--fx-s-3);
border: 1px solid transparent; border-radius: var(--fx-r-md); background: none; color: var(--fx-ink); text-align: left; font: inherit;
transition: background var(--m-quick) var(--m-ease-out), border-color var(--m-quick) var(--m-ease-out);
}
button.fx-row, a.fx-row { cursor: pointer; text-decoration: none; }
:is(button, a).fx-row:hover, .fx-row.is-on { background: rgb(108 200 255 / 14%); border-color: var(--fx-gold-rim-quiet); }
.fx-row:focus-visible { outline: 3px solid var(--fx-gold); outline-offset: 1px; }
.fx-row > .fx-icon { width: 36px; height: 36px; filter: drop-shadow(0 3px 3px rgb(0 0 0 / 30%)); }
.fx-row-text { display: grid; flex: 1; gap: 3px; min-width: 0; }
.fx-row-text b { overflow: hidden; font: 800 var(--fx-t-md)/1.15 var(--fx-font-display); text-overflow: ellipsis; white-space: nowrap; }
.fx-row-text small { overflow: hidden; color: var(--fx-ink-3); font: 700 var(--fx-t-sm)/1.25 var(--fx-font-ui); text-overflow: ellipsis; white-space: nowrap; }
.fx-row-end { flex: none; color: var(--fx-gold-light); font: 800 var(--fx-t-md)/1 var(--fx-font-display); font-variant-numeric: tabular-nums; }
/* ── field, toggle ───────────────────────────────────────────────────── */
.fx-field { display: grid; gap: 6px; min-width: 0; }
.fx-field > span { color: var(--fx-ink-blue); font: 800 var(--fx-t-xs)/1 var(--fx-font-ui); letter-spacing: var(--fx-track-label); text-transform: uppercase; }
.fx-field > small { color: var(--fx-ink-3); font: 600 var(--fx-t-sm)/1.35 var(--fx-font-ui); }
.fx-input {
width: 100%; min-height: 46px; padding: 0 var(--fx-s-4); border: 1px solid var(--fx-rim); border-radius: var(--fx-r-full);
background: var(--fx-deep); color: var(--fx-ink); font: 700 var(--fx-t-md)/1.2 var(--fx-font-ui);
box-shadow: inset 0 2px 6px rgb(0 0 0 / 45%), 0 1px 0 rgb(255 255 255 / 7%); outline: none;
transition: border-color var(--m-quick) var(--m-ease-out), box-shadow var(--m-quick) var(--m-ease-out);
}
.fx-input::placeholder { color: var(--fx-ink-3); }
.fx-input:focus-visible { border-color: var(--fx-gold-rim); box-shadow: inset 0 2px 6px rgb(0 0 0 / 45%), 0 0 0 4px rgb(255 196 107 / 22%); }
.fx-input[aria-invalid='true'] { border-color: var(--fx-alarm); }
.fx-toggle { display: inline-flex; align-items: center; gap: var(--fx-s-3); color: var(--fx-ink); font: 800 var(--fx-t-md)/1.2 var(--fx-font-display); cursor: pointer; }
.fx-toggle > input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.fx-toggle > i {
position: relative; flex: none; width: 52px; height: 30px; border: 1px solid var(--fx-rim); border-radius: var(--fx-r-full);
background: var(--fx-deep); box-shadow: inset 0 2px 6px rgb(0 0 0 / 50%);
transition: background var(--m-base) var(--m-ease-out), border-color var(--m-base) var(--m-ease-out);
}
/* The knob is a pearl: lit from the top left, a little shadow under it. */
.fx-toggle > i::after {
content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
background: radial-gradient(circle at 34% 28%, white, var(--fx-pearl) 55%, var(--fx-cream));
box-shadow: 0 2px 0 rgb(4 18 34 / 45%), 0 3px 8px rgb(0 0 0 / 35%);
transition: transform var(--m-move) var(--m-ease-spring);
}
.fx-toggle > input:checked + i { border-color: var(--fx-pearl); background: linear-gradient(180deg, var(--fx-gold-face), var(--fx-gold)); box-shadow: inset 0 2px 4px rgb(200 138 61 / 45%); }
.fx-toggle > input:checked + i::after { transform: translateX(22px); }
.fx-toggle > input:focus-visible + i { outline: 3px solid var(--fx-gold); outline-offset: 3px; }
.fx-toggle > input:disabled + i { filter: saturate(.3); opacity: .6; }
/* ── tooltip ─────────────────────────────────────────────────────────── */
.fx-tip { position: relative; display: inline-flex; }
.fx-tooltip {
position: absolute; z-index: var(--fx-z-tooltip); left: 50%; bottom: calc(100% + 12px); width: max-content; min-width: 180px; max-width: 280px;
display: grid; gap: 8px; padding: var(--fx-s-3); border-color: var(--fx-gold-rim); border-radius: var(--fx-r-md);
box-shadow: var(--fx-rim-light), var(--fx-lift-2); text-align: left; pointer-events: none;
opacity: 0; visibility: hidden; transform: translate(-50%, 6px) scale(.96); transform-origin: 50% 100%;
transition: opacity var(--m-base) var(--m-ease-out), transform var(--m-move) var(--m-ease-spring), visibility 0s linear var(--m-base);
}
.fx-tooltip::after { content: ''; position: absolute; left: 50%; bottom: -7px; width: 12px; height: 12px; margin-left: -6px; rotate: 45deg; border: solid var(--fx-gold-rim); border-width: 0 1px 1px 0; background: var(--fx-glass-bottom); }
.fx-tip:is(:hover, :focus-within) > .fx-tooltip, .fx-tooltip.is-open { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.fx-tooltip-head { display: flex; align-items: center; gap: var(--fx-s-2); font: 800 var(--fx-t-md)/1.1 var(--fx-font-display); color: var(--fx-gold-light); }
.fx-tooltip-head .fx-icon { width: 26px; height: 26px; }
.fx-tooltip p { margin: 0; color: var(--fx-ink-2); font: 600 var(--fx-t-sm)/1.4 var(--fx-font-ui); }
.fx-tooltip dl { display: grid; gap: 4px; margin: 0; padding-top: 8px; border-top: 1px solid var(--fx-gold-rim-quiet); }
.fx-tooltip dl > div { display: flex; justify-content: space-between; gap: var(--fx-s-3); }
.fx-tooltip dt { color: var(--fx-ink-blue); font: 800 var(--fx-t-sm)/1.2 var(--fx-font-ui); }
.fx-tooltip dd { margin: 0; font: 800 var(--fx-t-sm)/1.2 var(--fx-font-display); font-variant-numeric: tabular-nums; }
/* ── toast ───────────────────────────────────────────────────────────── */
.fx-toast {
position: relative; display: flex; align-items: center; gap: var(--fx-s-3); width: min(380px, 100%); padding: var(--fx-s-3) var(--fx-s-3) var(--fx-s-3) var(--fx-s-3);
border-radius: var(--fx-r-lg); box-shadow: var(--fx-rim-light), var(--fx-lift-2); overflow: hidden;
}
.fx-toast::before { content: ''; position: absolute; inset: 10px auto 10px 0; width: 4px; border-radius: 0 4px 4px 0; background: var(--tone, var(--fx-gold)); }
.fx-toast-art { display: grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle at 35% 28%, rgb(255 255 255 / 30%), transparent 55%), color-mix(in oklab, var(--tone, var(--fx-gold)), var(--fx-deep) 62%); box-shadow: inset 0 -3px 6px rgb(0 0 0 / 30%), 0 2px 0 rgb(2 10 24 / 45%); }
.fx-toast-art .fx-icon { width: 32px; height: 32px; }
.fx-toast-text { display: grid; flex: 1; gap: 2px; min-width: 0; }
.fx-toast-text b { font: 800 var(--fx-t-md)/1.2 var(--fx-font-display); }
.fx-toast-text span { color: var(--fx-ink-2); font: 600 var(--fx-t-sm)/1.35 var(--fx-font-ui); }
/* ── stat ────────────────────────────────────────────────────────────── */
.fx-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.fx-stat { display: inline-flex; align-items: center; gap: 10px; min-height: 58px; padding: 8px 16px 8px 10px; border-radius: 18px; box-shadow: var(--fx-rim-light), var(--fx-foot); }
.fx-stat > .fx-icon { width: 38px; height: 38px; filter: drop-shadow(0 3px 3px rgb(0 0 0 / 35%)); }
.fx-stat b { display: block; color: var(--fx-gold-light); font: 800 22px/1 var(--fx-font-display); font-variant-numeric: tabular-nums; }
.fx-stat b small { margin-left: 3px; color: var(--fx-ink-3); font-size: var(--fx-t-sm); }
.fx-stat > span > span { color: var(--fx-ink-3); font: 700 var(--fx-t-sm)/1.3 var(--fx-font-ui); }
/* ── desktop tile and dock ───────────────────────────────────────────── */
.fx-tile { display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: 118px; padding: 0; border: 0; background: none; color: var(--fx-ink); font: inherit; cursor: pointer; }
.fx-tile-glass {
position: relative; display: grid; place-items: center; aspect-ratio: 1; border: 1.5px solid var(--fx-gold-rim); border-radius: var(--fx-r-xl);
background: radial-gradient(circle at 30% 22%, rgb(255 255 255 / 34%), transparent 34%), linear-gradient(160deg, oklch(62% .12 var(--hue, 220)), oklch(36% .1 var(--hue, 220)) 70%, oklch(28% .08 var(--hue, 220)));
box-shadow: var(--fx-plump), var(--fx-foot-deep), var(--fx-lift-2);
transition: transform var(--m-quick) var(--m-ease-spring), box-shadow var(--m-quick) var(--m-ease-out);
}
.fx-tile-glass > .fx-icon { width: 62%; height: 62%; filter: drop-shadow(0 6px 6px rgb(0 0 0 / 35%)); transition: transform var(--m-move) var(--m-ease-spring); }
.fx-tile-glass > .fx-badge { position: absolute; top: -6px; right: -6px; }
.fx-tile:hover .fx-tile-glass, .fx-tile:focus-visible .fx-tile-glass { transform: translateY(-3px); }
.fx-tile:hover .fx-tile-glass > .fx-icon { transform: scale(1.08) rotate(-3deg); }
.fx-tile:active .fx-tile-glass { transform: translateY(3px); box-shadow: var(--fx-plump), 0 2px 0 rgb(4 18 34 / 55%); }
.fx-tile:focus-visible { outline: none; }
.fx-tile:focus-visible .fx-tile-glass { outline: 3px solid var(--fx-gold); outline-offset: 4px; }
.fx-tile.is-open .fx-tile-glass::after { content: ''; position: absolute; bottom: -12px; width: 18px; height: 5px; border-radius: 3px; background: var(--fx-gold); box-shadow: 0 0 10px var(--fx-gold); }
.fx-tile-title { text-align: center; font: 800 var(--fx-t-md)/1.2 var(--fx-font-display); text-shadow: var(--fx-on-water); }
.fx-dock { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 8px 10px; overflow-x: auto; border-color: var(--fx-gold-rim); border-radius: var(--fx-r-xl); box-shadow: var(--fx-rim-light), var(--fx-lift-2); scrollbar-width: none; }
.fx-dock-item {
position: relative; flex: none; display: grid; place-items: center; width: 60px; height: 60px; padding: 0; border: 0; border-radius: 18px; background: none; cursor: pointer;
transition: transform var(--m-quick) var(--m-ease-spring), background var(--m-quick) var(--m-ease-out);
}
.fx-dock-item:hover { background: rgb(255 255 255 / 8%); transform: translateY(-4px) scale(1.06); }
.fx-dock-item:focus-visible { outline: 3px solid var(--fx-gold); outline-offset: 1px; }
.fx-dock-item > .fx-icon { width: 46px; height: 46px; filter: drop-shadow(0 4px 4px rgb(0 0 0 / 35%)); }
.fx-dock-item > i { position: absolute; bottom: 1px; left: 50%; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; }
.fx-dock-item.is-open > i { background: var(--fx-ink-2); }
.fx-dock-item.is-front > i { width: 16px; margin-left: -8px; border-radius: 3px; background: var(--fx-gold); box-shadow: 0 0 8px var(--fx-gold); }
.fx-dock-item > .fx-badge { position: absolute; top: 0; right: 0; }
.fx-dock-sep { flex: none; width: 1px; height: 40px; margin: 0 4px; background: var(--fx-gold-rim-quiet); }
@media (prefers-reduced-motion: reduce) {
:is(.fx-button, .fx-round, .fx-tile-glass, .fx-dock-item, .fx-tab, .fx-chip):is(:hover, :active) { transform: none !important; }
.fx-tile:hover .fx-tile-glass > .fx-icon { transform: none; }
}
}

203
src/kit.tsx Normal file
View file

@ -0,0 +1,203 @@
'use client'
import { useId, useState, type AnchorHTMLAttributes, type ButtonHTMLAttributes, type CSSProperties, type InputHTMLAttributes, type ReactNode } from 'react'
import FishiesImg from './FishiesImg'
import { ICON_SIZES, iconByName, iconUrl, type IconSize, type SystemIconName } from './icons'
import './kit.css'
/* fishies-ui components. Each export's first doc sentence is its Handbook entry (the build reads
them), so a component is described once, here, next to the code that draws it. */
const cx = (...names: (string | false | null | undefined)[]) => names.filter(Boolean).join(' ')
const px = (size: IconSize | number) => typeof size === 'number' ? size : ICON_SIZES[size]
/** A painted icon from the system set, by name, at one of the set's sizes. */
export function SystemIcon({ name, size = 'md', fallback, className }: { name: SystemIconName; size?: IconSize | number; fallback?: ReactNode; className?: string }) {
const [failed, setFailed] = useState(false)
const icon = iconByName(name)
const side = px(size)
if (!icon || failed) return fallback ? <>{fallback}</> : null
return <span className={cx('fx-icon', className)} style={{ width: side, height: side }} aria-hidden="true">
<FishiesImg src={iconUrl(icon)} width={side} height={side} alt="" draggable={false} decoding="async" onError={() => setFailed(true)}/>
</span>
}
export type ButtonTone = 'glass' | 'gold' | 'ghost' | 'danger'
type ButtonOwn = { tone?: ButtonTone; size?: 'sm' | 'md' | 'lg'; icon?: SystemIconName; children?: ReactNode }
/** A plump toy button: glass for everyday actions, gold for the one thing to press, ghost for a quiet third choice, danger for what cannot be undone. */
export function Button({ tone = 'glass', size = 'md', icon, children, className, type = 'button', ...rest }: ButtonOwn & ButtonHTMLAttributes<HTMLButtonElement>) {
return <button type={type} className={cx('fx-button', `is-${tone}`, size !== 'md' && `is-${size}`, className)} {...rest}>
{icon && <SystemIcon name={icon} size={size === 'lg' ? 30 : size === 'sm' ? 20 : 26}/>}{children}
</button>
}
/** The same button as a link, for an action that goes somewhere. */
export function ButtonLink({ tone = 'glass', size = 'md', icon, children, className, ...rest }: ButtonOwn & AnchorHTMLAttributes<HTMLAnchorElement>) {
return <a className={cx('fx-button', `is-${tone}`, size !== 'md' && `is-${size}`, className)} {...rest}>
{icon && <SystemIcon name={icon} size={size === 'lg' ? 30 : size === 'sm' ? 20 : 26}/>}{children}
</a>
}
/** A round toy button for window controls, the video player and close; `label` is what it says to a screen reader. */
export function RoundButton({ label, tone = 'navy', size = 'md', icon, children, className, type = 'button', ...rest }: { label: string; tone?: 'navy' | 'coral' | 'gold'; size?: 'sm' | 'md' | 'lg'; icon?: SystemIconName; children?: ReactNode } & ButtonHTMLAttributes<HTMLButtonElement>) {
return <button type={type} aria-label={label} title={label} className={cx('fx-round', tone !== 'navy' && `is-${tone}`, size !== 'md' && `is-${size}`, className)} {...rest}>
{icon ? <SystemIcon name={icon} size={size === 'lg' ? 34 : 26}/> : children}
</button>
}
/** A small reading or choice: a dot of colour for a kind, an icon, or gold when chosen. */
export function Chip({ tone, icon, selected, onClick, children, className }: { tone?: string; icon?: SystemIconName; selected?: boolean; onClick?: () => void; children: ReactNode; className?: string }) {
const style = tone ? { '--tone': tone } as CSSProperties : undefined
const inner = <>{tone && <i aria-hidden="true"/>}{icon && <SystemIcon name={icon} size={18}/>}{children}</>
return onClick
? <button type="button" className={cx('fx-chip', className)} style={style} aria-pressed={selected} onClick={onClick}>{inner}</button>
: <span className={cx('fx-chip', selected && 'is-on', className)} style={style}>{inner}</span>
}
/** A coral count bubble that sits on a tile, a dock item or a bell; a dot when the number does not matter. */
export function Badge({ count, label }: { count?: number; label?: string }) {
return count === undefined
? <span className="fx-badge is-dot" role="status" aria-label={label}/>
: <span className="fx-badge" role="status" aria-label={label}>{count > 99 ? '99+' : count}</span>
}
/** A gold-rimmed capsule for a small upper-case word beside a name (Beta, New, Admin). */
export function Tag({ children }: { children: ReactNode }) {
return <span className="fx-tag">{children}</span>
}
/** A glass card: an optional eyebrow, a title and a few lines. */
export function Card({ eyebrow, title, children, className }: { eyebrow?: string; title?: ReactNode; children?: ReactNode; className?: string }) {
return <article className={cx('fx-card', className)}>
{eyebrow && <span className="fx-eyebrow">{eyebrow}</span>}
{title && <h3>{title}</h3>}
{children}
</article>
}
/** A gold-rimmed glass panel with a title row (icon, title, actions) and a body. */
export function Panel({ title, icon, actions, children, className, style }: { title: ReactNode; icon?: SystemIconName; actions?: ReactNode; children?: ReactNode; className?: string; style?: CSSProperties }) {
return <section className={cx('fx-panel', className)} style={style}>
<header className="fx-panel-head">{icon && <SystemIcon name={icon} size={30}/>}<h2>{title}</h2>{actions}</header>
<div className="fx-panel-body">{children}</div>
</section>
}
/** A Keeper OS window frame: a title bar with round minimise and close buttons over a darker well. */
export function Window({ title, icon, onClose, onMinimize, closeLabel = 'Close', minimizeLabel = 'Minimise', children, className, style }: {
title: ReactNode; icon?: SystemIconName; onClose?: () => void; onMinimize?: () => void; closeLabel?: string; minimizeLabel?: string
children?: ReactNode; className?: string; style?: CSSProperties
}) {
return <section className={cx('fx-window', className)} style={style} role="dialog" aria-label={typeof title === 'string' ? title : undefined}>
<header className="fx-window-bar">
{icon && <SystemIcon name={icon} size={26}/>}
<h2>{title}</h2>
<span className="fx-window-buttons">
{onMinimize && <RoundButton label={minimizeLabel} size="sm" onClick={onMinimize}><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8h9" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round"/></svg></RoundButton>}
{onClose && <RoundButton label={closeLabel} size="sm" tone="coral" onClick={onClose}><svg viewBox="0 0 16 16" aria-hidden="true"><path d="m4.5 4.5 7 7m0-7-7 7" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round"/></svg></RoundButton>}
</span>
</header>
<div className="fx-window-body">{children}</div>
</section>
}
export type TabItem = { id: string; label: string; icon?: SystemIconName }
/** A row of pill tabs in a sunken track; the chosen one is gold. */
export function Tabs({ items, value, onChange, label }: { items: readonly TabItem[]; value: string; onChange: (id: string) => void; label: string }) {
const move = (from: number, step: number) => onChange(items[(from + step + items.length) % items.length]!.id)
return <div className="fx-tabs" role="tablist" aria-label={label}>
{items.map((item, index) => <button key={item.id} type="button" role="tab" className="fx-tab" aria-selected={item.id === value} tabIndex={item.id === value ? 0 : -1}
onClick={() => onChange(item.id)} onKeyDown={event => { if (event.key === 'ArrowRight') move(index, 1); if (event.key === 'ArrowLeft') move(index, -1) }}>
{item.icon && <SystemIcon name={item.icon} size={22}/>}{item.label}
</button>)}
</div>
}
/** A list of rows; each row has an icon, a title, a detail line and a value at its end. */
export function List({ children, label }: { children: ReactNode; label?: string }) {
return <ul className="fx-list" aria-label={label}>{children}</ul>
}
/** One row of a list; a button when it does something, a link when it goes somewhere. */
export function ListRow({ icon, title, detail, end, onClick, href, selected }: { icon?: SystemIconName; title: ReactNode; detail?: ReactNode; end?: ReactNode; onClick?: () => void; href?: string; selected?: boolean }) {
const inner = <>{icon && <SystemIcon name={icon} size={36}/>}<span className="fx-row-text"><b>{title}</b>{detail && <small>{detail}</small>}</span>{end !== undefined && <span className="fx-row-end">{end}</span>}</>
return <li>{href ? <a className={cx('fx-row', selected && 'is-on')} href={href}>{inner}</a>
: onClick ? <button type="button" className={cx('fx-row', selected && 'is-on')} onClick={onClick} aria-pressed={selected}>{inner}</button>
: <div className={cx('fx-row', selected && 'is-on')}>{inner}</div>}</li>
}
/** A labelled text field in a sunken pill, with an optional hint under it. */
export function Field({ label, hint, className, ...input }: { label: string; hint?: string } & InputHTMLAttributes<HTMLInputElement>) {
const id = useId()
return <label className={cx('fx-field', className)} htmlFor={id}>
<span>{label}</span>
<input id={id} className="fx-input" aria-describedby={hint ? `${id}-hint` : undefined} {...input}/>
{hint && <small id={`${id}-hint`}>{hint}</small>}
</label>
}
/** An on and off switch with a pearl knob; gold when on. */
export function Toggle({ label, checked, onChange, disabled }: { label: ReactNode; checked: boolean; onChange: (checked: boolean) => void; disabled?: boolean }) {
return <label className="fx-toggle">
<input type="checkbox" role="switch" checked={checked} disabled={disabled} onChange={event => onChange(event.target.checked)}/>
<i aria-hidden="true"/>{label}
</label>
}
export type TooltipRow = { label: ReactNode; value: ReactNode }
/** A designed tooltip, never plain text: an icon and title, a line, and labelled values; it opens on hover and on keyboard focus. */
export function Tooltip({ title, icon, text, rows, children, open }: { title: ReactNode; icon?: SystemIconName; text?: ReactNode; rows?: readonly TooltipRow[]; children: ReactNode; open?: boolean }) {
const id = useId()
return <span className="fx-tip" aria-describedby={id}>
{children}
<span className={cx('fx-tooltip', open && 'is-open')} role="tooltip" id={id}>
<span className="fx-tooltip-head">{icon && <SystemIcon name={icon} size={26}/>}{title}</span>
{text && <p>{text}</p>}
{rows && rows.length > 0 && <dl>{rows.map((row, index) => <div key={index}><dt>{row.label}</dt><dd>{row.value}</dd></div>)}</dl>}
</span>
</span>
}
/** A notice that slides in at the edge: an icon in a coloured bubble, a title, a line and a close. */
export function Toast({ title, children, icon, tone, onClose, closeLabel = 'Close' }: { title: ReactNode; children?: ReactNode; icon?: SystemIconName; tone?: string; onClose?: () => void; closeLabel?: string }) {
return <div className="fx-toast" role="status" style={tone ? { '--tone': tone } as CSSProperties : undefined}>
{icon && <span className="fx-toast-art"><SystemIcon name={icon} size={32}/></span>}
<span className="fx-toast-text"><b>{title}</b>{children && <span>{children}</span>}</span>
{onClose && <RoundButton label={closeLabel} size="sm" onClick={onClose}><svg viewBox="0 0 16 16" aria-hidden="true"><path d="m4.5 4.5 7 7m0-7-7 7" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round"/></svg></RoundButton>}
</div>
}
/** A number a keeper reads at a glance: an icon, the value in gold with its unit, and what it counts. */
export function Stat({ icon, value, unit, label }: { icon?: SystemIconName; value: ReactNode; unit?: string; label: ReactNode }) {
return <div className="fx-stat">
{icon && <SystemIcon name={icon} size={38}/>}
<span><b>{value}{unit && <small>{unit}</small>}</b><span>{label}</span></span>
</div>
}
/** A desktop tile: a plump glass square in its own hue holding an icon, a title under it, a badge and an open mark. */
export function DockTile({ icon, title, hue, badge, open, onClick }: { icon: SystemIconName; title: string; hue: number; badge?: number; open?: boolean; onClick?: () => void }) {
return <button type="button" className={cx('fx-tile', open && 'is-open')} onClick={onClick} style={{ '--hue': hue } as CSSProperties}>
<span className="fx-tile-glass"><SystemIcon name={icon} size={72}/>{badge !== undefined && badge > 0 && <Badge count={badge}/>}</span>
<span className="fx-tile-title">{title}</span>
</button>
}
/** A dock: a gold-rimmed glass shelf of icons; the app in front wears a gold bar, open ones a dot. */
export function Dock({ children, label }: { children: ReactNode; label: string }) {
return <nav className="fx-dock" aria-label={label}>{children}</nav>
}
/** One icon on a dock. */
export function DockItem({ icon, label, front, open, badge, onClick }: { icon: SystemIconName; label: string; front?: boolean; open?: boolean; badge?: number; onClick?: () => void }) {
return <button type="button" className={cx('fx-dock-item', open && 'is-open', front && 'is-front')} aria-label={label} title={label} onClick={onClick}>
<SystemIcon name={icon} size="lg"/>{badge !== undefined && badge > 0 && <Badge count={badge}/>}<i aria-hidden="true"/>
</button>
}
export { Spinner, Progress } from './loader'
export { default as Select } from './Select'
export { default as Image } from './FishiesImg'

54
src/loader.css Normal file
View file

@ -0,0 +1,54 @@
/* The Fishies loader: spinner, progress bar, and pictures that never paint half-loaded.
Unlayered on purpose, so a surface's own layered image rules cannot put a waiting picture's
pixels back on screen. See fx-image.ts and FishiesLoader.tsx. */
.fx-spinner {
display: inline-grid; place-items: center; flex: none;
width: var(--fx-size, 32px); height: var(--fx-size, 32px);
filter: drop-shadow(0 4px 10px rgb(1 8 20 / 45%));
}
.fx-spinner > svg { display: block; width: 100%; height: 100%; }
.fx-progress {
position: relative; display: block; overflow: hidden;
width: min(280px, 100%); height: 10px; border-radius: 999px;
border: 1px solid rgb(196 236 250 / 20%);
background: linear-gradient(180deg, rgb(4 16 26 / 72%), rgb(12 38 56 / 72%));
box-shadow: inset 0 1px 3px rgb(0 0 0 / 50%), 0 1px 0 rgb(255 255 255 / 7%);
}
.fx-progress > i {
position: absolute; top: 1px; bottom: 1px; left: 1px;
width: max(8px, calc((100% - 2px) * var(--fx-value, 0)));
border-radius: inherit;
background: linear-gradient(180deg, var(--fx-gold-face), var(--fx-gold) 55%, var(--fx-gold-deep));
box-shadow: 0 0 8px var(--fx-gold-rim);
transition: width 320ms cubic-bezier(.2, .8, .2, 1);
}
/* The bubble riding the gold's leading edge. */
.fx-progress > i::after {
content: ''; position: absolute; top: 50%; right: 1px; width: 6px; height: 6px; margin-top: -3px;
border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, rgb(255 255 255 / 35%) 70%);
}
.fx-progress[data-indeterminate] > i { width: 34%; animation: fx-sweep 1.4s cubic-bezier(.45, 0, .55, 1) infinite; }
@keyframes fx-sweep { from { transform: translateX(-105%); } to { transform: translateX(300%); } }
/* A waiting picture keeps its box, draws its pixels outside it (clipped, so never seen, however
the file arrives), and shows the spinner on glass in their place. */
:is(img, video)[data-fx='wait'], img[data-fx='error'] { object-position: -99999px -99999px !important; }
:is(img, video)[data-fx='wait'] {
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cstyle%3E.a%7Btransform-origin:24px 24px;animation:s 1.1s linear infinite%7D.b%7Bopacity:0;animation:u 1.8s ease-in infinite%7D.c%7Banimation-delay:.6s%7D.d%7Banimation-delay:1.2s%7D@keyframes s%7Bto%7Btransform:rotate(360deg)%7D%7D@keyframes u%7B0%25%7Bopacity:0;transform:translateY(7px)%7D30%25%7Bopacity:.95%7D100%25%7Bopacity:0;transform:translateY(-9px)%7D%7D@media (prefers-reduced-motion:reduce)%7B.a%7Banimation-duration:3.6s%7D.b%7Banimation:none;opacity:.8%7D%7D%3C/style%3E%3Ccircle cx='24' cy='24' r='21' fill='%230b2a3c' fill-opacity='.74' stroke='%23c4ecfa' stroke-opacity='.24'/%3E%3Ccircle cx='24' cy='24' r='16' fill='none' stroke='%23c4ecfa' stroke-opacity='.13' stroke-width='3'/%3E%3Ccircle class='a' cx='24' cy='24' r='16' fill='none' stroke='%23ffc46b' stroke-width='3' stroke-linecap='round' stroke-dasharray='25 76'/%3E%3Cg fill='%23dff6ff' fill-opacity='.16' stroke='%23dff6ff' stroke-width='1.1'%3E%3Ccircle class='b' cx='21.5' cy='26' r='2.7'/%3E%3Ccircle class='b c' cx='27' cy='27.5' r='1.9'/%3E%3Ccircle class='b d' cx='23.5' cy='30' r='1.3'/%3E%3C/g%3E%3C/svg%3E") center / clamp(12px, 36%, 40px) no-repeat,
radial-gradient(closest-side, rgb(196 236 250 / 10%), rgb(196 236 250 / 4%)) !important;
}
img[data-fx='error'] { background: rgb(196 236 250 / 5%) !important; }
:is(img, video)[data-fx='fade'] { animation: fx-in 240ms cubic-bezier(.2, .8, .2, 1); }
@keyframes fx-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
.fx-progress > i { transition: none; }
.fx-progress[data-indeterminate] > i { animation-duration: 4s; }
:is(img, video)[data-fx='fade'] { animation: none; }
:is(img, video)[data-fx='wait'] {
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Ccircle cx='24' cy='24' r='21' fill='%230b2a3c' fill-opacity='.74' stroke='%23c4ecfa' stroke-opacity='.24'/%3E%3Ccircle cx='24' cy='24' r='16' fill='none' stroke='%23c4ecfa' stroke-opacity='.13' stroke-width='3'/%3E%3Ccircle class='a' cx='24' cy='24' r='16' fill='none' stroke='%23ffc46b' stroke-width='3' stroke-linecap='round' stroke-dasharray='25 76'/%3E%3Cg fill='%23dff6ff' fill-opacity='.16' stroke='%23dff6ff' stroke-width='1.1'%3E%3Ccircle class='b' cx='21.5' cy='26' r='2.7'/%3E%3Ccircle class='b c' cx='27' cy='27.5' r='1.9'/%3E%3Ccircle class='b d' cx='23.5' cy='30' r='1.3'/%3E%3C/g%3E%3C/svg%3E") center / clamp(12px, 36%, 40px) no-repeat,
radial-gradient(closest-side, rgb(196 236 250 / 10%), rgb(196 236 250 / 4%)) !important;
}
}

43
src/loader.tsx Normal file
View file

@ -0,0 +1,43 @@
'use client'
import type { CSSProperties } from 'react'
import './loader.css'
/** The Fishies spinner: a glass porthole in the HUD's navy, a gold arc going round its rim and
* three bubbles rising through it. Drawn in code (no picture to wait for), so it is on screen
* from the first paint. Under reduced motion the bubbles hold still and the arc turns slowly.
*
* loader.css carries this exact drawing as the placeholder of every waiting picture
* (`svgDataUri` below; loader.test.ts keeps the two in step). */
export const SPINNER_SVG = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48">' +
'<style>.a{transform-origin:24px 24px;animation:s 1.1s linear infinite}' +
'.b{opacity:0;animation:u 1.8s ease-in infinite}.c{animation-delay:.6s}.d{animation-delay:1.2s}' +
'@keyframes s{to{transform:rotate(360deg)}}' +
'@keyframes u{0%{opacity:0;transform:translateY(7px)}30%{opacity:.95}100%{opacity:0;transform:translateY(-9px)}}' +
'@media (prefers-reduced-motion:reduce){.a{animation-duration:3.6s}.b{animation:none;opacity:.8}}</style>' +
'<circle cx="24" cy="24" r="21" fill="#0b2a3c" fill-opacity=".74" stroke="#c4ecfa" stroke-opacity=".24"/>' +
'<circle cx="24" cy="24" r="16" fill="none" stroke="#c4ecfa" stroke-opacity=".13" stroke-width="3"/>' +
'<circle class="a" cx="24" cy="24" r="16" fill="none" stroke="#ffc46b" stroke-width="3" stroke-linecap="round" stroke-dasharray="25 76"/>' +
'<g fill="#dff6ff" fill-opacity=".16" stroke="#dff6ff" stroke-width="1.1">' +
'<circle class="b" cx="21.5" cy="26" r="2.7"/><circle class="b c" cx="27" cy="27.5" r="1.9"/><circle class="b d" cx="23.5" cy="30" r="1.3"/>' +
'</g></svg>'
/** The drawing above as a CSS `url()` value. */
export function svgDataUri(svg: string) {
return `url("data:image/svg+xml,${svg.replace(/"/g, "'").replace(/[<>#%{}]/g, c => encodeURIComponent(c))}")`
}
/** The Fishies spinner for anything on its way: a glass porthole with a gold arc going round and bubbles rising. */
export function Spinner({ size = 32, label = 'Loading', className, style }: { size?: number; label?: string; className?: string; style?: CSSProperties }) {
return <span className={`fx-spinner${className ? ` ${className}` : ''}`} role="status" aria-label={label}
style={{ '--fx-size': `${size}px`, ...style } as CSSProperties} dangerouslySetInnerHTML={{ __html: SPINNER_SVG.replace('<svg ', '<svg aria-hidden="true" focusable="false" ') }}/>
}
/** A progress bar: a glass channel filling with gold, a bubble riding its leading edge; with no value the gold sweeps. */
export function Progress({ value, label = 'Loading', className, style }: { value?: number; label?: string; className?: string; style?: CSSProperties }) {
const known = typeof value === 'number' && Number.isFinite(value)
const percent = known ? Math.round(Math.min(1, Math.max(0, value)) * 100) : undefined
return <span className={`fx-progress${className ? ` ${className}` : ''}`} role="progressbar" aria-label={label}
aria-valuemin={0} aria-valuemax={100} aria-valuenow={percent} data-indeterminate={known ? undefined : ''}
style={{ '--fx-value': known ? percent! / 100 : 0, ...style } as CSSProperties}><i/></span>
}

64
src/select-state.ts Normal file
View file

@ -0,0 +1,64 @@
/** Keyboard and selection logic for the shared <Select>, kept pure so it can be tested without a DOM. */
export type SelectOptionState = { value: string; label: string; disabled?: boolean }
export type SelectState = { open: boolean; active: number }
export type SelectKeyResult = SelectState & { choose?: string; close?: 'focus' | 'blur'; handled: boolean }
const enabled = (options: readonly SelectOptionState[]) => options.map((option, index) => option.disabled ? -1 : index).filter(index => index >= 0)
export function selectedIndex(options: readonly SelectOptionState[], value: string) {
const index = options.findIndex(option => option.value === value)
return index >= 0 && !options[index]!.disabled ? index : enabled(options)[0] ?? -1
}
/** The next enabled option from `from` in `step` direction; the list ends where it ends. */
export function moveActive(options: readonly SelectOptionState[], from: number, step: 1 | -1) {
for (let index = from + step; index >= 0 && index < options.length; index += step) if (!options[index]!.disabled) return index
return from
}
/** The next enabled option after `from` whose label starts with `key`, wrapping around. */
export function typeahead(options: readonly SelectOptionState[], from: number, key: string) {
const needle = key.toLocaleLowerCase()
for (let offset = 1; offset <= options.length; offset++) {
const index = (from + offset + options.length) % options.length
const option = options[index]!
if (!option.disabled && option.label.trim().toLocaleLowerCase().startsWith(needle)) return index
}
return -1
}
export function selectKey(state: SelectState, key: string, options: readonly SelectOptionState[], value: string): SelectKeyResult {
const list = enabled(options)
if (!state.open) {
if (key === 'Enter' || key === ' ' || key === 'ArrowDown' || key === 'ArrowUp') return { open: true, active: selectedIndex(options, value), handled: true }
return { ...state, handled: false }
}
switch (key) {
case 'ArrowDown': return { open: true, active: moveActive(options, state.active, 1), handled: true }
case 'ArrowUp': return { open: true, active: moveActive(options, state.active, -1), handled: true }
case 'Home': return { open: true, active: list[0] ?? -1, handled: true }
case 'End': return { open: true, active: list[list.length - 1] ?? -1, handled: true }
case 'Enter': case ' ': {
const option = options[state.active]
return { open: false, active: state.active, choose: option && !option.disabled ? option.value : undefined, close: 'focus', handled: true }
}
case 'Escape': return { open: false, active: state.active, close: 'focus', handled: true }
case 'Tab': return { open: false, active: state.active, close: 'blur', handled: false }
}
if (key.length === 1) {
const found = typeahead(options, state.active, key)
return { open: true, active: found >= 0 ? found : state.active, handled: true }
}
return { ...state, handled: false }
}
/** Where the popup goes: below the trigger unless there is more room above, always inside the viewport. */
export function placePopup(rect: { top: number; bottom: number; left: number; width: number }, viewport: { width: number; height: number }, wanted: number, gap = 6, margin = 8) {
const below = viewport.height - rect.bottom - gap - margin, above = rect.top - gap - margin
const up = below < Math.min(wanted, 180) && above > below
const maxHeight = Math.max(0, Math.min(wanted, up ? above : below))
const width = Math.min(Math.max(rect.width, 160), viewport.width - margin * 2)
const left = Math.min(Math.max(margin, rect.left), viewport.width - margin - width)
return { up, maxHeight, width, left, top: up ? undefined : rect.bottom + gap, bottom: up ? viewport.height - rect.top + gap : undefined }
}

92
src/select.css Normal file
View file

@ -0,0 +1,92 @@
/* The shared dropdown (app/ui/Select.tsx), in the language menu's family: a quiet pill that opens a
dark panel with a gold checkmark. Each surface only sets the --fs-select-* tokens below; the
component copies the resolved tokens onto the portalled popup, so it matches wherever it opens. */
:root {
--fs-select-ink: var(--fx-ground-ink);
--fs-select-muted: var(--fx-muted);
--fs-select-line: #b7d3d342;
--fs-select-bg: #09232b8c;
--fs-select-panel: #09232bf5;
--fs-select-hover: #163741;
--fs-select-accent: var(--fx-gold);
--fs-select-radius: 8px;
--fs-select-shadow: 0 15px 35px #020d1688;
--fs-select-font: 800 13px/1.2;
}
.aquarium-game {
--fs-select-ink: var(--fx-ink);
--fs-select-muted: var(--fx-ink-3);
--fs-select-line: rgb(140 200 255 / 24%);
--fs-select-bg: rgb(255 255 255 / 5%);
--fs-select-panel: rgb(8 26 66 / 96%);
--fs-select-hover: rgb(140 200 255 / 14%);
--fs-select-accent: var(--fx-gold);
--fs-select-radius: 12px;
--fs-select-shadow: 0 16px 36px rgb(2 12 26 / 70%);
}
.fishies-admin {
--fs-select-ink: var(--admin-ink, #edf5f5);
--fs-select-muted: var(--admin-muted, #a5bac2);
--fs-select-line: #385966;
--fs-select-bg: #061c28;
--fs-select-panel: #0b2531f7;
--fs-select-hover: #17394a;
--fs-select-accent: var(--admin-gold, #ffc46b);
--fs-select-radius: 9px;
}
.fishies-env {
--fs-select-ink: var(--env-ink, #edf5f5);
--fs-select-muted: var(--env-muted, #a5bac2);
--fs-select-line: var(--env-line, #385966);
--fs-select-bg: #102c38;
--fs-select-panel: #0c2530f7;
--fs-select-hover: #17394a;
--fs-select-accent: var(--env-accent, #ffc46b);
}
/* Doubled class: beats surface-wide `button` rules (admin, site) without !important. */
.fs-select.fs-select {
display: inline-flex; align-items: center; justify-content: flex-start; gap: 8px;
min-width: 0; max-width: 100%; min-height: 40px; margin: 0; padding: 8px 12px;
border: 1px solid var(--fs-select-line); border-radius: var(--fs-select-radius);
background: var(--fs-select-bg); color: var(--fs-select-ink);
font: var(--fs-select-font) var(--font-ui), system-ui, sans-serif; letter-spacing: 0; text-align: left; text-transform: none;
box-shadow: none; text-shadow: none; cursor: pointer; transition: border-color .15s, background .15s;
}
.fs-select.fs-select:hover:not(:disabled), .fs-select.fs-select.is-open { border-color: color-mix(in srgb, var(--fs-select-accent) 55%, transparent); }
.fs-select.fs-select:disabled { opacity: .55; cursor: not-allowed; }
.fs-select.fs-select:focus-visible { outline: 2px solid var(--fs-select-accent); outline-offset: 2px; }
.fs-select .fs-select-value { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-select i { flex: none; margin-left: auto; color: var(--fs-select-muted); font-size: 14px; font-style: normal; line-height: 1; transition: transform .15s; }
.fs-select.is-open i { transform: rotate(180deg); }
.fs-select-icon { display: inline-grid; place-items: center; flex: none; width: 20px; }
.fs-select.fs-select.fs-select-compact { min-height: 32px; padding: 5px 10px; gap: 6px; }
.fs-select-popover {
width: max-content;
position: fixed; z-index: 10000; box-sizing: border-box; margin: 0; padding: 5px; list-style: none;
overflow-y: auto; overscroll-behavior: contain;
border: 1px solid var(--fs-select-line); border-radius: var(--fs-select-radius);
background: var(--fs-select-panel); color: var(--fs-select-ink); box-shadow: var(--fs-select-shadow);
font: var(--fs-select-font) var(--font-ui), system-ui, sans-serif; color-scheme: dark;
animation: fs-select-in .12s ease-out;
}
.fs-select-popover.is-up { animation-name: fs-select-in-up; }
.fs-select-popover li {
display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px;
min-height: 36px; padding: 7px 9px; border-radius: max(4px, calc(var(--fs-select-radius) - 3px));
color: var(--fs-select-ink); cursor: pointer; user-select: none;
}
.fs-select-popover li > span:not(.fs-select-icon) { grid-column: 2; overflow-wrap: anywhere; }
.fs-select-popover li.is-active, .fs-select-popover li[aria-selected=true] { background: var(--fs-select-hover); }
.fs-select-popover li[aria-disabled=true] { opacity: .45; cursor: not-allowed; }
.fs-select-popover b { grid-column: 3; color: var(--fs-select-accent); }
.fs-select-popover.fs-select-compact li { min-height: 32px; padding: 5px 8px; }
@media (pointer: coarse) {
.fs-select-popover li, .fs-select-popover.fs-select-compact li { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .fs-select-popover { animation: none; } }
@keyframes fs-select-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes fs-select-in-up { from { opacity: 0; transform: translateY(4px); } }
.fs-select-popover li.is-active { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fs-select-accent) 40%, transparent); }

98
src/tokens.generated.css Normal file
View file

@ -0,0 +1,98 @@
/* GENERATED by tools/fishies-ui/build.ts from apps/web/app/ui/tokens.ts. Do not edit: change the source and run `bun tools/fishies-ui/build.ts`. */
:root {
/* Brand */
--fx-ground: #071a24;
--fx-ground-ink: #edf5ed;
--fx-gold: #ffc46b;
--fx-sea: #83cfbd;
--fx-muted: #adc3c7;
/* Water */
--fx-abyss: #04101b;
--fx-deep: #08202f;
--fx-deep-2: #0d2c3f;
--fx-deep-3: #14435c;
--fx-navy: #173d63;
/* Ink */
--fx-ink: #eef6ff;
--fx-ink-2: rgb(238 246 255 / 80%);
--fx-ink-3: rgb(238 246 255 / 62%);
--fx-ink-blue: #a9c9ea;
--fx-ink-on-gold: #12304a;
/* Gold */
--fx-gold-light: #ffe2a6;
--fx-gold-face: #ffe4a8;
--fx-gold-deep: #e59a3e;
--fx-gold-foot: #c88a3d;
--fx-gold-warm: #ff9a6b;
--fx-amber: #f4c656;
/* Tones */
--fx-tone-sky: #6cc8ff;
--fx-tone-coral: #ff8f87;
--fx-tone-kelp: #7fdc8f;
--fx-tone-violet: #b8a2ff;
--fx-tone-lagoon: #5cd8c6;
--fx-tone-mute: #8fa7b5;
--fx-good: #6fe3b0;
--fx-alarm: #ff8478;
--fx-pearl: #fff4d6;
--fx-cream: #f3dfb2;
--fx-plum: #36203f;
/* Glass */
--fx-glass-top: rgb(22 58 120 / 70%);
--fx-glass-bottom: rgb(8 26 66 / 88%);
--fx-glass-quiet-top: rgb(22 58 120 / 62%);
--fx-glass-quiet-bottom: rgb(8 26 66 / 82%);
--fx-glass-sheen: rgb(255 255 255 / 16%);
--fx-glass: linear-gradient(180deg, var(--fx-glass-sheen), transparent 46%), linear-gradient(180deg, var(--fx-glass-top), var(--fx-glass-bottom));
--fx-glass-quiet: linear-gradient(180deg, var(--fx-glass-sheen), transparent 46%), linear-gradient(180deg, var(--fx-glass-quiet-top), var(--fx-glass-quiet-bottom));
--fx-glass-well: rgb(4 16 30 / 55%);
--fx-glass-blur: blur(14px) saturate(1.2);
/* Rims */
--fx-rim: rgb(140 200 255 / 34%);
--fx-rim-bright: rgb(140 200 255 / 55%);
--fx-gold-rim: rgb(255 196 107 / 58%);
--fx-gold-rim-quiet: rgb(255 196 107 / 26%);
--fx-rim-light: inset 0 1px rgb(255 240 210 / 30%);
--fx-ground-rim: #9ebfbe26;
/* Depth */
--fx-lift-1: 0 2px 10px rgb(2 10 18 / 34%);
--fx-lift-2: 0 10px 30px rgb(2 8 20 / 45%);
--fx-lift-3: 0 24px 60px rgb(2 8 20 / 60%);
--fx-foot: 0 4px 0 rgb(4 18 34 / 55%);
--fx-foot-deep: 0 6px 0 rgb(4 18 34 / 55%);
--fx-plump: inset 0 2px rgb(255 255 255 / 40%), inset 0 -6px 12px rgb(0 0 0 / 28%);
--fx-on-water: 0 1px 2px #020c1a, 0 4px 16px rgb(2 12 26 / 80%);
/* Type */
--fx-font-display: var(--font-display), "Baloo 2", ui-rounded, sans-serif;
--fx-font-ui: var(--font-ui), Nunito, ui-rounded, sans-serif;
--fx-t-xs: 12px;
--fx-t-sm: 13px;
--fx-t-md: 15px;
--fx-t-lg: 19px;
--fx-t-xl: 24px;
--fx-t-2xl: 31px;
--fx-t-3xl: 40px;
--fx-track-tight: -.015em;
--fx-track-label: .14em;
/* Radii */
--fx-r-sm: 10px;
--fx-r-md: 14px;
--fx-r-lg: 20px;
--fx-r-xl: 28px;
--fx-r-full: 999px;
/* Spacing */
--fx-s-1: 4px;
--fx-s-2: 8px;
--fx-s-3: 12px;
--fx-s-4: 16px;
--fx-s-5: 24px;
--fx-s-6: 32px;
--fx-s-7: 48px;
/* Layers */
--fx-z-raised: 10;
--fx-z-sticky: 100;
--fx-z-dock: 900;
--fx-z-modal: 1000;
--fx-z-toast: 1100;
--fx-z-tooltip: 1200;
}

211
src/tokens.ts Normal file
View file

@ -0,0 +1,211 @@
/** fishies-ui design tokens: the one source of every colour, size, surface and layer the game, the
* site, the Field Guide and the Keeper OS draw with (Atlas landing-site 3mk66d, m2olue).
*
* Data only. `bun tools/fishies-ui/build.ts` writes tokens.generated.css (`:root` custom
* properties) and the Handbook's Brand and UI sections from it; kit.test.ts fails when either is
* stale. A surface that still has its own names for these (`--hud-gold`, `--site-ink`, `--accent`)
* points them here; it never repeats a value.
*
* Motion is a slot, not a value: the names below are filled by the motion system
* (apps/web/app/motion/motion.css, Atlas interface 3ll72y), so a duration lives in one place. */
export type Token = {
/** The CSS custom property. */
readonly name: `--${string}`
/** The value written into tokens.generated.css. A slot has none: another file fills it. */
readonly value?: string
/** One line: what it is for. The Handbook prints this; nowhere else repeats it. A slot's line
* lives with its value, in the stylesheet that fills it. */
readonly use?: string
}
export type TokenGroup = {
readonly id: 'brand' | 'water' | 'ink' | 'gold' | 'tone' | 'glass' | 'rim' | 'depth' | 'type' | 'radius' | 'space' | 'layer' | 'motion'
readonly title: string
readonly use: string
/** How the showcase draws a sample of each token. */
readonly swatch: 'colour' | 'surface' | 'shadow' | 'text' | 'radius' | 'space' | 'layer' | 'motion' | 'font'
/** Filled by another stylesheet (named in `use`); tokens.generated.css leaves these out. */
readonly slot?: true
readonly tokens: readonly Token[]
}
export const TOKEN_GROUPS: readonly TokenGroup[] = [
{
id: 'brand', title: 'Brand', swatch: 'colour',
use: 'The five colours every store page, capsule, banner, the site and the Field Guide sit on.',
tokens: [
{ name: '--fx-ground', value: '#071a24', use: 'The night-water ground behind the site, the Field Guide and every brand picture.' },
{ name: '--fx-ground-ink', value: '#edf5ed', use: 'Words on the ground: headings and links on the site.' },
{ name: '--fx-gold', value: '#ffc46b', use: 'The one warm accent: the thing to press, the coin, the playhead, a focus ring.' },
{ name: '--fx-sea', value: '#83cfbd', use: 'Sea-green for links and quiet highlights on the ground.' },
{ name: '--fx-muted', value: '#adc3c7', use: 'Body copy on the ground, a step quieter than the headings.' },
],
},
{
id: 'water', title: 'Water', swatch: 'colour',
use: 'The deep blues under the glass; each one is the water a few metres further down.',
tokens: [
{ name: '--fx-abyss', value: '#04101b', use: 'The deepest water: behind full-screen moments and the video frame.' },
{ name: '--fx-deep', value: '#08202f', use: 'A sunken well inside a panel: inputs, tracks, empty slots.' },
{ name: '--fx-deep-2', value: '#0d2c3f', use: 'A raised well: a hovered row, a chosen tab’s ground.' },
{ name: '--fx-deep-3', value: '#14435c', use: 'The lightest deep: dividers that need to show on glass.' },
{ name: '--fx-navy', value: '#173d63', use: 'The body of a round toy button (window controls, the player’s buttons).' },
],
},
{
id: 'ink', title: 'Ink', swatch: 'colour',
use: 'Words on glass, in three weights; the quietest still reads at 6.7:1 on a panel.',
tokens: [
{ name: '--fx-ink', value: '#eef6ff', use: 'Everything a player reads on glass: titles, values, labels.' },
{ name: '--fx-ink-2', value: 'rgb(238 246 255 / 80%)', use: 'Sentences under a title.' },
{ name: '--fx-ink-3', value: 'rgb(238 246 255 / 62%)', use: 'Captions, units and hints; never anything a player must act on.' },
{ name: '--fx-ink-blue', value: '#a9c9ea', use: 'Labels that name a value beside it (Level, Coins, Fish).' },
{ name: '--fx-ink-on-gold', value: '#12304a', use: 'Words on a gold button or a gold chip.' },
],
},
{
id: 'gold', title: 'Gold', swatch: 'colour',
use: 'The toy gold of the HUD: a face, a rim and a darker foot that makes a button sit up.',
tokens: [
{ name: '--fx-gold-light', value: '#ffe2a6', use: 'Gold words on glass: window titles, the clock, numbers that matter.' },
{ name: '--fx-gold-face', value: '#ffe4a8', use: 'The lit top of a gold button.' },
{ name: '--fx-gold-deep', value: '#e59a3e', use: 'The far end of a gold fill: a progress bar, the played part of a video.' },
{ name: '--fx-gold-foot', value: '#c88a3d', use: 'The solid edge under a gold button, its toy thickness.' },
{ name: '--fx-gold-warm', value: '#ff9a6b', use: 'Gold leaning to coral, where a fill runs warm (sunrise, a streak).' },
{ name: '--fx-amber', value: '#f4c656', use: 'The landing’s amber: the wordmark’s gleam and the reel’s titles.' },
],
},
{
id: 'tone', title: 'Tones', swatch: 'colour',
use: 'Six hues that tell kinds apart (an app tile, a chip, a chart line) and two that mean good and bad.',
tokens: [
{ name: '--fx-tone-sky', value: '#6cc8ff', use: 'Sky blue: water, visits, anything about other keepers.' },
{ name: '--fx-tone-coral', value: '#ff8f87', use: 'Coral: reports, a count that wants you, the close button.' },
{ name: '--fx-tone-kelp', value: '#7fdc8f', use: 'Kelp green: live, online, growing.' },
{ name: '--fx-tone-violet', value: '#b8a2ff', use: 'Violet: rare things and night.' },
{ name: '--fx-tone-lagoon', value: '#5cd8c6', use: 'Lagoon: the landing’s shallow water.' },
{ name: '--fx-tone-mute', value: '#8fa7b5', use: 'Grey-blue: off, empty, not yet.' },
{ name: '--fx-good', value: '#6fe3b0', use: 'Done, fed, clean, saved.' },
{ name: '--fx-alarm', value: '#ff8478', use: 'Hungry, dirty, failed: what needs a hand now.' },
{ name: '--fx-pearl', value: '#fff4d6', use: 'Pearl: the warm white of a badge rim and the landing’s cream.' },
{ name: '--fx-cream', value: '#f3dfb2', use: 'Cream: the shaded side of a pearl knob, warm sand.' },
{ name: '--fx-plum', value: '#36203f', use: 'Plum: the landing’s deep warm shadow under cream.' },
],
},
{
id: 'glass', title: 'Glass', swatch: 'surface',
use: 'The one material everything floats on: tinted water glass with a sheen across its top.',
tokens: [
{ name: '--fx-glass-top', value: 'rgb(22 58 120 / 70%)', use: 'The upper tint of glass.' },
{ name: '--fx-glass-bottom', value: 'rgb(8 26 66 / 88%)', use: 'The lower tint of glass, darker so words sit on it.' },
{ name: '--fx-glass-quiet-top', value: 'rgb(22 58 120 / 62%)', use: 'Glass over the live tank, a little thinner so the fish show through.' },
{ name: '--fx-glass-quiet-bottom', value: 'rgb(8 26 66 / 82%)', use: 'The lower tint of quiet glass.' },
{ name: '--fx-glass-sheen', value: 'rgb(255 255 255 / 16%)', use: 'The light across the top half of a pane.' },
{ name: '--fx-glass', value: 'linear-gradient(180deg, var(--fx-glass-sheen), transparent 46%), linear-gradient(180deg, var(--fx-glass-top), var(--fx-glass-bottom))', use: 'A pane: windows, panels, menus, the dock.' },
{ name: '--fx-glass-quiet', value: 'linear-gradient(180deg, var(--fx-glass-sheen), transparent 46%), linear-gradient(180deg, var(--fx-glass-quiet-top), var(--fx-glass-quiet-bottom))', use: 'A pane over the tank: HUD capsules, the fish card.' },
{ name: '--fx-glass-well', value: 'rgb(4 16 30 / 55%)', use: 'The darker water inside a window, under its title bar.' },
{ name: '--fx-glass-blur', value: 'blur(14px) saturate(1.2)', use: 'What glass does to the reef behind it (backdrop-filter).' },
],
},
{
id: 'rim', title: 'Rims', swatch: 'surface',
use: 'A hairline of light round every pane; gold marks the panes that are yours to use.',
tokens: [
{ name: '--fx-rim', value: 'rgb(140 200 255 / 34%)', use: 'The blue hairline round glass.' },
{ name: '--fx-rim-bright', value: 'rgb(140 200 255 / 55%)', use: 'The hairline on hover.' },
{ name: '--fx-gold-rim', value: 'rgb(255 196 107 / 58%)', use: 'The gold hairline round windows, the dock, tiles and the chosen tab.' },
{ name: '--fx-gold-rim-quiet', value: 'rgb(255 196 107 / 26%)', use: 'Gold dividers: under a title bar, between dock groups.' },
{ name: '--fx-rim-light', value: 'inset 0 1px rgb(255 240 210 / 30%)', use: 'The lit inner top edge of a gold-rimmed pane.' },
{ name: '--fx-ground-rim', value: '#9ebfbe26', use: 'Hairlines on the ground: card edges and rules between sections of the site.' },
],
},
{
id: 'depth', title: 'Depth', swatch: 'shadow',
use: 'Soft lifts for panes over water, and the solid foot that makes a toy control look pressable.',
tokens: [
{ name: '--fx-lift-1', value: '0 2px 10px rgb(2 10 18 / 34%)', use: 'A chip or a small button just off the water.' },
{ name: '--fx-lift-2', value: '0 10px 30px rgb(2 8 20 / 45%)', use: 'A panel, the dock, a menu.' },
{ name: '--fx-lift-3', value: '0 24px 60px rgb(2 8 20 / 60%)', use: 'A window or a moment that takes the screen.' },
{ name: '--fx-foot', value: '0 4px 0 rgb(4 18 34 / 55%)', use: 'The toy foot under a glass button or tile; pressing sinks into it.' },
{ name: '--fx-foot-deep', value: '0 6px 0 rgb(4 18 34 / 55%)', use: 'The foot under a desktop tile, which stands taller.' },
{ name: '--fx-plump', value: 'inset 0 2px rgb(255 255 255 / 40%), inset 0 -6px 12px rgb(0 0 0 / 28%)', use: 'The lit top and shaded belly that make a tile round.' },
{ name: '--fx-on-water', value: '0 1px 2px #020c1a, 0 4px 16px rgb(2 12 26 / 80%)', use: 'The shadow under words that sit straight on the water.' },
],
},
{
id: 'type', title: 'Type', swatch: 'text',
use: 'Baloo 2 for the game’s voice (numbers, labels, buttons, titles), Nunito for sentences; nothing under 12px.',
tokens: [
{ name: '--fx-font-display', value: 'var(--font-display), "Baloo 2", ui-rounded, sans-serif', use: 'Titles, numbers, buttons, labels.' },
{ name: '--fx-font-ui', value: 'var(--font-ui), Nunito, ui-rounded, sans-serif', use: 'Sentences and anything read as text.' },
{ name: '--fx-t-xs', value: '12px', use: 'The floor: units, captions, a badge’s count.' },
{ name: '--fx-t-sm', value: '13px', use: 'Chips, list details, helper lines.' },
{ name: '--fx-t-md', value: '15px', use: 'Buttons, list titles, body copy in the game.' },
{ name: '--fx-t-lg', value: '19px', use: 'A panel’s title.' },
{ name: '--fx-t-xl', value: '24px', use: 'A stat’s value, a window’s hero number.' },
{ name: '--fx-t-2xl', value: '31px', use: 'A page heading.' },
{ name: '--fx-t-3xl', value: '40px', use: 'A moment’s headline (level up, a new fish).' },
{ name: '--fx-track-tight', value: '-.015em', use: 'Display type at size.' },
{ name: '--fx-track-label', value: '.14em', use: 'Upper-case eyebrows above a group.' },
],
},
{
id: 'radius', title: 'Radii', swatch: 'radius',
use: 'Round, never sharp: the smaller the thing, the rounder it reads.',
tokens: [
{ name: '--fx-r-sm', value: '10px', use: 'Rows, inputs, keys.' },
{ name: '--fx-r-md', value: '14px', use: 'Cards, menus, tooltips.' },
{ name: '--fx-r-lg', value: '20px', use: 'Panels and windows.' },
{ name: '--fx-r-xl', value: '28px', use: 'Desktop tiles and the dock.' },
{ name: '--fx-r-full', value: '999px', use: 'Buttons, chips, tabs, badges, tracks.' },
],
},
{
id: 'space', title: 'Spacing', swatch: 'space',
use: 'A 4px grid: every gap, padding and margin is one of these.',
tokens: [
{ name: '--fx-s-1', value: '4px', use: 'Inside a chip, between a value and its unit.' },
{ name: '--fx-s-2', value: '8px', use: 'Between an icon and its label, between chips.' },
{ name: '--fx-s-3', value: '12px', use: 'Inside a button, between rows.' },
{ name: '--fx-s-4', value: '16px', use: 'A card’s inset.' },
{ name: '--fx-s-5', value: '24px', use: 'A panel’s inset, between groups.' },
{ name: '--fx-s-6', value: '32px', use: 'Between sections of a page.' },
{ name: '--fx-s-7', value: '48px', use: 'Around a page’s hero.' },
],
},
{
id: 'layer', title: 'Layers', swatch: 'layer',
use: 'Named heights, so a toast never slides under a window and a tooltip never under a toast.',
tokens: [
{ name: '--fx-z-raised', value: '10', use: 'A card lifted above its siblings (a dragged tile).' },
{ name: '--fx-z-sticky', value: '100', use: 'Headers and rails that stay as the page scrolls.' },
{ name: '--fx-z-dock', value: '900', use: 'The menu bar and the dock.' },
{ name: '--fx-z-modal', value: '1000', use: 'A window or sheet that holds the screen, with its backdrop.' },
{ name: '--fx-z-toast', value: '1100', use: 'Toasts, above any window.' },
{ name: '--fx-z-tooltip', value: '1200', use: 'Tooltips and open menus, above everything.' },
],
},
{
id: 'motion', title: 'Motion', swatch: 'motion', slot: true,
use: 'Named slots the motion system fills (apps/web/app/motion/motion.css, where each one is described): arrivals overshoot a little and settle, presses squash, exits get out of the way.',
tokens: ['--m-quick', '--m-base', '--m-move', '--m-show', '--m-ease-out', '--m-ease-spring', '--m-ease-calm', '--m-ease-in', '--m-stagger'].map(name => ({ name: name as `--${string}` })),
},
]
/** Every token by name. */
export const TOKENS: ReadonlyMap<string, Token> = new Map(TOKEN_GROUPS.flatMap(group => group.tokens.map(token => [token.name, token] as const)))
/** A token's `var()`, checked: a typo is a type error rather than a silently missing colour. */
export const fx = (name: Token['name']) => `var(${name})`
/** The stylesheet tokens.generated.css holds (motion slots are left to the motion system). */
export function tokensCss(): string {
const lines: string[] = []
for (const group of TOKEN_GROUPS) {
if (group.slot) continue
lines.push(` /* ${group.title} */`)
for (const token of group.tokens) lines.push(` ${token.name}: ${token.value};`)
}
return `:root {\n${lines.join('\n')}\n}\n`
}