Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ system font, and asks whose product it is and which you would work in all day. `

| Source | What it makes |
|---|---|
| `palette.toml` | `dist/`: `tokens.css` (every role as `--spin-*`), `starlight.css` (the website's `--sl-color-*`), `dashboard.css` (shadcn's HSL variables, light on `:root`, dark on `.dark`, and the dashboard's radius, scrim, dense type scale, a page's ranks of type, heading tracking, motion and a terminal's black surface and sixteen ANSI colours as `--terminal-*`), `t3code.css` (the agent client's own variables, the roots its theme derives the rest from, on `html:root` and `html.dark:root`, with the dashboard's corner and the faces), `tokens.json`, and `perception.js` and `simulate.svg` for the preview |
| `palette.toml` | `dist/`: `tokens.css` (every role as `--spin-*`), `starlight.css` (the website's `--sl-color-*`), `dashboard.css` (shadcn's HSL variables, light on `:root`, dark on `.dark`, and the dashboard's radius, scrim, dense type scale, a page's ranks of type, heading tracking, motion and a terminal's black surface and sixteen ANSI colours as `--terminal-*`), `t3code.css` (the agent client's own variables, the roots its theme derives the rest from, on `html:root` and `html.dark:root`, with the dashboard's corner and the faces), `tokens.json`, and for this repository's own pages `fonts.css` (the two faces' `@font-face` rules, the one place they are declared), `perception.js` and `simulate.svg` |
| spin's `dashboard/e2e/catalog.spec.ts` | `screens/`: every route, tab, dialog and menu of the app in both themes at 1440 and 390 px, and what each draws that this palette does not have - a colour, a face, a size, a radius, contrast, overflow, a target too small (`task screens SCREENS=<dir>`). The catalog and the audit are committed; the images, hundreds a release, are an archive on a release of this repository that `screens.json` names and Pages unpacks. [See them](https://spin-stack.github.io/brand/screens.html) |
| `assets/mark.png` | `logos/`: the stack of disks, cut from the mark as it was drawn (1024 px on a clear ground): the tile on the brand's navy (512, 256; the touch icon at 180, the favicon at 64 and 32) for a dark ground, and clear (512, 256) for any ground: the drawing has nothing under the stack, so `mark-dark-*` (512, 256), the name the dark page asks for, is the clear mark. Each is the drawing reduced; a size it would have to enlarge fails |

Expand Down Expand Up @@ -79,7 +79,9 @@ does not ship (`cmd/palette`'s tests).
- **No meaning by hue alone**: a status carries a shape too (the preview's states: a dot, a
diamond, a square), since a floor for colour-vision deficiencies is a floor, not comfort.

Type and layout are tokens too: Inter and JetBrains Mono (`fonts/`, OFL) at three weights that
Type and layout are tokens too: Geist and Geist Mono (`fonts/`, OFL; declared once for this
repository's pages in `dist/fonts.css`, and a page that declares a face of its own fails
`go test`) at three weights that
say rank (600 a page's title, its verdict, a figure and a section's heading, 500 a button, a label
and a row's name, 400 the rest; `--spin-weight-*`), a 16 px reading size (below it iOS zooms into a
focused input) and 13 px for the dashboard's tables, a dashboard page's six ranks and its figure,
Expand Down Expand Up @@ -153,6 +155,6 @@ always a `v<YYYYMMDD>.<NN>`.

## License

Apache License 2.0, as spin. The fonts are Inter and JetBrains Mono, each under the SIL Open Font
License (`fonts/LICENSE-Inter.txt`, `fonts/LICENSE-JetBrains-Mono.txt`); `versions.yaml` says
which release of each the files are.
Apache License 2.0, as spin. The fonts are Geist and Geist Mono, each under the SIL Open Font
License (`fonts/LICENSE-Geist.txt`, `fonts/LICENSE-Geist-Mono.txt`); `versions.yaml` says which
release of each the files are.
5 changes: 3 additions & 2 deletions cmd/palette/consumers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
"github.com/spin-stack/go-tools/consumers"
)

// laboratory is what dist/ holds for this repository's own pages, which no consumer copies.
var laboratory = []string{"dist/perception.js", "dist/simulate.svg"}
// laboratory is what dist/ holds for this repository's own pages, which no consumer copies: a
// consumer installs the faces from @fontsource, which declares them, and not from fonts.css.
var laboratory = []string{"dist/fonts.css", "dist/perception.js", "dist/simulate.svg"}

// TestTheTableIsOfThisRepository holds consumers.toml to the tree: a copy of a file this
// repository does not have is a row nobody can satisfy, and an output nobody copies is either a
Expand Down
109 changes: 67 additions & 42 deletions cmd/palette/fonts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"slices"
"strings"
"testing"

"github.com/BurntSushi/toml"
)

const root = "../.."
Expand All @@ -19,10 +17,9 @@ const root = "../.."
// subset at each weight the palette gives a rank, named as @fontsource names them, and the
// face's licence.
func shipped(p palette, face string) []string {
slug := strings.ReplaceAll(strings.ToLower(face), " ", "-")
files := []string{"LICENSE-" + strings.ReplaceAll(face, " ", "-") + ".txt"}
for _, w := range []int{p.Type.WeightRegular, p.Type.WeightMedium, p.Type.WeightStrong, p.Type.HeadingWeight} {
if f := fmt.Sprintf("%s-latin-%d-normal.woff2", slug, w); !slices.Contains(files, f) {
for _, w := range append(weights(p), p.Type.HeadingWeight) {
if f := faceFile(face, w); !slices.Contains(files, f) {
files = append(files, f)
}
}
Expand All @@ -33,18 +30,8 @@ func shipped(p palette, face string) []string {
// failing: the page loads, in another face. So every font stack dist/ writes leads with a face
// whose files are in fonts/, at every weight the palette ranks, and fonts/ holds no other face.
func TestEveryFaceAnOutputNamesIsShipped(t *testing.T) {
var p palette
if _, err := toml.DecodeFile(filepath.Join(root, "palette.toml"), &p); err != nil {
t.Fatal(err)
}
results, err := holds(p)
if err != nil {
t.Fatal(err)
}
files, err := outputs(p, results)
if err != nil {
t.Fatal(err)
}
p := readPalette(t)
files := written(t, p)

named := map[string][]string{}
stack := regexp.MustCompile(`--[a-z-]*font[a-z-]*:\s*([^;]+);`)
Expand Down Expand Up @@ -95,37 +82,75 @@ func TestEveryFaceAnOutputNamesIsShipped(t *testing.T) {
}
}

// The pages this repository publishes draw the palette's faces from fonts/: an @font-face whose
// family is not the palette's, or whose file is not there, leaves that page in a fallback.
func TestThePagesLoadThePalettesFaces(t *testing.T) {
var p palette
if _, err := toml.DecodeFile(filepath.Join(root, "palette.toml"), &p); err != nil {
t.Fatal(err)
// dist/fonts.css declares the palette's two faces at each weight fonts/ ships, each from its own
// file there: a rule whose file is missing, or a face at a weight it does not declare, leaves the
// pages that link it drawing that weight in a fallback.
func TestTheFacesSheetDeclaresEachShippedFile(t *testing.T) {
p := readPalette(t)
css := string(written(t, p)["fonts.css"])
rule := regexp.MustCompile(`@font-face \{ font-family: '([^']+)'; src: url\(\.\./fonts/([^)]+)\) format\('woff2'\); font-weight: (\d+);`)
declared := map[string]bool{}
for _, m := range rule.FindAllStringSubmatch(css, -1) {
family, file, weight := m[1], m[2], m[3]
declared[family+" "+weight] = true
if family != p.Type.Sans && family != p.Type.Mono {
t.Errorf("fonts.css declares %q, which is neither of the palette's faces", family)
}
if _, err := os.Stat(filepath.Join(root, "fonts", file)); err != nil {
t.Errorf("fonts.css gives %q at %s the file %s, which fonts/ has not", family, weight, file)
}
}
for _, face := range []string{p.Type.Sans, p.Type.Mono} {
for _, w := range weights(p) {
if !declared[fmt.Sprintf("%s %d", face, w)] {
t.Errorf("fonts.css does not declare %q at %d", face, w)
}
}
}
if n := strings.Count(css, "@font-face"); n != len(declared) {
t.Errorf("fonts.css has %d @font-face rules and %d the test reads: it no longer reads how they are written", n, len(declared))
}
rule := regexp.MustCompile(`@font-face \{ font-family: '([^']+)'; src: url\(([^)]+)\)[^}]*font-weight: (\d+); \}`)
for _, page := range []string{"index.html", "screens.html", "five-seconds.html", "recognition.html", "target.html"} {
raw, err := os.ReadFile(filepath.Join(root, page))
}

// The faces are declared once, in dist/fonts.css. Every page this repository publishes that draws
// in the palette - it links dist/tokens.css - links fonts.css too, and no page and no stylesheet
// of its own declares a face: a page that did would draw a face fonts.css does not, or the same
// face from another file, and change apart from the rest.
func TestEveryPageTakesTheFacesFromTheOneSheet(t *testing.T) {
var pages, sheets []string
for _, pattern := range []string{"*.html", "*/*.html", "*.css", "*/*.css"} {
found, err := filepath.Glob(filepath.Join(root, pattern))
if err != nil {
t.Fatal(err)
}
loaded := map[string]bool{}
for _, m := range rule.FindAllStringSubmatch(string(raw), -1) {
family, src, weight := m[1], m[2], m[3]
loaded[family] = true
if family != p.Type.Sans && family != p.Type.Mono {
t.Errorf("%s loads %q, which is neither of the palette's faces", page, family)
}
if _, err := os.Stat(filepath.Join(root, filepath.Dir(page), src)); err != nil {
t.Errorf("%s loads %s, which is not there", page, src)
}
if want := fmt.Sprintf("%s-latin-%s-normal.woff2", strings.ReplaceAll(strings.ToLower(family), " ", "-"), weight); filepath.Base(src) != want {
t.Errorf("%s gives %q at %s the file %s, not %s", page, family, weight, filepath.Base(src), want)
for _, f := range found {
rel, _ := filepath.Rel(root, f)
switch {
case strings.HasPrefix(rel, "dist/"):
case strings.HasSuffix(rel, ".html"):
pages = append(pages, rel)
default:
sheets = append(sheets, rel)
}
}
for _, face := range []string{p.Type.Sans, p.Type.Mono} {
if !loaded[face] {
t.Errorf("%s has no @font-face for %q", page, face)
}
}
if !slices.Contains(pages, "target.html") || !slices.Contains(sheets, "lab.css") {
t.Fatalf("pages %v and sheets %v: the test no longer finds what it holds", pages, sheets)
}
links := func(page, file string, raw []byte) bool {
href, _ := filepath.Rel(filepath.Dir(page), file)
return strings.Contains(string(raw), `<link rel="stylesheet" href="`+href+`">`)
}
for _, f := range append(pages, sheets...) {
raw, err := os.ReadFile(filepath.Join(root, f))
if err != nil {
t.Fatal(err)
}
if strings.Contains(string(raw), "@font-face") {
t.Errorf("%s declares a face of its own: link dist/fonts.css instead", f)
}
if strings.HasSuffix(f, ".html") && links(f, "dist/tokens.css", raw) && !links(f, "dist/fonts.css", raw) {
t.Errorf("%s draws in the palette and does not link dist/fonts.css", f)
}
}
}
27 changes: 27 additions & 0 deletions cmd/palette/outputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func outputs(p palette, results []result) (map[string][]byte, error) {
files["starlight.css"] = []byte(starlightCSS(p, dark, light))
files["dashboard.css"] = []byte(dashboardCSS(p, dark, light))
files["t3code.css"] = []byte(t3codeCSS(p, dark, light, term))
files["fonts.css"] = []byte(fontsCSS(p))
files["perception.js"] = []byte(perceptionJS(results))
files["simulate.svg"] = []byte(simulateSVG())
return files, nil
Expand Down Expand Up @@ -503,6 +504,32 @@ func t3codeCSS(p palette, dark, light, term map[string]rgb) string {
return b.String()
}

// faceFile is the file fonts/ holds for a face at a weight: the latin subset, named as @fontsource
// names it ("Geist Mono" at 500 is geist-mono-latin-500-normal.woff2).
func faceFile(face string, weight int) string {
return fmt.Sprintf("%s-latin-%d-normal.woff2", strings.ReplaceAll(strings.ToLower(face), " ", "-"), weight)
}

// weights is the weights fonts/ ships each face at: the three a weight says (type.weight_*).
func weights(p palette) []int {
return []int{p.Type.WeightRegular, p.Type.WeightMedium, p.Type.WeightStrong}
}

// fontsCSS is the palette's two faces at each weight they are shipped at, as @font-face rules for
// this repository's pages, which link it and declare no face of their own: the six pages that each
// wrote these rules by hand were six places a face could change in one and not the others. A
// consumer installs the same files from @fontsource, which declares them for it.
func fontsCSS(p palette) string {
var b strings.Builder
b.WriteString(header)
for _, face := range []string{p.Type.Sans, p.Type.Mono} {
for _, w := range weights(p) {
fmt.Fprintf(&b, "@font-face { font-family: '%s'; src: url(../fonts/%s) format('woff2'); font-weight: %d; font-style: normal; }\n", face, faceFile(face, w), w)
}
}
return b.String()
}

// appSizeVars is the app's sizes that are not a control's: a list's row and the navigation's
// width. A size a consumer has no variable for is one it writes itself, and then it drifts.
func appSizeVars(p palette) string {
Expand Down
14 changes: 5 additions & 9 deletions consumers.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# name what a consumer's versions.yaml calls this repository
# scopes the npm scopes whose packages are this repository's to pin: the faces. A scope is
# the whole name before a package's slash, so both are listed: a consumer that
# installs @fontsource-variable/inter, the Inter a fork comes with, is told it is no
# package brand pins only because that scope is here.
# installs a variable face, as a fork may come with, is told it is no package brand
# pins only because that scope is here.
#
# Of each consumer:
#
Expand Down Expand Up @@ -81,13 +81,9 @@ packages = "package.json"
# what it leaves). The copy sits beside the fork's theme, apps/web/src/index.css, and the fork's
# entry imports it.
#
# Its faces are the packages versions.yaml pins, as every consumer's are: the static
# @fontsource/inter and @fontsource/jetbrains-mono, in place of the @fontsource-variable/inter the
# fork comes with. The variable package's family is "Inter Variable", a name no output writes, so
# the copy beside it draws in the system's fallback; and the dashboard around the frame draws the
# static files, so the two would be one face from two files. What the variable face gives up is
# small: the conversation asks for 400, 500 and 600, which fonts/ ships, and for 700 in a
# message's bold, which the browser then draws at 600.
# Its faces are the packages versions.yaml pins, as every consumer's are: @fontsource/geist and
# @fontsource/geist-mono, the static files the dashboard around the frame draws too. A message's
# bold asks for 700, which fonts/ does not ship, and the browser draws at 600.
[[consumer]]
name = "agent client"
repo = "spin-stack/t3code"
Expand Down
8 changes: 4 additions & 4 deletions dist/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
--terminal-bright-cyan: #5FE3D6;
--terminal-bright-white: #FFFFFF;
--spin-wordmark: "Spinbox";
--spin-font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
--spin-font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
--spin-font-sans: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
--spin-font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
--spin-text-2xs: 11px;
--spin-text-2xs-lh: 16px;
--spin-text-xs: 12px;
Expand All @@ -174,7 +174,7 @@
--spin-rank-title-size: clamp(1.75rem, 1.421rem + 1.348vw, 2.5rem);
--spin-rank-title-lh: 1.15;
--spin-rank-title-weight: 600;
--spin-rank-title-tracking: -0.035em;
--spin-rank-title-tracking: -0.05em;
--spin-rank-title-case: none;
--spin-rank-verdict-font: var(--spin-font-sans);
--spin-rank-verdict-size: 20px;
Expand Down Expand Up @@ -204,7 +204,7 @@
--spin-rank-label-size: 11px;
--spin-rank-label-lh: 16px;
--spin-rank-label-weight: 500;
--spin-rank-label-tracking: 0.08em;
--spin-rank-label-tracking: 0.09em;
--spin-rank-label-case: uppercase;
--spin-rank-figure-font: var(--spin-font-mono);
--spin-rank-figure-size: 24px;
Expand Down
7 changes: 7 additions & 0 deletions dist/fonts.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/starlight.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
--sl-color-text-accent: #024F6A;
}
:root {
--sl-font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
--sl-font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
--sl-font: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
--sl-font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}
:root {
--sl-text-h1: clamp(1.75rem, 1.421rem + 1.348vw, 2.5rem);
Expand Down
4 changes: 2 additions & 2 deletions dist/t3code.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ html.dark:root {
html:root {
--radius: 6px;
--control-radius: 6px;
--font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
--font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
--font-sans: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
--font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
--diff-addition-foreground: var(--success-foreground);
--diff-deletion-foreground: var(--error-foreground);
--surface-grain: none;
Expand Down
10 changes: 5 additions & 5 deletions dist/tokens.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@
--spin-chart-warning: #B07C00;
--spin-chart-critical: #D04A9E;
--spin-wordmark: "Spinbox";
--spin-font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
--spin-font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
--spin-font-sans: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
--spin-font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
--spin-text-reading: 16px;
--spin-text-dense: 13px;
--spin-line-height: 1.6;
Expand All @@ -152,7 +152,7 @@
--spin-heading-tracking: -0.02em;
--spin-font-heading: var(--spin-font-sans);
--spin-font-display: var(--spin-font-mono);
--spin-display-tracking: -0.035em;
--spin-display-tracking: -0.05em;
--spin-numeric: tabular-nums;
--spin-text-display: clamp(2rem, 1.452rem + 2.247vw, 3.25rem);
--spin-text-h1: clamp(1.75rem, 1.421rem + 1.348vw, 2.5rem);
Expand All @@ -163,7 +163,7 @@
--spin-rank-title-size: clamp(1.75rem, 1.421rem + 1.348vw, 2.5rem);
--spin-rank-title-lh: 1.15;
--spin-rank-title-weight: 600;
--spin-rank-title-tracking: -0.035em;
--spin-rank-title-tracking: -0.05em;
--spin-rank-title-case: none;
--spin-rank-verdict-font: var(--spin-font-sans);
--spin-rank-verdict-size: 20px;
Expand Down Expand Up @@ -193,7 +193,7 @@
--spin-rank-label-size: 11px;
--spin-rank-label-lh: 16px;
--spin-rank-label-weight: 500;
--spin-rank-label-tracking: 0.08em;
--spin-rank-label-tracking: 0.09em;
--spin-rank-label-case: uppercase;
--spin-rank-figure-font: var(--spin-font-mono);
--spin-rank-figure-size: 24px;
Expand Down
10 changes: 5 additions & 5 deletions dist/tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@
]
},
"type": {
"Sans": "Inter",
"Mono": "JetBrains Mono",
"Sans": "Geist",
"Mono": "Geist Mono",
"FallbackSans": "system-ui, -apple-system, 'Segoe UI', sans-serif",
"FallbackMono": "ui-monospace, 'SF Mono', Menlo, monospace",
"ReadingSize": 16,
Expand Down Expand Up @@ -203,7 +203,7 @@
"HeadingTracking": -0.02,
"Heading": "sans",
"Display": "mono",
"DisplayTracking": -0.035,
"DisplayTracking": -0.05,
"Fluid": {
"display": [
32,
Expand Down Expand Up @@ -243,7 +243,7 @@
"Face": "mono",
"Step": "2xs",
"Weight": 500,
"Tracking": 0.08,
"Tracking": 0.09,
"Upper": true
},
"name": {
Expand All @@ -263,7 +263,7 @@
"Fluid": "h1",
"Leading": 1.15,
"Weight": 600,
"Tracking": -0.035
"Tracking": -0.05
},
"verdict": {
"Face": "sans",
Expand Down
Loading