@sinnstack/ui 0.0.0-stage → 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.
Files changed (306) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/LICENSE +373 -0
  3. package/README.md +188 -2
  4. package/docs/blocks.md +373 -0
  5. package/docs/data.md +128 -0
  6. package/docs/finishes.md +165 -0
  7. package/docs/motion.md +166 -0
  8. package/docs/primitives.md +510 -0
  9. package/docs/seo.md +191 -0
  10. package/docs/tokens.md +122 -0
  11. package/package.json +132 -3
  12. package/scripts/check-contrast.mjs +180 -0
  13. package/src/blocks/BlockRenderer.astro +60 -0
  14. package/src/blocks/CTABanner.astro +121 -0
  15. package/src/blocks/CTAPair.astro +110 -0
  16. package/src/blocks/CardGrid.astro +167 -0
  17. package/src/blocks/ConsentEmbed.astro +125 -0
  18. package/src/blocks/ConsentManager.astro +147 -0
  19. package/src/blocks/ConsentScript.astro +47 -0
  20. package/src/blocks/ContactCard.astro +164 -0
  21. package/src/blocks/ContactForm.astro +224 -0
  22. package/src/blocks/ErrorPage.astro +242 -0
  23. package/src/blocks/FAQ.astro +135 -0
  24. package/src/blocks/FeatureGrid.astro +148 -0
  25. package/src/blocks/Hero.astro +171 -0
  26. package/src/blocks/HeroCarousel.astro +220 -0
  27. package/src/blocks/HighlightCards.astro +107 -0
  28. package/src/blocks/LocationHours.astro +311 -0
  29. package/src/blocks/LogoCloud.astro +135 -0
  30. package/src/blocks/MaintenancePage.astro +173 -0
  31. package/src/blocks/MediaText.astro +177 -0
  32. package/src/blocks/PageHeader.astro +126 -0
  33. package/src/blocks/ProseSection.astro +98 -0
  34. package/src/blocks/Reviews.astro +194 -0
  35. package/src/blocks/RichText.astro +58 -0
  36. package/src/blocks/StatsBand.astro +117 -0
  37. package/src/blocks/Steps.astro +141 -0
  38. package/src/blocks/Testimonials.astro +144 -0
  39. package/src/blocks/Topbar.astro +158 -0
  40. package/src/blocks/cms/card-grid.ts +48 -0
  41. package/src/blocks/cms/consent.ts +16 -0
  42. package/src/blocks/cms/contact-card.ts +46 -0
  43. package/src/blocks/cms/contact-form.ts +37 -0
  44. package/src/blocks/cms/cta-banner.ts +27 -0
  45. package/src/blocks/cms/cta-pair.ts +30 -0
  46. package/src/blocks/cms/data-base.ts +5 -0
  47. package/src/blocks/cms/data.ts +257 -0
  48. package/src/blocks/cms/faq.ts +38 -0
  49. package/src/blocks/cms/feature-grid.ts +47 -0
  50. package/src/blocks/cms/fixtures.ts +591 -0
  51. package/src/blocks/cms/hero-carousel.ts +36 -0
  52. package/src/blocks/cms/hero.ts +33 -0
  53. package/src/blocks/cms/highlight-cards.ts +41 -0
  54. package/src/blocks/cms/images.ts +37 -0
  55. package/src/blocks/cms/index.ts +59 -0
  56. package/src/blocks/cms/location-hours.ts +67 -0
  57. package/src/blocks/cms/logo-cloud.ts +36 -0
  58. package/src/blocks/cms/media-text.ts +26 -0
  59. package/src/blocks/cms/page-header.ts +27 -0
  60. package/src/blocks/cms/pages.ts +35 -0
  61. package/src/blocks/cms/prose-section.ts +25 -0
  62. package/src/blocks/cms/reviews.ts +50 -0
  63. package/src/blocks/cms/schema-dsl.ts +134 -0
  64. package/src/blocks/cms/schema.ts +794 -0
  65. package/src/blocks/cms/shared.ts +63 -0
  66. package/src/blocks/cms/stats-band.ts +35 -0
  67. package/src/blocks/cms/steps.ts +40 -0
  68. package/src/blocks/cms/testimonials.ts +46 -0
  69. package/src/blocks/cms/topbar.ts +27 -0
  70. package/src/blocks/cms/types.ts +27 -0
  71. package/src/blocks/consent.ts +14 -0
  72. package/src/blocks/icons.ts +47 -0
  73. package/src/blocks/index.ts +42 -0
  74. package/src/blocks/internal/Actions.astro +35 -0
  75. package/src/blocks/internal/BlockHeader.astro +45 -0
  76. package/src/blocks/internal/BlockShell.astro +58 -0
  77. package/src/blocks/internal/CarouselScript.astro +7 -0
  78. package/src/blocks/internal/ConsentEmbedScript.astro +7 -0
  79. package/src/blocks/internal/ConsentManagerScript.astro +7 -0
  80. package/src/blocks/internal/HoursScript.astro +7 -0
  81. package/src/blocks/internal/Placeholder.astro +13 -0
  82. package/src/blocks/internal/RichTextNode.astro +133 -0
  83. package/src/blocks/internal/StandaloneDocument.astro +53 -0
  84. package/src/blocks/internal/consent.ts +96 -0
  85. package/src/blocks/internal/fields.ts +18 -0
  86. package/src/blocks/internal/registry-contract.ts +67 -0
  87. package/src/blocks/internal/reviews.ts +22 -0
  88. package/src/blocks/internal/slug.ts +12 -0
  89. package/src/blocks/internal/util.ts +23 -0
  90. package/src/blocks/lib/contact.ts +92 -0
  91. package/src/blocks/lib/error-pages.ts +119 -0
  92. package/src/blocks/lib/faq.ts +37 -0
  93. package/src/blocks/lib/hours.ts +201 -0
  94. package/src/blocks/lib/maintenance.ts +129 -0
  95. package/src/blocks/lib/markdown.ts +350 -0
  96. package/src/blocks/lib/rich-text.ts +132 -0
  97. package/src/blocks/registry.ts +79 -0
  98. package/src/blocks/scripts/carousel.ts +218 -0
  99. package/src/blocks/scripts/consent-embed.ts +105 -0
  100. package/src/blocks/scripts/consent-manager.ts +112 -0
  101. package/src/blocks/scripts/consent-store.ts +86 -0
  102. package/src/blocks/scripts/error-page.ts +71 -0
  103. package/src/blocks/scripts/hours.ts +107 -0
  104. package/src/blocks/scripts/maintenance.ts +109 -0
  105. package/src/blocks/styles/blocks.css +1320 -0
  106. package/src/blocks/styles/consent.css +102 -0
  107. package/src/blocks/styles/faq.css +28 -0
  108. package/src/blocks/styles/location.css +92 -0
  109. package/src/blocks/styles/prose-section.css +13 -0
  110. package/src/blocks/styles/quotes.css +123 -0
  111. package/src/blocks/styles/rich-text.css +14 -0
  112. package/src/blocks/types.ts +293 -0
  113. package/src/data/ChartAxis.astro +19 -0
  114. package/src/data/ChartContainer.astro +152 -0
  115. package/src/data/ChartLegend.astro +25 -0
  116. package/src/data/ChartSeries.astro +14 -0
  117. package/src/data/ChartTable.astro +17 -0
  118. package/src/data/ChartTooltip.astro +20 -0
  119. package/src/data/Sparkline.astro +55 -0
  120. package/src/data/cms.ts +130 -0
  121. package/src/data/index.ts +10 -0
  122. package/src/data/internal/scale.ts +107 -0
  123. package/src/data/lib/chart.ts +459 -0
  124. package/src/data/lib/render.ts +219 -0
  125. package/src/data/lib/sparkline.ts +117 -0
  126. package/src/data/schema.ts +65 -0
  127. package/src/data/scripts/chart.ts +324 -0
  128. package/src/data/styles/chart.css +392 -0
  129. package/src/finishes/aurora.css +75 -0
  130. package/src/finishes/autumn.css +87 -0
  131. package/src/finishes/blueprint.css +69 -0
  132. package/src/finishes/brutalist.css +55 -0
  133. package/src/finishes/clay.css +48 -0
  134. package/src/finishes/day-cycle.css +46 -0
  135. package/src/finishes/fog.css +71 -0
  136. package/src/finishes/glass.css +149 -0
  137. package/src/finishes/holographic.css +91 -0
  138. package/src/finishes/night.css +77 -0
  139. package/src/finishes/paper.css +58 -0
  140. package/src/finishes/polished-glass.css +159 -0
  141. package/src/finishes/rain.css +84 -0
  142. package/src/finishes/scripts/day-cycle.ts +30 -0
  143. package/src/finishes/scripts/holographic.ts +37 -0
  144. package/src/finishes/scripts/spotlight.ts +30 -0
  145. package/src/finishes/spotlight.css +41 -0
  146. package/src/finishes/spring.css +80 -0
  147. package/src/finishes/terminal.css +49 -0
  148. package/src/motion/Marquee.astro +90 -0
  149. package/src/motion/MotionProvider.astro +50 -0
  150. package/src/motion/PageTransitions.astro +61 -0
  151. package/src/motion/Parallax.astro +44 -0
  152. package/src/motion/ParallaxLayer.astro +31 -0
  153. package/src/motion/RevealOnScroll.astro +59 -0
  154. package/src/motion/SceneRegistry.astro +38 -0
  155. package/src/motion/ScrollScene.astro +81 -0
  156. package/src/motion/index.ts +12 -0
  157. package/src/motion/integration.ts +48 -0
  158. package/src/motion/runtime/page-transitions.ts +68 -0
  159. package/src/motion/runtime/runtime.ts +180 -0
  160. package/src/motion/runtime/scenes.ts +248 -0
  161. package/src/motion/runtime/types.ts +103 -0
  162. package/src/motion/styles/motion.css +332 -0
  163. package/src/motion/transitions.ts +74 -0
  164. package/src/motion/virtual.d.ts +4 -0
  165. package/src/primitives/Accordion.astro +129 -0
  166. package/src/primitives/Breadcrumbs.astro +50 -0
  167. package/src/primitives/BulletList.astro +69 -0
  168. package/src/primitives/Button.astro +73 -0
  169. package/src/primitives/ButtonGroup.astro +54 -0
  170. package/src/primitives/Callout.astro +137 -0
  171. package/src/primitives/Caption.astro +35 -0
  172. package/src/primitives/Card.astro +72 -0
  173. package/src/primitives/CardContent.astro +24 -0
  174. package/src/primitives/CardFooter.astro +36 -0
  175. package/src/primitives/CardHeader.astro +86 -0
  176. package/src/primitives/Checkbox.astro +38 -0
  177. package/src/primitives/ChoiceGroup.astro +23 -0
  178. package/src/primitives/Cluster.astro +49 -0
  179. package/src/primitives/Container.astro +44 -0
  180. package/src/primitives/DescriptionList.astro +83 -0
  181. package/src/primitives/Dialog.astro +38 -0
  182. package/src/primitives/Disclosure.astro +67 -0
  183. package/src/primitives/Divider.astro +93 -0
  184. package/src/primitives/Drawer.astro +33 -0
  185. package/src/primitives/Fieldset.astro +80 -0
  186. package/src/primitives/Flex.astro +64 -0
  187. package/src/primitives/FocusRing.astro +63 -0
  188. package/src/primitives/FocusTrap.astro +64 -0
  189. package/src/primitives/Footer.astro +155 -0
  190. package/src/primitives/Form.astro +68 -0
  191. package/src/primitives/FormDescription.astro +26 -0
  192. package/src/primitives/FormError.astro +106 -0
  193. package/src/primitives/FormField.astro +72 -0
  194. package/src/primitives/Grid.astro +64 -0
  195. package/src/primitives/Heading.astro +45 -0
  196. package/src/primitives/IconButton.astro +48 -0
  197. package/src/primitives/Image.astro +125 -0
  198. package/src/primitives/Input.astro +86 -0
  199. package/src/primitives/Label.astro +50 -0
  200. package/src/primitives/Link.astro +81 -0
  201. package/src/primitives/LinkButton.astro +66 -0
  202. package/src/primitives/List.astro +39 -0
  203. package/src/primitives/ListItem.astro +178 -0
  204. package/src/primitives/MediaObject.astro +66 -0
  205. package/src/primitives/MetricCard.astro +278 -0
  206. package/src/primitives/NavLink.astro +81 -0
  207. package/src/primitives/NavMenu.astro +109 -0
  208. package/src/primitives/Navbar.astro +197 -0
  209. package/src/primitives/Panel.astro +153 -0
  210. package/src/primitives/Picture.astro +167 -0
  211. package/src/primitives/Popover.astro +95 -0
  212. package/src/primitives/Prose.astro +45 -0
  213. package/src/primitives/Radio.astro +21 -0
  214. package/src/primitives/Rating.astro +135 -0
  215. package/src/primitives/ReducedMotion.astro +90 -0
  216. package/src/primitives/SegmentedControl.astro +132 -0
  217. package/src/primitives/Select.astro +109 -0
  218. package/src/primitives/Sheet.astro +45 -0
  219. package/src/primitives/SkipLink.astro +31 -0
  220. package/src/primitives/Slider.astro +186 -0
  221. package/src/primitives/Spacer.astro +35 -0
  222. package/src/primitives/Stack.astro +51 -0
  223. package/src/primitives/Surface.astro +70 -0
  224. package/src/primitives/Switch.astro +22 -0
  225. package/src/primitives/Table.astro +382 -0
  226. package/src/primitives/Tabs.astro +126 -0
  227. package/src/primitives/Text.astro +56 -0
  228. package/src/primitives/Textarea.astro +75 -0
  229. package/src/primitives/Thumbnail.astro +154 -0
  230. package/src/primitives/Toggle.astro +99 -0
  231. package/src/primitives/Tooltip.astro +50 -0
  232. package/src/primitives/VisuallyHidden.astro +29 -0
  233. package/src/primitives/index.ts +103 -0
  234. package/src/primitives/internal/AccordionScript.astro +7 -0
  235. package/src/primitives/internal/ChoiceField.astro +91 -0
  236. package/src/primitives/internal/FocusTrapScript.astro +8 -0
  237. package/src/primitives/internal/FormValidationScript.astro +10 -0
  238. package/src/primitives/internal/IndeterminateScript.astro +13 -0
  239. package/src/primitives/internal/ModalPanel.astro +114 -0
  240. package/src/primitives/internal/OverlayScript.astro +7 -0
  241. package/src/primitives/internal/ReducedMotionScript.astro +7 -0
  242. package/src/primitives/internal/SliderScript.astro +7 -0
  243. package/src/primitives/internal/SparklineScript.astro +7 -0
  244. package/src/primitives/internal/TableSortScript.astro +7 -0
  245. package/src/primitives/internal/TabsScript.astro +7 -0
  246. package/src/primitives/internal/TooltipScript.astro +7 -0
  247. package/src/primitives/internal/image-plan.ts +82 -0
  248. package/src/primitives/internal/image.ts +129 -0
  249. package/src/primitives/internal/slider.ts +170 -0
  250. package/src/primitives/lib/deprecate.ts +47 -0
  251. package/src/primitives/lib/focus-trap.ts +197 -0
  252. package/src/primitives/lib/focus.ts +60 -0
  253. package/src/primitives/lib/motion.ts +68 -0
  254. package/src/primitives/scripts/accordion.ts +123 -0
  255. package/src/primitives/scripts/form-validation.ts +225 -0
  256. package/src/primitives/scripts/overlay.ts +71 -0
  257. package/src/primitives/scripts/reduced-motion.ts +59 -0
  258. package/src/primitives/scripts/slider.ts +150 -0
  259. package/src/primitives/scripts/sparkline.ts +131 -0
  260. package/src/primitives/scripts/table-sort.ts +68 -0
  261. package/src/primitives/scripts/tabs.ts +151 -0
  262. package/src/primitives/scripts/tooltip.ts +28 -0
  263. package/src/primitives/styles/a11y.css +104 -0
  264. package/src/primitives/styles/accordion.css +53 -0
  265. package/src/primitives/styles/breadcrumbs.css +59 -0
  266. package/src/primitives/styles/bullet-list.css +89 -0
  267. package/src/primitives/styles/button.css +237 -0
  268. package/src/primitives/styles/choice.css +164 -0
  269. package/src/primitives/styles/cluster.css +24 -0
  270. package/src/primitives/styles/container.css +19 -0
  271. package/src/primitives/styles/data.css +849 -0
  272. package/src/primitives/styles/disclosure.css +140 -0
  273. package/src/primitives/styles/divider.css +50 -0
  274. package/src/primitives/styles/flex.css +42 -0
  275. package/src/primitives/styles/form.css +241 -0
  276. package/src/primitives/styles/grid.css +36 -0
  277. package/src/primitives/styles/media.css +247 -0
  278. package/src/primitives/styles/nav.css +792 -0
  279. package/src/primitives/styles/overlay.css +362 -0
  280. package/src/primitives/styles/prose.css +146 -0
  281. package/src/primitives/styles/scale.css +175 -0
  282. package/src/primitives/styles/segmented.css +165 -0
  283. package/src/primitives/styles/slider.css +170 -0
  284. package/src/primitives/styles/spacer.css +17 -0
  285. package/src/primitives/styles/stack.css +25 -0
  286. package/src/primitives/styles/surface.css +403 -0
  287. package/src/primitives/styles/tabs.css +223 -0
  288. package/src/primitives/styles/typography.css +144 -0
  289. package/src/primitives/styles/utilities.css +24 -0
  290. package/src/primitives/types.ts +385 -0
  291. package/src/primitives/utils.ts +254 -0
  292. package/src/seo/JSONLD.astro +35 -0
  293. package/src/seo/SEOHead.astro +47 -0
  294. package/src/seo/cms.ts +59 -0
  295. package/src/seo/index.ts +10 -0
  296. package/src/seo/integration.ts +268 -0
  297. package/src/seo/internal/url.ts +68 -0
  298. package/src/seo/lib/jsonld.ts +342 -0
  299. package/src/seo/lib/meta.ts +205 -0
  300. package/src/seo/lib/redirects.ts +293 -0
  301. package/src/seo/lib/robots.ts +33 -0
  302. package/src/seo/lib/rss.ts +98 -0
  303. package/src/seo/lib/sitemap.ts +105 -0
  304. package/src/seo/schema.ts +43 -0
  305. package/src/tokens/base.css +71 -0
  306. package/src/tokens/tokens.css +210 -0
@@ -0,0 +1,178 @@
1
+ ---
2
+ /**
3
+ * ListItem — one structured entry: optional leading visual (icon, image, initials),
4
+ * a title with description and meta line, and a trailing value or actions.
5
+ *
6
+ * - `href` makes the whole row a link (the title is the only real link, stretched over
7
+ * the row; other buttons in the row still work). A chevron is shown automatically.
8
+ * - `value` + `valueFormat` render a right-aligned figure with tabular digits, so values
9
+ * line up down the list; `valueDetail` adds a muted second line; `delta` adds a signed change.
10
+ * - `meta` items are separated with a middle dot; give them `srLabel` for context.
11
+ * - Slots: `leading`, `trailing` (actions, badges), default (extra content under the text).
12
+ *
13
+ * @example
14
+ * <ListItem initials="Ana Ruiz" title="Ana Ruiz" description="Lead developer"
15
+ * meta={['Fort Worth', { label: '4.9 ★', srLabel: 'Rated' }]} href="/team/ana-ruiz" />
16
+ * <ListItem title="Invoice #1042" meta={['Due Nov 30']} value={1284.5} valueFormat="currency" valueDetail="Unpaid" valueTone="warning" />
17
+ */
18
+ import type { HeadingLevel, ListMetaItem, ValueFormat, ValueTone } from './types';
19
+ import { deltaDirection, deltaIconSvg, deltaTone, formatValue, initialsOf, LEGACY_VALUE_TONES } from './utils';
20
+ import { renameValue } from './lib/deprecate';
21
+ import './styles/utilities.css';
22
+ import './styles/data.css';
23
+
24
+ type Props = {
25
+ title: string;
26
+ description?: string;
27
+ meta?: Array<string | ListMetaItem>;
28
+ href?: string;
29
+ newTab?: boolean;
30
+ /** Highlight as the current/selected entry. */
31
+ current?: boolean;
32
+ /** Name to derive initials from for a leading avatar (when there's no `leading` slot). */
33
+ initials?: string;
34
+ avatarTone?: 'accent' | 'neutral';
35
+ /** Trailing figure. */
36
+ value?: string | number;
37
+ valueFormat?: ValueFormat;
38
+ valueDetail?: string;
39
+ valueTone?: ValueTone;
40
+ /** Signed change shown under the value (number; with `deltaFormat`). */
41
+ delta?: number;
42
+ deltaFormat?: ValueFormat;
43
+ higherIsBetter?: boolean;
44
+ /** Render the title as a heading (for content-heavy lists). Default: plain text. */
45
+ titleLevel?: HeadingLevel;
46
+ /** Single-line title and description with ellipsis. */
47
+ truncate?: boolean;
48
+ /** Align columns to the top (for multi-line descriptions). */
49
+ align?: 'center' | 'start';
50
+ chevron?: boolean;
51
+ locale?: string;
52
+ as?: 'li' | 'div';
53
+ class?: string;
54
+ id?: string;
55
+ };
56
+
57
+ const {
58
+ title,
59
+ description,
60
+ meta = [],
61
+ href,
62
+ newTab = false,
63
+ current = false,
64
+ initials,
65
+ avatarTone = 'accent',
66
+ value,
67
+ valueFormat = 'text',
68
+ valueDetail,
69
+ valueTone,
70
+ delta,
71
+ deltaFormat = 'delta-percent',
72
+ higherIsBetter = true,
73
+ titleLevel,
74
+ truncate = false,
75
+ align = 'center',
76
+ chevron = Boolean(href),
77
+ locale = 'en-US',
78
+ as: Tag = 'li',
79
+ class: className,
80
+ id,
81
+ } = Astro.props;
82
+
83
+ const TitleTag = (titleLevel ? `h${titleLevel}` : 'p') as 'p';
84
+ const hasLeadingSlot = Astro.slots.has('leading');
85
+ const hasTrailingSlot = Astro.slots.has('trailing');
86
+ const hasValue = value !== undefined && value !== null && value !== '';
87
+ const display = hasValue ? formatValue(value, valueFormat, locale) : '';
88
+ const metaItems = meta.map((m) => (typeof m === 'string' ? { label: m } : m));
89
+ const hasDelta = typeof delta === 'number';
90
+ const dTone = hasDelta ? deltaTone(delta, higherIsBetter) : undefined;
91
+ const dDir = hasDelta ? deltaDirection(delta) : 'flat';
92
+ const dText = hasDelta ? formatValue(delta, deltaFormat, locale) : '';
93
+ const dWord = dDir === 'up' ? 'Up' : dDir === 'down' ? 'Down' : 'No change';
94
+ ---
95
+
96
+ <Tag
97
+ id={id}
98
+ class:list={['sinn-list-item', className]}
99
+ data-align={align === 'start' ? 'start' : undefined}
100
+ data-truncate={truncate ? '' : undefined}
101
+ aria-current={current && !href ? 'true' : undefined}
102
+ >
103
+ {
104
+ (hasLeadingSlot || initials) && (
105
+ <div class="sinn-list-item__leading">
106
+ {hasLeadingSlot ? (
107
+ <slot name="leading" />
108
+ ) : (
109
+ <span class="sinn-avatar" data-tone={avatarTone === 'accent' ? undefined : avatarTone} aria-hidden="true">
110
+ {initialsOf(initials ?? '')}
111
+ </span>
112
+ )}
113
+ </div>
114
+ )
115
+ }
116
+ <div class="sinn-list-item__main">
117
+ <TitleTag class="sinn-list-item__title">
118
+ {
119
+ href ? (
120
+ <a
121
+ class="sinn-list-item__link"
122
+ href={href}
123
+ aria-current={current ? 'page' : undefined}
124
+ target={newTab ? '_blank' : undefined}
125
+ rel={newTab ? 'noopener' : undefined}
126
+ >
127
+ {title}
128
+ </a>
129
+ ) : (
130
+ title
131
+ )
132
+ }
133
+ </TitleTag>
134
+ {description && <p class="sinn-list-item__description">{description}</p>}
135
+ {
136
+ metaItems.length > 0 && (
137
+ <ul role="list" class="sinn-list-item__meta">
138
+ {metaItems.map((m) => (
139
+ <li>
140
+ {m.srLabel && <span class="sinn-sr-only">{m.srLabel}: </span>}
141
+ {m.label}
142
+ </li>
143
+ ))}
144
+ </ul>
145
+ )
146
+ }
147
+ <slot />
148
+ </div>
149
+ {
150
+ (hasValue || hasDelta || hasTrailingSlot || chevron) && (
151
+ <div class="sinn-list-item__trailing">
152
+ {(hasValue || hasDelta) && (
153
+ <div class="sinn-list-item__value">
154
+ {hasValue && (
155
+ <span class="sinn-list-item__value-main" data-value-tone={valueTone && valueTone !== 'default' ? renameValue('ListItem', 'valueTone', valueTone, LEGACY_VALUE_TONES) : undefined}>
156
+ {display}
157
+ </span>
158
+ )}
159
+ {hasDelta && (
160
+ <span class="sinn-delta sinn-list-item__value-detail" data-value-tone={dTone}>
161
+ <Fragment set:html={deltaIconSvg(dDir)} />
162
+ <span aria-hidden="true">{dText}</span>
163
+ <span class="sinn-sr-only">{dWord} {dText.replace(/^[+−-]/, '')}</span>
164
+ </span>
165
+ )}
166
+ {valueDetail && <span class="sinn-list-item__value-detail">{valueDetail}</span>}
167
+ </div>
168
+ )}
169
+ {hasTrailingSlot && <slot name="trailing" />}
170
+ {chevron && (
171
+ <svg class="sinn-list-item__chevron" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
172
+ <path d="M6 3.5 10.5 8 6 12.5" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" />
173
+ </svg>
174
+ )}
175
+ </div>
176
+ )
177
+ }
178
+ </Tag>
@@ -0,0 +1,66 @@
1
+ ---
2
+ /**
3
+ * MediaObject — media beside related content: comments with avatars, news items with a
4
+ * thumbnail, provider bios with a photo, feature rows, testimonials.
5
+ *
6
+ * - `media` slot (Image, Thumbnail, an icon, a video) at a fixed `mediaWidth`; the text takes
7
+ * the rest and can shrink without overflowing.
8
+ * - `mediaPosition="end"` puts the media after the text (follows RTL automatically).
9
+ * - `stackBelow` stacks the media above the text when the MediaObject itself is narrower than
10
+ * s 24rem · m 32rem · l 44rem (a container query, so it works the same in a sidebar or a
11
+ * full-width column). Without it, media and text always sit side by side.
12
+ * - It's a size container, so give it a definite width context (normal block flow, a grid cell).
13
+ *
14
+ * @example
15
+ * <MediaObject mediaWidth="l" stackBelow="m">
16
+ * <Image slot="media" src={anaRuiz} alt="Ana Ruiz" width={320} aspect="4/5" radius="m" />
17
+ * <Heading level={3}>Ana Ruiz</Heading>
18
+ * <Text tone="muted">Lead developer · 14 years in Fort Worth</Text>
19
+ * <Text>Ana focuses on performance and accessibility…</Text>
20
+ * </MediaObject>
21
+ */
22
+ import type { HTMLAttributes, HTMLTag } from 'astro/types';
23
+ import type { Space } from './types';
24
+ import './styles/scale.css';
25
+ import './styles/utilities.css';
26
+ import './styles/media.css';
27
+
28
+ type Props = HTMLAttributes<'div'> & {
29
+ as?: HTMLTag;
30
+ mediaWidth?: 'xs' | 's' | 'm' | 'l' | 'xl' | 'third' | 'half' | 'auto';
31
+ mediaPosition?: 'start' | 'end';
32
+ align?: 'start' | 'center';
33
+ gap?: Space;
34
+ stackBelow?: 's' | 'm' | 'l';
35
+ };
36
+
37
+ const {
38
+ as: Tag = 'div',
39
+ mediaWidth = 'm',
40
+ mediaPosition = 'start',
41
+ align = 'start',
42
+ gap = 's',
43
+ stackBelow,
44
+ class: className,
45
+ ...rest
46
+ } = Astro.props;
47
+ ---
48
+
49
+ <Tag
50
+ class:list={['sinn-media-object', className]}
51
+ data-media-width={mediaWidth === 'm' ? undefined : mediaWidth}
52
+ data-media-position={mediaPosition === 'end' ? 'end' : undefined}
53
+ data-align={align === 'center' ? 'center' : undefined}
54
+ data-stack-below={stackBelow}
55
+ data-gap={gap}
56
+ {...rest}
57
+ >
58
+ <div class="sinn-media-object__inner">
59
+ <div class="sinn-media-object__media">
60
+ <slot name="media" />
61
+ </div>
62
+ <div class="sinn-media-object__body">
63
+ <slot />
64
+ </div>
65
+ </div>
66
+ </Tag>
@@ -0,0 +1,278 @@
1
+ ---
2
+ /**
3
+ * MetricCard — a key number, its change, and its trend (a "stat tile").
4
+ *
5
+ * The figure contract:
6
+ * - `label`: sentence case, no trailing colon.
7
+ * - `value`: large and semibold with proportional figures, auto-compacted (1,284 · 12.9K · $4.2M).
8
+ * The exact value is kept in a `<data value>` element.
9
+ * - `delta`: signed, against a named period ("vs last month"). Colored by direction × whether
10
+ * up is good (`higherIsBetter`), always with an arrow and an unambiguous screen-reader phrase.
11
+ * Pass `previous` instead to have it computed.
12
+ * - `trend`: a sparkline of up to ~12 points in a muted color, with the current period as an
13
+ * accent dot. Hover or arrow keys read out each point (≈1 KB script, only on pages that
14
+ * use it), and a visually hidden table carries the same data for screen readers.
15
+ * - `target`: a progress meter toward a goal.
16
+ *
17
+ * States: `loading` (skeleton at final size), and an empty value renders "—" with "No data".
18
+ * `href` makes the whole card a link (the label is the link). Put a row of cards in a Grid.
19
+ *
20
+ * @example
21
+ * <Grid min="xs">
22
+ * <MetricCard label="New leads" value={1284} delta={0.124} period="vs last month"
23
+ * trend={[820, 870, 910, 900, 980, 1010, 1060, 1100, 1090, 1180, 1220, 1284]}
24
+ * trendLabels={months} />
25
+ * <MetricCard label="Avg. wait time" value={14} unit="min" delta={-0.08} higherIsBetter={false} period="vs last month" />
26
+ * <MetricCard label="Revenue" value={4_200_000} format="currency" target={5_000_000} targetLabel="annual goal" />
27
+ * </Grid>
28
+ */
29
+ import type { HTMLAttributes } from 'astro/types';
30
+ import type { FormatSpec, ValueFormat } from './types';
31
+ import { deltaDirection, deltaIconSvg, deltaTone, formatValue, pct, uid } from './utils';
32
+ import SparklineScript from './internal/SparklineScript.astro';
33
+ import './styles/scale.css';
34
+ import './styles/utilities.css';
35
+ import './styles/data.css';
36
+ import { renameValue } from './lib/deprecate';
37
+
38
+ type Props = Omit<HTMLAttributes<'div'>, 'title'> & {
39
+ label: string;
40
+ value: number | null | undefined;
41
+ /** Default: compact number (auto above 10,000). */
42
+ format?: ValueFormat;
43
+ /** Small unit after the value ("min", "beds"). */
44
+ unit?: string;
45
+ /** Change as a fraction for percent deltas (0.124 = +12.4%), or an absolute number with deltaFormat="delta". */
46
+ delta?: number;
47
+ deltaFormat?: ValueFormat;
48
+ /** Previous-period value; used to compute `delta` as a percent change when `delta` is omitted. */
49
+ previous?: number;
50
+ period?: string;
51
+ higherIsBetter?: boolean;
52
+ trend?: number[];
53
+ /** One label per trend point (e.g. month names). */
54
+ trendLabels?: string[];
55
+ /** Show the sparkline below the figures (default) or beside them on wide cards. */
56
+ trendPosition?: 'bottom' | 'end';
57
+ /** Hover/keyboard readout on the sparkline. */
58
+ interactive?: boolean;
59
+ target?: number;
60
+ targetLabel?: string;
61
+ footnote?: string;
62
+ href?: string;
63
+ /** `s`, `m` or `l` (a big headline figure). `hero` is the deprecated name for `l`. */
64
+ size?: 's' | 'm' | 'l' | 'hero';
65
+ variant?: 'outline' | 'plain';
66
+ loading?: boolean;
67
+ locale?: string;
68
+ /** Element to render: `li` inside a list of metrics, `article`/`section` when it stands alone. */
69
+ as?: 'div' | 'article' | 'section' | 'li';
70
+ };
71
+
72
+ const {
73
+ label,
74
+ value,
75
+ format = 'compact',
76
+ unit,
77
+ delta: deltaProp,
78
+ deltaFormat = 'delta-percent',
79
+ previous,
80
+ period,
81
+ higherIsBetter = true,
82
+ trend,
83
+ trendLabels,
84
+ trendPosition = 'bottom',
85
+ interactive = true,
86
+ target,
87
+ targetLabel = 'goal',
88
+ footnote,
89
+ href,
90
+ size: sizeProp = 'm',
91
+ variant = 'outline',
92
+ loading = false,
93
+ locale = 'en-US',
94
+ as: Tag = 'div',
95
+ class: className,
96
+ ...rest
97
+ } = Astro.props;
98
+ const size = renameValue('MetricCard', 'size', sizeProp, { hero: 'l' });
99
+
100
+ const id = uid('sinn-metric');
101
+ const hasValue = typeof value === 'number' && Number.isFinite(value);
102
+ const display = hasValue ? formatValue(value, format, locale) : '—';
103
+ // The value spec, reused for trend points, with compacting forced to 'auto' for readouts.
104
+ const valueSpec: FormatSpec = typeof format === 'string' ? { kind: format } : format;
105
+
106
+ // ----- Delta -----
107
+ const delta =
108
+ deltaProp ?? (hasValue && typeof previous === 'number' && previous !== 0 ? (value! - previous) / Math.abs(previous) : undefined);
109
+ const hasDelta = typeof delta === 'number' && Number.isFinite(delta);
110
+ const dDir = hasDelta ? deltaDirection(delta!) : 'flat';
111
+ const dTone = hasDelta ? deltaTone(delta!, higherIsBetter) : undefined;
112
+ const dText = hasDelta ? formatValue(delta, deltaFormat, locale) : '';
113
+ const dUnsigned = dText.replace(/^[+−-]/, '');
114
+ const dSentence = hasDelta
115
+ ? `${dDir === 'up' ? 'Up' : dDir === 'down' ? 'Down' : 'No change'}${dDir === 'flat' ? '' : ` ${dUnsigned}`}${period ? ` ${period}` : ''}`
116
+ : '';
117
+
118
+ // ----- Sparkline geometry (server-side; the SVG scales uniformly) -----
119
+ const VW = 240;
120
+ const VH = 48;
121
+ const PAD = 5;
122
+ const pts = (trend ?? []).filter((n) => Number.isFinite(n));
123
+ const hasTrend = pts.length >= 2;
124
+ let linePath = '';
125
+ let areaPath = '';
126
+ let coords: Array<[number, number]> = [];
127
+ if (hasTrend) {
128
+ const min = Math.min(...pts);
129
+ const max = Math.max(...pts);
130
+ const span = max - min || 1;
131
+ coords = pts.map((v, i) => [
132
+ +(PAD + (i * (VW - 2 * PAD)) / (pts.length - 1)).toFixed(2),
133
+ +(PAD + (1 - (v - min) / span) * (VH - 2 * PAD)).toFixed(2),
134
+ ]);
135
+ linePath = coords.map(([x, y], i) => `${i ? 'L' : 'M'}${x} ${y}`).join(' ');
136
+ areaPath = `${linePath} L${coords[coords.length - 1][0]} ${VH} L${coords[0][0]} ${VH} Z`;
137
+ }
138
+ const labels = pts.map((_, i) => trendLabels?.[i] ?? `Point ${i + 1}`);
139
+ const pointText = pts.map((v) => formatValue(v, { ...valueSpec, compact: valueSpec.compact ?? 'auto' }, locale));
140
+ const last = coords[coords.length - 1];
141
+ const summary = hasTrend
142
+ ? `${label} trend: ${labels[0]} ${pointText[0]}, ${labels[pts.length - 1]} ${pointText[pts.length - 1]}; high ${formatValue(Math.max(...pts), valueSpec, locale)}, low ${formatValue(Math.min(...pts), valueSpec, locale)}.`
143
+ : '';
144
+
145
+ // ----- Target meter -----
146
+ const hasTarget = hasValue && typeof target === 'number' && target > 0;
147
+ const targetPct = hasTarget ? pct(value!, target!) : 0;
148
+ // Written as `(value as number) /`, not `value! /`: the language server's .astro parser
149
+ // (@astrojs/astro2tsx 0.1.4) reads a `/` after `!` as a regex and misses the closing `---`.
150
+ const targetText = hasTarget
151
+ ? `${formatValue((value as number) / (target as number), { kind: 'percent', digits: 0 }, locale)} of ${formatValue(target, valueSpec, locale)} ${targetLabel}`
152
+ : '';
153
+
154
+ const hasIcon = Astro.slots.has('icon');
155
+ ---
156
+
157
+ <Tag
158
+ class:list={['sinn-metric', className]}
159
+ data-size={size === 'm' ? undefined : size}
160
+ data-variant={variant === 'outline' ? undefined : variant}
161
+ data-trend-position={hasTrend && trendPosition === 'end' ? 'end' : undefined}
162
+ aria-busy={loading ? 'true' : undefined}
163
+ {...rest}
164
+ >
165
+ <div class="sinn-metric__header">
166
+ <p class="sinn-metric__label" id={`${id}-label`}>
167
+ {href ? <a class="sinn-metric__link" href={href}>{label}</a> : label}
168
+ </p>
169
+ {hasIcon && <span class="sinn-metric__icon" aria-hidden="true"><slot name="icon" /></span>}
170
+ </div>
171
+
172
+ {
173
+ loading ? (
174
+ <div class="sinn-metric__main" aria-hidden="true">
175
+ <span class="sinn-skeleton" data-skeleton="value" />
176
+ <span class="sinn-skeleton" data-skeleton="delta" />
177
+ {(trend || trendLabels) && <span class="sinn-skeleton" data-skeleton="trend" />}
178
+ <span class="sinn-sr-only">Loading</span>
179
+ </div>
180
+ ) : (
181
+ <div class="sinn-metric__body">
182
+ <div class="sinn-metric__main">
183
+ <div class="sinn-metric__figures">
184
+ <p class="sinn-metric__value">
185
+ {hasValue ? (
186
+ <data value={String(value)}>{display}</data>
187
+ ) : (
188
+ <>
189
+ <span class="sinn-metric__empty" aria-hidden="true">—</span>
190
+ <span class="sinn-sr-only">No data</span>
191
+ </>
192
+ )}
193
+ {hasValue && unit && <span class="sinn-metric__unit">{unit}</span>}
194
+ </p>
195
+ {hasDelta && (
196
+ <p class="sinn-metric__delta">
197
+ <span class="sinn-delta" data-value-tone={dTone} aria-hidden="true">
198
+ <Fragment set:html={deltaIconSvg(dDir)} />
199
+ {dText}
200
+ </span>
201
+ {period && <span class="sinn-metric__period" aria-hidden="true">{period}</span>}
202
+ <span class="sinn-sr-only">{dSentence}</span>
203
+ </p>
204
+ )}
205
+ </div>
206
+ {hasTarget && (
207
+ <div class="sinn-metric__progress">
208
+ <span class="sinn-bar" data-pct={targetPct} aria-hidden="true" />
209
+ <span class="sinn-metric__progress-text">{targetText}</span>
210
+ </div>
211
+ )}
212
+ </div>
213
+
214
+ {hasTrend && (
215
+ <div
216
+ class="sinn-sparkline"
217
+ data-sinn-sparkline={interactive ? '' : undefined}
218
+ data-points={coords.map(([x, y]) => `${x},${y}`).join(';')}
219
+ data-labels={labels.join('|')}
220
+ data-values={pointText.join('|')}
221
+ data-vw={VW}
222
+ tabindex={interactive ? 0 : undefined}
223
+ role="img"
224
+ aria-label={summary}
225
+ aria-describedby={interactive ? `${id}-hint` : undefined}
226
+ >
227
+ <svg viewBox={`0 0 ${VW} ${VH}`} aria-hidden="true" focusable="false">
228
+ <line class="sinn-sparkline__baseline" x1="0" x2={VW} y1={VH - 0.5} y2={VH - 0.5} />
229
+ <path class="sinn-sparkline__area" d={areaPath} />
230
+ <path class="sinn-sparkline__line" d={linePath} />
231
+ {interactive && (
232
+ <g class="sinn-sparkline__hover-layer" visibility="hidden">
233
+ <line class="sinn-sparkline__crosshair" x1="0" x2="0" y1="0" y2={VH} />
234
+ <circle class="sinn-sparkline__hover" cx="0" cy="0" r="4" />
235
+ </g>
236
+ )}
237
+ <circle class="sinn-sparkline__current" cx={last[0]} cy={last[1]} r="4.5" />
238
+ </svg>
239
+ {interactive && (
240
+ <div class="sinn-sparkline__tip" hidden>
241
+ <strong />
242
+ <span />
243
+ </div>
244
+ )}
245
+ </div>
246
+ )}
247
+ </div>
248
+ )
249
+ }
250
+
251
+ {
252
+ hasTrend && !loading && (
253
+ <>
254
+ {interactive && (
255
+ <>
256
+ <span id={`${id}-hint`} class="sinn-sr-only">Use the left and right arrow keys to read each value.</span>
257
+ <span class="sinn-sr-only" aria-live="polite" data-sinn-sparkline-live />
258
+ </>
259
+ )}
260
+ <table class="sinn-sr-only">
261
+ <caption>{label} by period</caption>
262
+ <thead>
263
+ <tr><th scope="col">Period</th><th scope="col">{label}</th></tr>
264
+ </thead>
265
+ <tbody>
266
+ {labels.map((l, i) => (
267
+ <tr><th scope="row">{l}</th><td>{pointText[i]}</td></tr>
268
+ ))}
269
+ </tbody>
270
+ </table>
271
+ </>
272
+ )
273
+ }
274
+
275
+ {footnote && <p class="sinn-metric__footnote">{footnote}</p>}
276
+ <slot />
277
+ </Tag>
278
+ {hasTrend && interactive && !loading && <SparklineScript />}
@@ -0,0 +1,81 @@
1
+ ---
2
+ /**
3
+ * NavLink — one navigation destination. Sets `aria-current` automatically by comparing
4
+ * `href` with the page being rendered (`Astro.url`):
5
+ * - `"page"` on the current page;
6
+ * - `"true"` on a section link when `match="prefix"` and the page is inside it
7
+ * (/services is marked on /services/hosting).
8
+ *
9
+ * Styling (underline bar, pill) comes from the NavMenu it sits in. Inside a NavMenu,
10
+ * wrap each NavLink in `<li>`, or pass `listItem` to have it render the `<li>` itself.
11
+ *
12
+ * @example
13
+ * <NavMenu label="Main">
14
+ * <NavLink listItem href="/">Home</NavLink>
15
+ * <NavLink listItem href="/services" match="prefix">Services</NavLink>
16
+ * </NavMenu>
17
+ */
18
+ import type { HTMLAttributes } from 'astro/types';
19
+ import { currentFor } from './utils';
20
+ import './styles/utilities.css';
21
+ import './styles/nav.css';
22
+
23
+ type Props = HTMLAttributes<'a'> & {
24
+ href: string;
25
+ match?: 'exact' | 'prefix';
26
+ /**
27
+ * Override detection, e.g. when the "current" item depends on data, not the URL.
28
+ * `true`/`'page'`: this is the current page. `'true'`: the current page is inside this
29
+ * section. `false`: never current.
30
+ */
31
+ current?: boolean | 'page' | 'true';
32
+ /** Render inside an `<li>`. */
33
+ listItem?: boolean;
34
+ newTab?: boolean;
35
+ newTabLabel?: string;
36
+ };
37
+
38
+ const {
39
+ href,
40
+ match = 'exact',
41
+ current,
42
+ listItem = false,
43
+ newTab = false,
44
+ newTabLabel = 'opens in a new tab',
45
+ class: className,
46
+ ...rest
47
+ } = Astro.props;
48
+
49
+ const detected = currentFor(href, Astro.url, match);
50
+ const ariaCurrent = current === undefined ? detected : current === 'true' ? 'true' : current ? 'page' : undefined;
51
+ ---
52
+
53
+ {
54
+ listItem ? (
55
+ <li>
56
+ <a
57
+ href={href}
58
+ class:list={['sinn-nav-link', className]}
59
+ aria-current={ariaCurrent}
60
+ target={newTab ? '_blank' : undefined}
61
+ rel={newTab ? 'noopener' : undefined}
62
+ {...rest}
63
+ >
64
+ <slot />
65
+ {newTab && <span class="sinn-sr-only"> ({newTabLabel})</span>}
66
+ </a>
67
+ </li>
68
+ ) : (
69
+ <a
70
+ href={href}
71
+ class:list={['sinn-nav-link', className]}
72
+ aria-current={ariaCurrent}
73
+ target={newTab ? '_blank' : undefined}
74
+ rel={newTab ? 'noopener' : undefined}
75
+ {...rest}
76
+ >
77
+ <slot />
78
+ {newTab && <span class="sinn-sr-only"> ({newTabLabel})</span>}
79
+ </a>
80
+ )
81
+ }