@sinnstack/ui 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/LICENSE +373 -0
- package/README.md +186 -2
- package/docs/blocks.md +364 -0
- package/docs/data.md +128 -0
- package/docs/motion.md +166 -0
- package/docs/primitives.md +510 -0
- package/docs/seo.md +187 -0
- package/docs/tokens.md +122 -0
- package/package.json +141 -3
- package/scripts/check-contrast.mjs +180 -0
- package/src/blocks/BlockRenderer.astro +54 -0
- package/src/blocks/CTABanner.astro +121 -0
- package/src/blocks/CTAPair.astro +110 -0
- package/src/blocks/CardGrid.astro +167 -0
- package/src/blocks/ConsentEmbed.astro +125 -0
- package/src/blocks/ConsentManager.astro +147 -0
- package/src/blocks/ConsentScript.astro +47 -0
- package/src/blocks/ContactCard.astro +164 -0
- package/src/blocks/ContactForm.astro +224 -0
- package/src/blocks/ErrorPage.astro +242 -0
- package/src/blocks/FAQ.astro +135 -0
- package/src/blocks/FeatureGrid.astro +148 -0
- package/src/blocks/Hero.astro +171 -0
- package/src/blocks/HeroCarousel.astro +220 -0
- package/src/blocks/HighlightCards.astro +107 -0
- package/src/blocks/LocationHours.astro +311 -0
- package/src/blocks/LogoCloud.astro +135 -0
- package/src/blocks/MaintenancePage.astro +168 -0
- package/src/blocks/MediaText.astro +177 -0
- package/src/blocks/PageHeader.astro +126 -0
- package/src/blocks/ProseSection.astro +98 -0
- package/src/blocks/Reviews.astro +194 -0
- package/src/blocks/RichText.astro +57 -0
- package/src/blocks/StatsBand.astro +117 -0
- package/src/blocks/Steps.astro +141 -0
- package/src/blocks/Testimonials.astro +144 -0
- package/src/blocks/Topbar.astro +158 -0
- package/src/blocks/cms/card-grid.ts +80 -0
- package/src/blocks/cms/consent.ts +45 -0
- package/src/blocks/cms/contact-card.ts +88 -0
- package/src/blocks/cms/contact-form.ts +55 -0
- package/src/blocks/cms/cta-banner.ts +48 -0
- package/src/blocks/cms/cta-pair.ts +63 -0
- package/src/blocks/cms/data-base.ts +7 -0
- package/src/blocks/cms/data.ts +257 -0
- package/src/blocks/cms/faq.ts +70 -0
- package/src/blocks/cms/feature-grid.ts +80 -0
- package/src/blocks/cms/fixtures.ts +599 -0
- package/src/blocks/cms/hero-carousel.ts +80 -0
- package/src/blocks/cms/hero.ts +77 -0
- package/src/blocks/cms/highlight-cards.ts +76 -0
- package/src/blocks/cms/images.ts +38 -0
- package/src/blocks/cms/index.ts +87 -0
- package/src/blocks/cms/location-hours.ts +149 -0
- package/src/blocks/cms/logo-cloud.ts +62 -0
- package/src/blocks/cms/media-text.ts +44 -0
- package/src/blocks/cms/page-header.ts +49 -0
- package/src/blocks/cms/pages.ts +81 -0
- package/src/blocks/cms/prose-section.ts +45 -0
- package/src/blocks/cms/reviews.ts +101 -0
- package/src/blocks/cms/shared.ts +115 -0
- package/src/blocks/cms/stats-band.ts +61 -0
- package/src/blocks/cms/steps.ts +67 -0
- package/src/blocks/cms/testimonials.ts +80 -0
- package/src/blocks/cms/topbar.ts +64 -0
- package/src/blocks/cms/types.ts +63 -0
- package/src/blocks/consent.ts +14 -0
- package/src/blocks/icons.ts +47 -0
- package/src/blocks/index.ts +42 -0
- package/src/blocks/internal/Actions.astro +29 -0
- package/src/blocks/internal/BlockHeader.astro +45 -0
- package/src/blocks/internal/BlockShell.astro +58 -0
- package/src/blocks/internal/CarouselScript.astro +7 -0
- package/src/blocks/internal/ConsentEmbedScript.astro +7 -0
- package/src/blocks/internal/ConsentManagerScript.astro +7 -0
- package/src/blocks/internal/HoursScript.astro +7 -0
- package/src/blocks/internal/Placeholder.astro +13 -0
- package/src/blocks/internal/RichTextNode.astro +133 -0
- package/src/blocks/internal/StandaloneDocument.astro +53 -0
- package/src/blocks/internal/tina.ts +19 -0
- package/src/blocks/internal/util.ts +23 -0
- package/src/blocks/lib/consent.ts +96 -0
- package/src/blocks/lib/contact.ts +86 -0
- package/src/blocks/lib/error-pages.ts +119 -0
- package/src/blocks/lib/faq.ts +37 -0
- package/src/blocks/lib/hours.ts +201 -0
- package/src/blocks/lib/maintenance.ts +129 -0
- package/src/blocks/lib/reviews.ts +22 -0
- package/src/blocks/lib/rich-text.ts +143 -0
- package/src/blocks/lib/slug.ts +12 -0
- package/src/blocks/registry.ts +79 -0
- package/src/blocks/scripts/carousel.ts +218 -0
- package/src/blocks/scripts/consent-embed.ts +105 -0
- package/src/blocks/scripts/consent-manager.ts +112 -0
- package/src/blocks/scripts/consent-store.ts +86 -0
- package/src/blocks/scripts/error-page.ts +71 -0
- package/src/blocks/scripts/hours.ts +106 -0
- package/src/blocks/scripts/maintenance.ts +109 -0
- package/src/blocks/styles/blocks.css +1320 -0
- package/src/blocks/styles/consent.css +102 -0
- package/src/blocks/styles/faq.css +28 -0
- package/src/blocks/styles/location.css +92 -0
- package/src/blocks/styles/prose-section.css +13 -0
- package/src/blocks/styles/quotes.css +123 -0
- package/src/blocks/styles/rich-text.css +14 -0
- package/src/blocks/types.ts +283 -0
- package/src/data/ChartAxis.astro +19 -0
- package/src/data/ChartContainer.astro +151 -0
- package/src/data/ChartLegend.astro +25 -0
- package/src/data/ChartSeries.astro +14 -0
- package/src/data/ChartTable.astro +17 -0
- package/src/data/ChartTooltip.astro +20 -0
- package/src/data/Sparkline.astro +55 -0
- package/src/data/cms.ts +190 -0
- package/src/data/index.ts +10 -0
- package/src/data/lib/chart.ts +450 -0
- package/src/data/lib/render.ts +219 -0
- package/src/data/lib/scale.ts +107 -0
- package/src/data/lib/sparkline.ts +117 -0
- package/src/data/scripts/chart.ts +324 -0
- package/src/data/styles/chart.css +392 -0
- package/src/motion/Marquee.astro +90 -0
- package/src/motion/MotionProvider.astro +50 -0
- package/src/motion/PageTransitions.astro +61 -0
- package/src/motion/Parallax.astro +44 -0
- package/src/motion/ParallaxLayer.astro +31 -0
- package/src/motion/RevealOnScroll.astro +59 -0
- package/src/motion/SceneRegistry.astro +38 -0
- package/src/motion/ScrollScene.astro +81 -0
- package/src/motion/index.ts +12 -0
- package/src/motion/integration.ts +48 -0
- package/src/motion/runtime/page-transitions.ts +68 -0
- package/src/motion/runtime/runtime.ts +180 -0
- package/src/motion/runtime/scenes.ts +248 -0
- package/src/motion/runtime/types.ts +103 -0
- package/src/motion/styles/motion.css +332 -0
- package/src/motion/transitions.ts +74 -0
- package/src/motion/virtual.d.ts +4 -0
- package/src/primitives/Accordion.astro +129 -0
- package/src/primitives/Breadcrumbs.astro +50 -0
- package/src/primitives/BulletList.astro +69 -0
- package/src/primitives/Button.astro +73 -0
- package/src/primitives/ButtonGroup.astro +54 -0
- package/src/primitives/Callout.astro +137 -0
- package/src/primitives/Caption.astro +35 -0
- package/src/primitives/Card.astro +72 -0
- package/src/primitives/CardContent.astro +24 -0
- package/src/primitives/CardFooter.astro +36 -0
- package/src/primitives/CardHeader.astro +86 -0
- package/src/primitives/Checkbox.astro +38 -0
- package/src/primitives/ChoiceGroup.astro +23 -0
- package/src/primitives/Cluster.astro +49 -0
- package/src/primitives/Container.astro +44 -0
- package/src/primitives/DescriptionList.astro +83 -0
- package/src/primitives/Dialog.astro +38 -0
- package/src/primitives/Disclosure.astro +67 -0
- package/src/primitives/Divider.astro +93 -0
- package/src/primitives/Drawer.astro +33 -0
- package/src/primitives/Fieldset.astro +80 -0
- package/src/primitives/Flex.astro +64 -0
- package/src/primitives/FocusRing.astro +63 -0
- package/src/primitives/FocusTrap.astro +64 -0
- package/src/primitives/Footer.astro +155 -0
- package/src/primitives/Form.astro +68 -0
- package/src/primitives/FormDescription.astro +26 -0
- package/src/primitives/FormError.astro +106 -0
- package/src/primitives/FormField.astro +72 -0
- package/src/primitives/Grid.astro +64 -0
- package/src/primitives/Heading.astro +45 -0
- package/src/primitives/IconButton.astro +48 -0
- package/src/primitives/Image.astro +125 -0
- package/src/primitives/Input.astro +84 -0
- package/src/primitives/Label.astro +50 -0
- package/src/primitives/Link.astro +81 -0
- package/src/primitives/LinkButton.astro +66 -0
- package/src/primitives/List.astro +39 -0
- package/src/primitives/ListItem.astro +178 -0
- package/src/primitives/MediaObject.astro +66 -0
- package/src/primitives/MetricCard.astro +276 -0
- package/src/primitives/NavLink.astro +81 -0
- package/src/primitives/NavMenu.astro +109 -0
- package/src/primitives/Navbar.astro +197 -0
- package/src/primitives/Panel.astro +153 -0
- package/src/primitives/Picture.astro +167 -0
- package/src/primitives/Popover.astro +95 -0
- package/src/primitives/Prose.astro +45 -0
- package/src/primitives/Radio.astro +21 -0
- package/src/primitives/Rating.astro +135 -0
- package/src/primitives/ReducedMotion.astro +90 -0
- package/src/primitives/SegmentedControl.astro +132 -0
- package/src/primitives/Select.astro +107 -0
- package/src/primitives/Sheet.astro +45 -0
- package/src/primitives/SkipLink.astro +31 -0
- package/src/primitives/Slider.astro +186 -0
- package/src/primitives/Spacer.astro +35 -0
- package/src/primitives/Stack.astro +51 -0
- package/src/primitives/Surface.astro +70 -0
- package/src/primitives/Switch.astro +22 -0
- package/src/primitives/Table.astro +382 -0
- package/src/primitives/Tabs.astro +126 -0
- package/src/primitives/Text.astro +56 -0
- package/src/primitives/Textarea.astro +73 -0
- package/src/primitives/Thumbnail.astro +154 -0
- package/src/primitives/Toggle.astro +99 -0
- package/src/primitives/Tooltip.astro +50 -0
- package/src/primitives/VisuallyHidden.astro +29 -0
- package/src/primitives/index.ts +103 -0
- package/src/primitives/internal/AccordionScript.astro +7 -0
- package/src/primitives/internal/ChoiceField.astro +89 -0
- package/src/primitives/internal/FocusTrapScript.astro +8 -0
- package/src/primitives/internal/FormValidationScript.astro +10 -0
- package/src/primitives/internal/IndeterminateScript.astro +13 -0
- package/src/primitives/internal/ModalPanel.astro +114 -0
- package/src/primitives/internal/OverlayScript.astro +7 -0
- package/src/primitives/internal/ReducedMotionScript.astro +7 -0
- package/src/primitives/internal/SliderScript.astro +7 -0
- package/src/primitives/internal/SparklineScript.astro +7 -0
- package/src/primitives/internal/TableSortScript.astro +7 -0
- package/src/primitives/internal/TabsScript.astro +7 -0
- package/src/primitives/internal/TooltipScript.astro +7 -0
- package/src/primitives/lib/deprecate.ts +47 -0
- package/src/primitives/lib/focus-trap.ts +197 -0
- package/src/primitives/lib/focus.ts +60 -0
- package/src/primitives/lib/image-plan.ts +82 -0
- package/src/primitives/lib/image.ts +129 -0
- package/src/primitives/lib/motion.ts +68 -0
- package/src/primitives/lib/slider.ts +170 -0
- package/src/primitives/scripts/accordion.ts +123 -0
- package/src/primitives/scripts/form-validation.ts +225 -0
- package/src/primitives/scripts/overlay.ts +71 -0
- package/src/primitives/scripts/reduced-motion.ts +59 -0
- package/src/primitives/scripts/slider.ts +150 -0
- package/src/primitives/scripts/sparkline.ts +131 -0
- package/src/primitives/scripts/table-sort.ts +68 -0
- package/src/primitives/scripts/tabs.ts +151 -0
- package/src/primitives/scripts/tooltip.ts +28 -0
- package/src/primitives/styles/a11y.css +104 -0
- package/src/primitives/styles/accordion.css +53 -0
- package/src/primitives/styles/breadcrumbs.css +59 -0
- package/src/primitives/styles/bullet-list.css +89 -0
- package/src/primitives/styles/button.css +237 -0
- package/src/primitives/styles/choice.css +164 -0
- package/src/primitives/styles/cluster.css +24 -0
- package/src/primitives/styles/container.css +19 -0
- package/src/primitives/styles/data.css +849 -0
- package/src/primitives/styles/disclosure.css +140 -0
- package/src/primitives/styles/divider.css +50 -0
- package/src/primitives/styles/flex.css +42 -0
- package/src/primitives/styles/form.css +241 -0
- package/src/primitives/styles/grid.css +36 -0
- package/src/primitives/styles/media.css +247 -0
- package/src/primitives/styles/nav.css +792 -0
- package/src/primitives/styles/overlay.css +362 -0
- package/src/primitives/styles/prose.css +146 -0
- package/src/primitives/styles/scale.css +175 -0
- package/src/primitives/styles/segmented.css +165 -0
- package/src/primitives/styles/slider.css +170 -0
- package/src/primitives/styles/spacer.css +17 -0
- package/src/primitives/styles/stack.css +25 -0
- package/src/primitives/styles/surface.css +403 -0
- package/src/primitives/styles/tabs.css +223 -0
- package/src/primitives/styles/typography.css +144 -0
- package/src/primitives/styles/utilities.css +24 -0
- package/src/primitives/types.ts +385 -0
- package/src/primitives/utils.ts +254 -0
- package/src/seo/JSONLD.astro +35 -0
- package/src/seo/SEOHead.astro +47 -0
- package/src/seo/cms.ts +80 -0
- package/src/seo/index.ts +10 -0
- package/src/seo/integration.ts +231 -0
- package/src/seo/lib/jsonld.ts +334 -0
- package/src/seo/lib/meta.ts +205 -0
- package/src/seo/lib/redirects.ts +283 -0
- package/src/seo/lib/robots.ts +33 -0
- package/src/seo/lib/rss.ts +98 -0
- package/src/seo/lib/sitemap.ts +105 -0
- package/src/seo/lib/url.ts +68 -0
- package/src/tokens/base.css +71 -0
- package/src/tokens/tokens.css +210 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Card — groups related content in a distinct container. Compose with CardHeader,
|
|
4
|
+
* CardContent and CardFooter; put an image in the `media` slot.
|
|
5
|
+
*
|
|
6
|
+
* - Cards fill their grid cell, so a row of cards shares one height and footers line up.
|
|
7
|
+
* - Whole-card link: give CardHeader an `href`. The title becomes the only link and
|
|
8
|
+
* stretches over the card; other buttons and links in the card still work.
|
|
9
|
+
* - `orientation="horizontal"` puts media beside the content while the card is wider
|
|
10
|
+
* than ~30rem, and stacks it when narrower (no breakpoints).
|
|
11
|
+
* - `as="article"` when each card is self-contained (blog posts, products, providers).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <Grid min="s" as="ul">
|
|
15
|
+
* <li><Card as="article">
|
|
16
|
+
* <Image slot="media" src={photo} alt="" />
|
|
17
|
+
* <CardHeader title="Ana Ruiz" href="/team/ana-ruiz" description="Lead developer" />
|
|
18
|
+
* <CardContent><Text size="s">Booking new projects.</Text></CardContent>
|
|
19
|
+
* <CardFooter divider><Caption>Fort Worth</Caption></CardFooter>
|
|
20
|
+
* </Card></li>
|
|
21
|
+
* </Grid>
|
|
22
|
+
*/
|
|
23
|
+
import type { HTMLAttributes, HTMLTag } from 'astro/types';
|
|
24
|
+
import './styles/utilities.css';
|
|
25
|
+
import './styles/surface.css';
|
|
26
|
+
import { renameValue } from './lib/deprecate';
|
|
27
|
+
|
|
28
|
+
type Props = HTMLAttributes<'div'> & {
|
|
29
|
+
as?: HTMLTag;
|
|
30
|
+
variant?: 'outline' | 'elevated' | 'filled';
|
|
31
|
+
/** Padding and radius scale. */
|
|
32
|
+
size?: 's' | 'm' | 'l';
|
|
33
|
+
orientation?: 'vertical' | 'horizontal';
|
|
34
|
+
/** Aspect ratio of the media slot, in CSS `aspect-ratio` syntax like Image, Hero and MediaText. The dash forms (`16-9`) are deprecated. */
|
|
35
|
+
mediaAspect?: '16/9' | '3/2' | '4/3' | '1/1' | 'auto' | '16-9' | '3-2' | '4-3' | '1-1';
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const {
|
|
39
|
+
as: Tag = 'div',
|
|
40
|
+
variant = 'outline',
|
|
41
|
+
size = 'm',
|
|
42
|
+
orientation = 'vertical',
|
|
43
|
+
mediaAspect: mediaAspectProp = '16/9',
|
|
44
|
+
class: className,
|
|
45
|
+
...rest
|
|
46
|
+
} = Astro.props;
|
|
47
|
+
const mediaAspect = renameValue('Card', 'mediaAspect', mediaAspectProp, { '16-9': '16/9', '3-2': '3/2', '4-3': '4/3', '1-1': '1/1' });
|
|
48
|
+
// Internal attribute value: CSS attribute selectors keep the dash form.
|
|
49
|
+
const aspectKey = mediaAspect.replace('/', '-');
|
|
50
|
+
|
|
51
|
+
const hasMedia = Astro.slots.has('media');
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
<Tag
|
|
55
|
+
class:list={['sinn-card', className]}
|
|
56
|
+
data-variant={variant === 'outline' ? undefined : variant}
|
|
57
|
+
data-size={size}
|
|
58
|
+
data-orientation={orientation === 'vertical' ? undefined : orientation}
|
|
59
|
+
data-media-aspect={hasMedia && aspectKey !== '16-9' ? aspectKey : undefined}
|
|
60
|
+
{...rest}
|
|
61
|
+
>
|
|
62
|
+
{
|
|
63
|
+
hasMedia && (
|
|
64
|
+
<div class="sinn-card__media">
|
|
65
|
+
<slot name="media" />
|
|
66
|
+
</div>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
<div class="sinn-card__body">
|
|
70
|
+
<slot />
|
|
71
|
+
</div>
|
|
72
|
+
</Tag>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* CardContent — the card's main content. Stacks its children with `gap` and grows to
|
|
4
|
+
* fill spare height, which keeps CardFooters aligned across a row of cards.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <CardContent><Text size="s">…</Text><Cluster gap="3xs">…tags…</Cluster></CardContent>
|
|
8
|
+
*/
|
|
9
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
10
|
+
import type { Space } from './types';
|
|
11
|
+
import './styles/scale.css';
|
|
12
|
+
import './styles/utilities.css';
|
|
13
|
+
import './styles/surface.css';
|
|
14
|
+
|
|
15
|
+
type Props = HTMLAttributes<'div'> & {
|
|
16
|
+
gap?: Space;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { gap = 'xs', class: className, ...rest } = Astro.props;
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
<div class:list={['sinn-card__content', className]} data-gap={gap} {...rest}>
|
|
23
|
+
<slot />
|
|
24
|
+
</div>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* CardFooter — actions or metadata at the bottom of a card. Wraps on narrow cards.
|
|
4
|
+
*
|
|
5
|
+
* - `justify="end"` for actions, `"between"` for meta + action, `"stretch"` for
|
|
6
|
+
* equal-width buttons.
|
|
7
|
+
* - `divider` draws a hairline above it.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* <CardFooter justify="between" divider><Caption>Updated Nov 2026</Caption><Link href="…">Read</Link></CardFooter>
|
|
11
|
+
* <CardFooter justify="end"><Button variant="ghost">Cancel</Button><Button>Book</Button></CardFooter>
|
|
12
|
+
*/
|
|
13
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
14
|
+
import type { Space } from './types';
|
|
15
|
+
import './styles/scale.css';
|
|
16
|
+
import './styles/utilities.css';
|
|
17
|
+
import './styles/surface.css';
|
|
18
|
+
|
|
19
|
+
type Props = HTMLAttributes<'div'> & {
|
|
20
|
+
justify?: 'start' | 'end' | 'between' | 'stretch';
|
|
21
|
+
divider?: boolean;
|
|
22
|
+
gap?: Space;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const { justify = 'start', divider = false, gap = '2xs', class: className, ...rest } = Astro.props;
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
<div
|
|
29
|
+
class:list={['sinn-card__footer', className]}
|
|
30
|
+
data-justify={justify === 'start' ? undefined : justify}
|
|
31
|
+
data-divider={divider ? '' : undefined}
|
|
32
|
+
data-gap={gap}
|
|
33
|
+
{...rest}
|
|
34
|
+
>
|
|
35
|
+
<slot />
|
|
36
|
+
</div>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* CardHeader — the card's title area: optional eyebrow, title, description, and an
|
|
4
|
+
* `actions` slot pinned to the end (e.g. an IconButton menu).
|
|
5
|
+
*
|
|
6
|
+
* `href` makes the title the card's link and stretches it over the whole card
|
|
7
|
+
* ("block link" pattern): one focusable, well-named link instead of a link wrapping
|
|
8
|
+
* all the card's text. Keep the title short; it's what screen readers announce.
|
|
9
|
+
*
|
|
10
|
+
* `titleLevel` sets the heading level (default 3, for cards under a page's h2 sections).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <CardHeader eyebrow="Guide" title="Preparing for your first visit" href="/guides/first-visit"
|
|
14
|
+
* description="What to bring and what to expect." />
|
|
15
|
+
* <CardHeader title="Billing">
|
|
16
|
+
* <IconButton slot="actions" label="Billing options" size="s">…</IconButton>
|
|
17
|
+
* </CardHeader>
|
|
18
|
+
*/
|
|
19
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
20
|
+
import type { HeadingLevel, TextSize } from './types';
|
|
21
|
+
import Heading from './Heading.astro';
|
|
22
|
+
import Text from './Text.astro';
|
|
23
|
+
import './styles/utilities.css';
|
|
24
|
+
import './styles/surface.css';
|
|
25
|
+
|
|
26
|
+
type Props = Omit<HTMLAttributes<'div'>, 'title'> & {
|
|
27
|
+
title?: string;
|
|
28
|
+
titleLevel?: HeadingLevel;
|
|
29
|
+
titleSize?: TextSize;
|
|
30
|
+
/** id for the title, e.g. to label the card with aria-labelledby. */
|
|
31
|
+
titleId?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
/** Small label above the title ("Guide", "New"). */
|
|
34
|
+
eyebrow?: string;
|
|
35
|
+
/** Makes the whole card a link to this URL. */
|
|
36
|
+
href?: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
title,
|
|
41
|
+
titleLevel = 3,
|
|
42
|
+
titleSize = 'l',
|
|
43
|
+
titleId,
|
|
44
|
+
description,
|
|
45
|
+
eyebrow,
|
|
46
|
+
href,
|
|
47
|
+
class: className,
|
|
48
|
+
...rest
|
|
49
|
+
} = Astro.props;
|
|
50
|
+
|
|
51
|
+
const hasActions = Astro.slots.has('actions');
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
<div class:list={['sinn-card__header', className]} {...rest}>
|
|
55
|
+
<div class="sinn-card__heading">
|
|
56
|
+
{eyebrow && <p class="sinn-card__eyebrow">{eyebrow}</p>}
|
|
57
|
+
{
|
|
58
|
+
title && (
|
|
59
|
+
<Heading level={titleLevel} size={titleSize} id={titleId}>
|
|
60
|
+
{href ? (
|
|
61
|
+
<a class="sinn-card__link" href={href}>
|
|
62
|
+
{title}
|
|
63
|
+
</a>
|
|
64
|
+
) : (
|
|
65
|
+
title
|
|
66
|
+
)}
|
|
67
|
+
</Heading>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
{
|
|
71
|
+
description && (
|
|
72
|
+
<Text size="s" tone="muted" class="sinn-card__description">
|
|
73
|
+
{description}
|
|
74
|
+
</Text>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
<slot />
|
|
78
|
+
</div>
|
|
79
|
+
{
|
|
80
|
+
hasActions && (
|
|
81
|
+
<div class="sinn-card__actions">
|
|
82
|
+
<slot name="actions" />
|
|
83
|
+
</div>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
</div>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Checkbox — select zero or more options. Native `<input type="checkbox">`.
|
|
4
|
+
*
|
|
5
|
+
* `class` goes on the wrapper; everything else (`name`, `value`, `checked`,
|
|
6
|
+
* `required`, `disabled`…) goes on the input. Without a label, pass `aria-label`.
|
|
7
|
+
*
|
|
8
|
+
* `error` shows a message under the label, e.g. for a required "I agree" box.
|
|
9
|
+
* For a set of checkboxes, put the error on the surrounding Fieldset instead.
|
|
10
|
+
*
|
|
11
|
+
* `indeterminate` is a DOM property, not an attribute, so a tiny script (~100 B) applies it.
|
|
12
|
+
* The script is only included on pages that render an indeterminate checkbox.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* <Checkbox name="terms" required label="I agree to the terms"
|
|
16
|
+
* messages={{ valueMissing: 'You must agree to the terms to continue' }} />
|
|
17
|
+
* <Checkbox name="news" description="About once a month.">Send me the newsletter</Checkbox>
|
|
18
|
+
*/
|
|
19
|
+
import ChoiceField from './internal/ChoiceField.astro';
|
|
20
|
+
import IndeterminateScript from './internal/IndeterminateScript.astro';
|
|
21
|
+
import type { ChoiceFieldProps } from './types';
|
|
22
|
+
|
|
23
|
+
type Props = ChoiceFieldProps & {
|
|
24
|
+
/** Mixed state, e.g. a "select all" when only some items are selected. */
|
|
25
|
+
indeterminate?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const { indeterminate = false, ...rest } = Astro.props;
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
<ChoiceField
|
|
32
|
+
kind="checkbox"
|
|
33
|
+
extraInputAttrs={{ 'data-indeterminate': indeterminate ? '' : undefined }}
|
|
34
|
+
{...rest}
|
|
35
|
+
>
|
|
36
|
+
<slot />
|
|
37
|
+
</ChoiceField>
|
|
38
|
+
{indeterminate && <IndeterminateScript />}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* ChoiceGroup — a Fieldset preset for Radios and Checkboxes (tighter spacing).
|
|
4
|
+
* Same props as Fieldset. Group errors ("Select a contact method") go here, and
|
|
5
|
+
* Form's inline validation writes radio errors here too.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <ChoiceGroup legend="Contact method" required>
|
|
9
|
+
* <Radio name="contact" value="email" label="Email" required />
|
|
10
|
+
* <Radio name="contact" value="phone" label="Phone" required />
|
|
11
|
+
* </ChoiceGroup>
|
|
12
|
+
*/
|
|
13
|
+
import type { ComponentProps } from 'astro/types';
|
|
14
|
+
import Fieldset from './Fieldset.astro';
|
|
15
|
+
|
|
16
|
+
type Props = ComponentProps<typeof Fieldset>;
|
|
17
|
+
|
|
18
|
+
const { gap = 'xs', ...rest } = Astro.props;
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
<Fieldset gap={gap} {...rest}>
|
|
22
|
+
<slot />
|
|
23
|
+
</Fieldset>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Cluster — groups items horizontally and wraps them onto new lines as needed.
|
|
4
|
+
* For tags, buttons, nav links, meta rows.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <Cluster gap="xs" as="ul" justify="between">…</Cluster>
|
|
8
|
+
*/
|
|
9
|
+
import type { HTMLAttributes, HTMLTag } from 'astro/types';
|
|
10
|
+
import { LIST_TAGS, type Align, type Justify, type Space } from './types';
|
|
11
|
+
import './styles/utilities.css';
|
|
12
|
+
import './styles/scale.css';
|
|
13
|
+
import './styles/cluster.css';
|
|
14
|
+
|
|
15
|
+
type Props = HTMLAttributes<'div'> & {
|
|
16
|
+
as?: HTMLTag;
|
|
17
|
+
/** Gap between items on the same line. */
|
|
18
|
+
gap?: Space;
|
|
19
|
+
/** Gap between wrapped lines. Defaults to `gap`. */
|
|
20
|
+
rowGap?: Space;
|
|
21
|
+
justify?: Justify;
|
|
22
|
+
align?: Align;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
as: Tag = 'div',
|
|
27
|
+
gap = 's',
|
|
28
|
+
rowGap,
|
|
29
|
+
justify = 'start',
|
|
30
|
+
align = 'center',
|
|
31
|
+
class: className,
|
|
32
|
+
role,
|
|
33
|
+
...rest
|
|
34
|
+
} = Astro.props;
|
|
35
|
+
|
|
36
|
+
const resolvedRole = role ?? (LIST_TAGS.has(Tag) ? 'list' : undefined);
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
<Tag
|
|
40
|
+
class:list={['sinn-cluster', className]}
|
|
41
|
+
data-gap={gap}
|
|
42
|
+
data-row-gap={rowGap ?? gap}
|
|
43
|
+
data-justify={justify}
|
|
44
|
+
data-align={align}
|
|
45
|
+
role={resolvedRole}
|
|
46
|
+
{...rest}
|
|
47
|
+
>
|
|
48
|
+
<slot />
|
|
49
|
+
</Tag>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Container — constrains content to a consistent maximum width with side gutters.
|
|
4
|
+
* Also a query container by default, so blocks inside can use @container.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <Container size="narrow" as="main"><slot /></Container>
|
|
8
|
+
*/
|
|
9
|
+
import type { HTMLAttributes, HTMLTag } from 'astro/types';
|
|
10
|
+
import type { Space } from './types';
|
|
11
|
+
import './styles/utilities.css';
|
|
12
|
+
import './styles/scale.css';
|
|
13
|
+
import './styles/container.css';
|
|
14
|
+
|
|
15
|
+
type Props = Omit<HTMLAttributes<'div'>, 'size'> & {
|
|
16
|
+
/** Element to render. Use `main`, `section`, `article` etc. for landmarks. */
|
|
17
|
+
as?: HTMLTag;
|
|
18
|
+
/** Max width token. `full` removes the cap but keeps gutters. */
|
|
19
|
+
size?: 'narrow' | 'default' | 'wide' | 'full';
|
|
20
|
+
/** Inline padding on each side. */
|
|
21
|
+
gutter?: Space;
|
|
22
|
+
/** Set `container-type: inline-size` so children can use container queries. */
|
|
23
|
+
query?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
as: Tag = 'div',
|
|
28
|
+
size = 'default',
|
|
29
|
+
gutter = 'm',
|
|
30
|
+
query = true,
|
|
31
|
+
class: className,
|
|
32
|
+
...rest
|
|
33
|
+
} = Astro.props;
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
<Tag
|
|
37
|
+
class:list={['sinn-container', className]}
|
|
38
|
+
data-size={size}
|
|
39
|
+
data-gutter={gutter}
|
|
40
|
+
data-query={query ? '' : undefined}
|
|
41
|
+
{...rest}
|
|
42
|
+
>
|
|
43
|
+
<slot />
|
|
44
|
+
</Tag>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* DescriptionList — related terms and their values (`<dl>`), in four layouts:
|
|
4
|
+
*
|
|
5
|
+
* - `stacked` (default): term above value. Profiles, record details.
|
|
6
|
+
* - `inline`: term | value in aligned columns (subgrid), stacking below ~28rem of width.
|
|
7
|
+
* Settings summaries, client/account details.
|
|
8
|
+
* - `grid`: tiles of key facts with large values. Plan details, property facts.
|
|
9
|
+
* - `summary`: label … amount rows with tabular figures and an emphasized total.
|
|
10
|
+
* Invoices, price breakdowns, order summaries.
|
|
11
|
+
*
|
|
12
|
+
* Items come from `items` (with optional Intl formatting) or as children:
|
|
13
|
+
* `<div class="sinn-dl__item"><dt class="sinn-dl__term">…</dt><dd class="sinn-dl__desc">…</dd></div>`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* <DescriptionList layout="summary" items={[
|
|
17
|
+
* { term: 'Office visit', value: 180, format: 'currency' },
|
|
18
|
+
* { term: 'Partner discount', value: -95.5, format: 'currency', tone: 'success' },
|
|
19
|
+
* { term: 'You owe', value: 84.5, format: 'currency', emphasis: true },
|
|
20
|
+
* ]} />
|
|
21
|
+
*/
|
|
22
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
23
|
+
import type { DescriptionItem } from './types';
|
|
24
|
+
import { formatValue, LEGACY_VALUE_TONES } from './utils';
|
|
25
|
+
import { renameValue } from './lib/deprecate';
|
|
26
|
+
import './styles/utilities.css';
|
|
27
|
+
import './styles/data.css';
|
|
28
|
+
|
|
29
|
+
type Props = HTMLAttributes<'dl'> & {
|
|
30
|
+
items?: DescriptionItem[];
|
|
31
|
+
layout?: 'stacked' | 'inline' | 'grid' | 'summary';
|
|
32
|
+
/** Hairlines between items. Default on for inline and summary. */
|
|
33
|
+
divided?: boolean;
|
|
34
|
+
density?: 'default' | 'compact';
|
|
35
|
+
locale?: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const {
|
|
39
|
+
items = [],
|
|
40
|
+
layout = 'stacked',
|
|
41
|
+
divided = layout === 'inline' || layout === 'summary',
|
|
42
|
+
density = 'default',
|
|
43
|
+
locale = 'en-US',
|
|
44
|
+
class: className,
|
|
45
|
+
...rest
|
|
46
|
+
} = Astro.props;
|
|
47
|
+
|
|
48
|
+
const NUMERIC = new Set(['number', 'integer', 'compact', 'currency', 'percent', 'delta', 'delta-percent']);
|
|
49
|
+
const rows = items.map((item) => {
|
|
50
|
+
const kind = typeof item.format === 'string' ? item.format : item.format?.kind;
|
|
51
|
+
const hasValue = item.value !== undefined;
|
|
52
|
+
return {
|
|
53
|
+
...item,
|
|
54
|
+
text: hasValue ? formatValue(item.value, item.format ?? 'text', locale) : (item.description ?? '—'),
|
|
55
|
+
numeric: hasValue && kind ? NUMERIC.has(kind) : false,
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
<dl
|
|
61
|
+
class:list={['sinn-dl', className]}
|
|
62
|
+
data-layout={layout}
|
|
63
|
+
data-divided={divided ? '' : undefined}
|
|
64
|
+
data-density={density === 'compact' ? 'compact' : undefined}
|
|
65
|
+
{...rest}
|
|
66
|
+
>
|
|
67
|
+
{
|
|
68
|
+
rows.map((r) => (
|
|
69
|
+
<div class="sinn-dl__item" data-emphasis={r.emphasis ? '' : undefined}>
|
|
70
|
+
<dt class="sinn-dl__term">{r.term}</dt>
|
|
71
|
+
<dd
|
|
72
|
+
class="sinn-dl__desc"
|
|
73
|
+
data-numeric={r.numeric ? '' : undefined}
|
|
74
|
+
data-value-tone={r.tone && r.tone !== 'default' ? renameValue('DescriptionList', 'tone', r.tone, LEGACY_VALUE_TONES) : undefined}
|
|
75
|
+
>
|
|
76
|
+
{r.href ? <a href={r.href}>{r.text}</a> : r.text}
|
|
77
|
+
{r.detail && <span class="sinn-dl__detail">{r.detail}</span>}
|
|
78
|
+
</dd>
|
|
79
|
+
</div>
|
|
80
|
+
))
|
|
81
|
+
}
|
|
82
|
+
<slot />
|
|
83
|
+
</dl>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Dialog — modal window, built on native `<dialog>` + `showModal()`.
|
|
4
|
+
*
|
|
5
|
+
* Open it from any button with invoker commands (no JS needed in current browsers;
|
|
6
|
+
* a ~0.5 KB fallback covers older ones):
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* <Button commandfor="cancel-appt" command="show-modal" variant="outline" tone="danger">Cancel appointment</Button>
|
|
10
|
+
* <Dialog id="cancel-appt" title="Cancel this appointment?" role="alertdialog"
|
|
11
|
+
* description="Tue, Nov 18 at 9:30 AM with Ana Ruiz. This can't be undone.">
|
|
12
|
+
* <Fragment slot="footer">
|
|
13
|
+
* <Button variant="ghost" tone="neutral" commandfor="cancel-appt" command="close">Keep it</Button>
|
|
14
|
+
* <Button tone="danger" form="cancel-form" type="submit">Cancel appointment</Button>
|
|
15
|
+
* </Fragment>
|
|
16
|
+
* </Dialog>
|
|
17
|
+
*
|
|
18
|
+
* What the platform gives you: focus moves into the dialog and returns to the trigger on
|
|
19
|
+
* close, the rest of the page is inert, Esc closes (unless `dismissible="none"`), and
|
|
20
|
+
* screen readers announce it as a dialog named by its title. The page behind stops scrolling (CSS).
|
|
21
|
+
*
|
|
22
|
+
* - `role="alertdialog"` for confirmations that need an answer: no × button, Esc and
|
|
23
|
+
* backdrop clicks don't close it.
|
|
24
|
+
* - A `<form method="dialog">` inside closes it on submit and sets `dialog.returnValue`.
|
|
25
|
+
* - Listen for the native `close` event to react to how it was closed.
|
|
26
|
+
* - Put `autofocus` on the element that should get focus first (e.g. the safe action).
|
|
27
|
+
*/
|
|
28
|
+
import type { ModalPanelProps } from './types';
|
|
29
|
+
import ModalPanel from './internal/ModalPanel.astro';
|
|
30
|
+
|
|
31
|
+
type Props = ModalPanelProps;
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
<ModalPanel {...Astro.props}>
|
|
35
|
+
<slot name="header" slot="header" />
|
|
36
|
+
<slot />
|
|
37
|
+
<slot name="footer" slot="footer" />
|
|
38
|
+
</ModalPanel>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Disclosure — a summary line that shows or hides one region: "Show eligibility details",
|
|
4
|
+
* "What does this cost?", a long code sample.
|
|
5
|
+
*
|
|
6
|
+
* A native `<details>`/`<summary>`: 0 KB JavaScript, keyboard and screen-reader support
|
|
7
|
+
* built in ("collapsed/expanded"). Chrome also opens it for a link to an id inside it
|
|
8
|
+
* and for find-in-page. Opening animates where the browser supports it
|
|
9
|
+
* (`::details-content`) and is instant with reduced motion.
|
|
10
|
+
*
|
|
11
|
+
* Put several related ones in an Accordion. Don't hide content most people need.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <Disclosure summary="How we use your information">
|
|
15
|
+
* <p>We only use your phone number to confirm appointments.</p>
|
|
16
|
+
* </Disclosure>
|
|
17
|
+
* <Disclosure variant="card" open>
|
|
18
|
+
* <Fragment slot="summary">Visit hours <span class="my-tag">Updated</span></Fragment>
|
|
19
|
+
* …
|
|
20
|
+
* </Disclosure>
|
|
21
|
+
*/
|
|
22
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
23
|
+
import './styles/disclosure.css';
|
|
24
|
+
import { renameValue } from './lib/deprecate';
|
|
25
|
+
|
|
26
|
+
type Props = HTMLAttributes<'details'> & {
|
|
27
|
+
/** The always-visible line. Or use the `summary` slot for rich content. */
|
|
28
|
+
summary?: string;
|
|
29
|
+
open?: boolean;
|
|
30
|
+
/** `plain`: inline text link style. `divided`: rule above and below. `card`: boxed. `bordered` is the deprecated name for `divided`. */
|
|
31
|
+
variant?: 'plain' | 'divided' | 'card' | 'bordered';
|
|
32
|
+
size?: 's' | 'm' | 'l';
|
|
33
|
+
/** Chevron before (default for plain) or after the summary text. */
|
|
34
|
+
iconPosition?: 'start' | 'end';
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
summary,
|
|
39
|
+
open = false,
|
|
40
|
+
variant: variantProp = 'plain',
|
|
41
|
+
size = 'm',
|
|
42
|
+
iconPosition = variantProp === 'plain' ? 'start' : 'end',
|
|
43
|
+
class: className,
|
|
44
|
+
...rest
|
|
45
|
+
} = Astro.props;
|
|
46
|
+
|
|
47
|
+
const variant = renameValue('Disclosure', 'variant', variantProp, { bordered: 'divided' });
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
<details
|
|
51
|
+
class:list={['sinn-disclosure', className]}
|
|
52
|
+
data-variant={variant}
|
|
53
|
+
data-size={size}
|
|
54
|
+
data-icon={iconPosition}
|
|
55
|
+
open={open || undefined}
|
|
56
|
+
{...rest}
|
|
57
|
+
>
|
|
58
|
+
<summary class="sinn-disclosure__summary">
|
|
59
|
+
<span class="sinn-disclosure__title">{summary}<slot name="summary" /></span>
|
|
60
|
+
<svg class="sinn-disclosure__icon" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
61
|
+
<path d="M4 6l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"></path>
|
|
62
|
+
</svg>
|
|
63
|
+
</summary>
|
|
64
|
+
<div class="sinn-disclosure__content">
|
|
65
|
+
<slot />
|
|
66
|
+
</div>
|
|
67
|
+
</details>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Divider — visually separates content.
|
|
4
|
+
*
|
|
5
|
+
* Semantics:
|
|
6
|
+
* - horizontal, no label → `<hr>` (thematic break)
|
|
7
|
+
* - vertical or labelled → `role="separator"` (with `aria-orientation` / accessible name)
|
|
8
|
+
* - `decorative` → hidden from assistive tech (use when the split carries no meaning,
|
|
9
|
+
* e.g. between toolbar items)
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <Divider />
|
|
13
|
+
* <Divider label="or" emphasis="subtle" />
|
|
14
|
+
* <Cluster><a>Docs</a><Divider orientation="vertical" decorative space="none" /><a>Blog</a></Cluster>
|
|
15
|
+
*/
|
|
16
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
17
|
+
import type { Space } from './types';
|
|
18
|
+
import { renameProp } from './lib/deprecate';
|
|
19
|
+
import './styles/utilities.css';
|
|
20
|
+
import './styles/scale.css';
|
|
21
|
+
import './styles/divider.css';
|
|
22
|
+
|
|
23
|
+
type Props = Omit<HTMLAttributes<'div'>, 'children'> & {
|
|
24
|
+
orientation?: 'horizontal' | 'vertical';
|
|
25
|
+
/** Text shown in the middle of a horizontal divider ("or", "Section 2"). */
|
|
26
|
+
label?: string;
|
|
27
|
+
labelAlign?: 'start' | 'center' | 'end';
|
|
28
|
+
/** How strong the line reads. (`tone` is the deprecated name: tone means a colour family elsewhere.) */
|
|
29
|
+
emphasis?: 'subtle' | 'default' | 'strong';
|
|
30
|
+
/** @deprecated Use `emphasis`. */
|
|
31
|
+
tone?: 'subtle' | 'default' | 'strong';
|
|
32
|
+
variant?: 'solid' | 'dashed' | 'dotted';
|
|
33
|
+
thickness?: 'thin' | 'thick';
|
|
34
|
+
/** Margin on the axis it separates (block for horizontal, inline for vertical). */
|
|
35
|
+
space?: Space;
|
|
36
|
+
/** Hide from assistive tech. */
|
|
37
|
+
decorative?: boolean;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
orientation = 'horizontal',
|
|
42
|
+
label,
|
|
43
|
+
labelAlign = 'center',
|
|
44
|
+
emphasis: emphasisProp,
|
|
45
|
+
tone,
|
|
46
|
+
variant = 'solid',
|
|
47
|
+
thickness = 'thin',
|
|
48
|
+
space = 'm',
|
|
49
|
+
decorative = false,
|
|
50
|
+
class: className,
|
|
51
|
+
...rest
|
|
52
|
+
} = Astro.props;
|
|
53
|
+
|
|
54
|
+
const emphasis = renameProp('Divider', 'emphasis', emphasisProp, 'tone', tone) ?? 'default';
|
|
55
|
+
const isVertical = orientation === 'vertical';
|
|
56
|
+
const hasLabel = Boolean(label) && !isVertical;
|
|
57
|
+
const useHr = !isVertical && !hasLabel;
|
|
58
|
+
|
|
59
|
+
const shared = {
|
|
60
|
+
class: ['sinn-divider', className].filter(Boolean).join(' '),
|
|
61
|
+
'data-orientation': orientation,
|
|
62
|
+
'data-emphasis': emphasis,
|
|
63
|
+
'data-variant': variant,
|
|
64
|
+
'data-thickness': thickness,
|
|
65
|
+
'data-space': space,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const a11y = decorative
|
|
69
|
+
? { 'aria-hidden': 'true' as const }
|
|
70
|
+
: useHr
|
|
71
|
+
? {}
|
|
72
|
+
: {
|
|
73
|
+
role: 'separator',
|
|
74
|
+
'aria-orientation': orientation,
|
|
75
|
+
'aria-label': hasLabel ? label : undefined,
|
|
76
|
+
};
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
{
|
|
80
|
+
useHr ? (
|
|
81
|
+
<hr {...shared} {...a11y} {...rest} />
|
|
82
|
+
) : (
|
|
83
|
+
<div
|
|
84
|
+
{...shared}
|
|
85
|
+
data-label={hasLabel ? '' : undefined}
|
|
86
|
+
data-label-align={hasLabel ? labelAlign : undefined}
|
|
87
|
+
{...a11y}
|
|
88
|
+
{...rest}
|
|
89
|
+
>
|
|
90
|
+
{hasLabel && <span aria-hidden="true">{label}</span>}
|
|
91
|
+
</div>
|
|
92
|
+
)
|
|
93
|
+
}
|