Demo content from demo/developer-guide (1e24351)

This commit is contained in:
f451-admin 2026-10-06 09:07:17 +02:00
parent 893d29d13e
commit bcd02cdfb5
4 changed files with 54 additions and 7 deletions

View file

@ -83,7 +83,9 @@ files are public, because the layout needs them before sign-in.
| `GET` / `PUT` / `DELETE /api/theme` | Instance theme with origin per token | | `GET` / `PUT` / `DELETE /api/theme` | Instance theme with origin per token |
| `GET` / `PUT` / `DELETE /api/spaces/:space/theme` | Space theme | | `GET` / `PUT` / `DELETE /api/spaces/:space/theme` | Space theme |
| `GET` / `PUT` / `DELETE /api/me/theme` | Personal theme. Session only — API tokens get `403`. `?format=yaml` exports; `PUT` with `Content-Type: application/yaml` imports. Without a stored theme `GET` answers `200` with an empty one. | | `GET` / `PUT` / `DELETE /api/me/theme` | Personal theme. Session only — API tokens get `403`. `?format=yaml` exports; `PUT` with `Content-Type: application/yaml` imports. Without a stored theme `GET` answers `200` with an empty one. |
| `GET /api/theme/resolved?space=` | The finished chain (default, instance, space, user) plus `brand`. Without a session the user level is missing, without `space` the space level. | | `GET /api/theme/resolved?space=` | The finished chain (default, instance, space, user). Fields: `css`, `origin` (per token), `brand`, `layers`, `attributes` (the switches that deviate from Editorial), `switches` (the full set) and `stylesheets` (URLs of the theme stylesheets, in order). Without a session the user level is missing, without `space` the space level. |
| `GET` / `PUT` / `DELETE /api/theme/stylesheet`, `/api/spaces/:space/theme/stylesheet` | Theme stylesheet (`_meta/theme.css`). `GET` is public (`text/css`, ETag); `PUT` (body: CSS) and `DELETE` commit with the caller's account; a rule violation answers `422` with `errors[]` (code, line) |
| `GET /api/theme/fonts/:name`, `/api/spaces/:space/theme/fonts/:name` | A WOFF2 font from `_meta/fonts/`; added through Git only |
| `GET /api/theme/scopes` | The scopes the caller may view or write | | `GET /api/theme/scopes` | The scopes the caller may view or write |
| `GET /api/theme/editor?scope=` | What the settings page needs for one scope | | `GET /api/theme/editor?scope=` | What the settings page needs for one scope |
| `GET` / `PUT` / `DELETE /api/theme/contrast` | Contrast thresholds, instance only | | `GET` / `PUT` / `DELETE /api/theme/contrast` | Contrast thresholds, instance only |

View file

@ -82,14 +82,17 @@ future routes.
Instance and space themes are files, not rows: `_meta/theme.yaml`, Instance and space themes are files, not rows: `_meta/theme.yaml`,
`_meta/themes/<slug>.yaml`, `_meta/brand/` in the space repository, and in `_meta/themes/<slug>.yaml`, `_meta/brand/` in the space repository, and in
the instance repository named by `F451_INSTANCE_CONFIG` also the instance repository named by `F451_INSTANCE_CONFIG` also
`_meta/contrast.yaml`. The api reads them with a five-minute cache that `_meta/contrast.yaml`. Either repository may also hold `_meta/theme.css` (the
writes and webhook pushes empty. theme stylesheet) and `_meta/fonts/` (its WOFF2 fonts). The api reads them
with a five-minute cache that writes and webhook pushes empty.
One resolver in `packages/design-tokens` turns a list of levels (default, One resolver in `packages/design-tokens` turns a list of levels (default,
instance, space, user) into the full token set, with an origin per token, the instance, space, user) into the full token set, with an origin per token, the
derived colours and the contrast check. The shipped default and the layout's derived colours and the contrast check. The shipped default and the layout's
inline `<style>` go through the same code, so there is no second way for inline `<style>` go through the same code, so theme values have one way to
values to become CSS; see [[web-frontend]]. become CSS; see [[web-frontend]]. The theme stylesheet is the deliberate
second way: free CSS, checked only for forbidden constructs and without any
design checks.
The single exception to "nothing lives only in the database" is The single exception to "nothing lives only in the database" is
`user_settings`: the personal theme, one row per user. A user has no `user_settings`: the personal theme, one row per user. A user has no

View file

@ -49,8 +49,19 @@ A switch is a catalog token with `range: { kind: 'choice', values: […] }` and
A switch creates **no CSS variable**. `toAttributes(resolved)` returns a A switch creates **no CSS variable**. `toAttributes(resolved)` returns a
`data-<name>` attribute for every switch whose value differs from Editorial `data-<name>` attribute for every switch whose value differs from Editorial
(the first value of `values`); `GET /api/theme/resolved` delivers them as (the first value of `values`); `GET /api/theme/resolved` delivers them as
`attributes`, the root layout writes them on `<html>`. The settings page's `attributes` (only the deviations) and as `switches` (the full set, which the
preview carrier does the same on the preview element. Server Components read for the frame); the root layout writes `attributes` on
`<html>`. The settings page's preview carrier does the same on the preview
element.
**Migration.** Files from before 1.2.5 are read in the new form:
`heading-number: counter(sec) '.'` becomes `numeral`, and `heading-number-sub`
becomes `heading-depth`, each with the warning `value_migrated`; the next save
writes the new form.
**Locked.** `layout-note-w` and `layout-note-gap` are locked until margin
notes exist ([#63](https://github.com/rotecodefraktion/f451/issues/63)); a
file that sets them is rejected on save and ignored on read.
The stylesheets branch on the attribute and follow one pattern: one rule per The stylesheets branch on the attribute and follow one pattern: one rule per
value sets **private `--_…` custom properties** on the carrier; the block value sets **private `--_…` custom properties** on the carrier; the block
@ -122,6 +133,25 @@ Built-in templates are generated, not written by hand.
Built-ins cannot be overwritten or deleted through the api; their slugs are Built-ins cannot be overwritten or deleted through the api; their slugs are
reserved. reserved.
## Adopting and saving templates in the settings page
The pure functions live in `apps/web/lib/theme-editor.ts`, so they are testable
without the page:
- `adoptTemplate(draft, template)` replaces the draft's `base`, `light` and
`dark` values with the template's. `use` stays, so the template remains
selected; it works for built-in and own templates alike.
- `embedTemplate(draft, template)` merges the template under the draft's own
values and drops `use` — a template saved from "Fokus plus two colours" really
contains Fokus.
- `templateFile(draft, name, template)` builds the file for **Save as
template …**: `embedTemplate` if a template is chosen, then `name`, with no
`use` and no `brand`.
- `templateState(data, draft, templates)` says what applies, for the select and
the line below it: the draft's own template, "Own settings (no template)",
and "Underneath" — template "X" (instance), own settings (instance), or the
Editorial default, taken from `data.belowLayers`.
## Theme stylesheet ## Theme stylesheet
A scope (instance or space) may have `_meta/theme.css` and A scope (instance or space) may have `_meta/theme.css` and

View file

@ -50,6 +50,18 @@ from `packages/design-tokens`. See [[markdown-and-editor]] for the
package's counterpart on the content side, and [[extending]] for the steps package's counterpart on the content side, and [[extending]] for the steps
to add a token. to add a token.
### Switches, frame and theme stylesheets
Building-block and frame switches reach the page as `data-<name>` attributes
on `<html>` (only values that differ from Editorial); the stylesheets branch on
them. The frame switches change markup: `frameShape(switches, { hasTree })` in
`apps/web/lib/frame-shape.ts` decides from the resolved `switches` whether the
layout renders the top bar, the title row (leading `#` heading or frontmatter
title), the status bar and the page tree's filter and search field. Pages
without a tree always get the top bar. The root layout also links the theme
stylesheets (`stylesheets` from the resolved theme) after
`F451_CUSTOM_STYLESHEET`. Details in [[theme-templates]].
> [!NOTE] > [!NOTE]
> `packages/design-tokens/src/catalog.ts` separates *values* (`tokens.ts`) > `packages/design-tokens/src/catalog.ts` separates *values* (`tokens.ts`)
> from *description* (`catalog.ts`: which settings-page group a token > from *description* (`catalog.ts`: which settings-page group a token