~ knotless Search/
↑↓ move↵ open⇧↵ all results

zat.dev/zds

atproto pds · mirror of https://tangled.org/zat.dev/zds

0
0
105 lines · 5.5 KB Raw History
# skins

A skin restyles the homepage, the OAuth cards (sign-in, account picker,
consent, details and handoff), the account pages, `/signup` and `/stats`
without touching anything else. The operator
picks one with `ZDS_WEB_SKIN` (`--web-skin`); `glass`, the default, adds
nothing to the existing appearance.

Each skin is a folder of CSS:

- `base.css`: tokens and the page ground, shared by both pages.
- `home.css`: the homepage, layered after `src/http/landing/assets.zig`.
- `authorize.css`: the OAuth cards, layered after `../authorize.css`.
- `signup.css`: `/signup`, layered after `../../signup.zig`'s own style.
- `stats.css`: `/stats`, layered after `home.css` (the page shares the
  homepage stylesheet).
- `account.css`: the account pages, layered after `../account.html`'s own
  style; ground ink outside the `.card` sheets, paper ink inside.
- optionally one `.js`, put last in the body of both pages.

`../skin.zig` embeds every skin at build time, puts the selected one in a
`<style>` element after the page's own stylesheet, and adds every skin's CSS
to the pages' content security policy, so switching skins needs only a
restart.

## the contract

- CSS first. A skin restates tokens and surfaces with the class names the
  pages already use. It may add one script that decorates the page after
  load (see garden), but every page must read and work the same if that
  script never runs, and a skin must never hide or reorder what a page says: the OAuth cards show who is asking
  and what they get, and that stays exactly as `page.zig` renders it.
- Nothing remote. No `@import`, fonts or images from other origins. The one
  font is the operator's `ZDS_WEB_FONT`, which `../skin.zig` declares as
  `"zds sans"` and the server serves from its own origin; skin CSS names it
  through `--paper-sans` and never declares a face itself. The garden's five
  ground textures are served the same way by `../textures.zig` at
  `/web/texture?name=…`, cached for a year. The skin tests enforce no
  network calls, a 12 KB uncompressed CSS budget per page and 96 KB for a
  script as shipped (its comment lines are stripped at build time).
- Fast everywhere. Prefer static layers to animation, and avoid
  `backdrop-filter` and large blurs, which cost every frame on phones.
  Respect `prefers-reduced-motion` and `forced-colors`.
- Both themes. The pages follow `prefers-color-scheme` and the saved
  `data-theme`; a skin covers `:root`, `html[data-theme]` and the dark
  variants. Check a phone with the keyboard down and a desktop width in each.

To add a skin, add a folder here, a `Skin` variant and its `sheets` entry in
`../skin.zig`, and a line in the operations doc.

## paper

Cream paper sheets resting on a green ground, after the "garden" sign-in
mockup: thick card edges, buttons and fields that press down, a sans for
reading and monospace for handles, DIDs and NSIDs. The original painted its
card with a WebGL shader and shipped about 340 KB of textures; this keeps the
look with a few box-shadows and one 180px noise tile.

## garden

Paper, with the garden sign-in it came from brought to life under it:
Brooke's WebGL2 engine, ported to every skinned page by `garden/garden.js`.

The garden is opt-in at build time: only `zig build -Dweb-garden=true` embeds
its script and ground textures (about 250 KB). A build without it refuses
`ZDS_WEB_SKIN=garden` at startup instead of quietly falling back.

- **The scene.** A ray-traced height field: rolling terrain that flattens
  under the sign-in card, trees grown branch by branch that sway in the
  wind, bushes, rocks, flower clumps on stems, and ponds with a real ripple
  simulation and light-driven caustics. Five CC0 photo textures (grass,
  sand, dirt, bark) from OpenGameArt, served by `../textures.zig`.
- **Critters.** Crows wheel high over the pointer; click one and it drops,
  lies stunned, gets up, looks about and flies off. Butterflies settle on
  flowers, moths circle the pointer at night, fish scatter from splashes,
  the fox trots after a nearby pointer, hops up onto the card and its
  buttons, and leaves fading footprints. Pollen by day, fireflies by night.
- **The light** follows the pointer and drifts back to rest when it goes
  quiet; everything is lit and shadowed from it.
- **Riding.** The buttons at the bottom left ride along with a bird (a moth
  at night) or the fox, and switch day, night or the system theme (the same
  saved `zds.theme` choice as the homepage menu). Esc steps out.

Two kinds of page:

- **Sign-in and the other OAuth cards** (`main.card`): the scene paints the
  card itself, its fields, buttons, words and icons, as raised sheets with
  their own heights. A button lifts on hover and focus and presses on click.
  The DOM card stays exactly where it was, invisible, so typing, focus,
  autofill and screen readers work as before. Words are repainted only
  when something on the card changes.
- **Everything else** (home, stats, account, signup): the cards stay real
  paper on the page; the scene lifts and shadows them. While the page
  scrolls the scene's shadows settle and CSS casts them, so nothing trails
  the cards. Critters keep off the cards.

It stays out of the way:

- starts on `requestIdleCallback` after `load`; until its first frame the
  page is exactly paper, and a lost GL context gives the page back to paper.
- skipped without WebGL2, with Save-Data, or in forced colours.
- the scene is as tall as the screen gets (`100lvh`) and re-lays out only
  when the width changes, so a phone's address bar never moves a pond.
- lowers its resolution when frames run long; pointer events never reach
  the canvases.