writing / post19 nov 2026

One :root, three platforms

I wrote that one block of CSS keeps this site and my apps from drifting apart, and it turned out that no app reads the files that block writes.

this post

published
2026-11-19
reading
06 min
parts
7
the exhibit: ~ / system

A sentence that was too strong

On 2 November 2026 this site got a script, pnpm tokens. It writes the colours, some sizes and the motion times of the site into two files: one for iPhone apps and one for Android.

One day later I wrote, in Personal software, again, that with this script "the app and the site cannot drift apart without a failing check".

That sentence was too strong. No app reads the two files yet. That annoyed me.

I'd rather say so here than leave it standing, so this is the correction, with the design it's about.

One block

Three kinds of program share one design system: this site, the two iPhone apps resync and Durandal, and terminal home on a TV with Android. The system is the set of colours, sizes and parts that all of them are drawn with.

A token is a named value of that system, such as the red or the size of a touch target. On the site the tokens sit in the stylesheet, in one block named :root.

Before the script, each app had its values by hand. The commit that added the script says what the files are for: they come from :root, "so the apps stop keeping hand copies". That was the whole want: no hand copies, anywhere.

From one block to two filesdiagram

Swift for the iPhone, an XML file of colours for Android.

One token, three forms

Each token changes shape on its way out.

One token in three forms
In the CSSIn SwiftFor Android
--signal: #ff3b30Color(.sRGB, red: 255 / 255, …)#FFFF3B30
--tap: 2.75rem4444dp
--motion-step: 40ms0.0440

Swift wants the three colour channels as amounts, so ff becomes 255 / 255. Android wants one number with FF in front, which means fully opaque.

A size in CSS is in rem, and a rem is 16 pixels on this site. The iPhone has points and Android has dp, the units those systems scale to the screen, so 2.75 rem becomes 44. A time becomes seconds for Swift and stays in milliseconds for Android.

What the script takes:

  • The colours, with aliases resolved: a token that points at another token gets that token's value.
  • Six sizes, from a fixed list: the touch target, the gutter at the edge of a screen, two numbers for the focus ring (the outline on the control that a TV remote is on), and two for the safe area of a TV, the margin that everything to read stays inside.
  • The motion times, such as the 40 ms of one step.

It leaves out the colours of the charts, of the sidebar and of code. Both files carry a header that says where they come from: generated from the stylesheet, do not edit, change the token there.

A check that guards the files

The same script has a second mode, pnpm tokens:check. It builds both files in memory and compares them with the files on disk. When one differs, it prints Stale: with the name of the file and ends with an error.

The check is in the list of checks that a change must pass before it is done, and in the workflow that should run on each pull request. Change a colour in :root, forget pnpm tokens, and it fails. The workflow itself doesn't run right now; the last section has that.

The script also fails early on a missing value. One of its tests removes --tap from a sample stylesheet and expects the error no --tap.

So the check proves one thing: the generated files can't drift from the stylesheet. Hold that thought.

What the three apps do today

The check compares the stylesheet with the two generated files. Both live in the repository of the site. It never looks at an app, and none of the three apps reads a generated file. This is where each one keeps its colours, on its main branch:

Where each app has its colours
AppWhere its colours are
resyncits own Tokens.swift, from the app's first commit on 1 November
Durandala copy of resync's design folder, with additions of its own
terminal hometen hex values in one file of its code

resync's file is one day older than the script. It has the same name as the generated file and other content: 12 colours as hex numbers, where the generated file has 26 colours as amounts of red, green and blue.

Durandal's README says where its design folder comes from: it's resync's copy, and "when a part changes there, copy it over". Its own additions are four greys for charts and a list of motion times that is kept by hand. A comment on that list says its first five match the motion tokens of the site.

The TV app has no line that names a generated token.

So the three apps still have hand copies, and one of them is a hand copy of another hand copy. The generated files match the stylesheet. Nobody reads them.

One value shows the gap. On 2 November the system got a new grey for a pressed control, #7d7c78, named --held. The generated files have it. The two Swift copies have no token of that name, and terminal home still has the grey that it replaced.

The shapes go by hand

The script moves values out to the apps. Shapes go the other way, by hand.

The /system page of this site shows controls of the three apps again, drawn in the browser at the size of the device: a tab bar, a shutter, a tile of the TV. The system calls them Native parts. The instructions for the code of this site have a rule for them: a native part is a specimen of the app's own code, and when you change one, you say which app file it mirrors.

Of the 64 component files of Native parts, 58 name the app file in a comment. The Tile, for example, mirrors terminal home's TermTile.java. No check reads those comments.

Not settled yet

  • The workflow doesn't run now. Since 17 November the workflow of the site's repository hasn't started, because of a billing setting of the account. The check passes when it is run by hand, which makes it a guard who only works when somebody walks him to the post.
  • The last step is by hand, and it hasn't happened. To use the files, an app has to take the generated file in place of its own. No commit in the three apps does that.
  • The old sentence is still online. Personal software, again still says that the app and the site cannot drift apart without a failing check.

How the apps get there, and when, I don't know yet. It's too early to say.

For now the two generated files sit in the repository, exact and up to date, like a key cut for a lock that nobody has fitted yet.