@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,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* SkipLink — lets keyboard users jump past repeated navigation straight to the main content.
|
|
4
|
+
* Hidden until focused, then appears in the top corner. Put it first inside <body>.
|
|
5
|
+
*
|
|
6
|
+
* The target should be the page's main landmark with a matching id. Add `tabindex="-1"` and
|
|
7
|
+
* `data-skip-target` to it, so focus really moves there (some screen readers otherwise keep
|
|
8
|
+
* reading from the link) without drawing a focus ring on the whole main area.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <body>
|
|
12
|
+
* <SkipLink />
|
|
13
|
+
* <Navbar … />
|
|
14
|
+
* <main id="main" tabindex="-1" data-skip-target>…</main>
|
|
15
|
+
* </body>
|
|
16
|
+
*/
|
|
17
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
18
|
+
import './styles/utilities.css';
|
|
19
|
+
import './styles/nav.css';
|
|
20
|
+
|
|
21
|
+
type Props = Omit<HTMLAttributes<'a'>, 'href'> & {
|
|
22
|
+
/** id of the element to skip to. */
|
|
23
|
+
target?: string;
|
|
24
|
+
/** Link text. Translate per site. */
|
|
25
|
+
label?: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const { target = 'main', label = 'Skip to main content', class: className, ...rest } = Astro.props;
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
<a href={`#${target}`} class:list={['sinn-skip-link', className]} {...rest}>{label}</a>
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Slider — picks a number (one thumb) or a range (two thumbs) along a track: a price
|
|
4
|
+
* filter, a radius, a volume.
|
|
5
|
+
*
|
|
6
|
+
* Each thumb is a native `<input type="range">`, so dragging, arrow keys, Page Up/Down,
|
|
7
|
+
* Home/End, form submission and screen-reader announcements are all native.
|
|
8
|
+
* A ~2 KB script keeps the filled part of the track and the readout in step, formats
|
|
9
|
+
* the announced value ("$20", not "20") and stops the two thumbs crossing.
|
|
10
|
+
*
|
|
11
|
+
* Without JavaScript the inputs still work and submit; the fill and readout, which
|
|
12
|
+
* would go stale, are hidden. With a range, check on the server that min ≤ max.
|
|
13
|
+
*
|
|
14
|
+
* Use an Input with `type="number"` when people know the exact value they want.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* <Slider name="radius" label="Search radius" min={5} max={50} step={5} value={25}
|
|
18
|
+
* format={{ kind: 'unit', unit: 'mile' }} marks />
|
|
19
|
+
* <Slider name="price" label="Price" min={0} max={500} step={10} value={[50, 300]}
|
|
20
|
+
* format={{ kind: 'currency', digits: 0 }} minGap={2} />
|
|
21
|
+
*/
|
|
22
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
23
|
+
import type { ControlSize, ValueFormat } from './types';
|
|
24
|
+
import { idList, uid } from './utils';
|
|
25
|
+
import { sliderModel, type SliderMarkInput } from './internal/slider';
|
|
26
|
+
import FormDescription from './FormDescription.astro';
|
|
27
|
+
import FormError from './FormError.astro';
|
|
28
|
+
import SliderScript from './internal/SliderScript.astro';
|
|
29
|
+
import './styles/scale.css';
|
|
30
|
+
import './styles/utilities.css';
|
|
31
|
+
import './styles/typography.css';
|
|
32
|
+
import './styles/form.css';
|
|
33
|
+
import './styles/slider.css';
|
|
34
|
+
|
|
35
|
+
type Props = Omit<HTMLAttributes<'div'>, 'onchange' | 'oninput'> & {
|
|
36
|
+
label: string;
|
|
37
|
+
/** Single slider: the field name. Range: the base for `${name}-min` / `${name}-max`. */
|
|
38
|
+
name?: string;
|
|
39
|
+
/** Range: explicit field names for the low and high thumbs. */
|
|
40
|
+
names?: [string, string];
|
|
41
|
+
min?: number;
|
|
42
|
+
max?: number;
|
|
43
|
+
step?: number;
|
|
44
|
+
/** One number, or `[low, high]` for a range. Default: the middle (single). */
|
|
45
|
+
value?: number | [number, number];
|
|
46
|
+
/** Range: the smallest distance between the thumbs, in steps. */
|
|
47
|
+
minGap?: number;
|
|
48
|
+
/** How values read and are announced: "$20", "25 miles", "40%". */
|
|
49
|
+
format?: ValueFormat;
|
|
50
|
+
locale?: string;
|
|
51
|
+
/** `true` labels both ends. An array adds ticks (with optional labels) at those values. */
|
|
52
|
+
marks?: boolean | Array<number | SliderMarkInput>;
|
|
53
|
+
/** Show the current value(s) beside the label. */
|
|
54
|
+
showValue?: boolean;
|
|
55
|
+
/** Range: names of the two thumbs, read after the label ("Price, Minimum"). Translate per site. */
|
|
56
|
+
thumbLabels?: [string, string];
|
|
57
|
+
hideLabel?: boolean;
|
|
58
|
+
description?: string;
|
|
59
|
+
error?: string;
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
size?: ControlSize;
|
|
62
|
+
form?: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const {
|
|
66
|
+
label,
|
|
67
|
+
name,
|
|
68
|
+
names,
|
|
69
|
+
min,
|
|
70
|
+
max,
|
|
71
|
+
step,
|
|
72
|
+
value,
|
|
73
|
+
minGap,
|
|
74
|
+
format,
|
|
75
|
+
locale = 'en-US',
|
|
76
|
+
marks,
|
|
77
|
+
showValue = true,
|
|
78
|
+
thumbLabels = ['Minimum', 'Maximum'],
|
|
79
|
+
hideLabel = false,
|
|
80
|
+
description,
|
|
81
|
+
error,
|
|
82
|
+
disabled = false,
|
|
83
|
+
size = 'm',
|
|
84
|
+
form,
|
|
85
|
+
id = uid('sinn-slider'),
|
|
86
|
+
class: className,
|
|
87
|
+
'aria-describedby': describedBy,
|
|
88
|
+
...rest
|
|
89
|
+
} = Astro.props;
|
|
90
|
+
|
|
91
|
+
const m = sliderModel({ min, max, step, value, minGap, format, locale, marks });
|
|
92
|
+
if (import.meta.env?.DEV) for (const w of m.warnings) console.warn(`[sinn] Slider "${label}": ${w}`);
|
|
93
|
+
|
|
94
|
+
const labelId = `${id}-label`;
|
|
95
|
+
const descId = description ? `${id}-desc` : undefined;
|
|
96
|
+
const errorId = `${id}-error`;
|
|
97
|
+
const inputIds = m.range ? [`${id}-min`, `${id}-max`] : [id];
|
|
98
|
+
const fieldNames = m.range ? (names ?? (name ? [`${name}-min`, `${name}-max`] : [undefined, undefined])) : [name];
|
|
99
|
+
const describedby = idList(describedBy as string | undefined, descId, error ? errorId : undefined);
|
|
100
|
+
// Only formats that differ from the native number reading need the format on the client.
|
|
101
|
+
const fmtAttr = format && format !== 'number' ? JSON.stringify(format) : undefined;
|
|
102
|
+
const labelled = m.marks.filter((k) => k.label);
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
<div
|
|
106
|
+
class:list={['sinn-slider', className]}
|
|
107
|
+
data-size={size}
|
|
108
|
+
data-range={m.range ? '' : undefined}
|
|
109
|
+
data-top={m.range ? m.top : undefined}
|
|
110
|
+
data-min-gap={m.range && m.minGap ? m.minGap : undefined}
|
|
111
|
+
data-format={fmtAttr}
|
|
112
|
+
data-locale={fmtAttr && locale !== 'en-US' ? locale : undefined}
|
|
113
|
+
data-disabled={disabled ? '' : undefined}
|
|
114
|
+
data-sinn-slider
|
|
115
|
+
{...rest}
|
|
116
|
+
>
|
|
117
|
+
<div class:list={['sinn-slider__head', { 'sinn-slider__head--sr': hideLabel && !showValue }]}>
|
|
118
|
+
{
|
|
119
|
+
m.range ? (
|
|
120
|
+
<span id={labelId} class:list={['sinn-type', 'sinn-label', { 'sinn-sr-only': hideLabel }]} data-size="s">
|
|
121
|
+
{label}
|
|
122
|
+
</span>
|
|
123
|
+
) : (
|
|
124
|
+
<label id={labelId} for={id} class:list={['sinn-type', 'sinn-label', { 'sinn-sr-only': hideLabel }]} data-size="s">
|
|
125
|
+
{label}
|
|
126
|
+
</label>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
{
|
|
130
|
+
showValue && (
|
|
131
|
+
// Hidden from AT: each thumb already announces its value (an <output> is a live region).
|
|
132
|
+
<output class="sinn-slider__output" for={inputIds.join(' ')} aria-hidden="true">
|
|
133
|
+
{m.output}
|
|
134
|
+
</output>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
</div>
|
|
138
|
+
{description && <FormDescription id={descId}>{description}</FormDescription>}
|
|
139
|
+
<div
|
|
140
|
+
class="sinn-slider__control"
|
|
141
|
+
role={m.range ? 'group' : undefined}
|
|
142
|
+
aria-labelledby={m.range ? labelId : undefined}
|
|
143
|
+
>
|
|
144
|
+
<div class="sinn-slider__rail" aria-hidden="true">
|
|
145
|
+
<svg class="sinn-slider__svg" width="100%" height="100%" focusable="false">
|
|
146
|
+
<rect class="sinn-slider__track" x="0" y="0" width="100%" height="100%" rx="3"></rect>
|
|
147
|
+
<rect class="sinn-slider__fill" x={`${m.fill[0]}%`} y="0" width={`${m.fill[1] - m.fill[0]}%`} height="100%" rx="3"></rect>
|
|
148
|
+
{m.marks.map((k) => <circle class="sinn-slider__tick" cx={`${k.pct}%`} cy="50%" r="2" data-value={k.value} data-active={k.active ? '' : undefined} />)}
|
|
149
|
+
</svg>
|
|
150
|
+
</div>
|
|
151
|
+
{
|
|
152
|
+
m.values.map((v, i) => (
|
|
153
|
+
<input
|
|
154
|
+
type="range"
|
|
155
|
+
class="sinn-slider__input"
|
|
156
|
+
id={inputIds[i]}
|
|
157
|
+
name={fieldNames[i]}
|
|
158
|
+
min={m.min}
|
|
159
|
+
max={m.max}
|
|
160
|
+
step={m.step}
|
|
161
|
+
value={v}
|
|
162
|
+
aria-valuetext={m.texts[i]}
|
|
163
|
+
aria-labelledby={m.range ? `${labelId} ${inputIds[i]}-name` : undefined}
|
|
164
|
+
aria-describedby={describedby}
|
|
165
|
+
aria-invalid={error ? 'true' : undefined}
|
|
166
|
+
disabled={disabled || undefined}
|
|
167
|
+
form={form}
|
|
168
|
+
/>
|
|
169
|
+
))
|
|
170
|
+
}
|
|
171
|
+
{m.range && thumbLabels.map((t, i) => <span id={`${inputIds[i]}-name`} hidden>{t}</span>)}
|
|
172
|
+
</div>
|
|
173
|
+
{
|
|
174
|
+
labelled.length > 0 && (
|
|
175
|
+
<div class="sinn-slider__marks" aria-hidden="true">
|
|
176
|
+
{labelled.map((k) => (
|
|
177
|
+
<span class="sinn-slider__mark" data-pct={k.pctRound} data-edge={k.edge}>
|
|
178
|
+
{k.label}
|
|
179
|
+
</span>
|
|
180
|
+
))}
|
|
181
|
+
</div>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
<FormError id={errorId} message={error} />
|
|
185
|
+
</div>
|
|
186
|
+
<SliderScript />
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Spacer — adds controlled empty space. Prefer `gap` on Stack/Cluster/Grid;
|
|
4
|
+
* use Spacer for one-off space or, with `grow`, to push flex siblings apart.
|
|
5
|
+
* Purely visual: hidden from assistive tech.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <Stack fill><h3>Title</h3><p>…</p><Spacer grow size="none" /><Button /></Stack>
|
|
9
|
+
*/
|
|
10
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
11
|
+
import type { Space } from './types';
|
|
12
|
+
import './styles/utilities.css';
|
|
13
|
+
import './styles/scale.css';
|
|
14
|
+
import './styles/spacer.css';
|
|
15
|
+
|
|
16
|
+
type Props = Omit<HTMLAttributes<'div'>, 'children'> & {
|
|
17
|
+
size?: Space;
|
|
18
|
+
/** `block` = vertical space, `inline` = horizontal space. */
|
|
19
|
+
axis?: 'block' | 'inline';
|
|
20
|
+
/** Flex-grow to fill the remaining space in a flex parent (size acts as the minimum). */
|
|
21
|
+
grow?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const { size = 'm', axis = 'block', grow = false, class: className, ...rest } = Astro.props;
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<div
|
|
28
|
+
class:list={['sinn-spacer', className]}
|
|
29
|
+
data-size={size}
|
|
30
|
+
data-axis={axis}
|
|
31
|
+
data-grow={grow ? '' : undefined}
|
|
32
|
+
aria-hidden="true"
|
|
33
|
+
{...rest}
|
|
34
|
+
>
|
|
35
|
+
</div>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Stack — arranges children vertically with consistent spacing (flex column + gap).
|
|
4
|
+
* Children's block margins are reset so the gap is the single source of spacing.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <Stack gap="s" as="ul"><li>…</li><li>…</li></Stack>
|
|
8
|
+
*/
|
|
9
|
+
import type { HTMLAttributes, HTMLTag } from 'astro/types';
|
|
10
|
+
import { LIST_TAGS, type Space } from './types';
|
|
11
|
+
import './styles/utilities.css';
|
|
12
|
+
import './styles/scale.css';
|
|
13
|
+
import './styles/stack.css';
|
|
14
|
+
|
|
15
|
+
type Props = HTMLAttributes<'div'> & {
|
|
16
|
+
as?: HTMLTag;
|
|
17
|
+
gap?: Space;
|
|
18
|
+
/** Cross-axis alignment. Defaults to stretch (full-width children). */
|
|
19
|
+
align?: 'start' | 'center' | 'end' | 'stretch';
|
|
20
|
+
/** Main-axis distribution. Only visible when the Stack is taller than its content (see `fill`). */
|
|
21
|
+
justify?: 'start' | 'center' | 'end' | 'between';
|
|
22
|
+
/** Take the parent's full height, e.g. so a card's footer can sit at the bottom. */
|
|
23
|
+
fill?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
as: Tag = 'div',
|
|
28
|
+
gap = 'm',
|
|
29
|
+
align = 'stretch',
|
|
30
|
+
justify = 'start',
|
|
31
|
+
fill = false,
|
|
32
|
+
class: className,
|
|
33
|
+
role,
|
|
34
|
+
...rest
|
|
35
|
+
} = Astro.props;
|
|
36
|
+
|
|
37
|
+
// list-style: none drops list semantics in Safari/VoiceOver; restore them.
|
|
38
|
+
const resolvedRole = role ?? (LIST_TAGS.has(Tag) ? 'list' : undefined);
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
<Tag
|
|
42
|
+
class:list={['sinn-stack', className]}
|
|
43
|
+
data-gap={gap}
|
|
44
|
+
data-align={align}
|
|
45
|
+
data-justify={justify}
|
|
46
|
+
data-fill={fill ? '' : undefined}
|
|
47
|
+
role={resolvedRole}
|
|
48
|
+
{...rest}
|
|
49
|
+
>
|
|
50
|
+
<slot />
|
|
51
|
+
</Tag>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Surface — a themed background and container treatment: page bands, hero sections,
|
|
4
|
+
* sidebars, tinted areas. Card and Panel are more specific surfaces; reach for those first.
|
|
5
|
+
*
|
|
6
|
+
* `scheme` forces light or dark for everything inside: every color token is `light-dark()`,
|
|
7
|
+
* so buttons, inputs and text inside flip with it. A dark band on a light page is one prop.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* <Surface as="section" background="subtle" padding="2xl"><Container>…</Container></Surface>
|
|
11
|
+
* <Surface scheme="dark" padding="xl" radius="l"><Heading level={2}>Ready to start?</Heading>…</Surface>
|
|
12
|
+
*/
|
|
13
|
+
import type { HTMLAttributes, HTMLTag } from 'astro/types';
|
|
14
|
+
import type { Space } from './types';
|
|
15
|
+
import { warnOnce } from './lib/deprecate';
|
|
16
|
+
import './styles/scale.css';
|
|
17
|
+
import './styles/utilities.css';
|
|
18
|
+
import './styles/surface.css';
|
|
19
|
+
|
|
20
|
+
type Props = HTMLAttributes<'div'> & {
|
|
21
|
+
as?: HTMLTag;
|
|
22
|
+
/**
|
|
23
|
+
* Fill: `default` · `subtle` · `sunken` · `raised` (neutral surfaces), `tinted` (the soft fill of
|
|
24
|
+
* `tone`), or `none`. The same words the blocks use for their `background`.
|
|
25
|
+
* `accent`, `success`, `warning` and `danger` are deprecated: use `background="tinted"` with that `tone`.
|
|
26
|
+
*/
|
|
27
|
+
background?: 'default' | 'subtle' | 'sunken' | 'raised' | 'tinted' | 'none' | 'accent' | 'success' | 'warning' | 'danger';
|
|
28
|
+
/** Colour family for `background="tinted"`. */
|
|
29
|
+
tone?: 'accent' | 'neutral' | 'success' | 'warning' | 'danger';
|
|
30
|
+
padding?: Space;
|
|
31
|
+
radius?: 'none' | 's' | 'm' | 'l';
|
|
32
|
+
border?: boolean;
|
|
33
|
+
elevation?: 0 | 1 | 2 | 3;
|
|
34
|
+
/** Force a color scheme for this subtree. */
|
|
35
|
+
scheme?: 'inherit' | 'light' | 'dark';
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const {
|
|
39
|
+
as: Tag = 'div',
|
|
40
|
+
background: backgroundProp = 'default',
|
|
41
|
+
tone: toneProp,
|
|
42
|
+
padding = 'm',
|
|
43
|
+
radius = 'none',
|
|
44
|
+
border = false,
|
|
45
|
+
elevation = 0,
|
|
46
|
+
scheme = 'inherit',
|
|
47
|
+
class: className,
|
|
48
|
+
...rest
|
|
49
|
+
} = Astro.props;
|
|
50
|
+
|
|
51
|
+
const LEGACY_TINTS = ['accent', 'success', 'warning', 'danger'] as const;
|
|
52
|
+
const legacyTint = (LEGACY_TINTS as readonly string[]).includes(backgroundProp) ? (backgroundProp as (typeof LEGACY_TINTS)[number]) : undefined;
|
|
53
|
+
if (legacyTint) warnOnce('Surface', `background="${legacyTint}" is deprecated; use background="tinted" tone="${legacyTint}".`);
|
|
54
|
+
const background = legacyTint ? 'tinted' : backgroundProp;
|
|
55
|
+
const tone = background === 'tinted' ? (toneProp ?? legacyTint ?? 'accent') : undefined;
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
<Tag
|
|
59
|
+
class:list={['sinn-surface', className]}
|
|
60
|
+
data-background={background === 'default' ? undefined : background}
|
|
61
|
+
data-tone={tone}
|
|
62
|
+
data-padding={padding}
|
|
63
|
+
data-radius={radius === 'none' ? undefined : radius}
|
|
64
|
+
data-border={border ? '' : undefined}
|
|
65
|
+
data-elevation={elevation || undefined}
|
|
66
|
+
data-scheme={scheme === 'inherit' ? undefined : scheme}
|
|
67
|
+
{...rest}
|
|
68
|
+
>
|
|
69
|
+
<slot />
|
|
70
|
+
</Tag>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Switch — an on/off setting that takes effect immediately.
|
|
4
|
+
* A native checkbox with `role="switch"`, so it submits with forms, works without
|
|
5
|
+
* JavaScript, and is announced as "switch, on/off".
|
|
6
|
+
*
|
|
7
|
+
* Use Checkbox when the choice only applies after the user submits a form,
|
|
8
|
+
* and Toggle for pressed/unpressed toolbar buttons.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <Switch name="notifications" label="Email notifications" checked />
|
|
12
|
+
* <Switch name="dark" labelPosition="start" label="Dark mode" description="Overrides your system setting." />
|
|
13
|
+
*/
|
|
14
|
+
import ChoiceField from './internal/ChoiceField.astro';
|
|
15
|
+
import type { ChoiceFieldProps } from './types';
|
|
16
|
+
|
|
17
|
+
type Props = ChoiceFieldProps;
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
<ChoiceField kind="switch" {...Astro.props}>
|
|
21
|
+
<slot />
|
|
22
|
+
</ChoiceField>
|