@sinnstack/ui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/README.md +6 -4
- package/docs/blocks.md +373 -364
- package/docs/data.md +128 -128
- package/docs/finishes.md +165 -0
- package/docs/primitives.md +4 -4
- package/docs/seo.md +191 -187
- package/package.json +15 -24
- package/src/blocks/BlockRenderer.astro +13 -7
- package/src/blocks/CTABanner.astro +8 -8
- package/src/blocks/CTAPair.astro +9 -9
- package/src/blocks/CardGrid.astro +7 -7
- package/src/blocks/ConsentEmbed.astro +1 -1
- package/src/blocks/ConsentManager.astro +1 -1
- package/src/blocks/ContactCard.astro +14 -14
- package/src/blocks/ContactForm.astro +4 -4
- package/src/blocks/ErrorPage.astro +1 -1
- package/src/blocks/FAQ.astro +9 -9
- package/src/blocks/FeatureGrid.astro +7 -7
- package/src/blocks/Hero.astro +11 -11
- package/src/blocks/HeroCarousel.astro +11 -11
- package/src/blocks/HighlightCards.astro +10 -10
- package/src/blocks/LocationHours.astro +14 -14
- package/src/blocks/LogoCloud.astro +7 -7
- package/src/blocks/MaintenancePage.astro +8 -3
- package/src/blocks/MediaText.astro +12 -12
- package/src/blocks/PageHeader.astro +9 -9
- package/src/blocks/ProseSection.astro +8 -8
- package/src/blocks/Reviews.astro +11 -11
- package/src/blocks/RichText.astro +58 -57
- package/src/blocks/StatsBand.astro +117 -117
- package/src/blocks/Steps.astro +9 -9
- package/src/blocks/Testimonials.astro +13 -13
- package/src/blocks/cms/card-grid.ts +48 -80
- package/src/blocks/cms/consent.ts +1 -30
- package/src/blocks/cms/contact-card.ts +4 -46
- package/src/blocks/cms/contact-form.ts +2 -20
- package/src/blocks/cms/cta-banner.ts +2 -23
- package/src/blocks/cms/cta-pair.ts +4 -37
- package/src/blocks/cms/data-base.ts +2 -4
- package/src/blocks/cms/data.ts +19 -19
- package/src/blocks/cms/faq.ts +4 -36
- package/src/blocks/cms/feature-grid.ts +47 -80
- package/src/blocks/cms/fixtures.ts +591 -599
- package/src/blocks/cms/hero-carousel.ts +4 -48
- package/src/blocks/cms/hero.ts +2 -46
- package/src/blocks/cms/highlight-cards.ts +4 -39
- package/src/blocks/cms/images.ts +1 -2
- package/src/blocks/cms/index.ts +59 -87
- package/src/blocks/cms/location-hours.ts +3 -85
- package/src/blocks/cms/logo-cloud.ts +36 -62
- package/src/blocks/cms/media-text.ts +2 -20
- package/src/blocks/cms/page-header.ts +27 -49
- package/src/blocks/cms/pages.ts +35 -81
- package/src/blocks/cms/prose-section.ts +2 -22
- package/src/blocks/cms/reviews.ts +5 -56
- package/src/blocks/cms/schema-dsl.ts +134 -0
- package/src/blocks/cms/schema.ts +794 -0
- package/src/blocks/cms/shared.ts +63 -115
- package/src/blocks/cms/stats-band.ts +35 -61
- package/src/blocks/cms/steps.ts +4 -31
- package/src/blocks/cms/testimonials.ts +4 -38
- package/src/blocks/cms/topbar.ts +4 -41
- package/src/blocks/cms/types.ts +1 -37
- package/src/blocks/consent.ts +2 -2
- package/src/blocks/index.ts +2 -2
- package/src/blocks/internal/Actions.astro +11 -5
- package/src/blocks/internal/BlockHeader.astro +7 -7
- package/src/blocks/internal/Placeholder.astro +3 -3
- package/src/blocks/internal/fields.ts +18 -0
- package/src/blocks/internal/registry-contract.ts +67 -0
- package/src/blocks/internal/util.ts +4 -4
- package/src/blocks/lib/contact.ts +10 -4
- package/src/blocks/lib/faq.ts +1 -1
- package/src/blocks/lib/markdown.ts +350 -0
- package/src/blocks/lib/rich-text.ts +132 -143
- package/src/blocks/scripts/consent-manager.ts +1 -1
- package/src/blocks/scripts/consent-store.ts +1 -1
- package/src/blocks/scripts/hours.ts +3 -2
- package/src/blocks/types.ts +33 -23
- package/src/data/ChartContainer.astro +2 -1
- package/src/data/cms.ts +130 -190
- package/src/data/lib/chart.ts +13 -4
- package/src/data/schema.ts +65 -0
- package/src/finishes/aurora.css +75 -0
- package/src/finishes/autumn.css +87 -0
- package/src/finishes/blueprint.css +69 -0
- package/src/finishes/brutalist.css +55 -0
- package/src/finishes/clay.css +48 -0
- package/src/finishes/day-cycle.css +46 -0
- package/src/finishes/fog.css +71 -0
- package/src/finishes/glass.css +149 -0
- package/src/finishes/holographic.css +91 -0
- package/src/finishes/night.css +77 -0
- package/src/finishes/paper.css +58 -0
- package/src/finishes/polished-glass.css +159 -0
- package/src/finishes/rain.css +84 -0
- package/src/finishes/scripts/day-cycle.ts +30 -0
- package/src/finishes/scripts/holographic.ts +37 -0
- package/src/finishes/scripts/spotlight.ts +30 -0
- package/src/finishes/spotlight.css +41 -0
- package/src/finishes/spring.css +80 -0
- package/src/finishes/terminal.css +49 -0
- package/src/primitives/Divider.astro +1 -1
- package/src/primitives/FocusRing.astro +1 -1
- package/src/primitives/FormField.astro +2 -2
- package/src/primitives/Image.astro +3 -3
- package/src/primitives/Input.astro +4 -2
- package/src/primitives/MetricCard.astro +3 -1
- package/src/primitives/Picture.astro +3 -3
- package/src/primitives/Prose.astro +1 -1
- package/src/primitives/Select.astro +4 -2
- package/src/primitives/Slider.astro +1 -1
- package/src/primitives/Table.astro +1 -1
- package/src/primitives/Textarea.astro +4 -2
- package/src/primitives/Thumbnail.astro +2 -2
- package/src/primitives/index.ts +4 -4
- package/src/primitives/internal/ChoiceField.astro +4 -2
- package/src/primitives/scripts/slider.ts +1 -1
- package/src/primitives/scripts/table-sort.ts +2 -2
- package/src/seo/cms.ts +59 -80
- package/src/seo/index.ts +1 -1
- package/src/seo/integration.ts +40 -3
- package/src/seo/lib/jsonld.ts +10 -2
- package/src/seo/lib/meta.ts +2 -2
- package/src/seo/lib/redirects.ts +14 -4
- package/src/seo/lib/rss.ts +1 -1
- package/src/seo/lib/sitemap.ts +1 -1
- package/src/seo/schema.ts +43 -0
- package/src/blocks/internal/tina.ts +0 -19
- /package/src/blocks/{lib → internal}/consent.ts +0 -0
- /package/src/blocks/{lib → internal}/reviews.ts +0 -0
- /package/src/blocks/{lib → internal}/slug.ts +0 -0
- /package/src/data/{lib → internal}/scale.ts +0 -0
- /package/src/primitives/{lib → internal}/image-plan.ts +0 -0
- /package/src/primitives/{lib → internal}/image.ts +0 -0
- /package/src/primitives/{lib → internal}/slider.ts +0 -0
- /package/src/seo/{lib → internal}/url.ts +0 -0
package/docs/data.md
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
# @sinnstack/ui/data
|
|
2
|
-
|
|
3
|
-
Charts and sparklines for Sinnstack sites. The SVG is rendered on the server, is responsive without JavaScript and works under a strict CSP. A 2.6 KB script adds the tooltip, keyboard reading and legend toggles.
|
|
4
|
-
|
|
5
|
-
| Component | What it does |
|
|
6
|
-
| --- | --- |
|
|
7
|
-
| **ChartContainer** | The frame: title, description, legend row, plot, data table, source. Handles loading, refetching, empty and error states. |
|
|
8
|
-
| **ChartAxis** | Y axis with gridlines (`axis="y"`); x axis with baseline and thinned labels (`axis="x"`). |
|
|
9
|
-
| **ChartSeries** | The marks: lines, stacked areas, grouped or stacked bars. |
|
|
10
|
-
| **ChartLegend** | Swatch and name for each series. Buttons show or hide a series; Alt/Option-click shows only that one. |
|
|
11
|
-
| **ChartTooltip** | Exact values under the pointer, a tap, or keyboard focus. Each move is announced to screen readers. |
|
|
12
|
-
| **ChartTable** | The chart's data as a real table, with CSV download. ChartContainer includes it by default. |
|
|
13
|
-
| **Sparkline** | A small trend with no axes, inline in text or beside a metric. Screen readers get one sentence. |
|
|
14
|
-
|
|
15
|
-
```astro
|
|
16
|
-
---
|
|
17
|
-
import { ChartContainer, ChartAxis, ChartSeries, ChartLegend, ChartTooltip, defineChart } from '@sinnstack/ui/data';
|
|
18
|
-
const chart = defineChart({
|
|
19
|
-
type: 'line', x: months, yFormat: 'integer', yTitle: 'Deploys', subject: 'deploys by service',
|
|
20
|
-
series: [{ label: 'Website design', values: design }, { label: 'Astro development', values: dev }],
|
|
21
|
-
});
|
|
22
|
-
---
|
|
23
|
-
<ChartContainer chart={chart} title="Deploys by service" description="Per month, all clients, 2026."
|
|
24
|
-
source={{ label: 'Deploy log export', href: '/data' }}>
|
|
25
|
-
<ChartLegend slot="legend" chart={chart} />
|
|
26
|
-
<ChartAxis chart={chart} axis="y" />
|
|
27
|
-
<ChartAxis chart={chart} axis="x" />
|
|
28
|
-
<ChartSeries chart={chart} />
|
|
29
|
-
<ChartTooltip chart={chart} />
|
|
30
|
-
</ChartContainer>
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
`defineChart()` is a pure function: no DOM and no Astro. It does all the maths: a nice domain, ticks, mark positions, hit zones, the summary sentence and the table. The components only print what it returns. The same renderers (`@sinnstack/ui/data/render`) can be used outside Astro.
|
|
34
|
-
|
|
35
|
-
## defineChart options
|
|
36
|
-
|
|
37
|
-
| Option | Notes |
|
|
38
|
-
| --- | --- |
|
|
39
|
-
| `type` | `line`, `area` or `bar`. |
|
|
40
|
-
| `x` | Labels or dates. On lines and areas, ISO dates or `Date`s give a time axis with calendar ticks (Jan, Apr, Jul… and the year when it changes). Bars always use categories. |
|
|
41
|
-
| `series` | `{ label, values, slot?, muted? }`. `null` is a gap: lines break there and the table shows "—". |
|
|
42
|
-
| `yFormat` | Any primitives `ValueFormat`. With `compact: 'auto'`, only the **axis** is shortened ($200K). Tooltips, the table and the summary always show exact values ($182,000), with no cents when every value is a whole dollar. |
|
|
43
|
-
| `stacked` | Stacked bars or areas. Negatives stack downward. The tooltip lists a total, which is hidden while any series is hidden. |
|
|
44
|
-
| `yMin` / `yMax` / `yZero` / `yTicks` | Domain control. Bars always start at zero; `yZero: false` on bars is ignored with a warning. |
|
|
45
|
-
| `subject` | Used in the summary: "Line chart of *site visits by service*, January to December 2026. …" |
|
|
46
|
-
|
|
47
|
-
`chart.warnings` lists design problems: more than 8 series, more than 4 grouped bars, two series sharing a color, a value count that doesn't match `x`, and no data. ChartContainer logs them in dev.
|
|
48
|
-
|
|
49
|
-
## Design rules built in
|
|
50
|
-
|
|
51
|
-
- **Marks.** Bars are at most 24px wide, grouped bars sit 2px apart, and only the data end is rounded (4px, clipped with CSS so there's no seam). Stacked segments are separated by 2px gaps in the surface color, not strokes. Lines are 2px and don't scale with the plot. End dots are r 4 with a ring in the surface color. Area fills are a 10% wash.
|
|
52
|
-
- **Recessive frame.** Gridlines are hairlines. The zero line uses the darker axis color when the range crosses zero. X labels thin out with container queries (`data-tier` × `data-step-*`), so they never collide at any width. The y gutter is sized from the widest label.
|
|
53
|
-
- **Text never wears a series color.** Values and labels use text tokens; the swatch beside them carries the identity.
|
|
54
|
-
- **One axis.** There's no dual-axis option. Two measures on different scales belong in two charts.
|
|
55
|
-
- **`background`** (`default`, `raised`, `subtle`, the same words as Surface) tells the gaps and rings which background they sit on. Use `raised` inside cards. `surface` is the deprecated name and still works.
|
|
56
|
-
|
|
57
|
-
### Palette
|
|
58
|
-
|
|
59
|
-
`--sinn-color-series-1…8` in `@sinnstack/ui` are fixed in order: blue, orange, green, amber, pink, deep green, violet, red. Colors follow the series, not its rank, so hiding a series never repaints the others. Each mode has its own steps (light-dark()), checked with the dataviz palette validator:
|
|
60
|
-
|
|
61
|
-
- **Dark** on `#0e0f12` and on raised `#18191d`: every check passes.
|
|
62
|
-
- **Light** on `#ffffff`: lightness band, chroma, CVD separation between neighbors and normal-vision separation all pass. Slots 3, 4 and 5 (green, amber, pink) are under 3:1 contrast against white, so the relief rule applies: identity is never color alone (there's always a legend for 2+ series, plus line keys versus square keys), and the table view is always available. Avoid putting slots 3–5 next to each other as the only two series in a light chart.
|
|
63
|
-
- **More than 8 series** gets a warning. Fold the rest into "Other", or use small multiples.
|
|
64
|
-
- **Forced colors** (Windows contrast themes): lines become CanvasText with distinct dash patterns, and every other bar is outlined.
|
|
65
|
-
|
|
66
|
-
## Interaction
|
|
67
|
-
|
|
68
|
-
- **Pointer:** on lines and areas a crosshair snaps to the nearest x and lists every series there. On bars the category's band lifts, other categories dim to 45%, and the bar under the pointer leads the list.
|
|
69
|
-
- **Touch:** a tap shows the readout until you tap elsewhere. The plot keeps vertical scrolling (`touch-action: pan-y`).
|
|
70
|
-
- **Keyboard:** the plot is a single tab stop (`role="group"`, "interactive chart"). Use ←/→ to move, Home/End to jump to the ends, PageUp/PageDown to move 5, and Esc to hide. Moves are debounced and announced in a polite live region, e.g. "November 2026: Skilled nursing 1,840, Physical therapy 1,150".
|
|
71
|
-
- **Legend:** buttons with `aria-pressed`. At least one series always stays visible, and you're told why when you try to hide the last one. "Show all" appears while anything is hidden. Each change fires `sinn:series-change` on the figure.
|
|
72
|
-
- **No JavaScript:** every mark, label, summary and table still renders. Only the tooltip is missing.
|
|
73
|
-
- Data text (series names, labels) is only ever inserted with `textContent`. Tooltip data travels in an escaped `data-chart` attribute.
|
|
74
|
-
|
|
75
|
-
## Accessibility
|
|
76
|
-
|
|
77
|
-
- The `<figure>` is labelled by the heading in its `<figcaption>`, and the description is linked with `aria-describedby`.
|
|
78
|
-
- The SVG is `aria-hidden`. A visually hidden sentence summarizes the range and the high and low for each series. The table, with scoped headers, a caption and a focusable scroll region, carries every value.
|
|
79
|
-
- Sparklines are `role="img"` with the sentence as their label, e.g. "Visits: 1,240 in Jan to 1,795 in Dec (up 45%). High 1,840 (Nov), low 1,180 (Feb)." Pass `interactive` for a focusable readout.
|
|
80
|
-
- States: `loading` sets `aria-busy` with a status. `refetching` keeps the old chart, dimmed and busy, with no layout jump. `empty` is a status, and `error` is an alert with an `error` slot for a retry button. All four have the plot's footprint.
|
|
81
|
-
- Reduced motion stops the skeleton shimmer.
|
|
82
|
-
|
|
83
|
-
## Sparkline
|
|
84
|
-
|
|
85
|
-
```astro
|
|
86
|
-
Deploys rose all year <Sparkline values={monthly} labels={months} label="Deploys" format="integer" interactive />.
|
|
87
|
-
<Sparkline size="m" values={ratings} label="Rating" reference={4.5} referenceLabel="Goal" highlight="max" />
|
|
88
|
-
<Sparkline size="fill" type="bar" values={netNew} label="Net new clients" />
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
`size`: `inline` (1em tall, sits in text), `s`, `m`, `fill`. `type`: line, area, bar (negatives hang below zero). `highlight`: last (default), max, min, none. The line is the muted gray and the highlighted point is the accent color. Pass `slot` to use a series color instead.
|
|
92
|
-
|
|
93
|
-
## CMS
|
|
94
|
-
|
|
95
|
-
`@sinnstack/ui/data/cms`
|
|
96
|
-
|
|
97
|
-
## Budgets
|
|
98
|
-
|
|
99
|
-
| Asset | Limit | Now (gzip) |
|
|
100
|
-
| --- | --- | --- |
|
|
101
|
-
| Client script (`src/scripts/chart.ts`) | 3.5 KB | 2.6 KB |
|
|
102
|
-
| Styles (`styles.css`, all generated rules) | 5 KB | 3.8 KB |
|
|
103
|
-
|
|
104
|
-
The models and renderers run at build time and ship no client bytes.
|
|
105
|
-
|
|
106
|
-
## Testing
|
|
107
|
-
|
|
108
|
-
```sh
|
|
109
|
-
pnpm test # 41 unit tests: scales, models, formatting, CMS parsing, escaping
|
|
110
|
-
pnpm test:browser # 111 checks in Chrome, on pages built from the real renderers + client script, served under a strict CSP
|
|
111
|
-
pnpm test:visual # screenshot baselines: light/dark × 390/1024 + card
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Setup and flags: [TESTING.md](../../TESTING.md).
|
|
115
|
-
|
|
116
|
-
The browser checks cover:
|
|
117
|
-
- structure and labelling, and no CSP violations;
|
|
118
|
-
- label collisions at 320, 390, 700 and 1024px;
|
|
119
|
-
- bar width, gaps and rounding; line and dot specs;
|
|
120
|
-
- pointer, touch and keyboard tooltips, including edge flipping and announcements;
|
|
121
|
-
- every legend behavior; the table and CSV;
|
|
122
|
-
- all states; sparklines;
|
|
123
|
-
- an AA contrast sweep in light and dark; forced colors; reduced motion; no-JS rendering.
|
|
124
|
-
|
|
125
|
-
**Not yet verified:**
|
|
126
|
-
- **Astro:** `astro build` and `astro check` haven't been run. The test pages mirror the ChartContainer frame by hand, and everything inside it is the real renderer output.
|
|
127
|
-
- **Browsers:** only Chrome has been tested. Bars set their width in CSS on an SVG `<rect>` (`width: min(24px, …)`). Safari and Firefox support this, but it's untested here; without it, bars fall back to the 24px attribute. The rounded data end uses `clip-path: inset(… round …)` on SVG, and without it bars are square.
|
|
128
|
-
- **Assistive tech:** no real screen reader has been tried, so the live-region wording and "interactive chart" role description haven't been heard in VoiceOver or NVDA.
|
|
1
|
+
# @sinnstack/ui/data
|
|
2
|
+
|
|
3
|
+
Charts and sparklines for Sinnstack sites. The SVG is rendered on the server, is responsive without JavaScript and works under a strict CSP. A 2.6 KB script adds the tooltip, keyboard reading and legend toggles.
|
|
4
|
+
|
|
5
|
+
| Component | What it does |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| **ChartContainer** | The frame: title, description, legend row, plot, data table, source. Handles loading, refetching, empty and error states. |
|
|
8
|
+
| **ChartAxis** | Y axis with gridlines (`axis="y"`); x axis with baseline and thinned labels (`axis="x"`). |
|
|
9
|
+
| **ChartSeries** | The marks: lines, stacked areas, grouped or stacked bars. |
|
|
10
|
+
| **ChartLegend** | Swatch and name for each series. Buttons show or hide a series; Alt/Option-click shows only that one. |
|
|
11
|
+
| **ChartTooltip** | Exact values under the pointer, a tap, or keyboard focus. Each move is announced to screen readers. |
|
|
12
|
+
| **ChartTable** | The chart's data as a real table, with CSV download. ChartContainer includes it by default. |
|
|
13
|
+
| **Sparkline** | A small trend with no axes, inline in text or beside a metric. Screen readers get one sentence. |
|
|
14
|
+
|
|
15
|
+
```astro
|
|
16
|
+
---
|
|
17
|
+
import { ChartContainer, ChartAxis, ChartSeries, ChartLegend, ChartTooltip, defineChart } from '@sinnstack/ui/data';
|
|
18
|
+
const chart = defineChart({
|
|
19
|
+
type: 'line', x: months, yFormat: 'integer', yTitle: 'Deploys', subject: 'deploys by service',
|
|
20
|
+
series: [{ label: 'Website design', values: design }, { label: 'Astro development', values: dev }],
|
|
21
|
+
});
|
|
22
|
+
---
|
|
23
|
+
<ChartContainer chart={chart} title="Deploys by service" description="Per month, all clients, 2026."
|
|
24
|
+
source={{ label: 'Deploy log export', href: '/data' }}>
|
|
25
|
+
<ChartLegend slot="legend" chart={chart} />
|
|
26
|
+
<ChartAxis chart={chart} axis="y" />
|
|
27
|
+
<ChartAxis chart={chart} axis="x" />
|
|
28
|
+
<ChartSeries chart={chart} />
|
|
29
|
+
<ChartTooltip chart={chart} />
|
|
30
|
+
</ChartContainer>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`defineChart()` is a pure function: no DOM and no Astro. It does all the maths: a nice domain, ticks, mark positions, hit zones, the summary sentence and the table. The components only print what it returns. The same renderers (`@sinnstack/ui/data/render`) can be used outside Astro.
|
|
34
|
+
|
|
35
|
+
## defineChart options
|
|
36
|
+
|
|
37
|
+
| Option | Notes |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| `type` | `line`, `area` or `bar`. |
|
|
40
|
+
| `x` | Labels or dates. On lines and areas, ISO dates or `Date`s give a time axis with calendar ticks (Jan, Apr, Jul… and the year when it changes). Bars always use categories. |
|
|
41
|
+
| `series` | `{ label, values, slot?, muted? }`. `null` is a gap: lines break there and the table shows "—". |
|
|
42
|
+
| `yFormat` | Any primitives `ValueFormat`. With `compact: 'auto'`, only the **axis** is shortened ($200K). Tooltips, the table and the summary always show exact values ($182,000), with no cents when every value is a whole dollar. |
|
|
43
|
+
| `stacked` | Stacked bars or areas. Negatives stack downward. The tooltip lists a total, which is hidden while any series is hidden. |
|
|
44
|
+
| `yMin` / `yMax` / `yZero` / `yTicks` | Domain control. Bars always start at zero; `yZero: false` on bars is ignored with a warning. |
|
|
45
|
+
| `subject` | Used in the summary: "Line chart of *site visits by service*, January to December 2026. …" |
|
|
46
|
+
|
|
47
|
+
`chart.warnings` lists design problems: more than 8 series, more than 4 grouped bars, two series sharing a color, a value count that doesn't match `x`, and no data. ChartContainer logs them in dev.
|
|
48
|
+
|
|
49
|
+
## Design rules built in
|
|
50
|
+
|
|
51
|
+
- **Marks.** Bars are at most 24px wide, grouped bars sit 2px apart, and only the data end is rounded (4px, clipped with CSS so there's no seam). Stacked segments are separated by 2px gaps in the surface color, not strokes. Lines are 2px and don't scale with the plot. End dots are r 4 with a ring in the surface color. Area fills are a 10% wash.
|
|
52
|
+
- **Recessive frame.** Gridlines are hairlines. The zero line uses the darker axis color when the range crosses zero. X labels thin out with container queries (`data-tier` × `data-step-*`), so they never collide at any width. The y gutter is sized from the widest label.
|
|
53
|
+
- **Text never wears a series color.** Values and labels use text tokens; the swatch beside them carries the identity.
|
|
54
|
+
- **One axis.** There's no dual-axis option. Two measures on different scales belong in two charts.
|
|
55
|
+
- **`background`** (`default`, `raised`, `subtle`, the same words as Surface) tells the gaps and rings which background they sit on. Use `raised` inside cards. `surface` is the deprecated name and still works.
|
|
56
|
+
|
|
57
|
+
### Palette
|
|
58
|
+
|
|
59
|
+
`--sinn-color-series-1…8` in `@sinnstack/ui` are fixed in order: blue, orange, green, amber, pink, deep green, violet, red. Colors follow the series, not its rank, so hiding a series never repaints the others. Each mode has its own steps (light-dark()), checked with the dataviz palette validator:
|
|
60
|
+
|
|
61
|
+
- **Dark** on `#0e0f12` and on raised `#18191d`: every check passes.
|
|
62
|
+
- **Light** on `#ffffff`: lightness band, chroma, CVD separation between neighbors and normal-vision separation all pass. Slots 3, 4 and 5 (green, amber, pink) are under 3:1 contrast against white, so the relief rule applies: identity is never color alone (there's always a legend for 2+ series, plus line keys versus square keys), and the table view is always available. Avoid putting slots 3–5 next to each other as the only two series in a light chart.
|
|
63
|
+
- **More than 8 series** gets a warning. Fold the rest into "Other", or use small multiples.
|
|
64
|
+
- **Forced colors** (Windows contrast themes): lines become CanvasText with distinct dash patterns, and every other bar is outlined.
|
|
65
|
+
|
|
66
|
+
## Interaction
|
|
67
|
+
|
|
68
|
+
- **Pointer:** on lines and areas a crosshair snaps to the nearest x and lists every series there. On bars the category's band lifts, other categories dim to 45%, and the bar under the pointer leads the list.
|
|
69
|
+
- **Touch:** a tap shows the readout until you tap elsewhere. The plot keeps vertical scrolling (`touch-action: pan-y`).
|
|
70
|
+
- **Keyboard:** the plot is a single tab stop (`role="group"`, "interactive chart"). Use ←/→ to move, Home/End to jump to the ends, PageUp/PageDown to move 5, and Esc to hide. Moves are debounced and announced in a polite live region, e.g. "November 2026: Skilled nursing 1,840, Physical therapy 1,150".
|
|
71
|
+
- **Legend:** buttons with `aria-pressed`. At least one series always stays visible, and you're told why when you try to hide the last one. "Show all" appears while anything is hidden. Each change fires `sinn:series-change` on the figure.
|
|
72
|
+
- **No JavaScript:** every mark, label, summary and table still renders. Only the tooltip is missing.
|
|
73
|
+
- Data text (series names, labels) is only ever inserted with `textContent`. Tooltip data travels in an escaped `data-chart` attribute.
|
|
74
|
+
|
|
75
|
+
## Accessibility
|
|
76
|
+
|
|
77
|
+
- The `<figure>` is labelled by the heading in its `<figcaption>`, and the description is linked with `aria-describedby`.
|
|
78
|
+
- The SVG is `aria-hidden`. A visually hidden sentence summarizes the range and the high and low for each series. The table, with scoped headers, a caption and a focusable scroll region, carries every value.
|
|
79
|
+
- Sparklines are `role="img"` with the sentence as their label, e.g. "Visits: 1,240 in Jan to 1,795 in Dec (up 45%). High 1,840 (Nov), low 1,180 (Feb)." Pass `interactive` for a focusable readout.
|
|
80
|
+
- States: `loading` sets `aria-busy` with a status. `refetching` keeps the old chart, dimmed and busy, with no layout jump. `empty` is a status, and `error` is an alert with an `error` slot for a retry button. All four have the plot's footprint.
|
|
81
|
+
- Reduced motion stops the skeleton shimmer.
|
|
82
|
+
|
|
83
|
+
## Sparkline
|
|
84
|
+
|
|
85
|
+
```astro
|
|
86
|
+
Deploys rose all year <Sparkline values={monthly} labels={months} label="Deploys" format="integer" interactive />.
|
|
87
|
+
<Sparkline size="m" values={ratings} label="Rating" reference={4.5} referenceLabel="Goal" highlight="max" />
|
|
88
|
+
<Sparkline size="fill" type="bar" values={netNew} label="Net new clients" />
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`size`: `inline` (1em tall, sits in text), `s`, `m`, `fill`. `type`: line, area, bar (negatives hang below zero). `highlight`: last (default), max, min, none. The line is the muted gray and the highlighted point is the accent color. Pass `slot` to use a series color instead.
|
|
92
|
+
|
|
93
|
+
## CMS
|
|
94
|
+
|
|
95
|
+
`@sinnstack/ui/data/cms` maps hand-entered chart data from the CMS: a `chart` object (`title`, `description`, `type`, `stacked`, `format`, `labels`, `series[{ label, values }]`, `yTitle`, `sourceLabel`, `sourceHref`, `height`, `tableOpen`) and a `sparkline` object (`label`, `values`, `labels`, `format`, `type`, `reference`); see `CmsChart` and `CmsSparkline`. Editors type one value per line, matched to the labels; "1,240", "$9,000" and "91%" all work, and a blank line is a missing value. `chartFromCms(block.chart)` returns `{ chart, frame, errors }`. Spread `frame` onto ChartContainer, and show `errors` (plain sentences such as "PT has 2 values for 3 labels.") in previews. Charts fed from an API should call `defineChart()` in code. The SinnStackCMS fields for both objects ship in `@sinnstack/ui/data/schema` (`chartSchema`, `sparklineSchema`).
|
|
96
|
+
|
|
97
|
+
## Budgets
|
|
98
|
+
|
|
99
|
+
| Asset | Limit | Now (gzip) |
|
|
100
|
+
| --- | --- | --- |
|
|
101
|
+
| Client script (`src/scripts/chart.ts`) | 3.5 KB | 2.6 KB |
|
|
102
|
+
| Styles (`styles.css`, all generated rules) | 5 KB | 3.8 KB |
|
|
103
|
+
|
|
104
|
+
The models and renderers run at build time and ship no client bytes.
|
|
105
|
+
|
|
106
|
+
## Testing
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
pnpm test # 41 unit tests: scales, models, formatting, CMS parsing, escaping
|
|
110
|
+
pnpm test:browser # 111 checks in Chrome, on pages built from the real renderers + client script, served under a strict CSP
|
|
111
|
+
pnpm test:visual # screenshot baselines: light/dark × 390/1024 + card
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Setup and flags: [TESTING.md](../../TESTING.md).
|
|
115
|
+
|
|
116
|
+
The browser checks cover:
|
|
117
|
+
- structure and labelling, and no CSP violations;
|
|
118
|
+
- label collisions at 320, 390, 700 and 1024px;
|
|
119
|
+
- bar width, gaps and rounding; line and dot specs;
|
|
120
|
+
- pointer, touch and keyboard tooltips, including edge flipping and announcements;
|
|
121
|
+
- every legend behavior; the table and CSV;
|
|
122
|
+
- all states; sparklines;
|
|
123
|
+
- an AA contrast sweep in light and dark; forced colors; reduced motion; no-JS rendering.
|
|
124
|
+
|
|
125
|
+
**Not yet verified:**
|
|
126
|
+
- **Astro:** `astro build` and `astro check` haven't been run. The test pages mirror the ChartContainer frame by hand, and everything inside it is the real renderer output.
|
|
127
|
+
- **Browsers:** only Chrome has been tested. Bars set their width in CSS on an SVG `<rect>` (`width: min(24px, …)`). Safari and Firefox support this, but it's untested here; without it, bars fall back to the 24px attribute. The rounded data end uses `clip-path: inset(… round …)` on SVG, and without it bars are square.
|
|
128
|
+
- **Assistive tech:** no real screen reader has been tried, so the live-region wording and "interactive chart" role description haven't been heard in VoiceOver or NVDA.
|
package/docs/finishes.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Finishes
|
|
2
|
+
|
|
3
|
+
A finish is a rendering style that sits on top of any palette: how surfaces look (frosted, flat, lit), not which colours they use. Palettes and finishes are separate choices, so any palette works with any finish, in light and dark.
|
|
4
|
+
|
|
5
|
+
```astro
|
|
6
|
+
---
|
|
7
|
+
// src/layouts/Base.astro
|
|
8
|
+
import '@sinnstack/ui/tokens.css';
|
|
9
|
+
import '@sinnstack/ui/base.css';
|
|
10
|
+
import '../styles/theme.css'; // your palette
|
|
11
|
+
import '@sinnstack/ui/finishes/glass.css'; // opt in: costs nothing until data-finish is set
|
|
12
|
+
---
|
|
13
|
+
<html lang="en" data-finish="glass">
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
No `data-finish` attribute means the default finish: the library's normal solid surfaces.
|
|
17
|
+
|
|
18
|
+
## The contract
|
|
19
|
+
|
|
20
|
+
**A palette owns every colour token, and a finish never writes one.** A finish may:
|
|
21
|
+
|
|
22
|
+
- set the library's non-colour tokens (radius, border width, shadow shapes, focus width), scoped to the finish, and its own `--sinn-finish-<name>-*` tokens (blur, opacity, glow strength);
|
|
23
|
+
- read colour tokens, including mixing them with transparency (`color-mix(in oklch, var(--sinn-color-surface-raised) 74%, transparent)`);
|
|
24
|
+
- add decorative layers drawn from palette tokens.
|
|
25
|
+
|
|
26
|
+
It must not declare any `--sinn-color-*` (or `--sinn-shadow-color`) property, and every rule must be scoped to `[data-finish~='<name>']`. `test/finishes/finish-contract.unit.mjs` enforces both, so a finish can't quietly recolour a palette.
|
|
27
|
+
|
|
28
|
+
Selectors use `~=`, so finishes are a space-separated list and can combine later: `data-finish="glass aurora"`.
|
|
29
|
+
|
|
30
|
+
## Glass
|
|
31
|
+
|
|
32
|
+
`@sinnstack/ui/finishes/glass.css`, `data-finish="glass"`.
|
|
33
|
+
|
|
34
|
+
- **Backdrop:** soft glows of the palette's `accent-soft` fill over its normal page surface. Glass needs something behind it; on a flat page a blur has nothing to show. A site with its own backdrop (a photo, a video) overrides `background-image` on `:root` in `sinn.overrides`.
|
|
35
|
+
- **Frosted surfaces:** `Card`, `Panel` (not `plain`), `Dialog`, `Popover`, card-style `Accordion`/disclosure items, card variants of `FeatureGrid`, `Steps` and `Testimonials`, outline `ContactCard`/`ContactForm`, the consent banner, outline `Callout`, `Navbar` and `Footer`. Each keeps the surface token it already uses, made translucent, with a backdrop blur.
|
|
36
|
+
- **Section bands:** `background="subtle"`, `"sunken"` and `"default"` blocks become translucent, without blur (a full-width blur is expensive).
|
|
37
|
+
- **Left solid:** `strong` and `tinted` sections (their text relies on the fill), form controls (readable input), buttons, badges.
|
|
38
|
+
- **Fallbacks:** with `prefers-reduced-transparency: reduce`, or in a browser without `backdrop-filter`, everything renders as the default solid finish.
|
|
39
|
+
|
|
40
|
+
| Token | Default | What it changes |
|
|
41
|
+
| --- | --- | --- |
|
|
42
|
+
| `--sinn-finish-glass-blur` | `16px` | Blur radius behind frosted surfaces |
|
|
43
|
+
| `--sinn-finish-glass-saturate` | `1.4` | Saturation boost of what shows through |
|
|
44
|
+
| `--sinn-finish-glass-opacity` | `74%` | How much of each surface's colour remains (dialogs and popovers add 12%) |
|
|
45
|
+
| `--sinn-finish-glass-chrome` | `80%` | The same for `Navbar` and `Footer` |
|
|
46
|
+
| `--sinn-finish-glass-band` | `70%` | The same for section bands |
|
|
47
|
+
| `--sinn-finish-glass-glow` | `100%` | Strength of the backdrop glows (0–100%). They blend the page surface toward `accent-soft`, a fill every palette already guarantees text on, so any value stays within checked contrast |
|
|
48
|
+
|
|
49
|
+
Set them in `sinn.tokens` (or `sinn.overrides`) like any token.
|
|
50
|
+
|
|
51
|
+
### Contrast
|
|
52
|
+
|
|
53
|
+
Palettes are checked on solid surfaces. Under glass, a surface shows a little of the backdrop through it, so check a client palette with the finish on, in a real browser: sample the rendered background behind each run of text, since a token-pair checker can't see what shows through. The backdrop only blends the page surface toward `accent-soft`, so text placed directly on the page keeps the contrast the palette was checked for. Text on frosted surfaces sees a little of that backdrop through the fill; lower `--sinn-finish-glass-opacity` only after rechecking.
|
|
54
|
+
|
|
55
|
+
### Costs and caveats
|
|
56
|
+
|
|
57
|
+
- `backdrop-filter` is GPU work per frosted element. Pages with dozens of cards on screen at once should raise the opacity or remove the blur from the repeated item in `sinn.overrides`.
|
|
58
|
+
- Nested glass (a card inside a dialog) only blurs what's inside the nearest frosted ancestor.
|
|
59
|
+
- An element with `backdrop-filter` becomes the containing block for `position: fixed` descendants. Top-layer elements (dialogs, popovers, the navbar's mobile sheet) aren't affected.
|
|
60
|
+
|
|
61
|
+
## Polished glass
|
|
62
|
+
|
|
63
|
+
`@sinnstack/ui/finishes/polished-glass.css`, `data-finish="polished-glass"`.
|
|
64
|
+
|
|
65
|
+
The bold version of glass: clear panels floating over a scene, like a portfolio over a background video.
|
|
66
|
+
|
|
67
|
+
```css
|
|
68
|
+
/* Your scene: a photo, or a video's poster. Root-relative or absolute URL. */
|
|
69
|
+
@layer sinn.overrides {
|
|
70
|
+
:root { --sinn-finish-polished-glass-image: url('/media/backdrop.jpg'); }
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- **Dark only.** The finish sets `color-scheme: dark` on the page, so every `light-dark()` token resolves to the active palette's own dark side. The palette still picks every colour and its dark-side contrast checks still apply; the page's light/dark switch has no effect while the finish is on. Sections forced to light (`data-scheme="light"`) stay light and solid.
|
|
75
|
+
- **Scene:** your image if you set one, otherwise gradients from the palette's accent and focus colours, under a scrim of the palette's sunken surface. For a video backdrop, put the video in your layout behind the page (fixed, `z-index: -1`) and leave the image unset; the scrim still applies.
|
|
76
|
+
- **Panels:** cards, panels, card-style disclosures and feature/step/quote cards, contact cards and form controls get a thin light tint (the palette's text colour at a few percent), a translucent rim, a highlight along the top edge, a soft drop shadow and a strong blur. Callouts keep their tone as tinted glass. Text gets a faint shadow, except on buttons, controls and solid fills.
|
|
77
|
+
- **Chrome and overlays:** the navbar, footer, dialogs, popovers, the consent banner and the mobile menu sheet carry more fill, because they sit over content rather than the scene.
|
|
78
|
+
- **Left solid:** `strong` and `tinted` sections and buttons.
|
|
79
|
+
- **Fallbacks:** without `backdrop-filter`, panels stay solid over the scene. With `prefers-reduced-transparency: reduce`, the scene and every translucent effect go away and the page is the palette's plain dark side.
|
|
80
|
+
|
|
81
|
+
| Token | Default | What it changes |
|
|
82
|
+
| --- | --- | --- |
|
|
83
|
+
| `--sinn-finish-polished-glass-image` | `none` | The scene: `url(…)` of a photo |
|
|
84
|
+
| `--sinn-finish-polished-glass-scrim` | `82%` | How much the scene is dimmed (the bottom gets 12% more) |
|
|
85
|
+
| `--sinn-finish-polished-glass-tint` | `7%` | Light tint of panels |
|
|
86
|
+
| `--sinn-finish-polished-glass-blur` | `14px` | Blur behind panels (chrome +4px, overlays ×1.5) |
|
|
87
|
+
| `--sinn-finish-polished-glass-saturate` | `1.6` | Saturation of what shows through |
|
|
88
|
+
| `--sinn-finish-polished-glass-chrome` | `55%` | Fill of the navbar and footer |
|
|
89
|
+
| `--sinn-finish-polished-glass-overlay` | `78%` | Fill of dialogs, popovers and the mobile sheet |
|
|
90
|
+
|
|
91
|
+
### The scrim and contrast
|
|
92
|
+
|
|
93
|
+
Text on panels is safe at any scene brightness: panels add the palette's own colours on top of a dimmed scene. The risk is text placed directly on the scene, such as an intro paragraph or a sidebar heading in muted text, over a bright part of the photo. At the default 82% scrim, muted text passed AA in every playground palette over a photo with a bright sky and a pale sun. A darker photo can take a lighter scrim (more of the scene shows); a brighter one may need more. Check the rendered page, not the tokens, after changing the image or the scrim.
|
|
94
|
+
|
|
95
|
+
## Scenes: aurora, autumn, rain, fog
|
|
96
|
+
|
|
97
|
+
Decorative scenes behind the page. Each is two fixed layers drawn with gradients only (no images, no JavaScript), animated with transforms, so they cost the browser almost nothing per frame. They sit behind the page: opaque cards and solid sections cover them, and they show on the page background and through glass.
|
|
98
|
+
|
|
99
|
+
```astro
|
|
100
|
+
---
|
|
101
|
+
import '@sinnstack/ui/finishes/glass.css';
|
|
102
|
+
import '@sinnstack/ui/finishes/aurora.css';
|
|
103
|
+
---
|
|
104
|
+
<html data-finish="glass aurora">
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
| Finish | What it draws | Colour | Tune |
|
|
108
|
+
| --- | --- | --- | --- |
|
|
109
|
+
| `aurora` | Large soft blobs drifting on 48s/62s loops | The palette's `accent-soft` | `--sinn-finish-aurora-color`, `-strength` (100%), `-duration` (48s) |
|
|
110
|
+
| `autumn` | Leaves falling with a sway, a warm glow from the top corner | Own warm colours at low opacity | `--sinn-finish-autumn-leaf-1/2/3`, `-glow`, `-tile` (420px), `-duration` (24s) |
|
|
111
|
+
| `rain` | Slanted streaks falling, a cool cast from above | Own cool colours at low opacity | `--sinn-finish-rain-streak`, `-cast`, `-tile` (240px), `-duration` (0.8s), `-slant` (12deg) |
|
|
112
|
+
| `fog` | Wide soft bands drifting sideways on 70s/98s loops | The palette's `neutral-soft` | `--sinn-finish-fog-color`, `-density` (95%), `-duration` (70s) |
|
|
113
|
+
|
|
114
|
+
- **One scene at a time.** Every scene uses the root's `::before` and `::after`; two scenes together overwrite each other. A scene combines fine with `glass` or `polished-glass`.
|
|
115
|
+
- **Contrast.** Aurora and fog only blend the page toward a soft fill the palette already guarantees text and muted text on, so page text keeps its contrast (links on `neutral-soft` aren't in the palette checks). Autumn's leaves and rain's streaks are low-opacity decoration in their own colours: check client sites in a browser if they put small muted text directly on the page.
|
|
116
|
+
- **Motion.** Scenes stand still with `prefers-reduced-motion: reduce` (unless `<html data-motion="full">`) and with `data-motion="reduce"`. Rain hides its streaks when still, since still rain reads as scratches; the cool cast stays.
|
|
117
|
+
- **Print.** Scene layers aren't printed.
|
|
118
|
+
|
|
119
|
+
## Surfaces: brutalist, clay, blueprint, paper
|
|
120
|
+
|
|
121
|
+
Finishes that change shape and texture rather than add a scene. They mostly set the library's geometry tokens (`--sinn-radius-*`, `--sinn-border-width-*`, `--sinn-shadow-s/m/l`), so every component follows, plus a border or shadow on panels and buttons. Shadows are built from the palette's own `--sinn-shadow-color` or text colour.
|
|
122
|
+
|
|
123
|
+
| Finish | What changes |
|
|
124
|
+
| --- | --- |
|
|
125
|
+
| `brutalist` | Zero radius (pills stay round), 2px/3px borders in the text colour, hard offset shadows (3/5/8px), 3px focus ring. Solid, outline and soft buttons get a hard shadow and press into it on click. |
|
|
126
|
+
| `clay` | Radii 0.75/1.25/2rem (controls 1rem), layered soft shadows, borderless panels with a faint inner shade, softly lifted buttons and callouts. |
|
|
127
|
+
| `blueprint` | A drafting grid behind the page: 1px lines of `border-subtle` every 24px and `border` every 120px (`--sinn-finish-blueprint-cell`, `-major`). Thin borders, 2–4px corners, no shadows, `border-strong` outlines on panels, tabular figures. |
|
|
128
|
+
| `paper` | A fine grain (two dot patterns in the text colour at 5%, `--sinn-finish-paper-grain`) on the page, panels, navbar and footer, and a letterpress shadow on headings (`--sinn-finish-paper-press`). Texture only: pair it with the Paper palette for the warm stock. |
|
|
129
|
+
|
|
130
|
+
- **Combining.** `glass`, `polished-glass`, `blueprint` and `paper` each set the page's root background, so use one of them at a time. Brutalist and clay only change geometry and combine with a scene (`data-finish="clay aurora"`). Brutalist and glass clash.
|
|
131
|
+
- **Contrast.** The grid lines and grain are hairline or a few percent of the text colour, so text keeps its contrast; brutalist and clay don't touch fills.
|
|
132
|
+
|
|
133
|
+
## Interactive: spotlight, holographic, day-cycle
|
|
134
|
+
|
|
135
|
+
Each has a stylesheet and a small script. The script only writes that finish's `--sinn-finish-<name>-*` variables (through the CSSOM, which a strict CSP allows), only acts while the finish is on, and is optional: without it the effect rests in a sensible default. `test/finishes/finish-contract.unit.mjs` checks that scripts set nothing else.
|
|
136
|
+
|
|
137
|
+
```astro
|
|
138
|
+
---
|
|
139
|
+
import '@sinnstack/ui/finishes/spotlight.css';
|
|
140
|
+
---
|
|
141
|
+
<html data-finish="spotlight">
|
|
142
|
+
<body>
|
|
143
|
+
<slot />
|
|
144
|
+
<script>import '@sinnstack/ui/finishes/scripts/spotlight';</script>
|
|
145
|
+
</body>
|
|
146
|
+
</html>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
| Finish | What it does | Script sets | Colour |
|
|
150
|
+
| --- | --- | --- | --- |
|
|
151
|
+
| `spotlight` | A pool of light behind the page follows the pointer (mouse and pen only; rests at the top centre on touch) | `-x`, `-y` on `<html>`, once per frame at most | `accent-soft` (`--sinn-finish-spotlight-color`, `-size` 32rem) |
|
|
152
|
+
| `holographic` | On hover or keyboard focus, cards, panels and card-style feature/step/quote items get an iridescent 1.5px ring; its sheen turns toward the pointer | `-angle` on the hovered element | Iridescent film colours on the edge only (`--sinn-finish-holographic-colors`, `-width`) |
|
|
153
|
+
| `day-cycle` | Warm light where the sun would be at the visitor's local time: rising at the start edge at 6:00, overhead at noon, setting at the end edge at 18:00; a faint cool glow at night. Mirrors in right-to-left pages | `-x`, `-y`, `-sun`, `-night` on `<html>`, on load and every 5 minutes | Blends toward `warning-soft` (sun, at most 70%) and `accent-soft` (night) |
|
|
154
|
+
|
|
155
|
+
- **Combining.** Spotlight uses `body::before` and day cycle `body::after`, so they combine with each other, with a scene and with glass. Holographic only touches the targeted cards' `::before` and combines with anything except other finishes that style those cards' borders heavily (brutalist).
|
|
156
|
+
- **Contrast.** Spotlight and the night glow stay inside palette-checked fills. Day cycle's sun blends toward `warning-soft`, where palettes check text and links but not muted text: check muted text on the page in a browser.
|
|
157
|
+
- **Motion.** None of them animate on their own except holographic's hover fade, which is instant under reduced motion. Day cycle moves only every five minutes.
|
|
158
|
+
|
|
159
|
+
## Night, spring, terminal
|
|
160
|
+
|
|
161
|
+
| Finish | What it does | Notes |
|
|
162
|
+
| --- | --- | --- |
|
|
163
|
+
| `night` | A starfield behind the page: tiny dots in the palette's text colour, two layers twinkling out of step (opacity only, 7s and 11s loops) | Dark only, like `polished-glass`: sets `color-scheme: dark`. A scene (root `::before`/`::after`). Still under reduced motion. |
|
|
164
|
+
| `spring` | Petals and pollen drifting down slowly with a sway, in pale light from the top corner | Own soft colours at low opacity (`--sinn-finish-spring-*`). A scene. Still under reduced motion; check small muted text on the page. |
|
|
165
|
+
| `terminal` | Fine horizontal scanlines over the page and a soft glow on text in each element's own colour | No animation and no flicker (WCAG 2.3.1). Scanlines sit above the page at low strength (`--sinn-finish-terminal-scanlines`, 30% of the shadow colour), so recheck contrast if you raise them. Turned off with `prefers-contrast: more`, forced colours and print. Uses `body::before`, like `spotlight`: one of the two. Reads best with a dark palette. |
|
package/docs/primitives.md
CHANGED
|
@@ -22,7 +22,7 @@ import { Container, Stack, Heading, Text, Button, Checkbox } from '@sinnstack/ui
|
|
|
22
22
|
- **Zero specificity.** Selectors are wrapped in `:where()` (the few cross-component exceptions are listed above) and live in `@layer sinn.primitives`. Any site or block CSS overrides them without `!important`.
|
|
23
23
|
- **Logical properties throughout** (`inline-size`, `margin-block`, `padding-inline`), so RTL works with no extra code.
|
|
24
24
|
- **No breakpoints.** Grid and the Flex switcher respond to their own width, so they behave the same in a sidebar or a full-width slot. Container sets `container-type: inline-size` so blocks inside can use `@container`.
|
|
25
|
-
- **Every component** takes `class` and forwards any other HTML attribute (`id`, `aria-*`, `data-
|
|
25
|
+
- **Every component** takes `class` and forwards any other HTML attribute (`id`, `aria-*`, `data-sinn-field`…). Most take `as` to render a semantic element.
|
|
26
26
|
- **Lists keep their semantics.** When Stack, Cluster or Grid render as `ul`/`ol`, list bullets are removed and `role="list"` is added back, because Safari/VoiceOver drop list semantics once `list-style: none` is set.
|
|
27
27
|
|
|
28
28
|
## Prop vocabulary
|
|
@@ -183,7 +183,7 @@ Shared props on Text, Heading, Label and Caption: `size` (`xs`–`4xl`), `tone`
|
|
|
183
183
|
| **Link** | `a` | `tone` (`accent · neutral · inherit`), `underline` (`always · hover · none`), `newTab` (adds hidden "(opens in a new tab)" text), `external` (auto-detected against `Astro.site`; adds arrow icon and `rel="external"`). Styles `aria-current` |
|
|
184
184
|
| **Label** | `label` (`as`: `span · legend · div · dt`) | `required` (visual `*`; also put `required` on the input), `optional` (true or a translated string) |
|
|
185
185
|
| **Caption** | `p` (`as`: `figcaption · small · span · div`) | Muted by default. Give it an `id` and reference it from `aria-describedby` |
|
|
186
|
-
| **Prose** | `div` (`as`: `article · section`) | Typography for content whose markup you don't control (CMS rich text, Markdown): headings, lists, quotes, code, tables, figures. `size` (`s · m · l`), `measure` (~65ch), `align`. Links stay underlined. Wrap embedded components in `class="sinn-not-prose"` so they keep their own look. For
|
|
186
|
+
| **Prose** | `div` (`as`: `article · section`) | Typography for content whose markup you don't control (CMS rich text, Markdown): headings, lists, quotes, code, tables, figures. `size` (`s · m · l`), `measure` (~65ch), `align`. Links stay underlined. Wrap embedded components in `class="sinn-not-prose"` so they keep their own look. For CMS rich text use `RichText` from `@sinnstack/ui/blocks` |
|
|
187
187
|
|
|
188
188
|
A `<button class="sinn-link">` (an action that reads like a link, e.g. "Cookie settings") loses its button chrome and looks like Link.
|
|
189
189
|
|
|
@@ -228,7 +228,7 @@ Each control is the native element first: radios, range inputs, `<details>`, in-
|
|
|
228
228
|
| **Accordion** | a group of `<details>` | ~1 KB | `variant`: `divided` (default; `bordered` is the deprecated name) or `card`. `mode="single"` uses the native `name` attribute. `headingLevel` wraps titles in headings (exposed inside the summary in Chrome; not yet checked with VoiceOver/NVDA). The script adds "Show all sections" (3+ sections; its row is reserved from first paint), ↑/↓/Home/End between headers, opens the section holding a `#link` target, and opens everything for printing |
|
|
229
229
|
| **Tabs** | in-page links + panels | ~1.4 KB | `variant`: `underline` or `pill` (`pills` deprecated). `fullWidth` stretches the tabs across the row (`fitted` deprecated). Without JS, links switch panels through `:target`. The script adds the ARIA tabs pattern: roles, one tab stop, ←/→ (↑/↓ vertical, mirrored in RTL), Home/End, automatic or `manual` activation, disabled tabs skipped. `/page#pricing` and links to `#pricing` select that tab; `syncHash` writes the selection to the URL. Vertical tabs move above the panels below 36rem (container query). Long lists scroll inside themselves and fade at the edge. Every panel prints under its label |
|
|
230
230
|
|
|
231
|
-
**Content for Accordion and Tabs** comes from `items` (`{ id, title/label, content? }`) plus a named slot per `id` for rich content: `<Fragment slot="pricing">…</Fragment>`. Accordion also takes a function child that renders any item, for content from a list: `{(item, i) => <RichText value={answers[i]} />}` (Astro can't name slots in a loop). Plain `content` strings are escaped. The `items` shape is what a CMS list gives you, so an FAQ or tabs block can map its
|
|
231
|
+
**Content for Accordion and Tabs** comes from `items` (`{ id, title/label, content? }`) plus a named slot per `id` for rich content: `<Fragment slot="pricing">…</Fragment>`. Accordion also takes a function child that renders any item, for content from a list: `{(item, i) => <RichText value={answers[i]} />}` (Astro can't name slots in a loop). Plain `content` strings are escaped. The `items` shape is what a CMS list gives you, so an FAQ or tabs block can map its CMS fields straight onto it.
|
|
232
232
|
|
|
233
233
|
**Events** (bubble, composed): `sinn-slider-change` `{ value }` on commit (native `input`/`change` fire too); `sinn-tab-change` `{ id, index, previousId }`. SegmentedControl fires the native `change`.
|
|
234
234
|
|
|
@@ -492,7 +492,7 @@ Run `pnpm --filter @sinnstack/ui check` to test every color pairing these compon
|
|
|
492
492
|
| Responsive | ✅ intrinsic, plus container queries |
|
|
493
493
|
| Uses tokens | ✅ |
|
|
494
494
|
| a11y | ✅ by design · ⏳ axe run in CI against `apps/playground` |
|
|
495
|
-
| CMS schema | n/a for primitives. Blocks (e.g. a card grid, a callout, an FAQ or tabs block) compose these and own their
|
|
495
|
+
| CMS schema | n/a for primitives. Blocks (e.g. a card grid, a callout, an FAQ or tabs block) compose these and own their CMS data shapes. Accordion and Tabs take CMS-shaped `items` |
|
|
496
496
|
| Size budget | ✅ 0 KB JS except Toggle (~300 B), Checkbox `indeterminate` (~100 B), Form `validate="inline"` (~1.5 KB gzipped), overlay fallback (~0.5 KB), Tooltip (~300 B), Table sorting (~1 KB), sparkline readout (~1 KB), FocusTrap (~1.6 KB), ReducedMotion (~0.8 KB), Slider (~2 KB), Tabs (~1.4 KB), Accordion (~1 KB). Budgets per island in `.size-limit.json` |
|
|
497
497
|
| Docs entry | ✅ this file |
|
|
498
498
|
| Visual-regression baseline | ✅ SegmentedControl, Slider, Disclosure, Accordion, Tabs: `test/controls/baseline` (light, dark, no-JS × 390/1024) · ⏳ the rest: capture from `apps/playground` (320 px, 768 px, 1280 px, 200% zoom, dark mode, RTL) |
|