@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,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Animation presets for Astro's `transition:animate` directive, matching the PageTransitions
|
|
3
|
+
* presets. Use them on elements (or <html>) when you want Astro's per-element API:
|
|
4
|
+
*
|
|
5
|
+
* ---
|
|
6
|
+
* import { rise } from '@sinnstack/ui/motion/transitions';
|
|
7
|
+
* ---
|
|
8
|
+
* <main transition:animate={rise}>…</main>
|
|
9
|
+
*
|
|
10
|
+
* The keyframe names come from @sinnstack/ui/motion/styles.css (loaded by any motion component).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface Anim {
|
|
14
|
+
name: string;
|
|
15
|
+
delay?: number | string;
|
|
16
|
+
duration?: number | string;
|
|
17
|
+
easing?: string;
|
|
18
|
+
fillMode?: string;
|
|
19
|
+
direction?: string;
|
|
20
|
+
}
|
|
21
|
+
interface TransitionAnimationPair {
|
|
22
|
+
old: Anim | Anim[];
|
|
23
|
+
new: Anim | Anim[];
|
|
24
|
+
}
|
|
25
|
+
export interface TransitionDirectionalAnimations {
|
|
26
|
+
forwards: TransitionAnimationPair;
|
|
27
|
+
backwards: TransitionAnimationPair;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const OUT = 'cubic-bezier(0.4, 0, 1, 1)';
|
|
31
|
+
const IN = 'cubic-bezier(0, 0, 0.2, 1)';
|
|
32
|
+
|
|
33
|
+
export const fade: TransitionDirectionalAnimations = {
|
|
34
|
+
forwards: {
|
|
35
|
+
old: { name: 'sinn-vt-fade-out', duration: '160ms', easing: OUT, fillMode: 'both' },
|
|
36
|
+
new: { name: 'sinn-vt-fade-in', duration: '220ms', delay: '60ms', easing: IN, fillMode: 'both' },
|
|
37
|
+
},
|
|
38
|
+
backwards: {
|
|
39
|
+
old: { name: 'sinn-vt-fade-out', duration: '160ms', easing: OUT, fillMode: 'both' },
|
|
40
|
+
new: { name: 'sinn-vt-fade-in', duration: '220ms', delay: '60ms', easing: IN, fillMode: 'both' },
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const slide: TransitionDirectionalAnimations = {
|
|
45
|
+
forwards: {
|
|
46
|
+
old: { name: 'sinn-vt-slide-to-start', duration: '180ms', easing: OUT, fillMode: 'both' },
|
|
47
|
+
new: { name: 'sinn-vt-slide-from-end', duration: '260ms', delay: '60ms', easing: IN, fillMode: 'both' },
|
|
48
|
+
},
|
|
49
|
+
backwards: {
|
|
50
|
+
old: { name: 'sinn-vt-slide-to-end', duration: '180ms', easing: OUT, fillMode: 'both' },
|
|
51
|
+
new: { name: 'sinn-vt-slide-from-start', duration: '260ms', delay: '60ms', easing: IN, fillMode: 'both' },
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const rise: TransitionDirectionalAnimations = {
|
|
56
|
+
forwards: {
|
|
57
|
+
old: { name: 'sinn-vt-fade-out', duration: '160ms', easing: OUT, fillMode: 'both' },
|
|
58
|
+
new: { name: 'sinn-vt-rise-in', duration: '280ms', delay: '40ms', easing: IN, fillMode: 'both' },
|
|
59
|
+
},
|
|
60
|
+
backwards: {
|
|
61
|
+
old: { name: 'sinn-vt-fade-out', duration: '160ms', easing: OUT, fillMode: 'both' },
|
|
62
|
+
new: { name: 'sinn-vt-rise-in', duration: '280ms', delay: '40ms', easing: IN, fillMode: 'both' },
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** A stable, CSS-safe view-transition-name for shared elements: transition:name={morphName('photo', id)}. */
|
|
67
|
+
export function morphName(...parts: Array<string | number>): string {
|
|
68
|
+
return parts
|
|
69
|
+
.join('-')
|
|
70
|
+
.toLowerCase()
|
|
71
|
+
.replace(/[^a-z0-9_-]+/g, '-')
|
|
72
|
+
.replace(/^-+|-+$/g, '')
|
|
73
|
+
.replace(/^(\d)/, 'n$1');
|
|
74
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Accordion — a stack of expandable sections: FAQs, service details, policy sections.
|
|
4
|
+
*
|
|
5
|
+
* Each section is a native `<details>`, so it works with no JavaScript, and a link to
|
|
6
|
+
* `#its-id` (or to anything inside it) opens it. `mode="single"` uses the native `name`
|
|
7
|
+
* attribute so opening one closes the others (Chrome 120+, Safari 17.2+, Firefox 130+;
|
|
8
|
+
* older browsers just allow several open).
|
|
9
|
+
*
|
|
10
|
+
* A ~1 KB script adds a "Show all sections" button (multiple mode, 3+ sections),
|
|
11
|
+
* ↑/↓/Home/End between section headers, and opens every section for printing.
|
|
12
|
+
*
|
|
13
|
+
* Content: the slot named after each item's `id` (rich content), a function child that renders
|
|
14
|
+
* any item (`{(item, index) => <RichText value={answers[index]} />}`, for content from a list),
|
|
15
|
+
* or the item's `content` (plain text). Give `headingLevel` when sections are page structure (an FAQ), so they're
|
|
16
|
+
* reachable by heading navigation; pick the level that fits the page outline.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* <Accordion headingLevel={3} items={[
|
|
20
|
+
* { id: 'cost', title: 'What does a home visit cost?' },
|
|
21
|
+
* { id: 'areas', title: 'Which areas do you serve?', content: 'Clients across Texas, and remote anywhere.' },
|
|
22
|
+
* ]}>
|
|
23
|
+
* <Fragment slot="cost"><p>Projects start at a fixed price…</p></Fragment>
|
|
24
|
+
* </Accordion>
|
|
25
|
+
*/
|
|
26
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
27
|
+
import type { AccordionItem, HeadingLevel } from './types';
|
|
28
|
+
import { uid } from './utils';
|
|
29
|
+
import AccordionScript from './internal/AccordionScript.astro';
|
|
30
|
+
import './styles/disclosure.css';
|
|
31
|
+
import './styles/accordion.css';
|
|
32
|
+
import { renameValue } from './lib/deprecate';
|
|
33
|
+
|
|
34
|
+
type Props = HTMLAttributes<'div'> & {
|
|
35
|
+
items: AccordionItem[];
|
|
36
|
+
/** `multiple` (default): sections open independently. `single`: one open at a time. */
|
|
37
|
+
mode?: 'multiple' | 'single';
|
|
38
|
+
/** Wrap each title in this heading level. */
|
|
39
|
+
headingLevel?: Exclude<HeadingLevel, 1>;
|
|
40
|
+
/** `divided`: rules between sections. `card`: separate boxed sections. `bordered` is the deprecated name for `divided`. */
|
|
41
|
+
variant?: 'divided' | 'card' | 'bordered';
|
|
42
|
+
size?: 's' | 'm' | 'l';
|
|
43
|
+
iconPosition?: 'start' | 'end';
|
|
44
|
+
/** Show the "Show all / Hide all" button (multiple mode). Default: with 3+ sections. */
|
|
45
|
+
showAll?: boolean;
|
|
46
|
+
/** Button text. Translate per site. */
|
|
47
|
+
labels?: { showAll: string; hideAll: string };
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const {
|
|
51
|
+
items,
|
|
52
|
+
mode = 'multiple',
|
|
53
|
+
headingLevel,
|
|
54
|
+
variant: variantProp = 'divided',
|
|
55
|
+
size = 'm',
|
|
56
|
+
iconPosition = 'end',
|
|
57
|
+
showAll,
|
|
58
|
+
labels = { showAll: 'Show all sections', hideAll: 'Hide all sections' },
|
|
59
|
+
id = uid('sinn-accordion'),
|
|
60
|
+
class: className,
|
|
61
|
+
...rest
|
|
62
|
+
} = Astro.props;
|
|
63
|
+
|
|
64
|
+
const variant = renameValue('Accordion', 'variant', variantProp, { bordered: 'divided' });
|
|
65
|
+
if (import.meta.env?.DEV && !items.length) console.warn('[sinn] Accordion has no items; nothing is rendered.');
|
|
66
|
+
const H = headingLevel ? (`h${headingLevel}` as const) : null;
|
|
67
|
+
const toolbar = mode === 'multiple' && (showAll ?? items.length >= 3);
|
|
68
|
+
const anyClosed = items.some((i) => !i.open);
|
|
69
|
+
const sections = await Promise.all(
|
|
70
|
+
items.map(async (item, i) => ({
|
|
71
|
+
...item,
|
|
72
|
+
domId: item.id ?? `${id}-${i + 1}`,
|
|
73
|
+
html:
|
|
74
|
+
item.id && Astro.slots.has(item.id)
|
|
75
|
+
? await Astro.slots.render(item.id)
|
|
76
|
+
: Astro.slots.has('default')
|
|
77
|
+
? await Astro.slots.render('default', [item, i])
|
|
78
|
+
: null,
|
|
79
|
+
})),
|
|
80
|
+
);
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
{
|
|
84
|
+
items.length > 0 && (
|
|
85
|
+
<div
|
|
86
|
+
id={id}
|
|
87
|
+
class:list={['sinn-accordion', className]}
|
|
88
|
+
data-variant={variant}
|
|
89
|
+
data-mode={mode}
|
|
90
|
+
data-sinn-accordion
|
|
91
|
+
{...rest}
|
|
92
|
+
>
|
|
93
|
+
{toolbar && (
|
|
94
|
+
<div class="sinn-accordion__toolbar">
|
|
95
|
+
<button
|
|
96
|
+
type="button"
|
|
97
|
+
class="sinn-accordion__all"
|
|
98
|
+
data-sinn-accordion-all
|
|
99
|
+
data-show={labels.showAll}
|
|
100
|
+
data-hide={labels.hideAll}
|
|
101
|
+
aria-expanded={anyClosed ? 'false' : 'true'}
|
|
102
|
+
>
|
|
103
|
+
{anyClosed ? labels.showAll : labels.hideAll}
|
|
104
|
+
</button>
|
|
105
|
+
</div>
|
|
106
|
+
)}
|
|
107
|
+
{sections.map((s) => (
|
|
108
|
+
<details
|
|
109
|
+
id={s.domId}
|
|
110
|
+
class="sinn-disclosure sinn-accordion__item"
|
|
111
|
+
data-variant={variant}
|
|
112
|
+
data-size={size}
|
|
113
|
+
data-icon={iconPosition}
|
|
114
|
+
name={mode === 'single' ? id : undefined}
|
|
115
|
+
open={s.open || undefined}
|
|
116
|
+
>
|
|
117
|
+
<summary class="sinn-disclosure__summary">
|
|
118
|
+
<span class="sinn-disclosure__title">{H ? <H class="sinn-accordion__heading">{s.title}</H> : s.title}</span>
|
|
119
|
+
<svg class="sinn-disclosure__icon" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
120
|
+
<path d="M4 6l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" />
|
|
121
|
+
</svg>
|
|
122
|
+
</summary>
|
|
123
|
+
<div class="sinn-disclosure__content">{s.html ? <Fragment set:html={s.html} /> : s.content && <p>{s.content}</p>}</div>
|
|
124
|
+
</details>
|
|
125
|
+
))}
|
|
126
|
+
</div>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
<AccordionScript />
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Breadcrumbs — where this page sits in the site: Home › Section › This page.
|
|
4
|
+
*
|
|
5
|
+
* - A `<nav aria-label="Breadcrumb">` around an ordered list (WAI-ARIA APG breadcrumb pattern).
|
|
6
|
+
* - The last item is the current page: plain text with `aria-current="page"`, even if it has an
|
|
7
|
+
* `href`. Every other item needs an `href` (an item without one renders as text).
|
|
8
|
+
* - Separators are drawn in CSS (a chevron that flips in RTL), so screen readers don't announce them.
|
|
9
|
+
* - Wraps onto more lines when narrow; nothing is cut off.
|
|
10
|
+
* - Pair with `breadcrumbList()` from `@sinnstack/ui/seo/jsonld` for the matching structured data.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <Breadcrumbs items={[{ label: 'Home', href: '/' }, { label: 'Services', href: '/services' }, { label: 'Astro migration' }]} />
|
|
14
|
+
*/
|
|
15
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
16
|
+
import type { BreadcrumbItem } from './types';
|
|
17
|
+
import './styles/utilities.css';
|
|
18
|
+
import './styles/breadcrumbs.css';
|
|
19
|
+
|
|
20
|
+
type Props = HTMLAttributes<'nav'> & {
|
|
21
|
+
items: BreadcrumbItem[];
|
|
22
|
+
/** Accessible name of the <nav>. */
|
|
23
|
+
label?: string;
|
|
24
|
+
size?: 's' | 'm';
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const { items = [], label = 'Breadcrumb', size = 's', class: className, ...rest } = Astro.props;
|
|
28
|
+
const list = items.filter((item) => item && String(item.label ?? '').trim());
|
|
29
|
+
const last = list.length - 1;
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
{
|
|
33
|
+
list.length > 0 && (
|
|
34
|
+
<nav aria-label={label} class:list={['sinn-breadcrumbs', className]} data-size={size === 's' ? undefined : size} {...rest}>
|
|
35
|
+
<ol class="sinn-breadcrumbs__list" role="list">
|
|
36
|
+
{list.map((item, i) => (
|
|
37
|
+
<li class="sinn-breadcrumbs__item">
|
|
38
|
+
{i === last ? (
|
|
39
|
+
<span class="sinn-breadcrumbs__current" aria-current="page">{item.label}</span>
|
|
40
|
+
) : item.href ? (
|
|
41
|
+
<a class="sinn-breadcrumbs__link" href={item.href}>{item.label}</a>
|
|
42
|
+
) : (
|
|
43
|
+
<span class="sinn-breadcrumbs__text">{item.label}</span>
|
|
44
|
+
)}
|
|
45
|
+
</li>
|
|
46
|
+
))}
|
|
47
|
+
</ol>
|
|
48
|
+
</nav>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* BulletList: a plain list of short text items with a check-mark or dot marker, optionally in
|
|
4
|
+
* two balanced columns ("Our services include: …", "What's included", feature lists).
|
|
5
|
+
*
|
|
6
|
+
* For structured rows (icons, values, links with descriptions) use List + ListItem instead.
|
|
7
|
+
*
|
|
8
|
+
* - `marker`: `check` (a white disc with a hairline ring and an accent check), `dot`, or `none`.
|
|
9
|
+
* Markers are CSS only (decorative), so items can be plain strings (`items`) or your own
|
|
10
|
+
* `<li>` elements in the default slot (links, bold text…).
|
|
11
|
+
* - `columns={2}`: two columns that fill top to bottom and only appear when each column has at
|
|
12
|
+
* least `columnMin` of room (14rem by default), so there's no breakpoint to tune. `columnMin`
|
|
13
|
+
* takes a measure token key (`xs` 12rem · `s` 16rem · `m` 20rem · `l` 26rem · `xl` 34rem),
|
|
14
|
+
* rendered as `data-min`, so the list works under a strict CSP (no `style` attribute).
|
|
15
|
+
* - Keeps list semantics everywhere (`role="list"`; Safari drops them with `list-style: none`).
|
|
16
|
+
* - On strong surfaces (`data-surface="strong"`) the markers recolor for contrast.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* <BulletList marker="check" columns={2} items={['Website design', 'Astro development', 'CMS setup']} />
|
|
20
|
+
* <BulletList marker="dot"><li><a href="/faq">Read the FAQ</a></li><li>Call us any time</li></BulletList>
|
|
21
|
+
*/
|
|
22
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
23
|
+
import { MEASURE, type Measure } from './types';
|
|
24
|
+
import { warnOnce } from './lib/deprecate';
|
|
25
|
+
import './styles/bullet-list.css';
|
|
26
|
+
|
|
27
|
+
type Props = HTMLAttributes<'ul'> & {
|
|
28
|
+
items?: string[];
|
|
29
|
+
marker?: 'check' | 'dot' | 'none';
|
|
30
|
+
columns?: 1 | 2;
|
|
31
|
+
/** Narrowest a column may get before the list falls back to one column: a measure token key. */
|
|
32
|
+
columnMin?: Measure;
|
|
33
|
+
/** Space between items. */
|
|
34
|
+
gap?: '3xs' | '2xs' | 'xs' | 's';
|
|
35
|
+
ordered?: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const {
|
|
39
|
+
items = [],
|
|
40
|
+
marker = 'dot',
|
|
41
|
+
columns = 1,
|
|
42
|
+
columnMin,
|
|
43
|
+
gap = '2xs',
|
|
44
|
+
ordered = false,
|
|
45
|
+
class: className,
|
|
46
|
+
...rest
|
|
47
|
+
} = Astro.props;
|
|
48
|
+
// Earlier versions took any CSS length and wrote it into a `style` attribute, which a strict CSP
|
|
49
|
+
// blocks. Only token keys are accepted now; anything else falls back to the 14rem default.
|
|
50
|
+
const minKey = columnMin && (MEASURE as readonly string[]).includes(columnMin) ? columnMin : undefined;
|
|
51
|
+
if (columnMin && !minKey) {
|
|
52
|
+
warnOnce('BulletList', `columnMin="${columnMin}" isn't a measure key (${MEASURE.join(', ')}); using the 14rem default.`);
|
|
53
|
+
}
|
|
54
|
+
const Tag = ordered ? 'ol' : 'ul';
|
|
55
|
+
const list = items.map((i) => String(i ?? '').trim()).filter(Boolean);
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
<Tag
|
|
59
|
+
role="list"
|
|
60
|
+
class:list={['sinn-bullet-list', className]}
|
|
61
|
+
data-marker={marker}
|
|
62
|
+
data-columns={columns === 2 ? '2' : undefined}
|
|
63
|
+
data-gap={gap === '2xs' ? undefined : gap}
|
|
64
|
+
data-min={columns === 2 ? minKey : undefined}
|
|
65
|
+
{...rest}
|
|
66
|
+
>
|
|
67
|
+
{list.map((item) => <li>{item}</li>)}
|
|
68
|
+
<slot />
|
|
69
|
+
</Tag>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Button — triggers an action or submits a form.
|
|
4
|
+
*
|
|
5
|
+
* - `type` defaults to `"button"` (the HTML default is `"submit"`, which surprises
|
|
6
|
+
* people inside forms). Pass `type="submit"` explicitly for submit buttons.
|
|
7
|
+
* - `loading` keeps the button's size (no layout shift), shows a spinner, sets
|
|
8
|
+
* `aria-busy` and disables it so it can't be submitted twice.
|
|
9
|
+
* - Icons go in the `icon-start` / `icon-end` slots and should be `aria-hidden`.
|
|
10
|
+
* - Opens a dialog: `commandfor="dialog-id" command="show-modal"` (native invoker commands).
|
|
11
|
+
* - Navigates somewhere? Use LinkButton instead.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <Button variant="solid" type="submit">Save</Button>
|
|
15
|
+
* <Button variant="outline" tone="danger"><TrashIcon slot="icon-start" aria-hidden="true" />Delete</Button>
|
|
16
|
+
*/
|
|
17
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
18
|
+
import type { ButtonStyleProps, InvokerProps } from './types';
|
|
19
|
+
import './styles/utilities.css';
|
|
20
|
+
import './styles/button.css';
|
|
21
|
+
|
|
22
|
+
type Props = HTMLAttributes<'button'> &
|
|
23
|
+
ButtonStyleProps &
|
|
24
|
+
InvokerProps & {
|
|
25
|
+
loading?: boolean;
|
|
26
|
+
/** Screen-reader text while loading. Translate per site. */
|
|
27
|
+
loadingLabel?: string;
|
|
28
|
+
/** @internal Used by IconButton. */
|
|
29
|
+
iconOnly?: boolean;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
variant = 'solid',
|
|
34
|
+
tone = 'accent',
|
|
35
|
+
size = 'm',
|
|
36
|
+
fullWidth = false,
|
|
37
|
+
loading = false,
|
|
38
|
+
loadingLabel = 'Loading',
|
|
39
|
+
iconOnly = false,
|
|
40
|
+
type = 'button',
|
|
41
|
+
disabled = false,
|
|
42
|
+
class: className,
|
|
43
|
+
...rest
|
|
44
|
+
} = Astro.props;
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
<button
|
|
48
|
+
type={type}
|
|
49
|
+
class:list={['sinn-button', className]}
|
|
50
|
+
data-variant={variant}
|
|
51
|
+
data-tone={tone}
|
|
52
|
+
data-size={size}
|
|
53
|
+
data-full-width={fullWidth ? '' : undefined}
|
|
54
|
+
data-icon-only={iconOnly ? '' : undefined}
|
|
55
|
+
data-loading={loading ? '' : undefined}
|
|
56
|
+
aria-busy={loading ? 'true' : undefined}
|
|
57
|
+
disabled={disabled || loading}
|
|
58
|
+
{...rest}
|
|
59
|
+
>
|
|
60
|
+
<span class="sinn-button__content">
|
|
61
|
+
<slot name="icon-start" />
|
|
62
|
+
<slot />
|
|
63
|
+
<slot name="icon-end" />
|
|
64
|
+
</span>
|
|
65
|
+
{
|
|
66
|
+
loading && (
|
|
67
|
+
<>
|
|
68
|
+
<span class="sinn-button__spinner" aria-hidden="true" data-motion-essential />
|
|
69
|
+
<span class="sinn-sr-only">{loadingLabel}</span>
|
|
70
|
+
</>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
</button>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* ButtonGroup — groups related buttons (`role="group"`).
|
|
4
|
+
*
|
|
5
|
+
* - Spaced (default): buttons wrap with a gap, like a Cluster.
|
|
6
|
+
* - `attached`: one segmented shape with shared borders. Pairs best with
|
|
7
|
+
* `outline` buttons or `Toggle`s (e.g. a Bold / Italic / Underline set).
|
|
8
|
+
*
|
|
9
|
+
* Give it a `label` when the purpose isn't obvious from the buttons, e.g. "Text formatting".
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <ButtonGroup><Button variant="outline">Cancel</Button><Button>Save</Button></ButtonGroup>
|
|
13
|
+
* <ButtonGroup attached label="Text formatting"><Toggle …/><Toggle …/></ButtonGroup>
|
|
14
|
+
*/
|
|
15
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
16
|
+
import type { Space } from './types';
|
|
17
|
+
import './styles/utilities.css';
|
|
18
|
+
import './styles/scale.css';
|
|
19
|
+
import './styles/button.css';
|
|
20
|
+
|
|
21
|
+
type Props = HTMLAttributes<'div'> & {
|
|
22
|
+
/** Accessible name for the group. */
|
|
23
|
+
label?: string;
|
|
24
|
+
attached?: boolean;
|
|
25
|
+
orientation?: 'horizontal' | 'vertical';
|
|
26
|
+
/** Space between buttons when not attached. */
|
|
27
|
+
gap?: Space;
|
|
28
|
+
/** Buttons share the full width equally. */
|
|
29
|
+
fullWidth?: boolean;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
label,
|
|
34
|
+
attached = false,
|
|
35
|
+
orientation = 'horizontal',
|
|
36
|
+
gap = '2xs',
|
|
37
|
+
fullWidth = false,
|
|
38
|
+
class: className,
|
|
39
|
+
...rest
|
|
40
|
+
} = Astro.props;
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
<div
|
|
44
|
+
role="group"
|
|
45
|
+
aria-label={label}
|
|
46
|
+
class:list={['sinn-button-group', className]}
|
|
47
|
+
data-attached={attached ? '' : undefined}
|
|
48
|
+
data-orientation={orientation}
|
|
49
|
+
data-gap={gap}
|
|
50
|
+
data-full-width={fullWidth ? '' : undefined}
|
|
51
|
+
{...rest}
|
|
52
|
+
>
|
|
53
|
+
<slot />
|
|
54
|
+
</div>
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Callout — highlights important supporting information: tips, warnings, status notes,
|
|
4
|
+
* "this isn't legal advice".
|
|
5
|
+
*
|
|
6
|
+
* - Tone is never conveyed by color alone: each tone has its own icon and a visually
|
|
7
|
+
* hidden prefix ("Warning: ") read before the content. Override with `toneLabel`
|
|
8
|
+
* (translate it) or turn it off with `toneLabel={false}`.
|
|
9
|
+
* - Static by default (no live region). Use `live="polite"` (role="status") for a message
|
|
10
|
+
* that appears after an action, or `live="assertive"` (role="alert") only for urgent problems.
|
|
11
|
+
* For form errors use FormError instead.
|
|
12
|
+
* - `title` renders as bold text; pass `titleLevel` to make it a real heading.
|
|
13
|
+
* - Custom icon: `slot="icon"`. No icon: `icon={false}`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* <Callout tone="warning" title="Office closed Nov 27">Call (817) 555-0100 for urgent support.</Callout>
|
|
17
|
+
* <Callout tone="info" variant="stripe">Have your domain registrar login ready.</Callout>
|
|
18
|
+
*/
|
|
19
|
+
import type { HTMLAttributes, HTMLTag } from 'astro/types';
|
|
20
|
+
import type { HeadingLevel } from './types';
|
|
21
|
+
import { renameValue } from './lib/deprecate';
|
|
22
|
+
import './styles/utilities.css';
|
|
23
|
+
import './styles/surface.css';
|
|
24
|
+
|
|
25
|
+
type Tone = 'info' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
26
|
+
|
|
27
|
+
type Props = Omit<HTMLAttributes<'div'>, 'title'> & {
|
|
28
|
+
as?: HTMLTag;
|
|
29
|
+
tone?: Tone;
|
|
30
|
+
/** `soft` (tinted fill), `outline`, or `stripe` (a tone-coloured bar on the start edge). `accent` is the deprecated name for `stripe`. */
|
|
31
|
+
variant?: 'soft' | 'outline' | 'stripe' | 'accent';
|
|
32
|
+
size?: 's' | 'm';
|
|
33
|
+
title?: string;
|
|
34
|
+
/** Render the title as a heading of this level. */
|
|
35
|
+
titleLevel?: HeadingLevel;
|
|
36
|
+
icon?: boolean;
|
|
37
|
+
/** Visually hidden prefix announcing the tone. */
|
|
38
|
+
toneLabel?: string | false;
|
|
39
|
+
live?: 'off' | 'polite' | 'assertive';
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const DEFAULT_LABEL: Record<Tone, string | false> = {
|
|
43
|
+
info: 'Note',
|
|
44
|
+
success: 'Success',
|
|
45
|
+
warning: 'Warning',
|
|
46
|
+
danger: 'Important',
|
|
47
|
+
neutral: false,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const {
|
|
51
|
+
as: Tag = 'div',
|
|
52
|
+
tone = 'info',
|
|
53
|
+
variant: variantProp = 'soft',
|
|
54
|
+
size = 'm',
|
|
55
|
+
title,
|
|
56
|
+
titleLevel,
|
|
57
|
+
icon = true,
|
|
58
|
+
toneLabel = DEFAULT_LABEL[tone],
|
|
59
|
+
live = 'off',
|
|
60
|
+
class: className,
|
|
61
|
+
...rest
|
|
62
|
+
} = Astro.props;
|
|
63
|
+
|
|
64
|
+
// `accent` read as a tone (it collides with tone="accent" elsewhere); the bar is now `stripe`.
|
|
65
|
+
const variant = renameValue('Callout', 'variant', variantProp, { accent: 'stripe' });
|
|
66
|
+
const role = live === 'polite' ? 'status' : live === 'assertive' ? 'alert' : undefined;
|
|
67
|
+
const TitleTag = (titleLevel ? `h${titleLevel}` : 'p') as 'p';
|
|
68
|
+
const hasActions = Astro.slots.has('actions');
|
|
69
|
+
const customIcon = Astro.slots.has('icon');
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
<Tag
|
|
73
|
+
class:list={['sinn-callout', className]}
|
|
74
|
+
data-tone={tone === 'info' ? undefined : tone}
|
|
75
|
+
data-variant={variant === 'soft' ? undefined : variant}
|
|
76
|
+
data-size={size === 'm' ? undefined : size}
|
|
77
|
+
role={role}
|
|
78
|
+
{...rest}
|
|
79
|
+
>
|
|
80
|
+
{
|
|
81
|
+
icon && (
|
|
82
|
+
<span class="sinn-callout__icon" aria-hidden="true">
|
|
83
|
+
{customIcon ? (
|
|
84
|
+
<slot name="icon" />
|
|
85
|
+
) : (
|
|
86
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" focusable="false">
|
|
87
|
+
{tone === 'success' ? (
|
|
88
|
+
<>
|
|
89
|
+
<circle cx="12" cy="12" r="9" />
|
|
90
|
+
<path d="M8.5 12.5l2.5 2.5 4.5-5" />
|
|
91
|
+
</>
|
|
92
|
+
) : tone === 'warning' ? (
|
|
93
|
+
<>
|
|
94
|
+
<path d="M10.3 4.4 2.9 17.5A2 2 0 0 0 4.6 20.5h14.8a2 2 0 0 0 1.7-3L13.7 4.4a2 2 0 0 0-3.4 0z" />
|
|
95
|
+
<path d="M12 9.5v4" />
|
|
96
|
+
<circle cx="12" cy="16.75" r="0.6" fill="currentColor" />
|
|
97
|
+
</>
|
|
98
|
+
) : tone === 'danger' ? (
|
|
99
|
+
<>
|
|
100
|
+
<path d="M8.3 3h7.4L21 8.3v7.4L15.7 21H8.3L3 15.7V8.3z" />
|
|
101
|
+
<path d="M12 8v4.5" />
|
|
102
|
+
<circle cx="12" cy="15.75" r="0.6" fill="currentColor" />
|
|
103
|
+
</>
|
|
104
|
+
) : (
|
|
105
|
+
<>
|
|
106
|
+
<circle cx="12" cy="12" r="9" />
|
|
107
|
+
<path d="M12 11v5" />
|
|
108
|
+
<circle cx="12" cy="7.75" r="0.6" fill="currentColor" />
|
|
109
|
+
</>
|
|
110
|
+
)}
|
|
111
|
+
</svg>
|
|
112
|
+
)}
|
|
113
|
+
</span>
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
<div class="sinn-callout__body">
|
|
117
|
+
{
|
|
118
|
+
title && (
|
|
119
|
+
<TitleTag class="sinn-callout__title">
|
|
120
|
+
{toneLabel && <span class="sinn-sr-only">{toneLabel}: </span>}
|
|
121
|
+
{title}
|
|
122
|
+
</TitleTag>
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
<div class="sinn-callout__content">
|
|
126
|
+
{!title && toneLabel && <span class="sinn-sr-only">{toneLabel}: </span>}
|
|
127
|
+
<slot />
|
|
128
|
+
</div>
|
|
129
|
+
{
|
|
130
|
+
hasActions && (
|
|
131
|
+
<div class="sinn-callout__actions">
|
|
132
|
+
<slot name="actions" />
|
|
133
|
+
</div>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
</div>
|
|
137
|
+
</Tag>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Caption — secondary or supporting text: help text under a field, figure captions,
|
|
4
|
+
* timestamps, footnotes. Muted by default.
|
|
5
|
+
*
|
|
6
|
+
* Give it an `id` and reference it from the control's `aria-describedby` when it explains a field.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* <figure><img … /><Caption as="figcaption">Photo: Fort Worth Stockyards</Caption></figure>
|
|
10
|
+
* <input aria-describedby="pw-help" … /><Caption id="pw-help">At least 12 characters.</Caption>
|
|
11
|
+
*/
|
|
12
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
13
|
+
import type { TextAlign, TextTone } from './types';
|
|
14
|
+
import './styles/utilities.css';
|
|
15
|
+
import './styles/typography.css';
|
|
16
|
+
|
|
17
|
+
type Props = HTMLAttributes<'p'> & {
|
|
18
|
+
as?: 'p' | 'span' | 'div' | 'small' | 'figcaption';
|
|
19
|
+
size?: 'xs' | 's';
|
|
20
|
+
tone?: TextTone;
|
|
21
|
+
align?: TextAlign;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const { as: Tag = 'p', size = 's', tone = 'muted', align, class: className, ...rest } = Astro.props;
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<Tag
|
|
28
|
+
class:list={['sinn-type', 'sinn-caption', className]}
|
|
29
|
+
data-size={size}
|
|
30
|
+
data-tone={tone === 'default' ? undefined : tone}
|
|
31
|
+
data-align={align}
|
|
32
|
+
{...rest}
|
|
33
|
+
>
|
|
34
|
+
<slot />
|
|
35
|
+
</Tag>
|