oficina / slides Public

Editor: one set of type sizes and radii

editor.css states no type size or corner radius as a number (spec §7).
It uses rastrillo's --rst-fs-xs|sm|base|lg and --rst-radius-sm|pill,
and estilo's --estilo-float-radius, where one is within 1px. Values
they lack are named once in one block at the top of the file, between
/* slides: named values */ and /* end named values */. The strip's
gutter and menu ground and the layout pictures' inks are in that block
too. TestQuieterCSSUsesTokens holds this: a font-size, font shorthand
or any border radius (logical longhands included) outside the block
that states a number with a unit (a percentage counts, a bare 0 does
not) fails, naming the line.

Choices where 12px or 13px sat between two tokens: labels, legends,
headings, key caps, hints, layout names and the assistant's privacy
line take --rst-fs-xs (11.5px). Running text (none-yet lines, menu
titles, the save line, the view bar, the assistant's note) takes
--rst-fs-sm (12.5px). Named, because they sit in a fixed box and
must not grow on touch: the strip's numbers (12px), the presence
faces' initials (10px, 9px). The notes stay 15px, named
(--slides-fs-notes), because the stylesheet sets them larger than a
form's text to be read aloud and --rst-fs-base would make them equal.

Visible differences, from before and after screenshots (at rest, a
heading selected, a canvas shape selected, ten slides in the strip,
notes open and closed, phone view, the shortcuts dialog, 400px wide;
light and dark):
- Inspector labels and legends are 0.5px smaller (12 to 11.5px); the
  card is about 2px shorter.
- The menu titles (File, Edit...), the save line and the view bar are
  0.5px smaller (13 to 12.5px).
- Key caps in the shortcuts dialog and the layout names are 0.5px
  smaller; the layouts popover is 8px shorter.
- Strip items' and the assistant's boxes have a 9px corner, was 10px.
- The assistant's title is 17px, was 16px (not photographed: it needs
  SLIDES_AI=on).
- Below 40rem or with a coarse pointer the tokens take rastrillo's
  touch step, so the chrome's text grows there: the deck title 17 to
  19px, Share 14 to 16px, menu titles 13 to 14px, labels and hints 12
  to 13px, the view segments 12.5 to 14px. Nothing clipped at 400px.
Nothing else moved: the strip, the notes, the phone frame, the canvas
handles and the closed notes' dot are the same.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 51494eb1f21203e6a9f8d2ffe2d54f871704e532 parent d9e39f3
2 files changed, +213 −55
  • internal/slides/static/editor.css +93 −55
  • internal/slidestest/quieter_test.go +120 −0
diff --git a/internal/slides/static/editor.css b/internal/slides/static/editor.css
index 431aff8..d9b80b6 100644
--- a/internal/slides/static/editor.css
+++ b/internal/slides/static/editor.css
@@ -13,8 +13,18 @@
at 320px (spec §8): the stage scrolls inside its own region, which
is the one allowance the spec makes. */
-/* The desk (static/desk.css) and the layout pictures' inks. */
+/* Type sizes and corner radii are the published ones (spec §7):
+ rastrillo's --rst-fs-xs|sm|base|lg (11.5, 12.5, 14, 17px; a step
+ larger under a coarse pointer or below 40rem) and --rst-radius,
+ --rst-radius-sm, --rst-radius-pill (12, 8, 999px), and estilo's
+ --estilo-float-radius (9px), wherever one is within a pixel of what
+ the part needs. What they lack is named here, once, for what it is
+ for; nothing else in this file states a size or a radius as a number
+ (TestQuieterCSSUsesTokens). A size that must not grow on touch, in a
+ fixed box, is named here too. */
+/* slides: named values */
:root {
+ /* The layout pictures' inks. */
--slides-glyph-paper: light-dark(#ffffff, #23211f);
--slides-glyph-edge: light-dark(#cfc8bf, #4a4540);
--slides-glyph-ink: light-dark(#3d3832, #d8d2cb);
@@ -25,7 +35,34 @@
light slide in the dark theme and a dark one in the light. */
--slides-strip-gutter: 24px;
--slides-strip-menu-ground: light-dark(rgb(255 255 255 / 0.8), rgb(24 22 20 / 0.72));
-}
+ /* Type in a fixed box, which must not grow on touch: the strip's
+ numbers in their gutter, and the initials (and the "+n") in a
+ presence face's 22px circle. */
+ --slides-fs-strip-number: 12px;
+ --slides-fs-avatar: 10px;
+ --slides-fs-avatar-more: 9px;
+ /* The speaker notes: larger than a form's text (--rst-fs-base),
+ because they are written to be read aloud. */
+ --slides-fs-notes: 15px;
+ /* Corners: a short grip's and a handle's; the ring round the text
+ being edited; the slide lying on the desk, and on the phone's
+ screen; a thumbnail's; the deck title's and a menu title's hover
+ ground in the bar; a key cap's; the layouts popover's and the
+ shortcuts dialog's; the assistant's, and its sheet's top on a
+ phone; the phone frame's; a dot. */
+ --slides-radius-glyph: 2px;
+ --slides-radius-edit-ring: 2px;
+ --slides-radius-paper: 4px;
+ --slides-radius-thumb: 6px;
+ --slides-radius-bar-item: 6px;
+ --slides-radius-key: 6px;
+ --slides-radius-panel: 14px;
+ --slides-radius-assist: 16px;
+ --slides-radius-sheet: 18px;
+ --slides-radius-phone: 28px;
+ --slides-radius-circle: 50%;
+}
+/* end named values */
/* `hidden` must actually hide. The bundle shows and hides most of the
inspector with the hidden PROPERTY, and the UA's own
@@ -190,10 +227,11 @@
background: transparent;
block-size: 28px;
border: 1px solid transparent;
- border-radius: 6px;
+ border-radius: var(--slides-radius-bar-item);
box-sizing: border-box;
color: var(--rst-text);
- font: 600 17px/26px var(--rst-font, system-ui), sans-serif;
+ font: 600 var(--rst-fs-lg) var(--rst-font, system-ui), sans-serif;
+ line-height: 26px;
letter-spacing: -0.01em;
margin-inline-start: -7px;
max-inline-size: min(36rem, 100%);
@@ -220,11 +258,11 @@
[slides-menubar] [estilo-menubar-title] {
align-items: center;
block-size: 24px;
- border-radius: 6px;
+ border-radius: var(--slides-radius-bar-item);
color: var(--rst-text-muted);
cursor: pointer;
display: inline-flex;
- font-size: 13px;
+ font-size: var(--rst-fs-sm);
line-height: 24px;
min-block-size: 0;
padding: 0 8px;
@@ -238,7 +276,7 @@
layout's picture beside its name. */
[slides-menu-heading] {
color: var(--rst-text-muted);
- font-size: 12px;
+ font-size: var(--rst-fs-xs);
font-weight: 600;
margin: 6px 12px 2px;
}
@@ -258,7 +296,7 @@
}
[slides-head-end] [estilo-save-status] {
color: var(--rst-text-muted);
- font-size: 13px;
+ font-size: var(--rst-fs-sm);
margin-inline-end: 4px;
}
/* The history pill: Undo and Redo as one control. Each is an
@@ -267,7 +305,7 @@
look: a grey pill, a hairline between. */
[slides-history] {
align-items: center;
- border-radius: 999px;
+ border-radius: var(--rst-radius-pill);
display: inline-flex;
}
[slides-history] button:focus-visible,
@@ -285,7 +323,7 @@
background: none;
block-size: 32px;
border: 0;
- border-radius: 999px;
+ border-radius: var(--rst-radius-pill);
color: var(--rst-text-muted);
cursor: pointer;
display: inline-flex;
@@ -342,11 +380,11 @@
background: none;
block-size: 36px;
border: 0;
- border-radius: 999px;
+ border-radius: var(--rst-radius-pill);
color: var(--rst-text-muted);
cursor: pointer;
display: inline-flex;
- font: 600 14px/1 var(--rst-font, system-ui), sans-serif;
+ font: 600 var(--rst-fs-base)/1 var(--rst-font, system-ui), sans-serif;
gap: 6px;
padding: 0 14px 0 12px;
}
@@ -371,7 +409,7 @@
[slides-head-share],
[slides-present-form] [rst-btn] {
block-size: 36px;
- border-radius: 999px;
+ border-radius: var(--rst-radius-pill);
padding-inline: 16px;
}
[slides-present-form] [rst-btn] {
@@ -441,7 +479,7 @@
justify-content: flex-end;
}
[slides-head-share] {
- font-size: 14px;
+ font-size: var(--rst-fs-base);
padding-inline: 12px;
}
}
@@ -457,7 +495,7 @@
[slides-keys-dialog] {
background: var(--rst-surface);
border: 1px solid var(--rst-line);
- border-radius: 14px;
+ border-radius: var(--slides-radius-panel);
box-shadow: var(--rst-shadow-pop);
color: var(--rst-text);
inline-size: min(30rem, calc(100vw - 2rem));
@@ -492,8 +530,8 @@
[slides-keys-list] kbd {
background: var(--rst-surface-2);
border: 1px solid var(--rst-line);
- border-radius: 6px;
- font: 600 12px/1 var(--rst-font, system-ui), sans-serif;
+ border-radius: var(--slides-radius-key);
+ font: 600 var(--rst-fs-xs)/1 var(--rst-font, system-ui), sans-serif;
padding: 4px 7px;
}
[slides-keys-dialog] form > p {
@@ -523,7 +561,7 @@
hidden twin at the start of the link's name instead, once. */
[slides-strip-item] {
align-items: start;
- border-radius: 10px;
+ border-radius: var(--estilo-float-radius);
box-sizing: border-box;
column-gap: 6px;
display: grid;
@@ -582,7 +620,7 @@
[slides-layout-grid] {
background: var(--rst-surface);
border: 0;
- border-radius: 14px;
+ border-radius: var(--slides-radius-panel);
box-shadow:
0 0 0 1px light-dark(rgb(40 28 12 / 0.1), rgb(255 255 255 / 0.1)),
0 10px 20px -8px rgb(40 28 12 / 0.2),
@@ -609,11 +647,11 @@
align-items: center;
background: none;
border: 1px solid transparent;
- border-radius: 8px;
+ border-radius: var(--rst-radius-sm);
color: var(--rst-text);
cursor: pointer;
display: grid;
- font-size: 12px;
+ font-size: var(--rst-fs-xs);
gap: 6px;
justify-items: center;
padding: 8px 4px;
@@ -651,7 +689,7 @@
[slides-thumb] {
aspect-ratio: 16 / 9;
background: var(--rst-surface);
- border-radius: 6px;
+ border-radius: var(--slides-radius-thumb);
box-shadow:
0 0 0 1px light-dark(rgb(40 28 12 / 0.08), rgb(255 255 255 / 0.08)),
0 1px 2px rgb(40 28 12 / 0.10),
@@ -682,7 +720,7 @@
[slides-strip-number] {
color: var(--rst-text-muted);
display: block;
- font-size: 12px;
+ font-size: var(--slides-fs-strip-number);
font-variant-numeric: tabular-nums;
font-weight: 500;
line-height: 1.5;
@@ -740,7 +778,7 @@
0 12px 32px -16px rgb(40 28 12 / 0.35);
}
[slides-stage] > [slides-slide] {
- border-radius: 4px;
+ border-radius: var(--slides-radius-paper);
box-shadow: var(--slides-paper-shadow);
}
/* ── The notes card (spec §5) ──────────────────────────────────────
@@ -785,7 +823,7 @@
}
[slides-notes-heading] {
color: var(--rst-text-muted);
- font-size: 12px;
+ font-size: var(--rst-fs-xs);
font-weight: 600;
letter-spacing: 0.02em;
margin: 0;
@@ -796,7 +834,7 @@
background: none;
block-size: 28px;
border: 0;
- border-radius: 999px;
+ border-radius: var(--rst-radius-pill);
color: var(--rst-text-muted);
cursor: pointer;
display: inline-flex;
@@ -824,7 +862,7 @@
scrollbar-width: thin;
}
[slides-notes] {
- font-size: 15px;
+ font-size: var(--slides-fs-notes);
line-height: 1.55;
}
/* The top edge: a 24px strip (the target size, WCAG 2.5.8) centred on
@@ -845,7 +883,7 @@
[slides-notes-resize]::after {
background: var(--rst-line-strong);
block-size: 4px;
- border-radius: 2px;
+ border-radius: var(--slides-radius-glyph);
content: "";
inline-size: 36px;
inset-block-start: 10px;
@@ -878,7 +916,7 @@
background: var(--rst-surface);
block-size: 32px;
border: 1px solid var(--rst-line);
- border-radius: 8px;
+ border-radius: var(--rst-radius-sm);
box-shadow: 0 1px 2px rgb(23 32 60 / 0.08), 0 4px 10px -4px rgb(23 32 60 / 0.18);
box-sizing: border-box;
color: var(--rst-text-muted);
@@ -898,7 +936,7 @@
[slides-notes-open][data-has-notes]::after {
background: var(--rst-accent);
block-size: 6px;
- border-radius: 50%;
+ border-radius: var(--slides-radius-circle);
box-shadow: 0 0 0 1.5px var(--rst-surface);
content: "";
inline-size: 6px;
@@ -934,7 +972,7 @@
[slides-editor] .ProseMirror.ProseMirror-focused {
outline: 2px solid var(--rst-accent);
outline-offset: 3px;
- border-radius: 2px;
+ border-radius: var(--slides-radius-edit-ring);
}
[slides-editor] .ProseMirror > * {
margin: 0;
@@ -1072,11 +1110,11 @@
[slides-inspector-form] [rst-field-label],
[slides-inspector-form] legend {
color: var(--rst-text-muted);
- font-size: 12px;
+ font-size: var(--rst-fs-xs);
font-weight: 500;
}
[slides-inspector-form] [rst-field-hint] {
- font-size: 11.5px;
+ font-size: var(--rst-fs-xs);
line-height: 1.35;
margin: 0;
}
@@ -1090,11 +1128,11 @@
}
[slides-inspector-form] [rst-input][type="color"] {
block-size: 28px;
- border-radius: 8px;
+ border-radius: var(--rst-radius-sm);
padding: 2px;
}
[slides-inspector-form] [rst-input][type="file"] {
- font-size: 12px;
+ font-size: var(--rst-fs-xs);
}
[slides-inspector-form] [rst-field-row] {
flex-wrap: nowrap;
@@ -1121,7 +1159,7 @@
display: none;
}
[slides-inspector] [estilo-seg-item] {
- font-size: 12.5px;
+ font-size: var(--rst-fs-sm);
}
[slides-inspector] [estilo-seg-item] .icon {
block-size: 16px;
@@ -1136,7 +1174,7 @@
[slides-box-fields] > legend {
color: var(--rst-text-muted);
float: left;
- font-size: 12px;
+ font-size: var(--rst-fs-xs);
font-weight: 500;
grid-column: 1 / -1;
margin: 0;
@@ -1147,7 +1185,7 @@
gap: 6px;
}
[slides-inspector] [rst-btn="sm"] {
- border-radius: 999px;
+ border-radius: var(--rst-radius-pill);
}
[slides-inspector-form] [rst-callout] {
margin: 0;
@@ -1188,7 +1226,7 @@
padding: 0;
}
[slides-unused-none] {
- font-size: 12px;
+ font-size: var(--rst-fs-sm);
}
[slides-unused-list] {
display: grid;
@@ -1213,7 +1251,7 @@
/* The Boxes list: one button per box, the selected one pressed.
Pressed is a fill AND aria-pressed, never a tint alone. */
[slides-blocks-none] {
- font-size: 12px;
+ font-size: var(--rst-fs-sm);
}
[slides-blocks-buttons] {
display: grid;
@@ -1241,7 +1279,7 @@
color: var(--rst-text-muted);
display: flex;
flex-wrap: wrap;
- font-size: 13px;
+ font-size: var(--rst-fs-sm);
gap: var(--rst-sp-2) var(--rst-sp-4);
justify-content: center;
}
@@ -1317,7 +1355,7 @@
align-self: start;
background: var(--slides-desk);
block-size: 844px;
- border-radius: 28px;
+ border-radius: var(--slides-radius-phone);
box-shadow: var(--slides-paper-shadow);
box-sizing: border-box;
inline-size: 390px;
@@ -1354,7 +1392,7 @@
inline-size: 390px;
}
[slides-phone-screen] > [slides-slide] {
- border-radius: 4px;
+ border-radius: var(--slides-radius-paper);
box-shadow: var(--slides-paper-shadow);
}
/* The screen is the slide's room: the stage in it is as tall as the
@@ -1433,7 +1471,7 @@
[slides-handle]::after {
background: var(--rst-surface);
border: 2px solid var(--rst-accent);
- border-radius: 2px;
+ border-radius: var(--slides-radius-glyph);
content: "";
height: 8px;
left: 6px;
@@ -1521,11 +1559,11 @@
align-items: center;
background: var(--slides-presence-colour, var(--rst-text-muted));
border: 2px solid var(--rst-surface);
- border-radius: 999px;
+ border-radius: var(--rst-radius-pill);
box-sizing: border-box;
color: #fff;
display: flex;
- font-size: 10px;
+ font-size: var(--slides-fs-avatar);
font-weight: 700;
height: 22px;
justify-content: center;
@@ -1534,7 +1572,7 @@
}
[slides-presence-more] {
background: var(--rst-text-muted);
- font-size: 9px;
+ font-size: var(--slides-fs-avatar-more);
}
/* The outline on a block a colleague has selected, and their name in
@@ -1812,7 +1850,7 @@
[slides-assist] {
background: var(--rst-surface);
border: 0;
- border-radius: 16px;
+ border-radius: var(--slides-radius-assist);
box-shadow:
0 0 0 1px light-dark(rgb(40 28 12 / 0.1), rgb(255 255 255 / 0.1)),
0 10px 20px -8px rgb(40 28 12 / 0.2),
@@ -1839,7 +1877,7 @@
[slides-assist-head] h2 {
align-items: center;
display: flex;
- font-size: 16px;
+ font-size: var(--rst-fs-lg);
gap: 8px;
margin: 0;
}
@@ -1853,7 +1891,7 @@
background: none;
block-size: 32px;
border: 0;
- border-radius: 999px;
+ border-radius: var(--rst-radius-pill);
color: var(--rst-text-muted);
cursor: pointer;
display: inline-flex;
@@ -1892,7 +1930,7 @@
}
[slides-assist-privacy] {
color: var(--rst-text-muted);
- font-size: 12px;
+ font-size: var(--rst-fs-xs);
line-height: 1.45;
margin: 0;
}
@@ -1916,18 +1954,18 @@
}
[slides-assist-summary] {
background: var(--rst-surface-2);
- border-radius: 10px;
+ border-radius: var(--estilo-float-radius);
padding: 10px 12px;
}
[slides-assist-note] {
color: var(--rst-text-muted);
- font-size: 13px;
+ font-size: var(--rst-fs-sm);
}
/* An error is said in words that say so; the colour is the second
carrier, never the only one. */
[slides-assist-outcome][data-tone="error"] [slides-assist-note] {
background: var(--rst-tone-negative-bg);
- border-radius: 10px;
+ border-radius: var(--estilo-float-radius);
color: var(--rst-tone-negative-fg);
font-weight: 600;
padding: 10px 12px;
@@ -1942,7 +1980,7 @@
}
@media (max-width: 599px) {
[slides-assist] {
- border-radius: 18px 18px 0 0;
+ border-radius: var(--slides-radius-sheet) var(--slides-radius-sheet) 0 0;
inline-size: 100vw;
inset: auto 0 0 0;
max-block-size: 88dvh;
diff --git a/internal/slidestest/quieter_test.go b/internal/slidestest/quieter_test.go
index af10253..714544b 100644
--- a/internal/slidestest/quieter_test.go
+++ b/internal/slidestest/quieter_test.go
@@ -3,6 +3,8 @@ package slidestest
import (
"fmt"
"net/http"
+ "os"
+ "path/filepath"
"regexp"
"strings"
"testing"
@@ -85,3 +87,121 @@ func TestQuieterStripMarkup(t *testing.T) {
t.Errorf("the strip item template's link has no title:\n%s", tmpl)
}
}
+
+// The block in static/editor.css that holds every value the editor
+// needs and the published set lacks (spec §7), and the published sizes
+// and radii a declaration outside it uses instead.
+const (
+ namedValuesStart = "/* slides: named values */"
+ namedValuesEnd = "/* end named values */"
+ publishedSizes = "--rst-fs-xs|sm|base|lg, --rst-radius, --rst-radius-sm, --rst-radius-pill, --estilo-float-radius"
+)
+
+// TestQuieterCSSUsesTokens (spec §7): outside the one named-values
+// block, no font-size, font shorthand or border radius (border-radius
+// and every longhand, physical or logical: border-start-start-radius,
+// border-top-left-radius) in editor.css states a number with a unit;
+// it uses a published token or a name from the block. A percentage
+// counts as a unit (a circle's 50% is a named value); a bare 0, a
+// unitless line height (the 1 in "600 14px/1") and keywords (inherit)
+// are not sizes. Comments are not read. Inside the block every
+// declaration is a custom property, declared once, and each is used
+// somewhere: in editor.css or a template.
+func TestQuieterCSSUsesTokens(t *testing.T) {
+ raw := readStatic(t, "editor.css")
+ // With no block (or a broken one) the whole file is outside it, so
+ // every offending line is still listed.
+ start, end := 0, 0
+ if n, m := strings.Count(raw, namedValuesStart), strings.Count(raw, namedValuesEnd); n != 1 || m != 1 {
+ t.Errorf("static/editor.css has %d %q and %d %q, want one block, opened and closed once, at the top of the file", n, namedValuesStart, m, namedValuesEnd)
+ } else if start, end = strings.Index(raw, namedValuesStart), strings.Index(raw, namedValuesEnd)+len(namedValuesEnd); end < start {
+ t.Errorf("static/editor.css closes its named values before it opens them")
+ start, end = 0, 0
+ }
+ // Comments blanked to spaces, newlines kept, so an offset is still
+ // the line it was on.
+ css := regexp.MustCompile(`(?s)/\*.*?\*/`).ReplaceAllStringFunc(raw, blankKeepingLines)
+ block := css[start:end]
+ outside := css[:start] + blankKeepingLines(block) + css[end:]
+ lineAt := func(off int) int { return strings.Count(raw[:off], "\n") + 1 }
+
+ decl := regexp.MustCompile(`(?m)(?:^|[{;])\s*(--[-\w]+|[a-zA-Z][-a-zA-Z]*)\s*:\s*([^;{}]*)`)
+ sized := regexp.MustCompile(`^(font|font-size|border(-[a-z]+)*-radius)$`)
+ // A custom property that holds a size or a radius by its name, so
+ // the rule cannot be stepped round by naming a number outside the
+ // block.
+ sizedName := regexp.MustCompile(`^--.*(radius|-fs-|font-size)`)
+ withUnit := regexp.MustCompile(`(?:^|[^-\w.#])[+-]?(?:\d+\.?\d*|\.\d+)(?:[a-zA-Z]+|%)`)
+ for _, m := range decl.FindAllStringSubmatchIndex(outside, -1) {
+ prop, value := outside[m[2]:m[3]], outside[m[4]:m[5]]
+ if !sized.MatchString(prop) && !sizedName.MatchString(prop) {
+ continue
+ }
+ var nums []string
+ for _, u := range withUnit.FindAllString(value, -1) {
+ nums = append(nums, strings.TrimLeft(u, " \t\n:(,/"))
+ }
+ if len(nums) > 0 {
+ n := lineAt(m[2])
+ t.Errorf("static/editor.css:%d: \"%s: %s\" states %s: use a published token (%s) or add a named value to the block between %s and %s, named for what it is for",
+ n, prop, strings.TrimSpace(value), strings.Join(nums, ", "), publishedSizes, namedValuesStart, namedValuesEnd)
+ }
+ }
+
+ // Inside the block: custom properties only, each declared once and
+ // used somewhere.
+ if end == 0 {
+ return
+ }
+ if strings.Contains(css[:start], "{") {
+ t.Error("the named values block is not at the top of static/editor.css: a rule comes before it")
+ }
+ if strings.Count(block, "{") != 1 || strings.Count(block, "}") != 1 {
+ t.Fatalf("the named values block is not one rule: it has %d { and %d }", strings.Count(block, "{"), strings.Count(block, "}"))
+ }
+ body := block[strings.Index(block, "{")+1 : strings.Index(block, "}")]
+ used := outside
+ for _, name := range []string{"editor.html", "layout.html"} {
+ b, err := os.ReadFile(filepath.Join("..", "slides", "templates", name))
+ if err != nil {
+ t.Fatal(err)
+ }
+ used += string(b)
+ }
+ seen := map[string]bool{}
+ for _, d := range strings.Split(body, ";") {
+ d = strings.TrimSpace(d)
+ if d == "" {
+ continue
+ }
+ name, _, _ := strings.Cut(d, ":")
+ name = strings.TrimSpace(name)
+ switch {
+ case !strings.HasPrefix(name, "--"):
+ t.Errorf("the named values block declares %q, which is not a custom property: only names are declared there", d)
+ case seen[name]:
+ t.Errorf("the named values block declares %s twice", name)
+ case !strings.Contains(used, "var("+name+")") && !strings.Contains(used, "var("+name+",") && !strings.Contains(used, "var("+name+" "):
+ t.Errorf("the named values block declares %s and nothing uses it: drop it, or use it", name)
+ }
+ seen[name] = true
+ if strings.HasPrefix(name, "--") && regexp.MustCompile(`(?m)(?:^|[{;])\s*`+regexp.QuoteMeta(name)+`\s*:`).MatchString(outside) {
+ t.Errorf("%s is declared in the named values block and again outside it: a named value is declared once", name)
+ }
+ }
+ if len(seen) == 0 {
+ t.Error("the named values block declares nothing")
+ }
+}
+
+// blankKeepingLines is s with every byte but a newline made a space: the
+// same length, so an offset into it is an offset into s.
+func blankKeepingLines(s string) string {
+ b := []byte(s)
+ for i, c := range b {
+ if c != '\n' {
+ b[i] = ' '
+ }
+ }
+ return string(b)
+}