@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.
- package/CHANGELOG.md +89 -0
- package/LICENSE +373 -0
- package/README.md +188 -2
- package/docs/blocks.md +373 -0
- package/docs/data.md +128 -0
- package/docs/finishes.md +165 -0
- package/docs/motion.md +166 -0
- package/docs/primitives.md +510 -0
- package/docs/seo.md +191 -0
- package/docs/tokens.md +122 -0
- package/package.json +132 -3
- package/scripts/check-contrast.mjs +180 -0
- package/src/blocks/BlockRenderer.astro +60 -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 +173 -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 +58 -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 +48 -0
- package/src/blocks/cms/consent.ts +16 -0
- package/src/blocks/cms/contact-card.ts +46 -0
- package/src/blocks/cms/contact-form.ts +37 -0
- package/src/blocks/cms/cta-banner.ts +27 -0
- package/src/blocks/cms/cta-pair.ts +30 -0
- package/src/blocks/cms/data-base.ts +5 -0
- package/src/blocks/cms/data.ts +257 -0
- package/src/blocks/cms/faq.ts +38 -0
- package/src/blocks/cms/feature-grid.ts +47 -0
- package/src/blocks/cms/fixtures.ts +591 -0
- package/src/blocks/cms/hero-carousel.ts +36 -0
- package/src/blocks/cms/hero.ts +33 -0
- package/src/blocks/cms/highlight-cards.ts +41 -0
- package/src/blocks/cms/images.ts +37 -0
- package/src/blocks/cms/index.ts +59 -0
- package/src/blocks/cms/location-hours.ts +67 -0
- package/src/blocks/cms/logo-cloud.ts +36 -0
- package/src/blocks/cms/media-text.ts +26 -0
- package/src/blocks/cms/page-header.ts +27 -0
- package/src/blocks/cms/pages.ts +35 -0
- package/src/blocks/cms/prose-section.ts +25 -0
- package/src/blocks/cms/reviews.ts +50 -0
- package/src/blocks/cms/schema-dsl.ts +134 -0
- package/src/blocks/cms/schema.ts +794 -0
- package/src/blocks/cms/shared.ts +63 -0
- package/src/blocks/cms/stats-band.ts +35 -0
- package/src/blocks/cms/steps.ts +40 -0
- package/src/blocks/cms/testimonials.ts +46 -0
- package/src/blocks/cms/topbar.ts +27 -0
- package/src/blocks/cms/types.ts +27 -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 +35 -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/consent.ts +96 -0
- package/src/blocks/internal/fields.ts +18 -0
- package/src/blocks/internal/registry-contract.ts +67 -0
- package/src/blocks/internal/reviews.ts +22 -0
- package/src/blocks/internal/slug.ts +12 -0
- package/src/blocks/internal/util.ts +23 -0
- package/src/blocks/lib/contact.ts +92 -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/markdown.ts +350 -0
- package/src/blocks/lib/rich-text.ts +132 -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 +107 -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 +293 -0
- package/src/data/ChartAxis.astro +19 -0
- package/src/data/ChartContainer.astro +152 -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 +130 -0
- package/src/data/index.ts +10 -0
- package/src/data/internal/scale.ts +107 -0
- package/src/data/lib/chart.ts +459 -0
- package/src/data/lib/render.ts +219 -0
- package/src/data/lib/sparkline.ts +117 -0
- package/src/data/schema.ts +65 -0
- package/src/data/scripts/chart.ts +324 -0
- package/src/data/styles/chart.css +392 -0
- package/src/finishes/aurora.css +75 -0
- package/src/finishes/autumn.css +87 -0
- package/src/finishes/blueprint.css +69 -0
- package/src/finishes/brutalist.css +55 -0
- package/src/finishes/clay.css +48 -0
- package/src/finishes/day-cycle.css +46 -0
- package/src/finishes/fog.css +71 -0
- package/src/finishes/glass.css +149 -0
- package/src/finishes/holographic.css +91 -0
- package/src/finishes/night.css +77 -0
- package/src/finishes/paper.css +58 -0
- package/src/finishes/polished-glass.css +159 -0
- package/src/finishes/rain.css +84 -0
- package/src/finishes/scripts/day-cycle.ts +30 -0
- package/src/finishes/scripts/holographic.ts +37 -0
- package/src/finishes/scripts/spotlight.ts +30 -0
- package/src/finishes/spotlight.css +41 -0
- package/src/finishes/spring.css +80 -0
- package/src/finishes/terminal.css +49 -0
- package/src/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 +86 -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 +278 -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 +109 -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 +75 -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 +91 -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/internal/image-plan.ts +82 -0
- package/src/primitives/internal/image.ts +129 -0
- package/src/primitives/internal/slider.ts +170 -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/motion.ts +68 -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 +59 -0
- package/src/seo/index.ts +10 -0
- package/src/seo/integration.ts +268 -0
- package/src/seo/internal/url.ts +68 -0
- package/src/seo/lib/jsonld.ts +342 -0
- package/src/seo/lib/meta.ts +205 -0
- package/src/seo/lib/redirects.ts +293 -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/schema.ts +43 -0
- package/src/tokens/base.css +71 -0
- 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 './internal/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 './internal/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' } as const) : ({ loading: 'lazy', decoding: 'async' } as const);
|
|
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
|
+
}
|