@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,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Hero — opens a page: headline, supporting text and the main call to action.
|
|
4
|
+
*
|
|
5
|
+
* Layouts (`layout`; `variant` is the deprecated name)
|
|
6
|
+
* - `text`: type only. Fastest; the right default for most inner pages.
|
|
7
|
+
* - `split`: text beside an image or video. Stacks (text first) in containers under 48rem.
|
|
8
|
+
* - `media`: full-bleed image or video behind the text, under a scrim that keeps every line of
|
|
9
|
+
* text at ≥ 4.5:1 even over a pure white photo. `scrim="gradient"` darkens only the text side
|
|
10
|
+
* (start-aligned heroes), letting more of the photo show.
|
|
11
|
+
*
|
|
12
|
+
* Content: props (`eyebrow`, `heading`, `description`, `actions`, `image`) for CMS data, or slots
|
|
13
|
+
* (`heading`, `description`, `actions`, `media`, `meta`, default) for custom markup. Both can mix.
|
|
14
|
+
*
|
|
15
|
+
* Accessibility & performance
|
|
16
|
+
* - Heading level 1 by default; use 2 if the page already has an h1. A labelled <section>.
|
|
17
|
+
* - The hero image is usually the LCP element, so `image` loads with high priority (eager,
|
|
18
|
+
* fetchpriority=high) unless `imagePriority={false}`. Background media should be decorative
|
|
19
|
+
* (`alt: ""`); anything meaningful belongs in the text.
|
|
20
|
+
* - Background video: wrap it in primitives <ReducedMotion> in the `media` slot.
|
|
21
|
+
* - One solid action; `actions` makes the first solid and the rest outline automatically.
|
|
22
|
+
* - Placeholder: with no heading, renders a dashed placeholder in dev/CMS preview, nothing in builds.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* <Hero layout="split" eyebrow="Sinnstack web studio" heading="Websites that ship fast"
|
|
26
|
+
* description="Design, development and a CMS your team can edit."
|
|
27
|
+
* actions={[{ label: 'Book a visit', href: '/book' }, { label: 'See services', href: '/services' }]}
|
|
28
|
+
* image={{ src: office, alt: 'A developer walking a client through a new site' }} />
|
|
29
|
+
*/
|
|
30
|
+
import Heading from '../primitives/Heading.astro';
|
|
31
|
+
import Text from '../primitives/Text.astro';
|
|
32
|
+
import Image from '../primitives/Image.astro';
|
|
33
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
34
|
+
import type { ActionItem, BlockProps, ImageSource } from './types';
|
|
35
|
+
import BlockShell from './internal/BlockShell.astro';
|
|
36
|
+
import Actions from './internal/Actions.astro';
|
|
37
|
+
import Placeholder from './internal/Placeholder.astro';
|
|
38
|
+
import { blockIds, PLACEHOLDER_DEFAULT } from './internal/util';
|
|
39
|
+
import { sf, joinField } from './internal/fields';
|
|
40
|
+
import { renameProp } from '../primitives/lib/deprecate';
|
|
41
|
+
|
|
42
|
+
type Props = Omit<HTMLAttributes<'section'>, 'title'> &
|
|
43
|
+
BlockProps & {
|
|
44
|
+
/** Arrangement: `text`, `split` (text beside media) or `media` (media behind the text). */
|
|
45
|
+
layout?: 'text' | 'split' | 'media';
|
|
46
|
+
/** @deprecated Use `layout`. */
|
|
47
|
+
variant?: 'text' | 'split' | 'media';
|
|
48
|
+
eyebrow?: string;
|
|
49
|
+
heading?: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
actions?: ActionItem[];
|
|
52
|
+
/** Small print under the actions ("Fixed-price projects · No lock-in"). */
|
|
53
|
+
meta?: string;
|
|
54
|
+
/** Split: the side image. Media: the background (use alt ""). Or use the `media` slot. */
|
|
55
|
+
image?: ImageSource;
|
|
56
|
+
imagePriority?: boolean;
|
|
57
|
+
/** 1 unless the page already has an h1. */
|
|
58
|
+
headingLevel?: 1 | 2;
|
|
59
|
+
/** Headline scale: s 2xl · m 3xl · l 4xl. */
|
|
60
|
+
size?: 's' | 'm' | 'l';
|
|
61
|
+
/** Split only: which side the media sits on in wide containers. */
|
|
62
|
+
mediaPosition?: 'start' | 'end';
|
|
63
|
+
/** Split only: media box shape. */
|
|
64
|
+
mediaAspect?: '1/1' | '4/3' | '3/2' | '16/9' | '4/5';
|
|
65
|
+
/** Media only: minimum height. */
|
|
66
|
+
minHeight?: 'auto' | 'm' | 'l' | 'screen';
|
|
67
|
+
/** Media only: `even` darkens the whole image; `gradient` mainly the text side. */
|
|
68
|
+
scrim?: 'even' | 'gradient';
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const {
|
|
72
|
+
layout: layoutProp,
|
|
73
|
+
variant,
|
|
74
|
+
eyebrow,
|
|
75
|
+
heading,
|
|
76
|
+
description,
|
|
77
|
+
actions = [],
|
|
78
|
+
meta,
|
|
79
|
+
image,
|
|
80
|
+
imagePriority = true,
|
|
81
|
+
headingLevel = 1,
|
|
82
|
+
size = 'l',
|
|
83
|
+
align = 'start',
|
|
84
|
+
mediaPosition = 'end',
|
|
85
|
+
mediaAspect = '4/3',
|
|
86
|
+
minHeight = 'm',
|
|
87
|
+
scrim = 'even',
|
|
88
|
+
anchor,
|
|
89
|
+
spacing: spacingProp,
|
|
90
|
+
background = 'none',
|
|
91
|
+
tone = 'accent',
|
|
92
|
+
scheme,
|
|
93
|
+
containerSize = 'default',
|
|
94
|
+
placeholder = PLACEHOLDER_DEFAULT,
|
|
95
|
+
fieldPath,
|
|
96
|
+
id,
|
|
97
|
+
class: className,
|
|
98
|
+
...rest
|
|
99
|
+
} = Astro.props;
|
|
100
|
+
|
|
101
|
+
const layout = renameProp('Hero', 'layout', layoutProp, 'variant', variant) ?? 'text';
|
|
102
|
+
const spacing = spacingProp ?? (layout === 'media' ? 'xl' : 'l');
|
|
103
|
+
|
|
104
|
+
const slots = Astro.slots;
|
|
105
|
+
const hasHeading = Boolean(heading?.trim()) || slots.has('heading');
|
|
106
|
+
const hasMedia = layout !== 'text' && (Boolean(image) || slots.has('media'));
|
|
107
|
+
const { sectionId, headingId } = blockIds('hero', anchor, id);
|
|
108
|
+
const effectiveAlign = layout === 'split' ? 'start' : align;
|
|
109
|
+
const headingSize = ({ s: '2xl', m: '3xl', l: '4xl' } as const)[size];
|
|
110
|
+
const effectiveScrim = layout === 'media' && scrim === 'gradient' && effectiveAlign === 'start' ? 'gradient' : undefined;
|
|
111
|
+
const splitAspect = mediaAspect;
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
{
|
|
115
|
+
!hasHeading ? (
|
|
116
|
+
placeholder && <Placeholder label="Hero" hint="Add a heading to show this section." field={joinField(fieldPath)} />
|
|
117
|
+
) : (
|
|
118
|
+
<BlockShell
|
|
119
|
+
name="hero"
|
|
120
|
+
id={sectionId}
|
|
121
|
+
class={className}
|
|
122
|
+
spacing={spacing}
|
|
123
|
+
background={layout === 'media' ? 'none' : background}
|
|
124
|
+
tone={tone}
|
|
125
|
+
scheme={layout === 'media' ? undefined : scheme}
|
|
126
|
+
size={size}
|
|
127
|
+
containerSize={containerSize}
|
|
128
|
+
labelledby={headingId}
|
|
129
|
+
align={effectiveAlign}
|
|
130
|
+
data-layout={layout}
|
|
131
|
+
data-media-position={layout === 'split' && mediaPosition === 'start' ? 'start' : undefined}
|
|
132
|
+
data-media-aspect={layout === 'split' && splitAspect !== '4/3' ? splitAspect.replace('/', '-') : undefined}
|
|
133
|
+
data-min-height={layout === 'media' && minHeight !== 'm' ? minHeight : undefined}
|
|
134
|
+
data-scrim={effectiveScrim}
|
|
135
|
+
data-has-media={hasMedia ? '' : undefined}
|
|
136
|
+
{...sf(fieldPath)}
|
|
137
|
+
{...rest}
|
|
138
|
+
>
|
|
139
|
+
<Fragment slot="bleed">
|
|
140
|
+
{layout === 'media' && hasMedia && (
|
|
141
|
+
<div class="sinn-hero__bg" {...sf(fieldPath, 'image')}>
|
|
142
|
+
{slots.has('media') ? <slot name="media" /> : image && <Image src={image.src} alt={image.alt} width={image.width} height={image.height} layout="full" priority={imagePriority} sizes="100vw" />}
|
|
143
|
+
</div>
|
|
144
|
+
)}
|
|
145
|
+
</Fragment>
|
|
146
|
+
<div class="sinn-hero__layout">
|
|
147
|
+
<div class="sinn-hero__content">
|
|
148
|
+
{eyebrow && <p class="sinn-block__eyebrow" {...sf(fieldPath, 'eyebrow')}>{eyebrow}</p>}
|
|
149
|
+
<Heading level={headingLevel} size={headingSize} weight="bold" id={headingId} class="sinn-hero__title" {...sf(fieldPath, 'heading')}>
|
|
150
|
+
{slots.has('heading') ? <slot name="heading" /> : heading}
|
|
151
|
+
</Heading>
|
|
152
|
+
{(description || slots.has('description')) && (
|
|
153
|
+
<Text size="l" tone="muted" class="sinn-hero__description" measure {...sf(fieldPath, 'description')}>
|
|
154
|
+
{slots.has('description') ? <slot name="description" /> : description}
|
|
155
|
+
</Text>
|
|
156
|
+
)}
|
|
157
|
+
<slot />
|
|
158
|
+
<Actions actions={actions} class="sinn-hero__actions" fieldPath={fieldPath}>
|
|
159
|
+
{slots.has('actions') && <slot name="actions" />}
|
|
160
|
+
</Actions>
|
|
161
|
+
{(meta || slots.has('meta')) && <p class="sinn-hero__meta" {...sf(fieldPath, 'meta')}>{slots.has('meta') ? <slot name="meta" /> : meta}</p>}
|
|
162
|
+
</div>
|
|
163
|
+
{layout === 'split' && hasMedia && (
|
|
164
|
+
<div class="sinn-hero__media" {...sf(fieldPath, 'image')}>
|
|
165
|
+
{slots.has('media') ? <slot name="media" /> : image && <Image src={image.src} alt={image.alt} width={image.width} height={image.height} layout="full" aspect={splitAspect} priority={imagePriority} sizes="(min-width: 60rem) 50vw, 100vw" />}
|
|
166
|
+
</div>
|
|
167
|
+
)}
|
|
168
|
+
</div>
|
|
169
|
+
</BlockShell>
|
|
170
|
+
)
|
|
171
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* HeroCarousel — a few rotating hero messages over full-bleed images.
|
|
4
|
+
*
|
|
5
|
+
* Use sparingly: most visitors only see the first slide, so put the main message there (or use
|
|
6
|
+
* a Hero). This exists for sites that need it (a client home page with several messages).
|
|
7
|
+
*
|
|
8
|
+
* Progressive enhancement (checklist §2, option 2: .astro + a small script, ~2 KB)
|
|
9
|
+
* - Without JavaScript: a horizontal scroll-snap strip. Every slide is real HTML, swipeable on
|
|
10
|
+
* touch, scrollable by keyboard (the strip is focusable) and readable in order.
|
|
11
|
+
* - With JavaScript: previous/next buttons, a slide picker, arrow keys on the focused strip, and
|
|
12
|
+
* inactive slides made `inert` (out of the tab order and the accessibility tree). Swiping still
|
|
13
|
+
* works and keeps the controls in sync. Event: `sinn-slide-change` { index, previousIndex }.
|
|
14
|
+
*
|
|
15
|
+
* Accessibility (WAI-ARIA APG carousel pattern; WCAG 2.2.2 Pause, Stop, Hide)
|
|
16
|
+
* - `aria-roledescription="carousel"` on a labelled section; each slide is a labelled group
|
|
17
|
+
* ("2 of 3"). The controls come first in the tab order.
|
|
18
|
+
* - Autoplay is OFF by default. `autoplay={7}` rotates every 7 s, with a visible pause/play
|
|
19
|
+
* button. It never starts with reduced motion, pauses while the pointer is over the carousel or
|
|
20
|
+
* focus is inside it, while the tab is hidden and while it's off screen. The live region is
|
|
21
|
+
* off while rotating (no chatter) and polite when the user moves slides.
|
|
22
|
+
* - Slide text sits on the same scrim as the Hero media variant (≥ 4.5:1 over any photo).
|
|
23
|
+
* Background images are decorative (alt is always empty).
|
|
24
|
+
* - Slide headings are h2 (`headingLevel`). With `headingLevel={1}`, only the first slide's
|
|
25
|
+
* heading is an h1; the rest are h2, so the page never gets several h1s.
|
|
26
|
+
*
|
|
27
|
+
* Look
|
|
28
|
+
* - `minHeight="banner"`: a wide banner, clamp(26rem, 46vw, 38.5rem) tall, like a classic site
|
|
29
|
+
* slider; `m`/`l`/`screen` are taller.
|
|
30
|
+
* - `motion="zoom"`: the current slide's photo slowly settles from 108% to 100% (a "Ken Burns"
|
|
31
|
+
* effect) so the hero never looks frozen. Off with reduced motion.
|
|
32
|
+
* - `controls="split"`: round previous/next arrows on the sides (hidden on narrow screens, where
|
|
33
|
+
* swiping and the dots do the job) and a small pill with pause + dots at the bottom. `bar`
|
|
34
|
+
* (default) keeps every control in one bar. `--sinn-carousel-controls-offset` lifts the
|
|
35
|
+
* controls, e.g. above cards that overlap the bottom of the carousel.
|
|
36
|
+
*
|
|
37
|
+
* Performance: the first slide's image loads with high priority (it's usually the LCP); the rest
|
|
38
|
+
* are lazy. Every slide shares one height (the tallest content or `minHeight`), so there's no
|
|
39
|
+
* layout shift as slides change.
|
|
40
|
+
*
|
|
41
|
+
* Placeholder: no slide with a heading → dashed placeholder in dev/CMS preview, nothing in builds.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* <HeroCarousel label="Featured messages" autoplay={7} slides={[
|
|
45
|
+
* { eyebrow: 'Design, development and hosting', heading: 'Fast, accessible, editable', image: { src: hero1, alt: '' },
|
|
46
|
+
* actions: [{ label: 'Learn more', href: '/services' }] },
|
|
47
|
+
* { heading: 'Launches we’re proud of', image: { src: hero2, alt: '' }, actions: [{ label: 'Case studies', href: '/work' }] },
|
|
48
|
+
* ]} />
|
|
49
|
+
*/
|
|
50
|
+
import Container from '../primitives/Container.astro';
|
|
51
|
+
import Heading from '../primitives/Heading.astro';
|
|
52
|
+
import Text from '../primitives/Text.astro';
|
|
53
|
+
import Image from '../primitives/Image.astro';
|
|
54
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
55
|
+
import type { BlockProps, SlideItem } from './types';
|
|
56
|
+
import Actions from './internal/Actions.astro';
|
|
57
|
+
import Placeholder from './internal/Placeholder.astro';
|
|
58
|
+
import CarouselScript from './internal/CarouselScript.astro';
|
|
59
|
+
import { uid } from '../primitives/utils';
|
|
60
|
+
import { blockIds, PLACEHOLDER_DEFAULT } from './internal/util';
|
|
61
|
+
import { sf, joinField } from './internal/fields';
|
|
62
|
+
import './styles/blocks.css';
|
|
63
|
+
|
|
64
|
+
type Props = Omit<HTMLAttributes<'section'>, 'title'> &
|
|
65
|
+
Omit<BlockProps, 'background' | 'tone' | 'scheme'> & {
|
|
66
|
+
slides?: SlideItem[];
|
|
67
|
+
/** Accessible name of the carousel ("Featured messages"). */
|
|
68
|
+
label?: string;
|
|
69
|
+
/** Seconds per slide. 0 / omitted = no autoplay (recommended). Minimum 5. */
|
|
70
|
+
autoplay?: number;
|
|
71
|
+
headingLevel?: 1 | 2;
|
|
72
|
+
/** Slide height: banner (26–38.5rem, follows the width) · m (32rem) · l (75% of the viewport) · screen. */
|
|
73
|
+
minHeight?: 'banner' | 'm' | 'l' | 'screen';
|
|
74
|
+
/** `zoom`: the current photo slowly zooms out (off with reduced motion). */
|
|
75
|
+
motion?: 'none' | 'zoom';
|
|
76
|
+
/** `bar`: all controls in one bottom bar · `split`: arrows on the sides, dots + pause below. */
|
|
77
|
+
controls?: 'bar' | 'split';
|
|
78
|
+
/** `even` darkens the whole image; `gradient` mainly the text side (start-aligned only). */
|
|
79
|
+
scrim?: 'even' | 'gradient';
|
|
80
|
+
/** Headline scale: s 2xl · m 3xl · l 4xl. */
|
|
81
|
+
size?: 's' | 'm' | 'l';
|
|
82
|
+
imagePriority?: boolean;
|
|
83
|
+
/** Control labels, for other languages. */
|
|
84
|
+
labels?: Partial<typeof DEFAULT_LABELS>;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const DEFAULT_LABELS = {
|
|
88
|
+
previous: 'Previous slide',
|
|
89
|
+
next: 'Next slide',
|
|
90
|
+
pause: 'Pause automatic slide show',
|
|
91
|
+
play: 'Start automatic slide show',
|
|
92
|
+
picker: 'Choose a slide',
|
|
93
|
+
/** {n} and {total} are replaced. */
|
|
94
|
+
slide: '{n} of {total}',
|
|
95
|
+
goTo: 'Slide {n}',
|
|
96
|
+
strip: 'Slides',
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const {
|
|
100
|
+
slides = [],
|
|
101
|
+
label = 'Featured',
|
|
102
|
+
autoplay = 0,
|
|
103
|
+
headingLevel = 2,
|
|
104
|
+
minHeight = 'm',
|
|
105
|
+
motion = 'none',
|
|
106
|
+
controls = 'bar',
|
|
107
|
+
scrim = 'even',
|
|
108
|
+
size = 'm',
|
|
109
|
+
imagePriority = true,
|
|
110
|
+
labels: labelOverrides = {},
|
|
111
|
+
align = 'start',
|
|
112
|
+
anchor,
|
|
113
|
+
spacing = 'xl',
|
|
114
|
+
containerSize = 'default',
|
|
115
|
+
placeholder = PLACEHOLDER_DEFAULT,
|
|
116
|
+
fieldPath,
|
|
117
|
+
id,
|
|
118
|
+
class: className,
|
|
119
|
+
...rest
|
|
120
|
+
} = Astro.props;
|
|
121
|
+
|
|
122
|
+
const L = { ...DEFAULT_LABELS, ...labelOverrides };
|
|
123
|
+
const list = (slides ?? []).filter((s) => s && String(s.heading ?? '').trim());
|
|
124
|
+
const total = list.length;
|
|
125
|
+
const { sectionId } = blockIds('carousel', anchor, id);
|
|
126
|
+
const base = sectionId ?? uid('sinn-carousel');
|
|
127
|
+
const trackId = `${base}-track`;
|
|
128
|
+
const seconds = autoplay && autoplay > 0 ? Math.max(5, autoplay) : 0;
|
|
129
|
+
const headingSize = ({ s: '2xl', m: '3xl', l: '4xl' } as const)[size];
|
|
130
|
+
const fill = (s: string, n: number) => s.replace('{n}', String(n)).replace('{total}', String(total));
|
|
131
|
+
const effectiveScrim = scrim === 'gradient' && align === 'start' ? 'gradient' : undefined;
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
{
|
|
135
|
+
total === 0 ? (
|
|
136
|
+
placeholder && <Placeholder label="Hero carousel" hint="Add at least one slide with a heading." field={joinField(fieldPath, 'slides')} />
|
|
137
|
+
) : (
|
|
138
|
+
<section
|
|
139
|
+
id={sectionId}
|
|
140
|
+
class:list={['sinn-block', 'sinn-carousel', className]}
|
|
141
|
+
aria-roledescription="carousel"
|
|
142
|
+
aria-label={label}
|
|
143
|
+
data-sinn-carousel
|
|
144
|
+
data-autoplay={seconds || undefined}
|
|
145
|
+
data-spacing={spacing === 'l' ? undefined : spacing}
|
|
146
|
+
data-size={size === 'm' ? undefined : size}
|
|
147
|
+
data-align={align === 'center' ? 'center' : undefined}
|
|
148
|
+
data-min-height={minHeight === 'm' ? undefined : minHeight}
|
|
149
|
+
data-motion={motion === 'zoom' ? 'zoom' : undefined}
|
|
150
|
+
data-controls={controls === 'split' ? 'split' : undefined}
|
|
151
|
+
data-scrim={effectiveScrim}
|
|
152
|
+
data-count={total}
|
|
153
|
+
{...sf(fieldPath)}
|
|
154
|
+
{...rest}
|
|
155
|
+
>
|
|
156
|
+
{total > 1 && (
|
|
157
|
+
<div class="sinn-carousel__controls" data-carousel-controls hidden>
|
|
158
|
+
{seconds > 0 && (
|
|
159
|
+
<button type="button" class="sinn-carousel__button" data-carousel-rotate data-label-pause={L.pause} data-label-play={L.play}>
|
|
160
|
+
<svg class="sinn-carousel__icon" data-icon="pause" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M8 5h3v14H8zM13 5h3v14h-3z" fill="currentColor" /></svg>
|
|
161
|
+
<svg class="sinn-carousel__icon" data-icon="play" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M8 5.5v13l11-6.5z" fill="currentColor" /></svg>
|
|
162
|
+
<span class="sinn-sr-only" data-carousel-rotate-text>{L.pause}</span>
|
|
163
|
+
</button>
|
|
164
|
+
)}
|
|
165
|
+
<button type="button" class="sinn-carousel__button" data-carousel-prev aria-controls={trackId}>
|
|
166
|
+
<svg class="sinn-carousel__icon sinn-carousel__icon--dir" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m15 5-7 7 7 7" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" /></svg>
|
|
167
|
+
<span class="sinn-sr-only">{L.previous}</span>
|
|
168
|
+
</button>
|
|
169
|
+
<div class="sinn-carousel__picker" role="group" aria-label={L.picker}>
|
|
170
|
+
{list.map((slide, i) => (
|
|
171
|
+
<button type="button" class="sinn-carousel__dot" data-carousel-dot={i} aria-controls={`${base}-slide-${i}`} aria-current={i === 0 ? 'true' : undefined}>
|
|
172
|
+
<span class="sinn-sr-only">{fill(L.goTo, i + 1)}: {slide.heading}</span>
|
|
173
|
+
</button>
|
|
174
|
+
))}
|
|
175
|
+
</div>
|
|
176
|
+
<button type="button" class="sinn-carousel__button" data-carousel-next aria-controls={trackId}>
|
|
177
|
+
<svg class="sinn-carousel__icon sinn-carousel__icon--dir" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m9 5 7 7-7 7" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" /></svg>
|
|
178
|
+
<span class="sinn-sr-only">{L.next}</span>
|
|
179
|
+
</button>
|
|
180
|
+
</div>
|
|
181
|
+
)}
|
|
182
|
+
<div class="sinn-carousel__track" id={trackId} tabindex={total > 1 ? 0 : undefined} role={total > 1 ? 'group' : undefined} aria-label={total > 1 ? L.strip : undefined} aria-live={total > 1 ? 'polite' : undefined} {...sf(fieldPath, 'slides')}>
|
|
183
|
+
{list.map((slide, i) => {
|
|
184
|
+
const level = headingLevel === 1 && i === 0 ? 1 : 2;
|
|
185
|
+
return (
|
|
186
|
+
<div
|
|
187
|
+
class="sinn-carousel__slide"
|
|
188
|
+
id={`${base}-slide-${i}`}
|
|
189
|
+
role={total > 1 ? 'group' : undefined}
|
|
190
|
+
aria-roledescription={total > 1 ? 'slide' : undefined}
|
|
191
|
+
aria-label={total > 1 ? fill(L.slide, i + 1) : undefined}
|
|
192
|
+
data-current={i === 0 ? '' : undefined}
|
|
193
|
+
data-has-image={slide.image ? '' : undefined}
|
|
194
|
+
{...sf(fieldPath, slide.field)}
|
|
195
|
+
>
|
|
196
|
+
{slide.image && (
|
|
197
|
+
<div class="sinn-carousel__bg" {...sf(fieldPath, slide.field, 'image')}>
|
|
198
|
+
<Image src={slide.image.src} alt="" width={slide.image.width} height={slide.image.height} layout="full" sizes="100vw" priority={imagePriority && i === 0} />
|
|
199
|
+
</div>
|
|
200
|
+
)}
|
|
201
|
+
<Container size={containerSize} class="sinn-carousel__container" query={false}>
|
|
202
|
+
<div class="sinn-carousel__content">
|
|
203
|
+
{slide.eyebrow && <p class="sinn-block__eyebrow sinn-carousel__eyebrow" {...sf(fieldPath, slide.field, 'eyebrow')}>{slide.eyebrow}</p>}
|
|
204
|
+
<Heading level={level} size={headingSize} weight="bold" class="sinn-carousel__title" {...sf(fieldPath, slide.field, 'heading')}>
|
|
205
|
+
{slide.heading}
|
|
206
|
+
</Heading>
|
|
207
|
+
{slide.description && (
|
|
208
|
+
<Text size="l" class="sinn-carousel__description" measure {...sf(fieldPath, slide.field, 'description')}>{slide.description}</Text>
|
|
209
|
+
)}
|
|
210
|
+
<Actions actions={slide.actions ?? []} class="sinn-carousel__actions" fieldPath={joinField(fieldPath, slide.field)} />
|
|
211
|
+
</div>
|
|
212
|
+
</Container>
|
|
213
|
+
</div>
|
|
214
|
+
);
|
|
215
|
+
})}
|
|
216
|
+
</div>
|
|
217
|
+
{total > 1 && <CarouselScript />}
|
|
218
|
+
</section>
|
|
219
|
+
)
|
|
220
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* HighlightCards: a row of 2–4 solid-color cards, each with a heading, a short text or bullet
|
|
4
|
+
* points, and a button: "New projects · Agency partners · Support hours" under a home hero.
|
|
5
|
+
*
|
|
6
|
+
* - Each card is a strong surface: text, buttons, bullets and the focus ring recolor for contrast.
|
|
7
|
+
* `tone` per card (`accent`, `neutral`, or a tone your theme defines); by default they
|
|
8
|
+
* alternate accent / neutral.
|
|
9
|
+
* - `overlap`: on wide screens the row is pulled up over the section above (usually a hero or
|
|
10
|
+
* carousel) by `--sinn-highlight-overlap` (4.5rem). Give that section room at the bottom, e.g.
|
|
11
|
+
* HeroCarousel's `--sinn-carousel-controls-offset`.
|
|
12
|
+
* - `gap="none"` (default): the cards touch, as one band (no section spacing). `gap="m"`: separate
|
|
13
|
+
* rounded cards with the usual section spacing.
|
|
14
|
+
* - Cards sit side by side once the row is at least 60rem wide, otherwise they stack.
|
|
15
|
+
* On narrow screens with `gap="none"` they run edge to edge.
|
|
16
|
+
* - Buttons sit on one line at the bottom of every card, whatever the text length.
|
|
17
|
+
* - The section has no heading of its own: pass `label` to name it ("How can we help?").
|
|
18
|
+
* Card headings are h2 (`headingLevel`).
|
|
19
|
+
* - Placeholder: no card with a heading → dashed placeholder in dev/CMS preview.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* <HighlightCards label="How can we help?" overlap items={[
|
|
23
|
+
* { heading: 'New projects', description: 'Call or send us a brief…', actions: [{ label: 'Start a project', href: '/contact', variant: 'outline', arrow: true }] },
|
|
24
|
+
* { heading: 'Support hours', points: ['Studio: Mon–Fri, 9–5', 'Support plans: 24/7'], tone: 'neutral', actions: [{ label: 'Contact us', href: '/contact' }] },
|
|
25
|
+
* ]} />
|
|
26
|
+
*/
|
|
27
|
+
import Container from '../primitives/Container.astro';
|
|
28
|
+
import Heading from '../primitives/Heading.astro';
|
|
29
|
+
import Text from '../primitives/Text.astro';
|
|
30
|
+
import BulletList from '../primitives/BulletList.astro';
|
|
31
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
32
|
+
import type { BlockProps, HeadingLevelNumber, HighlightCardItem } from './types';
|
|
33
|
+
import Actions from './internal/Actions.astro';
|
|
34
|
+
import Placeholder from './internal/Placeholder.astro';
|
|
35
|
+
import { blockIds, PLACEHOLDER_DEFAULT } from './internal/util';
|
|
36
|
+
import { sf, joinField } from './internal/fields';
|
|
37
|
+
import './styles/blocks.css';
|
|
38
|
+
|
|
39
|
+
type Props = Omit<HTMLAttributes<'section'>, 'title'> &
|
|
40
|
+
Omit<BlockProps, 'background' | 'tone'> & {
|
|
41
|
+
items?: HighlightCardItem[];
|
|
42
|
+
/** Accessible name for the section (it has no visible heading of its own). */
|
|
43
|
+
label?: string;
|
|
44
|
+
headingLevel?: HeadingLevelNumber;
|
|
45
|
+
/** Pull the row up over the section above on wide screens. */
|
|
46
|
+
overlap?: boolean;
|
|
47
|
+
/** Space between cards: none (one band) or m (separate rounded cards). */
|
|
48
|
+
gap?: 'none' | 'm';
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const {
|
|
52
|
+
items = [],
|
|
53
|
+
label,
|
|
54
|
+
headingLevel = 2,
|
|
55
|
+
overlap = false,
|
|
56
|
+
gap = 'none',
|
|
57
|
+
align = 'start',
|
|
58
|
+
anchor,
|
|
59
|
+
spacing = gap === 'm' ? 'l' : 'none',
|
|
60
|
+
scheme,
|
|
61
|
+
containerSize = 'default',
|
|
62
|
+
placeholder = PLACEHOLDER_DEFAULT,
|
|
63
|
+
fieldPath,
|
|
64
|
+
id,
|
|
65
|
+
class: className,
|
|
66
|
+
...rest
|
|
67
|
+
} = Astro.props;
|
|
68
|
+
|
|
69
|
+
const cards = (items ?? []).filter((c) => c && String(c.heading ?? '').trim()).slice(0, 4);
|
|
70
|
+
if ((items ?? []).length > 4 && import.meta.env?.DEV) console.warn('[HighlightCards] Only the first four cards are shown.');
|
|
71
|
+
const { sectionId } = blockIds('highlights', anchor, id);
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
{
|
|
75
|
+
cards.length === 0 ? (
|
|
76
|
+
placeholder && <Placeholder label="Highlight cards" hint="Add a heading to at least one card." field={joinField(fieldPath, 'items')} />
|
|
77
|
+
) : (
|
|
78
|
+
<section
|
|
79
|
+
id={sectionId}
|
|
80
|
+
class:list={['sinn-block', 'sinn-highlights', className]}
|
|
81
|
+
aria-label={label || undefined}
|
|
82
|
+
data-spacing={spacing === 'l' ? undefined : spacing}
|
|
83
|
+
data-scheme={scheme}
|
|
84
|
+
data-align={align === 'center' ? 'center' : undefined}
|
|
85
|
+
data-overlap={overlap ? '' : undefined}
|
|
86
|
+
data-gap={gap}
|
|
87
|
+
data-count={cards.length}
|
|
88
|
+
{...sf(fieldPath)}
|
|
89
|
+
{...rest}
|
|
90
|
+
>
|
|
91
|
+
<Container size={containerSize} class="sinn-block__container" query={false}>
|
|
92
|
+
<ul class="sinn-highlights__list" role="list" {...sf(fieldPath, 'items')}>
|
|
93
|
+
{cards.map((card, i) => (
|
|
94
|
+
<li class="sinn-highlights__card" data-surface="strong" data-tone={card.tone ?? (i % 2 === 0 ? 'accent' : 'neutral')} {...sf(fieldPath, card.field)}>
|
|
95
|
+
<Heading level={headingLevel} size="xl" weight="regular" class="sinn-highlights__title" {...sf(fieldPath, card.field, 'heading')}>
|
|
96
|
+
{card.heading}
|
|
97
|
+
</Heading>
|
|
98
|
+
{card.description && <Text class="sinn-highlights__description" {...sf(fieldPath, card.field, 'description')}>{card.description}</Text>}
|
|
99
|
+
{!!card.points?.length && <BulletList items={card.points} marker="dot" gap="3xs" class="sinn-highlights__points" {...sf(fieldPath, card.field, 'points')} />}
|
|
100
|
+
<Actions actions={card.actions ?? []} size="m" class="sinn-highlights__actions" fieldPath={joinField(fieldPath, card.field)} />
|
|
101
|
+
</li>
|
|
102
|
+
))}
|
|
103
|
+
</ul>
|
|
104
|
+
</Container>
|
|
105
|
+
</section>
|
|
106
|
+
)
|
|
107
|
+
}
|