@sinnstack/ui 0.0.0-stage → 0.2.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 +15 -0
- package/LICENSE +373 -0
- package/README.md +186 -2
- package/docs/blocks.md +364 -0
- package/docs/data.md +128 -0
- package/docs/motion.md +166 -0
- package/docs/primitives.md +510 -0
- package/docs/seo.md +187 -0
- package/docs/tokens.md +122 -0
- package/package.json +141 -3
- package/scripts/check-contrast.mjs +180 -0
- package/src/blocks/BlockRenderer.astro +54 -0
- package/src/blocks/CTABanner.astro +121 -0
- package/src/blocks/CTAPair.astro +110 -0
- package/src/blocks/CardGrid.astro +167 -0
- package/src/blocks/ConsentEmbed.astro +125 -0
- package/src/blocks/ConsentManager.astro +147 -0
- package/src/blocks/ConsentScript.astro +47 -0
- package/src/blocks/ContactCard.astro +164 -0
- package/src/blocks/ContactForm.astro +224 -0
- package/src/blocks/ErrorPage.astro +242 -0
- package/src/blocks/FAQ.astro +135 -0
- package/src/blocks/FeatureGrid.astro +148 -0
- package/src/blocks/Hero.astro +171 -0
- package/src/blocks/HeroCarousel.astro +220 -0
- package/src/blocks/HighlightCards.astro +107 -0
- package/src/blocks/LocationHours.astro +311 -0
- package/src/blocks/LogoCloud.astro +135 -0
- package/src/blocks/MaintenancePage.astro +168 -0
- package/src/blocks/MediaText.astro +177 -0
- package/src/blocks/PageHeader.astro +126 -0
- package/src/blocks/ProseSection.astro +98 -0
- package/src/blocks/Reviews.astro +194 -0
- package/src/blocks/RichText.astro +57 -0
- package/src/blocks/StatsBand.astro +117 -0
- package/src/blocks/Steps.astro +141 -0
- package/src/blocks/Testimonials.astro +144 -0
- package/src/blocks/Topbar.astro +158 -0
- package/src/blocks/cms/card-grid.ts +80 -0
- package/src/blocks/cms/consent.ts +45 -0
- package/src/blocks/cms/contact-card.ts +88 -0
- package/src/blocks/cms/contact-form.ts +55 -0
- package/src/blocks/cms/cta-banner.ts +48 -0
- package/src/blocks/cms/cta-pair.ts +63 -0
- package/src/blocks/cms/data-base.ts +7 -0
- package/src/blocks/cms/data.ts +257 -0
- package/src/blocks/cms/faq.ts +70 -0
- package/src/blocks/cms/feature-grid.ts +80 -0
- package/src/blocks/cms/fixtures.ts +599 -0
- package/src/blocks/cms/hero-carousel.ts +80 -0
- package/src/blocks/cms/hero.ts +77 -0
- package/src/blocks/cms/highlight-cards.ts +76 -0
- package/src/blocks/cms/images.ts +38 -0
- package/src/blocks/cms/index.ts +87 -0
- package/src/blocks/cms/location-hours.ts +149 -0
- package/src/blocks/cms/logo-cloud.ts +62 -0
- package/src/blocks/cms/media-text.ts +44 -0
- package/src/blocks/cms/page-header.ts +49 -0
- package/src/blocks/cms/pages.ts +81 -0
- package/src/blocks/cms/prose-section.ts +45 -0
- package/src/blocks/cms/reviews.ts +101 -0
- package/src/blocks/cms/shared.ts +115 -0
- package/src/blocks/cms/stats-band.ts +61 -0
- package/src/blocks/cms/steps.ts +67 -0
- package/src/blocks/cms/testimonials.ts +80 -0
- package/src/blocks/cms/topbar.ts +64 -0
- package/src/blocks/cms/types.ts +63 -0
- package/src/blocks/consent.ts +14 -0
- package/src/blocks/icons.ts +47 -0
- package/src/blocks/index.ts +42 -0
- package/src/blocks/internal/Actions.astro +29 -0
- package/src/blocks/internal/BlockHeader.astro +45 -0
- package/src/blocks/internal/BlockShell.astro +58 -0
- package/src/blocks/internal/CarouselScript.astro +7 -0
- package/src/blocks/internal/ConsentEmbedScript.astro +7 -0
- package/src/blocks/internal/ConsentManagerScript.astro +7 -0
- package/src/blocks/internal/HoursScript.astro +7 -0
- package/src/blocks/internal/Placeholder.astro +13 -0
- package/src/blocks/internal/RichTextNode.astro +133 -0
- package/src/blocks/internal/StandaloneDocument.astro +53 -0
- package/src/blocks/internal/tina.ts +19 -0
- package/src/blocks/internal/util.ts +23 -0
- package/src/blocks/lib/consent.ts +96 -0
- package/src/blocks/lib/contact.ts +86 -0
- package/src/blocks/lib/error-pages.ts +119 -0
- package/src/blocks/lib/faq.ts +37 -0
- package/src/blocks/lib/hours.ts +201 -0
- package/src/blocks/lib/maintenance.ts +129 -0
- package/src/blocks/lib/reviews.ts +22 -0
- package/src/blocks/lib/rich-text.ts +143 -0
- package/src/blocks/lib/slug.ts +12 -0
- package/src/blocks/registry.ts +79 -0
- package/src/blocks/scripts/carousel.ts +218 -0
- package/src/blocks/scripts/consent-embed.ts +105 -0
- package/src/blocks/scripts/consent-manager.ts +112 -0
- package/src/blocks/scripts/consent-store.ts +86 -0
- package/src/blocks/scripts/error-page.ts +71 -0
- package/src/blocks/scripts/hours.ts +106 -0
- package/src/blocks/scripts/maintenance.ts +109 -0
- package/src/blocks/styles/blocks.css +1320 -0
- package/src/blocks/styles/consent.css +102 -0
- package/src/blocks/styles/faq.css +28 -0
- package/src/blocks/styles/location.css +92 -0
- package/src/blocks/styles/prose-section.css +13 -0
- package/src/blocks/styles/quotes.css +123 -0
- package/src/blocks/styles/rich-text.css +14 -0
- package/src/blocks/types.ts +283 -0
- package/src/data/ChartAxis.astro +19 -0
- package/src/data/ChartContainer.astro +151 -0
- package/src/data/ChartLegend.astro +25 -0
- package/src/data/ChartSeries.astro +14 -0
- package/src/data/ChartTable.astro +17 -0
- package/src/data/ChartTooltip.astro +20 -0
- package/src/data/Sparkline.astro +55 -0
- package/src/data/cms.ts +190 -0
- package/src/data/index.ts +10 -0
- package/src/data/lib/chart.ts +450 -0
- package/src/data/lib/render.ts +219 -0
- package/src/data/lib/scale.ts +107 -0
- package/src/data/lib/sparkline.ts +117 -0
- package/src/data/scripts/chart.ts +324 -0
- package/src/data/styles/chart.css +392 -0
- package/src/motion/Marquee.astro +90 -0
- package/src/motion/MotionProvider.astro +50 -0
- package/src/motion/PageTransitions.astro +61 -0
- package/src/motion/Parallax.astro +44 -0
- package/src/motion/ParallaxLayer.astro +31 -0
- package/src/motion/RevealOnScroll.astro +59 -0
- package/src/motion/SceneRegistry.astro +38 -0
- package/src/motion/ScrollScene.astro +81 -0
- package/src/motion/index.ts +12 -0
- package/src/motion/integration.ts +48 -0
- package/src/motion/runtime/page-transitions.ts +68 -0
- package/src/motion/runtime/runtime.ts +180 -0
- package/src/motion/runtime/scenes.ts +248 -0
- package/src/motion/runtime/types.ts +103 -0
- package/src/motion/styles/motion.css +332 -0
- package/src/motion/transitions.ts +74 -0
- package/src/motion/virtual.d.ts +4 -0
- package/src/primitives/Accordion.astro +129 -0
- package/src/primitives/Breadcrumbs.astro +50 -0
- package/src/primitives/BulletList.astro +69 -0
- package/src/primitives/Button.astro +73 -0
- package/src/primitives/ButtonGroup.astro +54 -0
- package/src/primitives/Callout.astro +137 -0
- package/src/primitives/Caption.astro +35 -0
- package/src/primitives/Card.astro +72 -0
- package/src/primitives/CardContent.astro +24 -0
- package/src/primitives/CardFooter.astro +36 -0
- package/src/primitives/CardHeader.astro +86 -0
- package/src/primitives/Checkbox.astro +38 -0
- package/src/primitives/ChoiceGroup.astro +23 -0
- package/src/primitives/Cluster.astro +49 -0
- package/src/primitives/Container.astro +44 -0
- package/src/primitives/DescriptionList.astro +83 -0
- package/src/primitives/Dialog.astro +38 -0
- package/src/primitives/Disclosure.astro +67 -0
- package/src/primitives/Divider.astro +93 -0
- package/src/primitives/Drawer.astro +33 -0
- package/src/primitives/Fieldset.astro +80 -0
- package/src/primitives/Flex.astro +64 -0
- package/src/primitives/FocusRing.astro +63 -0
- package/src/primitives/FocusTrap.astro +64 -0
- package/src/primitives/Footer.astro +155 -0
- package/src/primitives/Form.astro +68 -0
- package/src/primitives/FormDescription.astro +26 -0
- package/src/primitives/FormError.astro +106 -0
- package/src/primitives/FormField.astro +72 -0
- package/src/primitives/Grid.astro +64 -0
- package/src/primitives/Heading.astro +45 -0
- package/src/primitives/IconButton.astro +48 -0
- package/src/primitives/Image.astro +125 -0
- package/src/primitives/Input.astro +84 -0
- package/src/primitives/Label.astro +50 -0
- package/src/primitives/Link.astro +81 -0
- package/src/primitives/LinkButton.astro +66 -0
- package/src/primitives/List.astro +39 -0
- package/src/primitives/ListItem.astro +178 -0
- package/src/primitives/MediaObject.astro +66 -0
- package/src/primitives/MetricCard.astro +276 -0
- package/src/primitives/NavLink.astro +81 -0
- package/src/primitives/NavMenu.astro +109 -0
- package/src/primitives/Navbar.astro +197 -0
- package/src/primitives/Panel.astro +153 -0
- package/src/primitives/Picture.astro +167 -0
- package/src/primitives/Popover.astro +95 -0
- package/src/primitives/Prose.astro +45 -0
- package/src/primitives/Radio.astro +21 -0
- package/src/primitives/Rating.astro +135 -0
- package/src/primitives/ReducedMotion.astro +90 -0
- package/src/primitives/SegmentedControl.astro +132 -0
- package/src/primitives/Select.astro +107 -0
- package/src/primitives/Sheet.astro +45 -0
- package/src/primitives/SkipLink.astro +31 -0
- package/src/primitives/Slider.astro +186 -0
- package/src/primitives/Spacer.astro +35 -0
- package/src/primitives/Stack.astro +51 -0
- package/src/primitives/Surface.astro +70 -0
- package/src/primitives/Switch.astro +22 -0
- package/src/primitives/Table.astro +382 -0
- package/src/primitives/Tabs.astro +126 -0
- package/src/primitives/Text.astro +56 -0
- package/src/primitives/Textarea.astro +73 -0
- package/src/primitives/Thumbnail.astro +154 -0
- package/src/primitives/Toggle.astro +99 -0
- package/src/primitives/Tooltip.astro +50 -0
- package/src/primitives/VisuallyHidden.astro +29 -0
- package/src/primitives/index.ts +103 -0
- package/src/primitives/internal/AccordionScript.astro +7 -0
- package/src/primitives/internal/ChoiceField.astro +89 -0
- package/src/primitives/internal/FocusTrapScript.astro +8 -0
- package/src/primitives/internal/FormValidationScript.astro +10 -0
- package/src/primitives/internal/IndeterminateScript.astro +13 -0
- package/src/primitives/internal/ModalPanel.astro +114 -0
- package/src/primitives/internal/OverlayScript.astro +7 -0
- package/src/primitives/internal/ReducedMotionScript.astro +7 -0
- package/src/primitives/internal/SliderScript.astro +7 -0
- package/src/primitives/internal/SparklineScript.astro +7 -0
- package/src/primitives/internal/TableSortScript.astro +7 -0
- package/src/primitives/internal/TabsScript.astro +7 -0
- package/src/primitives/internal/TooltipScript.astro +7 -0
- package/src/primitives/lib/deprecate.ts +47 -0
- package/src/primitives/lib/focus-trap.ts +197 -0
- package/src/primitives/lib/focus.ts +60 -0
- package/src/primitives/lib/image-plan.ts +82 -0
- package/src/primitives/lib/image.ts +129 -0
- package/src/primitives/lib/motion.ts +68 -0
- package/src/primitives/lib/slider.ts +170 -0
- package/src/primitives/scripts/accordion.ts +123 -0
- package/src/primitives/scripts/form-validation.ts +225 -0
- package/src/primitives/scripts/overlay.ts +71 -0
- package/src/primitives/scripts/reduced-motion.ts +59 -0
- package/src/primitives/scripts/slider.ts +150 -0
- package/src/primitives/scripts/sparkline.ts +131 -0
- package/src/primitives/scripts/table-sort.ts +68 -0
- package/src/primitives/scripts/tabs.ts +151 -0
- package/src/primitives/scripts/tooltip.ts +28 -0
- package/src/primitives/styles/a11y.css +104 -0
- package/src/primitives/styles/accordion.css +53 -0
- package/src/primitives/styles/breadcrumbs.css +59 -0
- package/src/primitives/styles/bullet-list.css +89 -0
- package/src/primitives/styles/button.css +237 -0
- package/src/primitives/styles/choice.css +164 -0
- package/src/primitives/styles/cluster.css +24 -0
- package/src/primitives/styles/container.css +19 -0
- package/src/primitives/styles/data.css +849 -0
- package/src/primitives/styles/disclosure.css +140 -0
- package/src/primitives/styles/divider.css +50 -0
- package/src/primitives/styles/flex.css +42 -0
- package/src/primitives/styles/form.css +241 -0
- package/src/primitives/styles/grid.css +36 -0
- package/src/primitives/styles/media.css +247 -0
- package/src/primitives/styles/nav.css +792 -0
- package/src/primitives/styles/overlay.css +362 -0
- package/src/primitives/styles/prose.css +146 -0
- package/src/primitives/styles/scale.css +175 -0
- package/src/primitives/styles/segmented.css +165 -0
- package/src/primitives/styles/slider.css +170 -0
- package/src/primitives/styles/spacer.css +17 -0
- package/src/primitives/styles/stack.css +25 -0
- package/src/primitives/styles/surface.css +403 -0
- package/src/primitives/styles/tabs.css +223 -0
- package/src/primitives/styles/typography.css +144 -0
- package/src/primitives/styles/utilities.css +24 -0
- package/src/primitives/types.ts +385 -0
- package/src/primitives/utils.ts +254 -0
- package/src/seo/JSONLD.astro +35 -0
- package/src/seo/SEOHead.astro +47 -0
- package/src/seo/cms.ts +80 -0
- package/src/seo/index.ts +10 -0
- package/src/seo/integration.ts +231 -0
- package/src/seo/lib/jsonld.ts +334 -0
- package/src/seo/lib/meta.ts +205 -0
- package/src/seo/lib/redirects.ts +283 -0
- package/src/seo/lib/robots.ts +33 -0
- package/src/seo/lib/rss.ts +98 -0
- package/src/seo/lib/sitemap.ts +105 -0
- package/src/seo/lib/url.ts +68 -0
- package/src/tokens/base.css +71 -0
- package/src/tokens/tokens.css +210 -0
package/docs/blocks.md
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
# @sinnstack/ui/blocks
|
|
2
|
+
|
|
3
|
+
Page sections built from `@sinnstack/ui/primitives`, ready for TinaCMS. They're static HTML with no JavaScript, except for three small scripts that each load only on pages that use them: HeroCarousel (1.8 KB gzipped), consent (about 2 KB for the manager or an embed, 3 KB for both) and LocationHours' "Open now" (1.9 KB). Everything works without them. Each section is a container-query container, so it lays out for the space it's given, not the viewport.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add @sinnstack/ui
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| Entry | What's in it |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `@sinnstack/ui/blocks` | `Hero`, `HeroCarousel`, `PageHeader`, `MediaText`, `CTABanner`, `CTAPair`, `FeatureGrid`, `Steps`, `CardGrid`, `LogoCloud`, `ContactCard`, `StatsBand`, `HighlightCards`, `ContactForm`, `ProseSection`, `FAQ`, `Testimonials`, `Reviews`, `LocationHours`, `RichText`, `ConsentManager`, `ConsentEmbed`, `ConsentScript`, `Topbar`, `BlockRenderer`, `blockIcons`, `telHref`, `faqStructuredData`, `locationStructuredData`, types |
|
|
12
|
+
| `@sinnstack/ui/blocks/cms` | Tina template fragments, defaults, fixtures, data → props mappers, `createImageResolver`, `topbarField` / `topbarProps`, `consentField` / `consentProps` |
|
|
13
|
+
| `@sinnstack/ui/blocks/consent` | `hasConsent`, `onConsentChange`, `setConsent`, `openConsentSettings`, `getConsentRecord`: consent in your own code |
|
|
14
|
+
| `@sinnstack/ui/blocks/rich-text` | `richTextPlain`, `isRichTextEmpty`, `safeLinkUrl`, `safeMediaUrl`: the rules RichText uses |
|
|
15
|
+
| `@sinnstack/ui/blocks/hours` | Hours grouping and formatting, `openStatus`, `directionsHref`, `mapEmbedSrc`, `locationStructuredData` |
|
|
16
|
+
| `@sinnstack/ui/blocks/faq` | `faqItems`, `faqStructuredData` |
|
|
17
|
+
| `@sinnstack/ui/blocks/contact` | `telHref`, `mailHref`, `contactHref`, `safeHref`: click-to-call and safe contact links |
|
|
18
|
+
| `@sinnstack/ui/blocks/registry` | `blockRegistry`: template name → component + mapper |
|
|
19
|
+
| `@sinnstack/ui/blocks/icons` | The built-in icon set |
|
|
20
|
+
|
|
21
|
+
## Two ways to use a block
|
|
22
|
+
|
|
23
|
+
**With props**, in code:
|
|
24
|
+
|
|
25
|
+
```astro
|
|
26
|
+
<Hero layout="split" heading="Websites that ship fast"
|
|
27
|
+
actions={[{ label: 'Book a visit', href: '/book' }, { label: 'See services', href: '/services' }]}
|
|
28
|
+
image={{ src: office, alt: 'A developer walking a client through a new site' }} />
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Slots still work where you need markup, for example `heading`, `description`, `actions`, `media`, `footer` and `empty`.
|
|
32
|
+
|
|
33
|
+
**From the CMS**, through the renderer:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
// tina/config.ts
|
|
37
|
+
import { blockTemplates } from '@sinnstack/ui/blocks/cms';
|
|
38
|
+
// media: { tina: { publicFolder: 'src', mediaRoot: 'assets/uploads' } } ← keeps uploads optimizable
|
|
39
|
+
fields: [{ type: 'object', name: 'blocks', label: 'Sections', list: true, templates: blockTemplates }]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```astro
|
|
43
|
+
---
|
|
44
|
+
import { BlockRenderer } from '@sinnstack/ui/blocks';
|
|
45
|
+
import { createImageResolver } from '@sinnstack/ui/blocks/cms';
|
|
46
|
+
const resolveImage = createImageResolver(import.meta.glob('/src/assets/**/*.{jpg,jpeg,png,webp,avif,svg}', { eager: true }));
|
|
47
|
+
---
|
|
48
|
+
<BlockRenderer blocks={page.blocks} resolveImage={resolveImage} placeholder={isPreview} />
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The renderer works out each block's template from `_template`, or from Tina's `__typename` (`PageBlocksFeatureGrid` becomes `featureGrid`), and maps the CMS data to props. It also handles:
|
|
52
|
+
- **Heading levels:** editors never pick them. The first Hero is the page's h1, unless you pass `pageHasH1`, and every other section heading is an h2.
|
|
53
|
+
- **Click-to-edit:** it passes the raw data through so components can add `data-tina-field` attributes. It mirrors tinacms's `tinaField()`; check it against your Tina version.
|
|
54
|
+
- **Images:** CMS image paths become astro:assets images. An image it can't resolve is skipped with a dev warning, and a split or media Hero falls back to text-only rather than showing a broken image.
|
|
55
|
+
- **Unknown templates:** these are skipped, with a placeholder shown in preview.
|
|
56
|
+
- **Your own blocks:** `registry={{ ...blockRegistry, pricing: { component: Pricing, toProps } }}`. A Lit block is registered through a small `.astro` wrapper.
|
|
57
|
+
|
|
58
|
+
**CMS safety:** every CMS string is rendered as escaped text. Rich-text fields (ProseSection's body, FAQ answers) go through RichText, which renders only an allowlist of elements as Astro markup (never raw HTML) and keeps only safe URLs. Icons are chosen by name from the icon set, so raw SVG never comes from the CMS. Renaming or removing a field is a breaking change and needs a major version with a migration note.
|
|
59
|
+
|
|
60
|
+
## Shared props (every block)
|
|
61
|
+
|
|
62
|
+
| Prop | Values | Notes |
|
|
63
|
+
| --- | --- | --- |
|
|
64
|
+
| `anchor` | string | Slugified into the section id (`"Our Services!"` → `#our-services`) |
|
|
65
|
+
| `background` | `none` · `subtle` · `sunken` · `tinted` · `strong` | `tinted` and `strong` take their color from `tone` |
|
|
66
|
+
| `tone` | `accent` · `neutral` | |
|
|
67
|
+
| `scheme` | `light` · `dark` | Forces a scheme for one band, such as a dark section on a light page |
|
|
68
|
+
| `spacing` | `none` · `s` · `m` · `l` · `xl` | Vertical padding |
|
|
69
|
+
| `align` | `start` · `center` | |
|
|
70
|
+
| `size` | `s` · `m` · `l` | Meaning varies by block: type scale, icon size or logo height |
|
|
71
|
+
| `containerSize` | `narrow` · `default` · `wide` · `full` | |
|
|
72
|
+
| `placeholder` | boolean | Defaults to on in `astro dev` and off in builds |
|
|
73
|
+
|
|
74
|
+
**Strong surfaces recolor their content.** On a `strong` background the block redefines the text tokens, so every primitive inside adapts: muted text, eyebrows, links, solid and outline buttons, and focus rings. Raised surfaces inside, such as cards, feature cards and logo tiles, switch back to the page's own colors. A contrast check covers every text element in every fixture, in light and dark.
|
|
75
|
+
|
|
76
|
+
**Naming:** blocks use the same prop vocabulary as the primitives (see "Prop vocabulary" in `@sinnstack/ui/primitives`): `variant` is the visual treatment, `layout` the arrangement, `tone` a colour family, `background` the band's fill, `itemTitleLevel` the heading level of each item, aspect ratios in CSS syntax (`'16/9'`).
|
|
77
|
+
|
|
78
|
+
**Renamed props and values.** The old names still work and look the same (the markup carries the new attribute values); `astro dev` logs a one-time warning for each. CMS content keeps its stored field names and old values: the mappers upgrade them, so no content migration is needed.
|
|
79
|
+
|
|
80
|
+
| Block | Old | New |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| Hero, LogoCloud | `variant` (`text · split · media`, `grid · strip`) | `layout` |
|
|
83
|
+
| CTABanner | `variant="filled"`, `"subtle"` | `variant="solid"`, `"soft"` |
|
|
84
|
+
| FeatureGrid, Steps | `variant="cards"` | `variant="card"` |
|
|
85
|
+
| ContactCard | `variant="card"` | `variant="outline"` |
|
|
86
|
+
| ContactForm | `variant="panel"` | `variant="outline"` |
|
|
87
|
+
| CardGrid | `mediaAspect="16-9"` (dash forms) | `mediaAspect="16/9"` |
|
|
88
|
+
| CardGrid, FeatureGrid, Steps | `itemHeadingLevel` | `itemTitleLevel` |
|
|
89
|
+
| MediaText | `pointStyle` (`check · bullet`) | `marker` (`check · dot`) |
|
|
90
|
+
| Topbar | `tone="subtle"` | `background="subtle"` |
|
|
91
|
+
| types | `HeadingLevelNumber` | `HeadingLevel` (re-exported from primitives) |
|
|
92
|
+
|
|
93
|
+
**Empty content:** with no heading, or no items, a block shows a dashed placeholder in dev and CMS preview, and renders nothing in production. The exception is CardGrid, which shows its `emptyMessage`.
|
|
94
|
+
|
|
95
|
+
## The blocks
|
|
96
|
+
|
|
97
|
+
**Hero**
|
|
98
|
+
- `layout`: `text`, `split` or `media`.
|
|
99
|
+
- Split stacks with the text first below 48rem of container width. `mediaPosition` and `mediaAspect` adjust the image.
|
|
100
|
+
- Media puts a scrim over a full-bleed image. That keeps every line of text at 4.5:1 or better, even over a pure white photo; this was measured on real pixels. `scrim="gradient"` darkens only the text side.
|
|
101
|
+
- Its image loads eagerly with `fetchpriority=high`, because it's usually the page's largest paint.
|
|
102
|
+
- Background images are decorative, so their alt is always empty. For a background video, use the `media` slot with `<ReducedMotion>`.
|
|
103
|
+
|
|
104
|
+
**CTABanner**
|
|
105
|
+
- `variant`: `solid` (strong panel), `soft` (tinted panel) or `outline`. Combine it with `tone` and `bleed`.
|
|
106
|
+
- When there's room, the text and the actions sit side by side. `align="center"` stacks them.
|
|
107
|
+
|
|
108
|
+
**FeatureGrid**
|
|
109
|
+
- Icons come from the built-in set (24 icons, including `check`, `shield`, `clock`, `phone` and `stethoscope`), or from your own `icons` map. `iconSvg` is for trusted markup written in code.
|
|
110
|
+
- `variant`: `plain`, `card` or `divided`. `layout`: `stacked` or `inline`. `itemTitleLevel` sets each item's heading level.
|
|
111
|
+
- `columns` is a maximum, and columns never get narrower than about 16rem.
|
|
112
|
+
- A linked item is clickable as a whole, but it is a single link, and the focus ring wraps the whole item.
|
|
113
|
+
|
|
114
|
+
**CardGrid**
|
|
115
|
+
- `layout`: `grid` or `list`. `variant`: `outline`, `elevated` or `filled`. `mediaAspect`: `16/9`, `3/2`, `4/3` or `1/1`. In a list, the image takes a capped share of each card and stacks above the text when narrow.
|
|
116
|
+
- `featured`: the first card spans two columns, with its image filling the card's height. When two columns don't fit, it becomes a normal card.
|
|
117
|
+
- Cards in a row share a height, and each card is one link. `priorityCount` loads the first N images eagerly.
|
|
118
|
+
|
|
119
|
+
**LogoCloud**
|
|
120
|
+
- `layout`: `grid` (stepping down to 3 and then 2 columns) or `strip`.
|
|
121
|
+
- **Sizing:** `size` sets the logo height (24, 36 or 48px). A logo wider than its cell scales down as a whole.
|
|
122
|
+
- **Image handling:** raster logos are resized for that height at 2× and converted to WebP; SVGs are used as-is.
|
|
123
|
+
- `alt` is required: the organization's name.
|
|
124
|
+
- `mono` shows logos in grayscale until hover or focus. `tile` puts each logo on a white tile.
|
|
125
|
+
|
|
126
|
+
**HeroCarousel**
|
|
127
|
+
- A few rotating hero messages over full-bleed images. Use it sparingly: most visitors only see the first slide, so put the main message there.
|
|
128
|
+
- **Without JavaScript** it's a horizontal scroll-snap strip: every slide is real HTML, swipeable, and reachable by keyboard (the strip is focusable).
|
|
129
|
+
- **With JavaScript** (1.8 KB gzipped) it follows the WAI-ARIA APG carousel pattern:
|
|
130
|
+
- Previous/next buttons and a slide picker. Arrow keys, Home and End work on the focused strip.
|
|
131
|
+
- Inactive slides are `inert`. Swipes keep the controls in sync.
|
|
132
|
+
- Event: `sinn-slide-change` with `{ index, previousIndex }`.
|
|
133
|
+
- **Autoplay is off by default.** `autoplay={7}` rotates every 7 seconds (5 at least) and shows a pause/play button first in the tab order (WCAG 2.2.2).
|
|
134
|
+
- It never starts with reduced motion.
|
|
135
|
+
- It pauses on hover, while focus is inside, while the tab is hidden and while the carousel is off screen.
|
|
136
|
+
- The live region is off while it rotates and polite when a person moves it.
|
|
137
|
+
- Slides use the Hero media scrim. Background images are decorative, so their alt is always empty. The first image loads with high priority and the rest lazily.
|
|
138
|
+
- Slide headings are h2. With `headingLevel={1}` only the first slide's heading is an h1. BlockRenderer never gives a carousel the page's h1.
|
|
139
|
+
- `minHeight` (`m` · `l` · `screen`), `scrim` (`even` · `gradient`), `size`, `align`, and `labels` for other languages.
|
|
140
|
+
|
|
141
|
+
**PageHeader**
|
|
142
|
+
- The top band of an inner page: breadcrumbs, the page title (h1), and an optional eyebrow, intro and actions. Use it instead of a Hero on services, programs and contact pages.
|
|
143
|
+
- `breadcrumbs` is the trail from Home. The heading is added as the current crumb automatically. `breadcrumbPosition`: `above` (default) or `below` the title.
|
|
144
|
+
- BlockRenderer gives the page's h1 to the first Hero **or** PageHeader (`h1: true` in the registry).
|
|
145
|
+
- Background defaults to `subtle`. `strong` makes a colored band and recolors the breadcrumbs.
|
|
146
|
+
|
|
147
|
+
**MediaText**
|
|
148
|
+
- An image beside eyebrow, heading, intro, a checklist (`points`) and actions: the everyday "welcome / about / how we help" section.
|
|
149
|
+
- `mediaPosition`, `mediaAspect`, `mediaWidth` (`s` 40% · `m` 50% · `l` 58%), `stackOrder` (`media` or `text` first when stacked), `verticalAlign`, `marker` (`check` · `dot`, like BulletList).
|
|
150
|
+
- Stacks under a 48rem-wide container.
|
|
151
|
+
|
|
152
|
+
**Steps**
|
|
153
|
+
- A short process in order, as a real `<ol>`. The number or icon badge is `aria-hidden`, so the position isn't read twice.
|
|
154
|
+
- `marker`: `number`, `icon` or `none`. `layout`: `row` (side by side, joined by a connector, stacking under 44rem) or `list` (vertical with a line down the markers). `variant`: `plain` or `card`. `start` continues numbering.
|
|
155
|
+
|
|
156
|
+
**ContactCard**
|
|
157
|
+
- Address, phone, fax, email, hours and links. Each item's `type` picks its icon and link:
|
|
158
|
+
- Phones become click-to-call: `(888) 450-2884` → `tel:+18884502884`. Extensions and capital-letter vanity numbers are handled, and `countryCode` covers numbers outside the US.
|
|
159
|
+
- Fax numbers, addresses and hours are never links.
|
|
160
|
+
- Only http(s), mailto, tel, sms and relative URLs are linked, so CMS content can't inject other schemes.
|
|
161
|
+
- Addresses render in `<address>` with their line breaks.
|
|
162
|
+
- `embedded`: just the card, for a sidebar or grid column. `variant`: `outline` or `plain`. `columns`: up to 3 on wide containers.
|
|
163
|
+
- `note` is small print. Say what not to send by email: "Please don't email passwords or API keys."
|
|
164
|
+
|
|
165
|
+
**CTAPair**
|
|
166
|
+
- Two calls to action side by side on strong panels, one per audience ("Start a new project" beside "Agency partner?").
|
|
167
|
+
- By default, the first panel is `accent` and the second `neutral`; `tone` per panel overrides that. `bleed` (default) runs them edge to edge with no gap. Otherwise they're rounded panels in the container.
|
|
168
|
+
- Stacks under 40rem. A third panel is ignored. With only one, use CTABanner.
|
|
169
|
+
- The section has no heading of its own, so pass `label` to name it.
|
|
170
|
+
|
|
171
|
+
**StatsBand**
|
|
172
|
+
- A few headline figures ("24 · hours a day") in a strong band, optionally over a photo under the tone color (`--sinn-stats-wash`, 88%).
|
|
173
|
+
- Real text in a `<dl>`, value shown above its label. Never count up from 0: crawlers, no-JS and reduced-motion visitors would read zeros.
|
|
174
|
+
- `label` names the section when there's no `heading`. Up to 6 items; optional decorative `icon` per item. For dashboard metrics use MetricCard.
|
|
175
|
+
|
|
176
|
+
**HighlightCards**
|
|
177
|
+
- 2–4 solid-color cards (heading, text or bullet points, a button), e.g. "New projects · Agency partners · Support hours" under a hero.
|
|
178
|
+
- `tone` per card: `accent`, `neutral` or any tone your theme defines with `[data-surface][data-tone='name']`. Defaults alternate.
|
|
179
|
+
- `overlap` pulls the row up over the section above on wide screens (`--sinn-highlight-overlap`). `gap="none"` (one band) or `m` (separate cards).
|
|
180
|
+
- Buttons line up at the bottom of every card. Actions can take `arrow: true`.
|
|
181
|
+
|
|
182
|
+
**ContactForm**
|
|
183
|
+
- A message form that's honest about where it posts: `action` or `PUBLIC_FORM_ENDPOINT`. Without either, it shows a warning with `fallbackPhone` / `fallbackEmail` instead of pretending to send. The endpoint is never a CMS field.
|
|
184
|
+
- Default fields: first + last name (or `nameFields="single"`), `phone` (optional · required · hidden), email, message with `messageHint`. Your own fields in the default slot replace them (project brief, booking…).
|
|
185
|
+
- Honeypot field, hidden `source_page` (`source`), inline validation, `note` beside the button. `bare` renders just the form for your own layout; otherwise a section with heading and description. `variant`: `outline` (a raised, bordered panel) or `plain`.
|
|
186
|
+
- For sensitive details (health, legal or financial), the endpoint's provider must sign the right agreement (e.g. a HIPAA BAA).
|
|
187
|
+
|
|
188
|
+
**ProseSection** (template `proseSection`, label "Text")
|
|
189
|
+
- A section of long-form text: an about story, a policy, service details. Eyebrow, heading, buttons and a rich-text `body` (Tina rich text or plain text).
|
|
190
|
+
- Rendered by RichText (below). Headings in the body are placed under the section heading automatically, so an editor's "H1" never competes with the page title.
|
|
191
|
+
- `measure` (default on) keeps lines at about 65 characters; `size` is `s`, `m` or `l`.
|
|
192
|
+
|
|
193
|
+
**RichText** (component, not a block)
|
|
194
|
+
- Renders a Tina rich-text field (or plain text) inside the Prose primitive. Use it in your own layouts, e.g. for a blog post body.
|
|
195
|
+
- Only these render: paragraphs, headings, lists, links, quotes, code, images, rules, tables, and bold, italic, strikethrough and code text. Raw HTML, MDX templates and anything unknown are dropped, with a dev warning. Links keep only http(s), mailto, tel, sms and relative URLs; images only http(s) and site paths.
|
|
196
|
+
- `headingLevel` (default 2) is where the content's top heading lands; lower headings keep their spacing.
|
|
197
|
+
- Pass `resolveImage` so CMS images become optimized assets with a known size. Wide tables and code blocks scroll inside a focusable region, never the page.
|
|
198
|
+
|
|
199
|
+
**FAQ** (template `faq`)
|
|
200
|
+
- Questions as an Accordion: each is a native `<details>` with the question as a real heading (`itemTitleLevel`, default one below the section heading), so answers open without JavaScript and screen-reader users can jump between questions.
|
|
201
|
+
- Each question gets an id from its text (`/faq#what-does-a-site-cost` opens it); set `id` (the CMS field is "Link ID") to keep a link stable when the wording changes. Repeated questions get `-2`, `-3`…
|
|
202
|
+
- Answers are rich text or plain text. Questions without an answer are left out.
|
|
203
|
+
- `layout`: `stacked` or `split` (header and buttons beside the questions on wide containers). `variant`: `divided` or `card`. `mode`: `multiple` or `single`. `openFirst`. `actions` for "Ask us something else".
|
|
204
|
+
- **Structured data:** `faqPage(faqStructuredData(items), { url })` from `@sinnstack/ui/seo/jsonld`. One FAQPage per page, only for questions the page answers. Google currently shows FAQ results mainly for government and health sites; the markup is still valid for everyone.
|
|
205
|
+
|
|
206
|
+
**Testimonials** (template `testimonials`)
|
|
207
|
+
- Quotes with a name, role, company, optional portrait, star rating and source. Each is a `<figure>` with the words in a `<blockquote>` and the person in the `<figcaption>`. The portrait and quote mark are decorative.
|
|
208
|
+
- `layout`: `grid` (as many columns as fit, at most `columns`, sharing a height per row) or `single` (one large quote). `variant`: `card` or `plain`. No carousel, so every quote stays readable.
|
|
209
|
+
- Real quotes only, word for word and with permission. Reworded or invented testimonials mislead visitors and break consumer-protection rules (for example the FTC's rule on fake reviews and testimonials).
|
|
210
|
+
|
|
211
|
+
**Reviews** (template `reviews`)
|
|
212
|
+
- Published reviews with stars, author, date (`<time datetime>`, formatted for `locale`), source and an optional owner reply, under an optional overall rating ("4.9 · 37 reviews on Google", with "Read all reviews" and "Leave a review" links).
|
|
213
|
+
- Show reviews as written, including the critical ones. Ratings outside 1–`max` are left out, and the rest round to halves.
|
|
214
|
+
- No review structured data on purpose: a business's reviews of itself don't earn review stars in Google results.
|
|
215
|
+
|
|
216
|
+
**LocationHours** (template `locationHours`)
|
|
217
|
+
- Address (in `<address>`), phone and email links, a directions link, opening hours, holiday hours and a map.
|
|
218
|
+
- Hours are grouped ("Mon–Fri 9:00 AM – 5:00 PM") and formatted for `locale`, with day ranges read in full by screen readers ("Monday to Friday"). Days no row mentions are closed. A range that ends at or before it starts runs past midnight; 00:00–24:00 is open all day.
|
|
219
|
+
- **Open now** is worked out in the browser in the business's `timeZone` (not the visitor's), with today's row marked, re-checked every minute. Without JavaScript or without `timeZone` it's left out rather than guessed at build time.
|
|
220
|
+
- `special` (holiday hours) override the regular hours on their date; past dates hide themselves.
|
|
221
|
+
- `map`: `embed` (default: a Google Maps embed through ConsentEmbed, so Google gets nothing until the visitor allows it), `link` (links only) or `none`. `mapEmbedUrl` for your own embed link; `mapPoster` for a local still behind the consent notice.
|
|
222
|
+
- `layout`: `split` (details beside the map when there's room) or `stacked`.
|
|
223
|
+
- **Structured data:** `localBusiness({ ...locationStructuredData(props), name, url, type })` from `@sinnstack/ui/seo/jsonld`.
|
|
224
|
+
|
|
225
|
+
**Topbar** (site chrome, not a page block)
|
|
226
|
+
- The thin strip above the Navbar: contact items (same shape as ContactCard), quick or social `links`, or a `message`.
|
|
227
|
+
- Put it in the layout after SkipLink and before Navbar. It's a named region landmark ("Contact information").
|
|
228
|
+
- Below `collapse` (default 48rem of viewport), only phone numbers stay visible, so the bar never wraps on a phone.
|
|
229
|
+
- `background`: `strong` (default), `tinted` or `subtle`; `tone`: `neutral` (dark) or `accent` for the first two. Its content comes from site settings: add `topbarField()` to your Tina settings collection and pass `topbarProps(settings.topbar)` to `<Topbar>`.
|
|
230
|
+
|
|
231
|
+
## Consent
|
|
232
|
+
|
|
233
|
+
Nothing third-party loads before the visitor allows it: embedded maps and videos, analytics, marketing tags. These components check that for you. They're the mechanism, not legal advice; check the wording and categories against the privacy laws that apply to the site.
|
|
234
|
+
|
|
235
|
+
**ConsentManager** (site chrome; put it right after SkipLink in your layout)
|
|
236
|
+
- A banner fixed to the bottom of the screen: "Accept all" and "Reject all" side by side with the same style, and "Choose", which opens a dialog with a switch per category, all off until the visitor turns one on (this also honors a browser's Global Privacy Control signal).
|
|
237
|
+
- `categories`: the ones the site uses, as presets (`media`, `analytics`, `marketing`) or your own `{ id, label, description }`. "Necessary" is always listed and always on.
|
|
238
|
+
- Add a "Cookie settings" link anywhere with `data-consent-open` (e.g. `<button type="button" class="sinn-link" data-consent-open>Cookie settings</button>` in the footer). The dialog shows the saved choices.
|
|
239
|
+
- Choices are kept in localStorage (`sinn-consent`) with the policy `version` and the date. Bump `version` when you add a category or change what one covers, and everyone is asked again. Choices expire after `maxAgeDays` (default 365).
|
|
240
|
+
- Revoking a category unloads its embeds. If its scripts already ran, the page reloads so they stop.
|
|
241
|
+
- The banner is early in the tab order, never traps focus, and the page reserves room at its end so the banner doesn't cover the last content. Without JavaScript it's hidden, since nothing would need consent.
|
|
242
|
+
- From the CMS: add `consentField()` to your Tina settings and pass `consentProps(settings.consent)`.
|
|
243
|
+
|
|
244
|
+
**ConsentEmbed**
|
|
245
|
+
- An iframe (`src`, required `title`, `provider`, `kind`, `aspect`) that stays in an inert `<template>` until its `category` (default `media`) is allowed, so the browser makes no request to the provider.
|
|
246
|
+
- In its place: who hosts it, what loading it shares, "Load video" (this embed, this visit, nothing stored), "Always allow embedded content" (saves consent for the category) and a link to open it on the provider's site. Without JavaScript only the link shows.
|
|
247
|
+
- Keyboard focus moves into the embed once the visitor loads it. The box keeps its aspect ratio before and after, and grows to fit the notice on narrow screens.
|
|
248
|
+
- Your CSP needs `frame-src` for the provider.
|
|
249
|
+
|
|
250
|
+
**ConsentScript**
|
|
251
|
+
- A third-party script (`src`, `category`, default `analytics`) that's added to `<head>` only after consent, at most once per page view. Only `src` scripts: put a vendor's inline snippet in a file you host. Your CSP's `script-src` must list the vendor.
|
|
252
|
+
|
|
253
|
+
**In your own code:** `hasConsent('analytics')`, `onConsentChange(({ choices }) => …)`, `openConsentSettings()` from `@sinnstack/ui/blocks/consent`. The event is `sinn-consent-change` on `document`.
|
|
254
|
+
|
|
255
|
+
## Site pages
|
|
256
|
+
|
|
257
|
+
### ErrorPage
|
|
258
|
+
|
|
259
|
+
404, 410, 403 and 500 pages that lead visitors back into the site.
|
|
260
|
+
|
|
261
|
+
```astro
|
|
262
|
+
<!-- src/pages/404.astro: inside your normal layout -->
|
|
263
|
+
<Site title="Page not found">
|
|
264
|
+
<ErrorPage status={404} links={popular} pages={allPages} search={{ action: '/search' }}
|
|
265
|
+
contact={{ text: 'Need help now?', label: 'Call (817) 555-0100', href: 'tel:+18175550100' }} />
|
|
266
|
+
</Site>
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
```astro
|
|
270
|
+
---
|
|
271
|
+
// src/pages/500.astro: standalone, so a broken layout, nav data or CMS can't take this page down too
|
|
272
|
+
const { error } = Astro.props;
|
|
273
|
+
---
|
|
274
|
+
<ErrorPage status={500} document siteName="Sinnstack" error={error} />
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
- **Copy:** calm copy per status (`errorCopy`). Override it with `heading`, `description` and `eyebrow`, or from the CMS with `errorPagesField` and `errorPageProps`.
|
|
278
|
+
- **Missing pages (404 and 410):**
|
|
279
|
+
- **Failed address:** shown as text. It's rendered on the server with on-demand rendering, and by the browser on a prerendered 404.
|
|
280
|
+
- **"Did you mean…?":** suggests the closest page from `pages`. It catches typos (`/servcies`), case, `.html` and trailing slashes, pages that moved with the same slug, and reordered words. When nothing is close, it suggests nothing.
|
|
281
|
+
- **Site search:** if you pass `search`, the box is prefilled with words from the broken address.
|
|
282
|
+
- **Server errors (500+):** "Try again" reloads the failing URL, and home becomes the secondary action. `error` details appear only when `showDetails` is on (in development by default), and only as escaped text.
|
|
283
|
+
- **"Go back":** appears only when the visitor came from another page of this site.
|
|
284
|
+
- **Popular pages:** `links` (up to about six) render as a labelled `<nav>`, with icons by name. They sit in two columns under the text, or across the full width when there's a `media` slot illustration.
|
|
285
|
+
- **Analytics:** fires `sinn:error-page` with `{ status, path, referrer }` on `document`.
|
|
286
|
+
- **Status and indexing:** the HTTP status comes from the page. Astro sends 404 and 500 for those routes; elsewhere, set `Astro.response.status`. Add `noindex` in your layout; `document` mode adds it for you.
|
|
287
|
+
|
|
288
|
+
### MaintenancePage
|
|
289
|
+
|
|
290
|
+
```astro
|
|
291
|
+
<!-- src/pages/maintenance.astro -->
|
|
292
|
+
<MaintenancePage siteName="Sinnstack" until="2026-11-15T15:00:00-06:00" timeZone="America/Chicago"
|
|
293
|
+
notice="Client dashboards are unaffected. Urgent issue? Call (817) 555-0100."
|
|
294
|
+
contact={[{ label: 'Call (817) 555-0100', href: 'tel:+18175550100' }]} />
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
- **Standalone:** by default it renders a complete, self-contained page, with no layout, CMS or nav data, because those may be down too.
|
|
298
|
+
- **Return time:** `until` is rendered in the site's `timeZone`, then shown in the visitor's own zone with "(in about 2 hours)", kept up to date. Once that time passes, the page says it's taking longer than planned instead of showing a time in the past.
|
|
299
|
+
- **Comes back by itself:**
|
|
300
|
+
- After `until` (or right away when there isn't one), the page checks the site every `pollInterval` seconds, with backoff. It only checks while the tab is visible and the browser is online, and reloads once the real site answers.
|
|
301
|
+
- It recognizes its own page, so a host that wrongly serves the maintenance page with a 200 can't cause a reload loop.
|
|
302
|
+
- "Check now" checks on demand and announces the result in a live region.
|
|
303
|
+
- Without JS, the button and the "will reload" note stay hidden.
|
|
304
|
+
- **Serve it with a 503 and `Retry-After`,** so search engines treat the outage as temporary.
|
|
305
|
+
- **SSR sites:**
|
|
306
|
+
```ts
|
|
307
|
+
// src/middleware.ts
|
|
308
|
+
import { createMaintenanceMiddleware } from '@sinnstack/ui/blocks/maintenance';
|
|
309
|
+
export const onRequest = createMaintenanceMiddleware({
|
|
310
|
+
enabled: () => import.meta.env.MAINTENANCE === 'on',
|
|
311
|
+
until: import.meta.env.MAINTENANCE_UNTIL,
|
|
312
|
+
bypassToken: import.meta.env.MAINTENANCE_BYPASS, // team: visit /?maintenance-bypass=<token> once
|
|
313
|
+
allow: ['/api/health'],
|
|
314
|
+
});
|
|
315
|
+
```
|
|
316
|
+
- **What gets through:** assets, `/_image`, `robots.txt`, favicons and the maintenance route.
|
|
317
|
+
- **How it answers:** HTML requests get the page with `503`, `Retry-After` and `no-store`. JSON clients and form posts get a JSON 503 instead, so a submission isn't swallowed by an HTML page.
|
|
318
|
+
- **Bypass:** the bypass sets an httpOnly cookie for 12 hours, and the token is compared in constant time.
|
|
319
|
+
- **Static hosts:** build `/maintenance` and have your host or CDN serve it for all paths with status 503 and a `Retry-After` header. That usually needs an edge function or rule; see your host's docs.
|
|
320
|
+
|
|
321
|
+
## Testing
|
|
322
|
+
|
|
323
|
+
`test/content-blocks` (see its README):
|
|
324
|
+
- **Real code, no Astro:** it runs the real CMS mappers on the fixtures, then renders replica pages with the real CSS in Chrome. **70 checks**:
|
|
325
|
+
- Structure: one h1, labelled landmarks, unique ids.
|
|
326
|
+
- Layout at 1280, 900, 700, 390 and 320px and at 200% zoom.
|
|
327
|
+
- Scrim contrast over a white photo.
|
|
328
|
+
- A contrast sweep of every text node in light and dark.
|
|
329
|
+
- Focus rings on strong surfaces.
|
|
330
|
+
- The featured and list card layouts, logo sizing, placeholders, `data-tina-field`, anchors, RTL and forced colors.
|
|
331
|
+
- The schema: template fields are well-formed, and fixtures and defaults only use fields in the schema.
|
|
332
|
+
- **Visual regression:** `visual_regression.py` compares 68 baseline screenshots (every fixture, light and dark, at 390 and 1280px).
|
|
333
|
+
|
|
334
|
+
Newer blocks (HeroCarousel, PageHeader, MediaText, Steps, ContactCard, CTAPair, StatsBand, HighlightCards, ContactForm, Topbar):
|
|
335
|
+
- `test/unit/new-blocks.unit.mjs`: 51 tests covering phone normalization (extensions, vanity numbers, short codes, prose that isn't a number), link-scheme safety, and every mapper's edge cases (dropped items, unknown icons, the autoplay minimum, heading levels).
|
|
336
|
+
- The schema check in `test/content-blocks` covers their templates and fixtures too.
|
|
337
|
+
- **No replica pages yet.** They're browser-tested against the real `astro build` of the playground (`/program`, `/blocks-new` and `/sections`):
|
|
338
|
+
- axe in light, dark and mobile.
|
|
339
|
+
- Carousel behavior: buttons, picker, keys, swipe sync, autoplay pause and hover, reduced motion, no-JS and RTL.
|
|
340
|
+
- Click-to-call, the h1 and breadcrumb rules, no overflow at 320px or 200% zoom, and the phone-only topbar.
|
|
341
|
+
- Adding them to `generate_pages.py`, with visual baselines, is the next step.
|
|
342
|
+
|
|
343
|
+
ProseSection, RichText, FAQ, Testimonials, Reviews, LocationHours and the consent components:
|
|
344
|
+
- `test/astro-pages` builds **the real components with Astro** (no replica) under a strict CSP and runs **179 browser checks** (see its README):
|
|
345
|
+
- Every page in light and dark: no CSP violations or script errors, a contrast sweep of all text, and no horizontal scroll at 320, 390 and 768px. With `AXE_PATH` set, axe WCAG A/AA too.
|
|
346
|
+
- Rich text: heading shifting, unsafe links and images dropped, raw HTML and MDX never rendered, tables with a header row and a focusable scroll region.
|
|
347
|
+
- FAQ: ids, deep links, single mode, "Show all", arrow keys, no-JS.
|
|
348
|
+
- "Open now" at fixed times in America/Chicago, including a range past midnight, all-day and holiday hours.
|
|
349
|
+
- Consent: nothing under `/third-party/` is requested before consent; Accept, Reject, Choose, "Load video", "Always allow", revoking (embeds unload; scripts reload the page), old versions, expired and corrupt records, no-JS, focus handling, the banner never covering the page's end.
|
|
350
|
+
- CMS data through BlockRenderer, and right-to-left.
|
|
351
|
+
- `visual_regression.py`: 24 screenshots (6 pages, light and dark, 390 and 1280px).
|
|
352
|
+
- `test/unit/content-blocks.unit.mjs`: 34 tests for the rich-text rules, FAQ ids, review validation, hours and open-now logic, consent records and the five mappers. The schema check in `test/content-blocks` covers their templates and fixtures.
|
|
353
|
+
|
|
354
|
+
Site pages: `test/system-pages` (65 browser checks with a test server for real 404s and polling, 14 visual baselines) and `test/unit` (28 tests: suggestion matcher, copy, Retry-After, middleware).
|
|
355
|
+
|
|
356
|
+
```sh
|
|
357
|
+
pnpm test # the 28 + 51 + 34 unit tests
|
|
358
|
+
pnpm test:browser # the three browser suites
|
|
359
|
+
pnpm test:visual # the three screenshot suites
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Setup and flags: [TESTING.md](../../TESTING.md).
|
|
363
|
+
|
|
364
|
+
**Not yet verified:** Tina itself (the newer blocks are built with `astro build` in `test/astro-pages`). Load `blockTemplates` into a real `tina/config.ts` and confirm that visual editing picks up `data-tina-field`. For the site pages: `Astro.isPrerendered` and the `error` prop on 500.astro (Astro 5), and `context.rewrite` inside the maintenance middleware on your adapter.
|
package/docs/data.md
ADDED
|
@@ -0,0 +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 (Tina)
|
|
94
|
+
|
|
95
|
+
`@sinnstack/ui/data/cms` exports `chartField` and `sparklineField` for hand-entered data. 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.
|
|
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.
|