@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.
Files changed (280) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +373 -0
  3. package/README.md +186 -2
  4. package/docs/blocks.md +364 -0
  5. package/docs/data.md +128 -0
  6. package/docs/motion.md +166 -0
  7. package/docs/primitives.md +510 -0
  8. package/docs/seo.md +187 -0
  9. package/docs/tokens.md +122 -0
  10. package/package.json +141 -3
  11. package/scripts/check-contrast.mjs +180 -0
  12. package/src/blocks/BlockRenderer.astro +54 -0
  13. package/src/blocks/CTABanner.astro +121 -0
  14. package/src/blocks/CTAPair.astro +110 -0
  15. package/src/blocks/CardGrid.astro +167 -0
  16. package/src/blocks/ConsentEmbed.astro +125 -0
  17. package/src/blocks/ConsentManager.astro +147 -0
  18. package/src/blocks/ConsentScript.astro +47 -0
  19. package/src/blocks/ContactCard.astro +164 -0
  20. package/src/blocks/ContactForm.astro +224 -0
  21. package/src/blocks/ErrorPage.astro +242 -0
  22. package/src/blocks/FAQ.astro +135 -0
  23. package/src/blocks/FeatureGrid.astro +148 -0
  24. package/src/blocks/Hero.astro +171 -0
  25. package/src/blocks/HeroCarousel.astro +220 -0
  26. package/src/blocks/HighlightCards.astro +107 -0
  27. package/src/blocks/LocationHours.astro +311 -0
  28. package/src/blocks/LogoCloud.astro +135 -0
  29. package/src/blocks/MaintenancePage.astro +168 -0
  30. package/src/blocks/MediaText.astro +177 -0
  31. package/src/blocks/PageHeader.astro +126 -0
  32. package/src/blocks/ProseSection.astro +98 -0
  33. package/src/blocks/Reviews.astro +194 -0
  34. package/src/blocks/RichText.astro +57 -0
  35. package/src/blocks/StatsBand.astro +117 -0
  36. package/src/blocks/Steps.astro +141 -0
  37. package/src/blocks/Testimonials.astro +144 -0
  38. package/src/blocks/Topbar.astro +158 -0
  39. package/src/blocks/cms/card-grid.ts +80 -0
  40. package/src/blocks/cms/consent.ts +45 -0
  41. package/src/blocks/cms/contact-card.ts +88 -0
  42. package/src/blocks/cms/contact-form.ts +55 -0
  43. package/src/blocks/cms/cta-banner.ts +48 -0
  44. package/src/blocks/cms/cta-pair.ts +63 -0
  45. package/src/blocks/cms/data-base.ts +7 -0
  46. package/src/blocks/cms/data.ts +257 -0
  47. package/src/blocks/cms/faq.ts +70 -0
  48. package/src/blocks/cms/feature-grid.ts +80 -0
  49. package/src/blocks/cms/fixtures.ts +599 -0
  50. package/src/blocks/cms/hero-carousel.ts +80 -0
  51. package/src/blocks/cms/hero.ts +77 -0
  52. package/src/blocks/cms/highlight-cards.ts +76 -0
  53. package/src/blocks/cms/images.ts +38 -0
  54. package/src/blocks/cms/index.ts +87 -0
  55. package/src/blocks/cms/location-hours.ts +149 -0
  56. package/src/blocks/cms/logo-cloud.ts +62 -0
  57. package/src/blocks/cms/media-text.ts +44 -0
  58. package/src/blocks/cms/page-header.ts +49 -0
  59. package/src/blocks/cms/pages.ts +81 -0
  60. package/src/blocks/cms/prose-section.ts +45 -0
  61. package/src/blocks/cms/reviews.ts +101 -0
  62. package/src/blocks/cms/shared.ts +115 -0
  63. package/src/blocks/cms/stats-band.ts +61 -0
  64. package/src/blocks/cms/steps.ts +67 -0
  65. package/src/blocks/cms/testimonials.ts +80 -0
  66. package/src/blocks/cms/topbar.ts +64 -0
  67. package/src/blocks/cms/types.ts +63 -0
  68. package/src/blocks/consent.ts +14 -0
  69. package/src/blocks/icons.ts +47 -0
  70. package/src/blocks/index.ts +42 -0
  71. package/src/blocks/internal/Actions.astro +29 -0
  72. package/src/blocks/internal/BlockHeader.astro +45 -0
  73. package/src/blocks/internal/BlockShell.astro +58 -0
  74. package/src/blocks/internal/CarouselScript.astro +7 -0
  75. package/src/blocks/internal/ConsentEmbedScript.astro +7 -0
  76. package/src/blocks/internal/ConsentManagerScript.astro +7 -0
  77. package/src/blocks/internal/HoursScript.astro +7 -0
  78. package/src/blocks/internal/Placeholder.astro +13 -0
  79. package/src/blocks/internal/RichTextNode.astro +133 -0
  80. package/src/blocks/internal/StandaloneDocument.astro +53 -0
  81. package/src/blocks/internal/tina.ts +19 -0
  82. package/src/blocks/internal/util.ts +23 -0
  83. package/src/blocks/lib/consent.ts +96 -0
  84. package/src/blocks/lib/contact.ts +86 -0
  85. package/src/blocks/lib/error-pages.ts +119 -0
  86. package/src/blocks/lib/faq.ts +37 -0
  87. package/src/blocks/lib/hours.ts +201 -0
  88. package/src/blocks/lib/maintenance.ts +129 -0
  89. package/src/blocks/lib/reviews.ts +22 -0
  90. package/src/blocks/lib/rich-text.ts +143 -0
  91. package/src/blocks/lib/slug.ts +12 -0
  92. package/src/blocks/registry.ts +79 -0
  93. package/src/blocks/scripts/carousel.ts +218 -0
  94. package/src/blocks/scripts/consent-embed.ts +105 -0
  95. package/src/blocks/scripts/consent-manager.ts +112 -0
  96. package/src/blocks/scripts/consent-store.ts +86 -0
  97. package/src/blocks/scripts/error-page.ts +71 -0
  98. package/src/blocks/scripts/hours.ts +106 -0
  99. package/src/blocks/scripts/maintenance.ts +109 -0
  100. package/src/blocks/styles/blocks.css +1320 -0
  101. package/src/blocks/styles/consent.css +102 -0
  102. package/src/blocks/styles/faq.css +28 -0
  103. package/src/blocks/styles/location.css +92 -0
  104. package/src/blocks/styles/prose-section.css +13 -0
  105. package/src/blocks/styles/quotes.css +123 -0
  106. package/src/blocks/styles/rich-text.css +14 -0
  107. package/src/blocks/types.ts +283 -0
  108. package/src/data/ChartAxis.astro +19 -0
  109. package/src/data/ChartContainer.astro +151 -0
  110. package/src/data/ChartLegend.astro +25 -0
  111. package/src/data/ChartSeries.astro +14 -0
  112. package/src/data/ChartTable.astro +17 -0
  113. package/src/data/ChartTooltip.astro +20 -0
  114. package/src/data/Sparkline.astro +55 -0
  115. package/src/data/cms.ts +190 -0
  116. package/src/data/index.ts +10 -0
  117. package/src/data/lib/chart.ts +450 -0
  118. package/src/data/lib/render.ts +219 -0
  119. package/src/data/lib/scale.ts +107 -0
  120. package/src/data/lib/sparkline.ts +117 -0
  121. package/src/data/scripts/chart.ts +324 -0
  122. package/src/data/styles/chart.css +392 -0
  123. package/src/motion/Marquee.astro +90 -0
  124. package/src/motion/MotionProvider.astro +50 -0
  125. package/src/motion/PageTransitions.astro +61 -0
  126. package/src/motion/Parallax.astro +44 -0
  127. package/src/motion/ParallaxLayer.astro +31 -0
  128. package/src/motion/RevealOnScroll.astro +59 -0
  129. package/src/motion/SceneRegistry.astro +38 -0
  130. package/src/motion/ScrollScene.astro +81 -0
  131. package/src/motion/index.ts +12 -0
  132. package/src/motion/integration.ts +48 -0
  133. package/src/motion/runtime/page-transitions.ts +68 -0
  134. package/src/motion/runtime/runtime.ts +180 -0
  135. package/src/motion/runtime/scenes.ts +248 -0
  136. package/src/motion/runtime/types.ts +103 -0
  137. package/src/motion/styles/motion.css +332 -0
  138. package/src/motion/transitions.ts +74 -0
  139. package/src/motion/virtual.d.ts +4 -0
  140. package/src/primitives/Accordion.astro +129 -0
  141. package/src/primitives/Breadcrumbs.astro +50 -0
  142. package/src/primitives/BulletList.astro +69 -0
  143. package/src/primitives/Button.astro +73 -0
  144. package/src/primitives/ButtonGroup.astro +54 -0
  145. package/src/primitives/Callout.astro +137 -0
  146. package/src/primitives/Caption.astro +35 -0
  147. package/src/primitives/Card.astro +72 -0
  148. package/src/primitives/CardContent.astro +24 -0
  149. package/src/primitives/CardFooter.astro +36 -0
  150. package/src/primitives/CardHeader.astro +86 -0
  151. package/src/primitives/Checkbox.astro +38 -0
  152. package/src/primitives/ChoiceGroup.astro +23 -0
  153. package/src/primitives/Cluster.astro +49 -0
  154. package/src/primitives/Container.astro +44 -0
  155. package/src/primitives/DescriptionList.astro +83 -0
  156. package/src/primitives/Dialog.astro +38 -0
  157. package/src/primitives/Disclosure.astro +67 -0
  158. package/src/primitives/Divider.astro +93 -0
  159. package/src/primitives/Drawer.astro +33 -0
  160. package/src/primitives/Fieldset.astro +80 -0
  161. package/src/primitives/Flex.astro +64 -0
  162. package/src/primitives/FocusRing.astro +63 -0
  163. package/src/primitives/FocusTrap.astro +64 -0
  164. package/src/primitives/Footer.astro +155 -0
  165. package/src/primitives/Form.astro +68 -0
  166. package/src/primitives/FormDescription.astro +26 -0
  167. package/src/primitives/FormError.astro +106 -0
  168. package/src/primitives/FormField.astro +72 -0
  169. package/src/primitives/Grid.astro +64 -0
  170. package/src/primitives/Heading.astro +45 -0
  171. package/src/primitives/IconButton.astro +48 -0
  172. package/src/primitives/Image.astro +125 -0
  173. package/src/primitives/Input.astro +84 -0
  174. package/src/primitives/Label.astro +50 -0
  175. package/src/primitives/Link.astro +81 -0
  176. package/src/primitives/LinkButton.astro +66 -0
  177. package/src/primitives/List.astro +39 -0
  178. package/src/primitives/ListItem.astro +178 -0
  179. package/src/primitives/MediaObject.astro +66 -0
  180. package/src/primitives/MetricCard.astro +276 -0
  181. package/src/primitives/NavLink.astro +81 -0
  182. package/src/primitives/NavMenu.astro +109 -0
  183. package/src/primitives/Navbar.astro +197 -0
  184. package/src/primitives/Panel.astro +153 -0
  185. package/src/primitives/Picture.astro +167 -0
  186. package/src/primitives/Popover.astro +95 -0
  187. package/src/primitives/Prose.astro +45 -0
  188. package/src/primitives/Radio.astro +21 -0
  189. package/src/primitives/Rating.astro +135 -0
  190. package/src/primitives/ReducedMotion.astro +90 -0
  191. package/src/primitives/SegmentedControl.astro +132 -0
  192. package/src/primitives/Select.astro +107 -0
  193. package/src/primitives/Sheet.astro +45 -0
  194. package/src/primitives/SkipLink.astro +31 -0
  195. package/src/primitives/Slider.astro +186 -0
  196. package/src/primitives/Spacer.astro +35 -0
  197. package/src/primitives/Stack.astro +51 -0
  198. package/src/primitives/Surface.astro +70 -0
  199. package/src/primitives/Switch.astro +22 -0
  200. package/src/primitives/Table.astro +382 -0
  201. package/src/primitives/Tabs.astro +126 -0
  202. package/src/primitives/Text.astro +56 -0
  203. package/src/primitives/Textarea.astro +73 -0
  204. package/src/primitives/Thumbnail.astro +154 -0
  205. package/src/primitives/Toggle.astro +99 -0
  206. package/src/primitives/Tooltip.astro +50 -0
  207. package/src/primitives/VisuallyHidden.astro +29 -0
  208. package/src/primitives/index.ts +103 -0
  209. package/src/primitives/internal/AccordionScript.astro +7 -0
  210. package/src/primitives/internal/ChoiceField.astro +89 -0
  211. package/src/primitives/internal/FocusTrapScript.astro +8 -0
  212. package/src/primitives/internal/FormValidationScript.astro +10 -0
  213. package/src/primitives/internal/IndeterminateScript.astro +13 -0
  214. package/src/primitives/internal/ModalPanel.astro +114 -0
  215. package/src/primitives/internal/OverlayScript.astro +7 -0
  216. package/src/primitives/internal/ReducedMotionScript.astro +7 -0
  217. package/src/primitives/internal/SliderScript.astro +7 -0
  218. package/src/primitives/internal/SparklineScript.astro +7 -0
  219. package/src/primitives/internal/TableSortScript.astro +7 -0
  220. package/src/primitives/internal/TabsScript.astro +7 -0
  221. package/src/primitives/internal/TooltipScript.astro +7 -0
  222. package/src/primitives/lib/deprecate.ts +47 -0
  223. package/src/primitives/lib/focus-trap.ts +197 -0
  224. package/src/primitives/lib/focus.ts +60 -0
  225. package/src/primitives/lib/image-plan.ts +82 -0
  226. package/src/primitives/lib/image.ts +129 -0
  227. package/src/primitives/lib/motion.ts +68 -0
  228. package/src/primitives/lib/slider.ts +170 -0
  229. package/src/primitives/scripts/accordion.ts +123 -0
  230. package/src/primitives/scripts/form-validation.ts +225 -0
  231. package/src/primitives/scripts/overlay.ts +71 -0
  232. package/src/primitives/scripts/reduced-motion.ts +59 -0
  233. package/src/primitives/scripts/slider.ts +150 -0
  234. package/src/primitives/scripts/sparkline.ts +131 -0
  235. package/src/primitives/scripts/table-sort.ts +68 -0
  236. package/src/primitives/scripts/tabs.ts +151 -0
  237. package/src/primitives/scripts/tooltip.ts +28 -0
  238. package/src/primitives/styles/a11y.css +104 -0
  239. package/src/primitives/styles/accordion.css +53 -0
  240. package/src/primitives/styles/breadcrumbs.css +59 -0
  241. package/src/primitives/styles/bullet-list.css +89 -0
  242. package/src/primitives/styles/button.css +237 -0
  243. package/src/primitives/styles/choice.css +164 -0
  244. package/src/primitives/styles/cluster.css +24 -0
  245. package/src/primitives/styles/container.css +19 -0
  246. package/src/primitives/styles/data.css +849 -0
  247. package/src/primitives/styles/disclosure.css +140 -0
  248. package/src/primitives/styles/divider.css +50 -0
  249. package/src/primitives/styles/flex.css +42 -0
  250. package/src/primitives/styles/form.css +241 -0
  251. package/src/primitives/styles/grid.css +36 -0
  252. package/src/primitives/styles/media.css +247 -0
  253. package/src/primitives/styles/nav.css +792 -0
  254. package/src/primitives/styles/overlay.css +362 -0
  255. package/src/primitives/styles/prose.css +146 -0
  256. package/src/primitives/styles/scale.css +175 -0
  257. package/src/primitives/styles/segmented.css +165 -0
  258. package/src/primitives/styles/slider.css +170 -0
  259. package/src/primitives/styles/spacer.css +17 -0
  260. package/src/primitives/styles/stack.css +25 -0
  261. package/src/primitives/styles/surface.css +403 -0
  262. package/src/primitives/styles/tabs.css +223 -0
  263. package/src/primitives/styles/typography.css +144 -0
  264. package/src/primitives/styles/utilities.css +24 -0
  265. package/src/primitives/types.ts +385 -0
  266. package/src/primitives/utils.ts +254 -0
  267. package/src/seo/JSONLD.astro +35 -0
  268. package/src/seo/SEOHead.astro +47 -0
  269. package/src/seo/cms.ts +80 -0
  270. package/src/seo/index.ts +10 -0
  271. package/src/seo/integration.ts +231 -0
  272. package/src/seo/lib/jsonld.ts +334 -0
  273. package/src/seo/lib/meta.ts +205 -0
  274. package/src/seo/lib/redirects.ts +283 -0
  275. package/src/seo/lib/robots.ts +33 -0
  276. package/src/seo/lib/rss.ts +98 -0
  277. package/src/seo/lib/sitemap.ts +105 -0
  278. package/src/seo/lib/url.ts +68 -0
  279. package/src/tokens/base.css +71 -0
  280. package/src/tokens/tokens.css +210 -0
@@ -0,0 +1,109 @@
1
+ ---
2
+ /**
3
+ * NavMenu — a list of related navigation links (`<ul role="list">`).
4
+ *
5
+ * - Pass `items` (data, e.g. from the CMS) or NavLinks as children (wrapped in `<li>` / `listItem`).
6
+ * - `label` wraps it in `<nav aria-label>`. Leave it off when a parent already provides the
7
+ * `<nav>` (Navbar, Footer). Every `<nav>` on a page needs a distinct label.
8
+ * - `variant`: `underline` (top nav; current page gets a bar), `solid` (top nav; current page
9
+ * is a filled accent box, hover a neutral box), `pill` (sidebars; current page gets a tint),
10
+ * `plain`.
11
+ * - `size`: `m` (40px rows, default) or `l` (48px rows, more padding: roomier top nav).
12
+ * - Vertical menus show one level of nested `items` as an indented sub-list.
13
+ *
14
+ * @example
15
+ * <NavMenu label="Account" orientation="vertical" variant="pill" items={[
16
+ * { href: '/account', label: 'Overview' },
17
+ * { href: '/account/appointments', label: 'Appointments', match: 'prefix' },
18
+ * ]} />
19
+ */
20
+ import type { HTMLAttributes } from 'astro/types';
21
+ import type { NavItem, Space } from './types';
22
+ import NavLink from './NavLink.astro';
23
+ import './styles/scale.css';
24
+ import './styles/utilities.css';
25
+ import './styles/nav.css';
26
+
27
+ type Props = HTMLAttributes<'ul'> & {
28
+ items?: NavItem[];
29
+ /** Wrap in <nav aria-label={label}>. */
30
+ label?: string;
31
+ orientation?: 'horizontal' | 'vertical';
32
+ variant?: 'underline' | 'solid' | 'pill' | 'plain';
33
+ size?: 'm' | 'l';
34
+ gap?: Space;
35
+ };
36
+
37
+ const {
38
+ items = [],
39
+ label,
40
+ orientation = 'horizontal',
41
+ variant = 'underline',
42
+ size = 'm',
43
+ gap = '3xs',
44
+ class: className,
45
+ ...rest
46
+ } = Astro.props;
47
+ ---
48
+
49
+ {
50
+ label ? (
51
+ <nav aria-label={label}>
52
+ <ul
53
+ role="list"
54
+ class:list={['sinn-nav-menu', className]}
55
+ data-orientation={orientation}
56
+ data-variant={variant}
57
+ data-size={size === 'm' ? undefined : size}
58
+ data-gap={gap}
59
+ {...rest}
60
+ >
61
+ {items.map((item) => (
62
+ <li>
63
+ <NavLink href={item.href} match={item.match} current={item.current} newTab={item.newTab}>
64
+ {item.label}
65
+ </NavLink>
66
+ {orientation === 'vertical' && !!item.items?.length && (
67
+ <ul role="list" class="sinn-nav-menu__sub">
68
+ {item.items.map((child) => (
69
+ <NavLink listItem href={child.href} match={child.match} current={child.current} newTab={child.newTab}>
70
+ {child.label}
71
+ </NavLink>
72
+ ))}
73
+ </ul>
74
+ )}
75
+ </li>
76
+ ))}
77
+ <slot />
78
+ </ul>
79
+ </nav>
80
+ ) : (
81
+ <ul
82
+ role="list"
83
+ class:list={['sinn-nav-menu', className]}
84
+ data-orientation={orientation}
85
+ data-variant={variant}
86
+ data-size={size === 'm' ? undefined : size}
87
+ data-gap={gap}
88
+ {...rest}
89
+ >
90
+ {items.map((item) => (
91
+ <li>
92
+ <NavLink href={item.href} match={item.match} current={item.current} newTab={item.newTab}>
93
+ {item.label}
94
+ </NavLink>
95
+ {orientation === 'vertical' && !!item.items?.length && (
96
+ <ul role="list" class="sinn-nav-menu__sub">
97
+ {item.items.map((child) => (
98
+ <NavLink listItem href={child.href} match={child.match} current={child.current} newTab={child.newTab}>
99
+ {child.label}
100
+ </NavLink>
101
+ ))}
102
+ </ul>
103
+ )}
104
+ </li>
105
+ ))}
106
+ <slot />
107
+ </ul>
108
+ )
109
+ }
@@ -0,0 +1,197 @@
1
+ ---
2
+ /**
3
+ * Navbar — primary site navigation: brand, main links and actions in a `<header>`.
4
+ *
5
+ * Below the `collapse` breakpoint the links move into a menu sheet opened by a "Menu"
6
+ * button. The sheet is a native popover (`popovertarget`), so it needs no JavaScript:
7
+ * Esc and clicking outside close it, the toggle exposes its expanded state, and Tab moves
8
+ * from the toggle into the menu. Browsers without Popover API support (pre-2024) don't open it.
9
+ * Where CSS anchor positioning is supported the sheet drops down below the bar (which stays
10
+ * visible, its toggle becoming a close button); elsewhere it covers the bar with its own header.
11
+ *
12
+ * Look: `variant="solid"` marks the current page with a filled accent box (hover: a neutral box);
13
+ * `linkSize="l"` gives roomier 48px links. `toggleStyle="icon"` shows a square icon-only toggle
14
+ * ("Menu" stays its accessible name). `actionsVisibility="collapsed"` shows the `actions` slot
15
+ * only while collapsed, e.g. a "Call" button next to the toggle on phones.
16
+ *
17
+ * Slots:
18
+ * - `brand`: logo (an <img>/<svg> with alt text). Falls back to `brandLabel` text.
19
+ * - `actions`: buttons kept visible in the bar at every width (e.g. "Book now", a call button).
20
+ * - `menu-footer`: extra content shown only in the mobile sheet (phone number, secondary links).
21
+ * - default: custom navigation instead of `items`.
22
+ *
23
+ * Pair with SkipLink as the first element in <body>.
24
+ *
25
+ * @example
26
+ * <Navbar brandLabel="Sinnstack" items={[
27
+ * { href: '/', label: 'Home' },
28
+ * { href: '/services', label: 'Services', match: 'prefix' },
29
+ * { href: '/contact', label: 'Contact' },
30
+ * ]} sticky>
31
+ * <img slot="brand" src={logo.src} alt="Sinnstack" width="160" height="32" />
32
+ * <LinkButton slot="actions" href="/book" size="s">Book</LinkButton>
33
+ * </Navbar>
34
+ */
35
+ import type { HTMLAttributes } from 'astro/types';
36
+ import type { NavItem } from './types';
37
+ import { currentFor, uid } from './utils';
38
+ import Container from './Container.astro';
39
+ import NavMenu from './NavMenu.astro';
40
+ import './styles/utilities.css';
41
+ import './styles/button.css';
42
+ import './styles/nav.css';
43
+ import { renameProp } from './lib/deprecate';
44
+
45
+ type Props = HTMLAttributes<'header'> & {
46
+ items?: NavItem[];
47
+ /** aria-label of the <nav>. */
48
+ label?: string;
49
+ brandHref?: string;
50
+ /** Brand text, also used as the brand link's name when the `brand` slot is empty. */
51
+ brandLabel?: string;
52
+ /** Collapse to the menu button below this width: s 40rem · m 56rem · l 64rem · xl 75rem. */
53
+ collapse?: 's' | 'm' | 'l' | 'xl' | 'always' | 'never';
54
+ /** How the bar marks the current page: `underline` or `solid` (filled accent box). */
55
+ variant?: 'underline' | 'solid';
56
+ /** Link size in the bar: m (40px) · l (48px, more padding). */
57
+ linkSize?: 'm' | 'l';
58
+ /** Menu toggle: `label` (icon + "Menu") or `icon` (bordered square, icon only). */
59
+ toggleStyle?: 'label' | 'icon';
60
+ /** When the `actions` slot shows: always · only while collapsed · only while expanded. */
61
+ actionsVisibility?: 'always' | 'collapsed' | 'expanded';
62
+ /** Position of the links in the bar on wide screens. */
63
+ align?: 'start' | 'center' | 'end';
64
+ sticky?: boolean;
65
+ /** Translucent background with backdrop blur (use with `sticky`). */
66
+ blur?: boolean;
67
+ /** Same as actionsVisibility="expanded" (put the same actions in `menu-footer`). */
68
+ hideActionsWhenCollapsed?: boolean;
69
+ /** Width of the inner Container (`containerSize` on the blocks too; `size` means s/m/l elsewhere). */
70
+ containerSize?: 'narrow' | 'default' | 'wide' | 'full';
71
+ /** @deprecated Use `containerSize`. */
72
+ size?: 'narrow' | 'default' | 'wide' | 'full';
73
+ menuLabel?: string;
74
+ closeLabel?: string;
75
+ };
76
+
77
+ const {
78
+ items = [],
79
+ label = 'Main',
80
+ brandHref = '/',
81
+ brandLabel,
82
+ collapse = 'm',
83
+ variant = 'underline',
84
+ linkSize = 'm',
85
+ toggleStyle = 'label',
86
+ actionsVisibility,
87
+ align = 'start',
88
+ sticky = false,
89
+ blur = false,
90
+ hideActionsWhenCollapsed = false,
91
+ containerSize: containerSizeProp,
92
+ size,
93
+ menuLabel = 'Menu',
94
+ closeLabel = 'Close menu',
95
+ class: className,
96
+ ...rest
97
+ } = Astro.props;
98
+ const containerSize = renameProp('Navbar', 'containerSize', containerSizeProp, 'size', size) ?? 'default';
99
+
100
+ const panelId = uid('sinn-navbar-menu');
101
+ const hasBrandSlot = Astro.slots.has('brand');
102
+ const hasActions = Astro.slots.has('actions');
103
+ const hasMenuFooter = Astro.slots.has('menu-footer');
104
+ const hasCustomNav = Astro.slots.has('default');
105
+ const collapsible = collapse !== 'never';
106
+ const actionsWhen = actionsVisibility ?? (hideActionsWhenCollapsed ? 'expanded' : 'always');
107
+ ---
108
+
109
+ <header
110
+ class:list={['sinn-navbar', className]}
111
+ data-collapse={collapsible ? collapse : undefined}
112
+ data-align={align === 'start' ? undefined : align}
113
+ data-sticky={sticky ? '' : undefined}
114
+ data-blur={blur ? '' : undefined}
115
+ {...rest}
116
+ >
117
+ <Container size={containerSize} class="sinn-navbar__inner">
118
+ {
119
+ (hasBrandSlot || brandLabel) && (
120
+ <a href={brandHref} class="sinn-navbar__brand" aria-current={currentFor(brandHref, Astro.url) === 'page' ? 'page' : undefined}>
121
+ {hasBrandSlot ? <slot name="brand" /> : brandLabel}
122
+ </a>
123
+ )
124
+ }
125
+
126
+ <div id={panelId} class="sinn-navbar__panel" popover={collapsible ? 'auto' : undefined}>
127
+ {
128
+ collapsible && (
129
+ <div class="sinn-navbar__sheet-header">
130
+ <span>{menuLabel}</span>
131
+ <button
132
+ type="button"
133
+ class="sinn-button"
134
+ data-variant="ghost"
135
+ data-tone="neutral"
136
+ data-size="m"
137
+ data-icon-only
138
+ popovertarget={panelId}
139
+ popovertargetaction="hide"
140
+ >
141
+ <span class="sinn-button__content">
142
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
143
+ <path d="M6 6l12 12M18 6 6 18" />
144
+ </svg>
145
+ <span class="sinn-sr-only">{closeLabel}</span>
146
+ </span>
147
+ </button>
148
+ </div>
149
+ )
150
+ }
151
+ <nav aria-label={label}>
152
+ {hasCustomNav ? <slot /> : <NavMenu items={items} variant={variant} size={linkSize} />}
153
+ </nav>
154
+ {
155
+ hasMenuFooter && (
156
+ <div class="sinn-navbar__sheet-footer">
157
+ <slot name="menu-footer" />
158
+ </div>
159
+ )
160
+ }
161
+ </div>
162
+
163
+ {
164
+ hasActions && (
165
+ <div class="sinn-navbar__actions" data-visible={actionsWhen === 'always' ? undefined : actionsWhen}>
166
+ <slot name="actions" />
167
+ </div>
168
+ )
169
+ }
170
+
171
+ {
172
+ collapsible && (
173
+ <button
174
+ type="button"
175
+ class="sinn-button sinn-navbar__toggle"
176
+ data-variant={toggleStyle === 'icon' ? 'outline' : 'ghost'}
177
+ data-tone="neutral"
178
+ data-size={toggleStyle === 'icon' ? 'l' : 'm'}
179
+ data-icon-only={toggleStyle === 'icon' ? '' : undefined}
180
+ data-style={toggleStyle === 'icon' ? 'icon' : undefined}
181
+ popovertarget={panelId}
182
+ popovertargetaction="toggle"
183
+ >
184
+ <span class="sinn-button__content">
185
+ <svg data-icon="open" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
186
+ <path d="M4 7h16M4 12h16M4 17h16" />
187
+ </svg>
188
+ <svg data-icon="close" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
189
+ <path d="M6 6l12 12M18 6 6 18" />
190
+ </svg>
191
+ <span class="sinn-navbar__toggle-label">{menuLabel}</span>
192
+ </span>
193
+ </button>
194
+ )
195
+ }
196
+ </Container>
197
+ </header>
@@ -0,0 +1,153 @@
1
+ ---
2
+ /**
3
+ * Panel — a larger surface for a section of a page or app: settings groups, dashboard
4
+ * sections, sidebars, "Your appointments". Has a header (title, description, actions),
5
+ * a body, and an optional footer slot (e.g. Save / Cancel).
6
+ *
7
+ * - Renders a `<section>` labelled by its title, so it shows up as a named region.
8
+ * - `collapsible` uses native `<details>`: no JS, keyboard and screen-reader support built in.
9
+ * Panels sharing a `group` name behave as an exclusive accordion (native `name` attribute).
10
+ * Note: screen readers announce the summary as a button, so the title isn't reachable by
11
+ * heading navigation while collapsible. Header `actions` aren't shown in this mode
12
+ * (interactive content can't go inside a summary).
13
+ * - `flush` removes body padding for edge-to-edge tables and lists.
14
+ *
15
+ * @example
16
+ * <Panel title="Notifications" description="Choose how we contact you.">
17
+ * <Button slot="actions" variant="ghost" size="s">Reset</Button>
18
+ * <Stack gap="s"><Switch …/><Switch …/></Stack>
19
+ * <ButtonGroup slot="footer"><Button>Save</Button></ButtonGroup>
20
+ * </Panel>
21
+ */
22
+ import type { HTMLAttributes, HTMLTag } from 'astro/types';
23
+ import type { HeadingLevel, TextSize } from './types';
24
+ import { uid } from './utils';
25
+ import Heading from './Heading.astro';
26
+ import Text from './Text.astro';
27
+ import './styles/utilities.css';
28
+ import './styles/surface.css';
29
+
30
+ type Props = Omit<HTMLAttributes<'section'>, 'title'> & {
31
+ as?: HTMLTag;
32
+ title?: string;
33
+ titleLevel?: HeadingLevel;
34
+ titleSize?: TextSize;
35
+ description?: string;
36
+ variant?: 'outline' | 'elevated' | 'plain';
37
+ size?: 's' | 'm' | 'l';
38
+ /** Line between header and body. */
39
+ divider?: boolean;
40
+ /** No body padding (tables, lists that run edge to edge). */
41
+ flush?: boolean;
42
+ collapsible?: boolean;
43
+ /** Initial state when collapsible. */
44
+ open?: boolean;
45
+ /** Exclusive-accordion group name for collapsible panels. */
46
+ group?: string;
47
+ };
48
+
49
+ const {
50
+ as: Tag = 'section',
51
+ title,
52
+ titleLevel = 2,
53
+ titleSize = 'l',
54
+ description,
55
+ variant = 'outline',
56
+ size = 'm',
57
+ divider = true,
58
+ flush = false,
59
+ collapsible = false,
60
+ open = true,
61
+ group,
62
+ id = uid('sinn-panel'),
63
+ 'aria-labelledby': labelledBy,
64
+ class: className,
65
+ ...rest
66
+ } = Astro.props;
67
+
68
+ const titleId = title ? `${id}-title` : undefined;
69
+ const hasHeader = Boolean(title || description || Astro.slots.has('header'));
70
+ const hasActions = Astro.slots.has('actions') && !collapsible;
71
+ const hasFooter = Astro.slots.has('footer');
72
+ const showDivider = divider && hasHeader;
73
+ ---
74
+
75
+ <Tag
76
+ id={id}
77
+ class:list={['sinn-panel', className]}
78
+ data-variant={variant === 'outline' ? undefined : variant}
79
+ data-size={size}
80
+ aria-labelledby={(labelledBy as string | undefined) ?? titleId}
81
+ {...rest}
82
+ >
83
+ {
84
+ collapsible ? (
85
+ <details open={open} name={group}>
86
+ <summary class="sinn-panel__header" data-divider={showDivider ? '' : undefined}>
87
+ <div class="sinn-panel__heading">
88
+ {title && (
89
+ <Heading level={titleLevel} size={titleSize} id={titleId}>
90
+ {title}
91
+ </Heading>
92
+ )}
93
+ {description && (
94
+ <Text size="s" tone="muted" class="sinn-panel__description">
95
+ {description}
96
+ </Text>
97
+ )}
98
+ <slot name="header" />
99
+ </div>
100
+ <svg class="sinn-panel__chevron" viewBox="0 0 20 20" aria-hidden="true" focusable="false">
101
+ <path d="M5 7.5l5 5 5-5" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" />
102
+ </svg>
103
+ </summary>
104
+ <div class="sinn-panel__body" data-after-divider={showDivider ? '' : undefined} data-flush={flush ? '' : undefined}>
105
+ <slot />
106
+ </div>
107
+ {hasFooter && (
108
+ <div class="sinn-panel__footer">
109
+ <slot name="footer" />
110
+ </div>
111
+ )}
112
+ </details>
113
+ ) : (
114
+ <>
115
+ {hasHeader && (
116
+ <div class="sinn-panel__header" data-divider={showDivider ? '' : undefined}>
117
+ <div class="sinn-panel__heading">
118
+ {title && (
119
+ <Heading level={titleLevel} size={titleSize} id={titleId}>
120
+ {title}
121
+ </Heading>
122
+ )}
123
+ {description && (
124
+ <Text size="s" tone="muted" class="sinn-panel__description">
125
+ {description}
126
+ </Text>
127
+ )}
128
+ <slot name="header" />
129
+ </div>
130
+ {hasActions && (
131
+ <div class="sinn-panel__actions">
132
+ <slot name="actions" />
133
+ </div>
134
+ )}
135
+ </div>
136
+ )}
137
+ <div
138
+ class="sinn-panel__body"
139
+ data-after-divider={showDivider ? '' : undefined}
140
+ data-no-header={hasHeader ? undefined : ''}
141
+ data-flush={flush ? '' : undefined}
142
+ >
143
+ <slot />
144
+ </div>
145
+ {hasFooter && (
146
+ <div class="sinn-panel__footer">
147
+ <slot name="footer" />
148
+ </div>
149
+ )}
150
+ </>
151
+ )
152
+ }
153
+ </Tag>
@@ -0,0 +1,167 @@
1
+ ---
2
+ /**
3
+ * Picture — lets the browser pick the best source: modern formats (AVIF, then WebP, then a
4
+ * JPEG/PNG fallback) and, with `sources`, a different image or crop per screen size
5
+ * (art direction: a tall crop on phones, a wide one on desktop).
6
+ *
7
+ * Each `<source>` carries its own width/height, so the reserved box matches whichever
8
+ * source wins (no layout shift, even when the crop changes by breakpoint). Same loading,
9
+ * sizing and cropping props as Image.
10
+ *
11
+ * Sources are tried in order: list narrow `media` queries first.
12
+ *
13
+ * @example
14
+ * <Picture src={heroWide} alt="A team reviewing a website launch" layout="full" aspect="21/9" priority
15
+ * sources={[{ media: '(max-width: 40rem)', src: heroTall, aspect: '4/5' }]} />
16
+ */
17
+ import type { HTMLAttributes } from 'astro/types';
18
+ import type { Aspect, ImageLayout } from './lib/image-plan';
19
+ import {
20
+ buildImageSet,
21
+ fallbackFormatFor,
22
+ type ImageFormat,
23
+ type ImageQuality,
24
+ type ImageSet,
25
+ type ImageSource,
26
+ type PictureSource,
27
+ } from './lib/image';
28
+ import './styles/utilities.css';
29
+ import './styles/media.css';
30
+
31
+ type Props = Omit<HTMLAttributes<'img'>, 'src' | 'srcset' | 'width' | 'height' | 'alt' | 'loading'> & {
32
+ src: ImageSource;
33
+ alt: string;
34
+ width?: number;
35
+ height?: number;
36
+ layout?: ImageLayout;
37
+ aspect?: Aspect;
38
+ fit?: 'cover' | 'contain';
39
+ position?: 'center' | 'top' | 'bottom' | 'start' | 'end';
40
+ sizes?: string;
41
+ priority?: boolean;
42
+ /** Modern formats, best first. */
43
+ formats?: ImageFormat[];
44
+ /** Format for the <img> fallback. Default: PNG for PNG/GIF sources, otherwise JPEG. */
45
+ fallbackFormat?: ImageFormat;
46
+ quality?: ImageQuality;
47
+ inferSize?: boolean;
48
+ /** Remote images: largest CSS width it's shown at (`width`/`height` are the file's size). */
49
+ displayWidth?: number;
50
+ /** Art direction: alternative images/crops by media query. */
51
+ sources?: PictureSource[];
52
+ radius?: 'none' | 's' | 'm' | 'l' | 'full';
53
+ placeholder?: boolean;
54
+ caption?: string;
55
+ credit?: string;
56
+ /** Class on the <picture> element. */
57
+ pictureClass?: string;
58
+ };
59
+
60
+ const {
61
+ src,
62
+ alt,
63
+ width,
64
+ height,
65
+ layout = 'constrained',
66
+ aspect,
67
+ fit = 'cover',
68
+ position = 'center',
69
+ sizes,
70
+ priority = false,
71
+ formats = ['avif', 'webp'],
72
+ fallbackFormat = fallbackFormatFor(src),
73
+ quality,
74
+ inferSize = false,
75
+ displayWidth,
76
+ sources = [],
77
+ radius = 'none',
78
+ placeholder = Boolean(aspect && aspect !== 'auto'),
79
+ caption,
80
+ credit,
81
+ class: className,
82
+ pictureClass,
83
+ ...rest
84
+ } = Astro.props;
85
+
86
+ // SVGs aren't rasterized into other formats.
87
+ const isSvg = fallbackFormat === 'svg';
88
+ const modern = isSvg ? [] : formats;
89
+
90
+ const art: Array<{ media: string; set: ImageSet }> = [];
91
+ for (const s of sources) {
92
+ for (const f of modern) {
93
+ art.push({
94
+ media: s.media,
95
+ set: await buildImageSet({ src: s.src, width: s.width, height: s.height, displayWidth: s.displayWidth ?? displayWidth, aspect: s.aspect, layout, sizes: s.sizes ?? sizes, format: f, quality, inferSize, position, lazy: !priority }),
96
+ });
97
+ }
98
+ }
99
+ const base: ImageSet[] = [];
100
+ for (const f of modern) base.push(await buildImageSet({ src, width, height, displayWidth, aspect, layout, sizes, format: f, quality, inferSize, position, lazy: !priority }));
101
+ const fallback = await buildImageSet({ src, width, height, displayWidth, aspect, layout, sizes, format: fallbackFormat, quality, inferSize, position, lazy: !priority });
102
+
103
+ // With art direction the files are already cropped per source and each <source> carries its
104
+ // own width/height, so the <img> must not force the base aspect in CSS.
105
+ const priorityAttrs = priority ? { loading: 'eager', fetchpriority: 'high' } : { loading: 'lazy', decoding: 'async' };
106
+ const figure = Boolean(caption || credit);
107
+ ---
108
+
109
+ {
110
+ figure ? (
111
+ <figure class:list={['sinn-figure', className]}>
112
+ <picture class:list={['sinn-picture', pictureClass]} data-layout={layout === 'constrained' ? undefined : layout}>
113
+ {art.map(({ media, set }) => (
114
+ <source media={media} type={set.type} srcset={set.srcset ?? set.src} sizes={set.sizes} width={set.width} height={set.height} />
115
+ ))}
116
+ {base.map((set) => (
117
+ <source type={set.type} srcset={set.srcset ?? set.src} sizes={set.sizes} width={set.width} height={set.height} />
118
+ ))}
119
+ <img
120
+ class="sinn-image"
121
+ src={fallback.src}
122
+ srcset={fallback.srcset}
123
+ sizes={fallback.sizes}
124
+ width={fallback.width}
125
+ height={fallback.height}
126
+ alt={alt}
127
+ data-aspect={sources.length === 0 && aspect && aspect !== 'auto' ? aspect : undefined}
128
+ data-fit={fit === 'cover' ? undefined : fit}
129
+ data-position={position === 'center' ? undefined : position}
130
+ data-radius={radius === 'none' ? undefined : radius}
131
+ data-placeholder={placeholder ? '' : undefined}
132
+ {...priorityAttrs}
133
+ {...rest}
134
+ />
135
+ </picture>
136
+ <figcaption class="sinn-figure__caption">
137
+ {caption}
138
+ {credit && <span class="sinn-figure__credit">{caption ? ' · ' : ''}{credit}</span>}
139
+ </figcaption>
140
+ </figure>
141
+ ) : (
142
+ <picture class:list={['sinn-picture', pictureClass]} data-layout={layout === 'constrained' ? undefined : layout}>
143
+ {art.map(({ media, set }) => (
144
+ <source media={media} type={set.type} srcset={set.srcset ?? set.src} sizes={set.sizes} width={set.width} height={set.height} />
145
+ ))}
146
+ {base.map((set) => (
147
+ <source type={set.type} srcset={set.srcset ?? set.src} sizes={set.sizes} width={set.width} height={set.height} />
148
+ ))}
149
+ <img
150
+ class:list={['sinn-image', className]}
151
+ src={fallback.src}
152
+ srcset={fallback.srcset}
153
+ sizes={fallback.sizes}
154
+ width={fallback.width}
155
+ height={fallback.height}
156
+ alt={alt}
157
+ data-aspect={sources.length === 0 && aspect && aspect !== 'auto' ? aspect : undefined}
158
+ data-fit={fit === 'cover' ? undefined : fit}
159
+ data-position={position === 'center' ? undefined : position}
160
+ data-radius={radius === 'none' ? undefined : radius}
161
+ data-placeholder={placeholder ? '' : undefined}
162
+ {...priorityAttrs}
163
+ {...rest}
164
+ />
165
+ </picture>
166
+ )
167
+ }