@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,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* FormField — wraps a control with its label, description and validation message,
|
|
4
|
+
* and wires them together (for/id, aria-describedby, aria-invalid).
|
|
5
|
+
*
|
|
6
|
+
* Input, Textarea and Select use it internally, so you only need it for custom
|
|
7
|
+
* controls. Pass a function child to receive the wiring as a FieldContext and spread
|
|
8
|
+
* `field.attrs` onto your control:
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <FormField label="Date of birth" description="For example, 27 3 1985" required>
|
|
12
|
+
* {(field) => <MyDateControl {...field.attrs} name="dob" />}
|
|
13
|
+
* </FormField>
|
|
14
|
+
*
|
|
15
|
+
* A plain (non-function) child gets nothing injected: give the control the same `id`
|
|
16
|
+
* and point aria-describedby at `${id}-desc` / `${id}-error` yourself.
|
|
17
|
+
*
|
|
18
|
+
* With no label, description or error, only the control is rendered (no wrapper),
|
|
19
|
+
* so give the control an aria-label.
|
|
20
|
+
*/
|
|
21
|
+
import type { FieldProps } from './types';
|
|
22
|
+
import { fieldContext, uid } from './utils';
|
|
23
|
+
import Label from './Label.astro';
|
|
24
|
+
import FormDescription from './FormDescription.astro';
|
|
25
|
+
import FormError from './FormError.astro';
|
|
26
|
+
import './styles/utilities.css';
|
|
27
|
+
import './styles/form.css';
|
|
28
|
+
|
|
29
|
+
type Props = FieldProps & {
|
|
30
|
+
/** id of the control. Generated when omitted. */
|
|
31
|
+
id?: string;
|
|
32
|
+
required?: boolean;
|
|
33
|
+
/** Extra ids for the control's aria-describedby. */
|
|
34
|
+
'aria-describedby'?: string;
|
|
35
|
+
/** Class on the wrapper. `null` (Astro's type for a missing class) renders none. */
|
|
36
|
+
class?: string | null;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
id = uid('sinn-field'),
|
|
41
|
+
label,
|
|
42
|
+
description,
|
|
43
|
+
error,
|
|
44
|
+
hideLabel = false,
|
|
45
|
+
optional = false,
|
|
46
|
+
required = false,
|
|
47
|
+
messages,
|
|
48
|
+
'aria-describedby': describedBy,
|
|
49
|
+
class: className,
|
|
50
|
+
} = Astro.props;
|
|
51
|
+
|
|
52
|
+
const field = fieldContext({ id, description, error, required, messages, describedBy });
|
|
53
|
+
const control = await Astro.slots.render('default', [field]);
|
|
54
|
+
const wrapped = Boolean(label || description || error);
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
wrapped ? (
|
|
59
|
+
<div class:list={['sinn-field', className]} data-invalid={field.invalid ? '' : undefined}>
|
|
60
|
+
{label && (
|
|
61
|
+
<Label for={id} required={required} optional={optional} class={hideLabel ? 'sinn-sr-only' : undefined}>
|
|
62
|
+
{label}
|
|
63
|
+
</Label>
|
|
64
|
+
)}
|
|
65
|
+
{description && <FormDescription id={field.descriptionId}>{description}</FormDescription>}
|
|
66
|
+
<Fragment set:html={control} />
|
|
67
|
+
<FormError id={field.errorId} message={error} />
|
|
68
|
+
</div>
|
|
69
|
+
) : (
|
|
70
|
+
<Fragment set:html={control} />
|
|
71
|
+
)
|
|
72
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Grid — responsive grid with no breakpoints. Columns are added while each
|
|
4
|
+
* item can stay at least `min` wide; `columns` caps how many fit on one row.
|
|
5
|
+
* At 320px everything collapses to one column (no horizontal scroll).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <Grid min="s" columns={3} as="ul">{cards.map(c => <li><Card {...c} /></li>)}</Grid>
|
|
9
|
+
*/
|
|
10
|
+
import type { HTMLAttributes, HTMLTag } from 'astro/types';
|
|
11
|
+
import { LIST_TAGS, type Measure, type Space } from './types';
|
|
12
|
+
import { renameProp } from './lib/deprecate';
|
|
13
|
+
import './styles/utilities.css';
|
|
14
|
+
import './styles/scale.css';
|
|
15
|
+
import './styles/grid.css';
|
|
16
|
+
|
|
17
|
+
type Props = HTMLAttributes<'div'> & {
|
|
18
|
+
as?: HTMLTag;
|
|
19
|
+
/** Minimum item width (measure token). */
|
|
20
|
+
min?: Measure;
|
|
21
|
+
/** Maximum columns per row (1–6). Omit for as many as fit. */
|
|
22
|
+
columns?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
23
|
+
/** @deprecated Use `columns`. */
|
|
24
|
+
cols?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
25
|
+
/** `auto-fit`: stretch items when there are fewer than fill a row. Default `auto-fill` keeps columns stable. */
|
|
26
|
+
fit?: boolean;
|
|
27
|
+
gap?: Space;
|
|
28
|
+
/** Gap between rows. Defaults to `gap`. */
|
|
29
|
+
rowGap?: Space;
|
|
30
|
+
/** Align items within their row. Default stretch (equal-height cards). */
|
|
31
|
+
align?: 'start' | 'center' | 'end' | 'stretch';
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const {
|
|
35
|
+
as: Tag = 'div',
|
|
36
|
+
min = 's',
|
|
37
|
+
columns: columnsProp,
|
|
38
|
+
cols,
|
|
39
|
+
fit = false,
|
|
40
|
+
gap = 'm',
|
|
41
|
+
rowGap,
|
|
42
|
+
align = 'stretch',
|
|
43
|
+
class: className,
|
|
44
|
+
role,
|
|
45
|
+
...rest
|
|
46
|
+
} = Astro.props;
|
|
47
|
+
const columns = renameProp('Grid', 'columns', columnsProp, 'cols', cols);
|
|
48
|
+
|
|
49
|
+
const resolvedRole = role ?? (LIST_TAGS.has(Tag) ? 'list' : undefined);
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
<Tag
|
|
53
|
+
class:list={['sinn-grid', className]}
|
|
54
|
+
data-min={min}
|
|
55
|
+
data-cols={columns}
|
|
56
|
+
data-fit={fit ? '' : undefined}
|
|
57
|
+
data-gap={gap}
|
|
58
|
+
data-row-gap={rowGap ?? gap}
|
|
59
|
+
data-align={align === 'stretch' ? undefined : align}
|
|
60
|
+
role={resolvedRole}
|
|
61
|
+
{...rest}
|
|
62
|
+
>
|
|
63
|
+
<slot />
|
|
64
|
+
</Tag>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Heading — semantic h1–h6. `level` sets the document outline; `size` sets the look.
|
|
4
|
+
* Keep levels sequential on a page and change `size` when the design needs a different scale.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <Heading level={1}>Page title</Heading>
|
|
8
|
+
* <Heading level={2} size="xl">Section that looks smaller than a default h2</Heading>
|
|
9
|
+
*/
|
|
10
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
11
|
+
import type { FontWeight, HeadingLevel, TextAlign, TextSize, TextTone } from './types';
|
|
12
|
+
import './styles/utilities.css';
|
|
13
|
+
import './styles/typography.css';
|
|
14
|
+
|
|
15
|
+
type Props = HTMLAttributes<'h1'> & {
|
|
16
|
+
/** Required: outline level. Not inferred, so every heading is a deliberate choice. */
|
|
17
|
+
level: HeadingLevel;
|
|
18
|
+
/** Visual size. Defaults by level: 1→3xl, 2→2xl, 3→xl, 4→l, 5→m, 6→s. */
|
|
19
|
+
size?: TextSize;
|
|
20
|
+
tone?: TextTone;
|
|
21
|
+
weight?: FontWeight;
|
|
22
|
+
align?: TextAlign;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const DEFAULT_SIZE: Record<HeadingLevel, TextSize> = { 1: '3xl', 2: '2xl', 3: 'xl', 4: 'l', 5: 'm', 6: 's' };
|
|
26
|
+
|
|
27
|
+
const { level, size, tone = 'default', weight = 'semibold', align, class: className, ...rest } = Astro.props;
|
|
28
|
+
|
|
29
|
+
if (![1, 2, 3, 4, 5, 6].includes(level)) {
|
|
30
|
+
throw new Error(`<Heading> level must be 1–6, received ${String(level)}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const Tag = `h${level}` as 'h1';
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
<Tag
|
|
37
|
+
class:list={['sinn-type', 'sinn-heading', className]}
|
|
38
|
+
data-size={size ?? DEFAULT_SIZE[level]}
|
|
39
|
+
data-tone={tone === 'default' ? undefined : tone}
|
|
40
|
+
data-weight={weight}
|
|
41
|
+
data-align={align}
|
|
42
|
+
{...rest}
|
|
43
|
+
>
|
|
44
|
+
<slot />
|
|
45
|
+
</Tag>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* IconButton — a square button whose only visible content is an icon.
|
|
4
|
+
*
|
|
5
|
+
* `label` is required. It's rendered as visually hidden text (not `aria-label`),
|
|
6
|
+
* so browser auto-translation picks it up too. The icon should be `aria-hidden="true"`.
|
|
7
|
+
* Pass `href` to render a link (LinkButton) instead of a button.
|
|
8
|
+
*
|
|
9
|
+
* Defaults to the `ghost` variant, since icon buttons usually sit in toolbars and headers.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <IconButton label="Close dialog"><XIcon aria-hidden="true" /></IconButton>
|
|
13
|
+
* <IconButton label="GitHub" href="https://github.com/…" newTab><GitHubIcon aria-hidden="true" /></IconButton>
|
|
14
|
+
*/
|
|
15
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
16
|
+
import type { ButtonStyleProps, InvokerProps } from './types';
|
|
17
|
+
import Button from './Button.astro';
|
|
18
|
+
import LinkButton from './LinkButton.astro';
|
|
19
|
+
import './styles/utilities.css';
|
|
20
|
+
|
|
21
|
+
type Props = Omit<HTMLAttributes<'button'>, 'aria-label'> &
|
|
22
|
+
Omit<ButtonStyleProps, 'fullWidth'> &
|
|
23
|
+
InvokerProps & {
|
|
24
|
+
/** Accessible name. Required. */
|
|
25
|
+
label: string;
|
|
26
|
+
href?: string;
|
|
27
|
+
newTab?: boolean;
|
|
28
|
+
loading?: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const { label, href, variant = 'ghost', ...rest } = Astro.props;
|
|
32
|
+
|
|
33
|
+
if (!label) throw new Error('<IconButton> needs a `label` for its accessible name.');
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
{
|
|
37
|
+
href ? (
|
|
38
|
+
<LinkButton {...(rest as any)} href={href} variant={variant} iconOnly>
|
|
39
|
+
<slot />
|
|
40
|
+
<span class="sinn-sr-only">{label}</span>
|
|
41
|
+
</LinkButton>
|
|
42
|
+
) : (
|
|
43
|
+
<Button {...rest} variant={variant} iconOnly>
|
|
44
|
+
<slot />
|
|
45
|
+
<span class="sinn-sr-only">{label}</span>
|
|
46
|
+
</Button>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Image — a responsive `<img>` with consistent behavior across the site.
|
|
4
|
+
*
|
|
5
|
+
* Generated through Astro's image service (`getImage`): a WebP `srcset` sized to how the
|
|
6
|
+
* image is actually displayed, a matching `sizes` hint, and width/height attributes that
|
|
7
|
+
* reserve its box before it loads (no layout shift). Lazy by default; `priority` for the
|
|
8
|
+
* largest above-the-fold image (eager, fetchpriority="high"), one per page.
|
|
9
|
+
*
|
|
10
|
+
* - `alt` is required. Pass `alt=""` only for decorative images.
|
|
11
|
+
* - `width` is the largest CSS width it's shown at (local images); `layout` picks the
|
|
12
|
+
* srcset strategy: `constrained` (default), `full` (spans the viewport), `fixed` (1x/2x).
|
|
13
|
+
* - `aspect` crops the generated files to that ratio (and reserves that box); `position`
|
|
14
|
+
* picks the focus point. `fit="contain"` letterboxes instead in CSS.
|
|
15
|
+
* - Remote (string) images need their real `width`/`height` (or `inferSize`) and the domain
|
|
16
|
+
* allowed in `image.domains` / `image.remotePatterns`.
|
|
17
|
+
* - `caption` wraps it in `<figure>` with a `<figcaption>` (and an optional `credit`).
|
|
18
|
+
* - For multiple formats (AVIF + WebP) or art direction, use Picture.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* <Image src={office} alt="Front desk at the Fort Worth studio" width={800} aspect="3/2" />
|
|
22
|
+
* <Image src={hero} alt="" layout="full" aspect="21/9" priority />
|
|
23
|
+
*/
|
|
24
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
25
|
+
import type { Aspect, ImageLayout } from './internal/image-plan';
|
|
26
|
+
import { buildImageSet, type ImageFormat, type ImageQuality, type ImageSource } from './internal/image';
|
|
27
|
+
import './styles/utilities.css';
|
|
28
|
+
import './styles/media.css';
|
|
29
|
+
|
|
30
|
+
type Props = Omit<HTMLAttributes<'img'>, 'src' | 'srcset' | 'width' | 'height' | 'alt' | 'loading'> & {
|
|
31
|
+
src: ImageSource;
|
|
32
|
+
alt: string;
|
|
33
|
+
width?: number;
|
|
34
|
+
height?: number;
|
|
35
|
+
layout?: ImageLayout;
|
|
36
|
+
aspect?: Aspect;
|
|
37
|
+
fit?: 'cover' | 'contain';
|
|
38
|
+
position?: 'center' | 'top' | 'bottom' | 'start' | 'end';
|
|
39
|
+
sizes?: string;
|
|
40
|
+
priority?: boolean;
|
|
41
|
+
format?: ImageFormat;
|
|
42
|
+
quality?: ImageQuality;
|
|
43
|
+
inferSize?: boolean;
|
|
44
|
+
/** Remote images: largest CSS width it's shown at (`width`/`height` are the file's size). */
|
|
45
|
+
displayWidth?: number;
|
|
46
|
+
radius?: 'none' | 's' | 'm' | 'l' | 'full';
|
|
47
|
+
/** Neutral fill while loading. Turn off for transparent images. Default: on when cropped. */
|
|
48
|
+
placeholder?: boolean;
|
|
49
|
+
caption?: string;
|
|
50
|
+
credit?: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const {
|
|
54
|
+
src,
|
|
55
|
+
alt,
|
|
56
|
+
width,
|
|
57
|
+
height,
|
|
58
|
+
layout = 'constrained',
|
|
59
|
+
aspect,
|
|
60
|
+
fit = 'cover',
|
|
61
|
+
position = 'center',
|
|
62
|
+
sizes,
|
|
63
|
+
priority = false,
|
|
64
|
+
format = 'webp',
|
|
65
|
+
quality,
|
|
66
|
+
inferSize = false,
|
|
67
|
+
displayWidth,
|
|
68
|
+
radius = 'none',
|
|
69
|
+
placeholder = Boolean(aspect && aspect !== 'auto'),
|
|
70
|
+
caption,
|
|
71
|
+
credit,
|
|
72
|
+
class: className,
|
|
73
|
+
...rest
|
|
74
|
+
} = Astro.props;
|
|
75
|
+
|
|
76
|
+
const set = await buildImageSet({ src, width, height, displayWidth, aspect, layout, sizes, format, quality, inferSize, position, lazy: !priority });
|
|
77
|
+
const priorityAttrs = priority ? ({ loading: 'eager', fetchpriority: 'high' } as const) : ({ loading: 'lazy', decoding: 'async' } as const);
|
|
78
|
+
const figure = Boolean(caption || credit);
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
{
|
|
82
|
+
figure ? (
|
|
83
|
+
<figure class:list={['sinn-figure', className]}>
|
|
84
|
+
<img
|
|
85
|
+
class="sinn-image"
|
|
86
|
+
src={set.src}
|
|
87
|
+
srcset={set.srcset}
|
|
88
|
+
sizes={set.sizes}
|
|
89
|
+
width={set.width}
|
|
90
|
+
height={set.height}
|
|
91
|
+
alt={alt}
|
|
92
|
+
data-layout={layout === 'constrained' ? undefined : layout}
|
|
93
|
+
data-aspect={aspect && aspect !== 'auto' ? aspect : undefined}
|
|
94
|
+
data-fit={fit === 'cover' ? undefined : fit}
|
|
95
|
+
data-position={position === 'center' ? undefined : position}
|
|
96
|
+
data-radius={radius === 'none' ? undefined : radius}
|
|
97
|
+
data-placeholder={placeholder ? '' : undefined}
|
|
98
|
+
{...priorityAttrs}
|
|
99
|
+
{...rest}
|
|
100
|
+
/>
|
|
101
|
+
<figcaption class="sinn-figure__caption">
|
|
102
|
+
{caption}
|
|
103
|
+
{credit && <span class="sinn-figure__credit">{caption ? ' · ' : ''}{credit}</span>}
|
|
104
|
+
</figcaption>
|
|
105
|
+
</figure>
|
|
106
|
+
) : (
|
|
107
|
+
<img
|
|
108
|
+
class:list={['sinn-image', className]}
|
|
109
|
+
src={set.src}
|
|
110
|
+
srcset={set.srcset}
|
|
111
|
+
sizes={set.sizes}
|
|
112
|
+
width={set.width}
|
|
113
|
+
height={set.height}
|
|
114
|
+
alt={alt}
|
|
115
|
+
data-layout={layout === 'constrained' ? undefined : layout}
|
|
116
|
+
data-aspect={aspect && aspect !== 'auto' ? aspect : undefined}
|
|
117
|
+
data-fit={fit === 'cover' ? undefined : fit}
|
|
118
|
+
data-position={position === 'center' ? undefined : position}
|
|
119
|
+
data-radius={radius === 'none' ? undefined : radius}
|
|
120
|
+
data-placeholder={placeholder ? '' : undefined}
|
|
121
|
+
{...priorityAttrs}
|
|
122
|
+
{...rest}
|
|
123
|
+
/>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Input — single-line text entry. Native `<input>`, wrapped in FormField when it has a
|
|
4
|
+
* label, description or error.
|
|
5
|
+
*
|
|
6
|
+
* - Set `autocomplete` (e.g. "email", "given-name", "tel") whenever it applies: WCAG 1.3.5,
|
|
7
|
+
* and it's the biggest usability win on mobile.
|
|
8
|
+
* - For numbers that aren't quantities (ZIP, card, member ID) use `type="text"` with
|
|
9
|
+
* `inputmode="numeric"` instead of `type="number"`.
|
|
10
|
+
* - `start` / `end` slots add non-interactive addons inside the border ("$", ".com", an icon).
|
|
11
|
+
* - `class` goes on the field wrapper (or the input when there's no wrapper).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <Input name="email" type="email" label="Email" autocomplete="email" required />
|
|
15
|
+
* <Input name="price" label="Price" inputmode="decimal"><span slot="start">$</span></Input>
|
|
16
|
+
*/
|
|
17
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
18
|
+
import type { ControlSize, FieldContext, FieldProps, InputType } from './types';
|
|
19
|
+
import { uid } from './utils';
|
|
20
|
+
import FormField from './FormField.astro';
|
|
21
|
+
import './styles/utilities.css';
|
|
22
|
+
import './styles/form.css';
|
|
23
|
+
|
|
24
|
+
type Props = Omit<HTMLAttributes<'input'>, 'size' | 'type'> &
|
|
25
|
+
FieldProps & {
|
|
26
|
+
type?: InputType;
|
|
27
|
+
size?: ControlSize;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
label,
|
|
32
|
+
description,
|
|
33
|
+
error,
|
|
34
|
+
hideLabel,
|
|
35
|
+
optional,
|
|
36
|
+
messages,
|
|
37
|
+
type = 'text',
|
|
38
|
+
size = 'm',
|
|
39
|
+
id: idProp,
|
|
40
|
+
required = false,
|
|
41
|
+
'aria-describedby': describedBy,
|
|
42
|
+
class: className,
|
|
43
|
+
...rest
|
|
44
|
+
} = Astro.props;
|
|
45
|
+
// `??`, not a default: a default only replaces undefined, and id={null} would give "null-error" ids.
|
|
46
|
+
const id = idProp ?? uid('sinn-input');
|
|
47
|
+
|
|
48
|
+
const wrapped = Boolean(label || description || error);
|
|
49
|
+
// `class` goes on the field wrapper, or on the control itself when there is no wrapper.
|
|
50
|
+
const controlClass = wrapped ? undefined : className;
|
|
51
|
+
const start = Astro.slots.has('start') ? await Astro.slots.render('start') : '';
|
|
52
|
+
const end = Astro.slots.has('end') ? await Astro.slots.render('end') : '';
|
|
53
|
+
const grouped = Boolean(start || end);
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
<FormField
|
|
57
|
+
id={id}
|
|
58
|
+
label={label}
|
|
59
|
+
description={description}
|
|
60
|
+
error={error}
|
|
61
|
+
hideLabel={hideLabel}
|
|
62
|
+
optional={optional}
|
|
63
|
+
required={Boolean(required)}
|
|
64
|
+
messages={messages}
|
|
65
|
+
aria-describedby={describedBy as string | undefined}
|
|
66
|
+
class={className}
|
|
67
|
+
>
|
|
68
|
+
{
|
|
69
|
+
(field: FieldContext) =>
|
|
70
|
+
grouped ? (
|
|
71
|
+
<div class:list={['sinn-control-group', controlClass]} data-size={size}>
|
|
72
|
+
{start && <span class="sinn-control-group__addon"><Fragment set:html={start} /></span>}
|
|
73
|
+
<input type={type} class="sinn-control" data-size={size} {...field.attrs} {...rest} />
|
|
74
|
+
{end && <span class="sinn-control-group__addon"><Fragment set:html={end} /></span>}
|
|
75
|
+
</div>
|
|
76
|
+
) : (
|
|
77
|
+
<input
|
|
78
|
+
type={type}
|
|
79
|
+
class:list={['sinn-control', controlClass]}
|
|
80
|
+
data-size={size}
|
|
81
|
+
{...field.attrs}
|
|
82
|
+
{...rest}
|
|
83
|
+
/>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
</FormField>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Label — short label for a control or a piece of content.
|
|
4
|
+
* Renders a real `<label>` (pass `for`) by default; use `as="span"` for labels that
|
|
5
|
+
* don't name a form control (stat labels, metadata keys), or `as="legend"` inside a fieldset.
|
|
6
|
+
*
|
|
7
|
+
* The required asterisk is visual only: put `required` on the input itself so
|
|
8
|
+
* assistive tech announces it.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <Label for="email" required>Email</Label>
|
|
12
|
+
* <Label for="company" optional>Company</Label>
|
|
13
|
+
*/
|
|
14
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
15
|
+
import type { TextSize, TextTone } from './types';
|
|
16
|
+
import './styles/utilities.css';
|
|
17
|
+
import './styles/typography.css';
|
|
18
|
+
|
|
19
|
+
type Props = HTMLAttributes<'label'> & {
|
|
20
|
+
as?: 'label' | 'span' | 'legend' | 'div' | 'dt';
|
|
21
|
+
size?: Extract<TextSize, 'xs' | 's' | 'm'>;
|
|
22
|
+
tone?: TextTone;
|
|
23
|
+
/** Show a visual required marker. */
|
|
24
|
+
required?: boolean;
|
|
25
|
+
/** Show an "(optional)" hint. Pass a string to translate it. */
|
|
26
|
+
optional?: boolean | string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
as: Tag = 'label',
|
|
31
|
+
size = 's',
|
|
32
|
+
tone = 'default',
|
|
33
|
+
required = false,
|
|
34
|
+
optional = false,
|
|
35
|
+
class: className,
|
|
36
|
+
...rest
|
|
37
|
+
} = Astro.props;
|
|
38
|
+
|
|
39
|
+
const optionalText = typeof optional === 'string' ? optional : 'optional';
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
<Tag
|
|
43
|
+
class:list={['sinn-type', 'sinn-label', className]}
|
|
44
|
+
data-size={size}
|
|
45
|
+
data-tone={tone === 'default' ? undefined : tone}
|
|
46
|
+
{...rest}
|
|
47
|
+
><slot />{required && <span class="sinn-label__required" aria-hidden="true">*</span>}{
|
|
48
|
+
!required && optional && <span class="sinn-label__optional">({optionalText})</span>
|
|
49
|
+
}</Tag
|
|
50
|
+
>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Link — styled, accessible hyperlink for text content.
|
|
4
|
+
*
|
|
5
|
+
* - Underlined by default. Links inside body text must stay distinguishable without color (WCAG 1.4.1),
|
|
6
|
+
* so use `underline="hover"` or `"none"` only where context makes them obvious (nav, footers, cards).
|
|
7
|
+
* - Off-site links (absolute URL to another host than `Astro.site`) get an arrow icon and `rel="external"`.
|
|
8
|
+
* - `newTab` adds `target="_blank"`, `rel="noopener"` and a screen-reader hint.
|
|
9
|
+
* - `aria-current="page"` is passed through and styled.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <Link href="/pricing">See pricing</Link>
|
|
13
|
+
* <Link href="https://astro.build" newTab>Astro docs</Link>
|
|
14
|
+
*/
|
|
15
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
16
|
+
import './styles/utilities.css';
|
|
17
|
+
import './styles/typography.css';
|
|
18
|
+
|
|
19
|
+
type Props = HTMLAttributes<'a'> & {
|
|
20
|
+
href: string;
|
|
21
|
+
tone?: 'accent' | 'neutral' | 'inherit';
|
|
22
|
+
underline?: 'always' | 'hover' | 'none';
|
|
23
|
+
/** Open in a new tab. */
|
|
24
|
+
newTab?: boolean;
|
|
25
|
+
/** Screen-reader text appended when `newTab` is set. Translate per site. */
|
|
26
|
+
newTabLabel?: string;
|
|
27
|
+
/** Force the external icon on/off. Auto-detected from `href` and `Astro.site` when omitted. */
|
|
28
|
+
external?: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
href,
|
|
33
|
+
tone = 'accent',
|
|
34
|
+
underline = 'always',
|
|
35
|
+
newTab = false,
|
|
36
|
+
newTabLabel = 'opens in a new tab',
|
|
37
|
+
external,
|
|
38
|
+
rel,
|
|
39
|
+
class: className,
|
|
40
|
+
...rest
|
|
41
|
+
} = Astro.props;
|
|
42
|
+
|
|
43
|
+
let autoExternal = false;
|
|
44
|
+
if (/^https?:\/\//i.test(href)) {
|
|
45
|
+
try {
|
|
46
|
+
autoExternal = !Astro.site || new URL(href).host !== Astro.site.host;
|
|
47
|
+
} catch {
|
|
48
|
+
autoExternal = false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const isExternal = external ?? autoExternal;
|
|
52
|
+
|
|
53
|
+
const relSet = new Set(String(rel ?? '').split(/\s+/).filter(Boolean));
|
|
54
|
+
if (newTab) relSet.add('noopener');
|
|
55
|
+
if (isExternal) relSet.add('external');
|
|
56
|
+
const relValue = relSet.size ? [...relSet].join(' ') : undefined;
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
<a
|
|
60
|
+
href={href}
|
|
61
|
+
class:list={['sinn-link', className]}
|
|
62
|
+
data-tone={tone === 'accent' ? undefined : tone}
|
|
63
|
+
data-underline={underline === 'always' ? undefined : underline}
|
|
64
|
+
target={newTab ? '_blank' : undefined}
|
|
65
|
+
rel={relValue}
|
|
66
|
+
{...rest}
|
|
67
|
+
><slot />{
|
|
68
|
+
isExternal && (
|
|
69
|
+
<svg class="sinn-link__icon" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
70
|
+
<path
|
|
71
|
+
d="M5 3h8v8M13 3 3 13"
|
|
72
|
+
fill="none"
|
|
73
|
+
stroke="currentColor"
|
|
74
|
+
stroke-width="2"
|
|
75
|
+
stroke-linecap="round"
|
|
76
|
+
stroke-linejoin="round"
|
|
77
|
+
/>
|
|
78
|
+
</svg>
|
|
79
|
+
)
|
|
80
|
+
}{newTab && <span class="sinn-sr-only"> ({newTabLabel})</span>}</a
|
|
81
|
+
>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* LinkButton — a navigation link styled as a button. It's still an `<a>`:
|
|
4
|
+
* it navigates, opens in new tabs, and is announced as a link.
|
|
5
|
+
*
|
|
6
|
+
* `disabled` removes the `href` and sets `aria-disabled` (links can't be truly disabled).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* <LinkButton href="/contact" size="l">Book a consultation</LinkButton>
|
|
10
|
+
* <LinkButton href="https://cal.com/…" variant="outline" newTab>Schedule</LinkButton>
|
|
11
|
+
*/
|
|
12
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
13
|
+
import type { ButtonStyleProps } from './types';
|
|
14
|
+
import './styles/utilities.css';
|
|
15
|
+
import './styles/button.css';
|
|
16
|
+
|
|
17
|
+
type Props = HTMLAttributes<'a'> &
|
|
18
|
+
ButtonStyleProps & {
|
|
19
|
+
href: string;
|
|
20
|
+
newTab?: boolean;
|
|
21
|
+
newTabLabel?: string;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** @internal Used by IconButton. */
|
|
24
|
+
iconOnly?: boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
href,
|
|
29
|
+
variant = 'solid',
|
|
30
|
+
tone = 'accent',
|
|
31
|
+
size = 'm',
|
|
32
|
+
fullWidth = false,
|
|
33
|
+
newTab = false,
|
|
34
|
+
newTabLabel = 'opens in a new tab',
|
|
35
|
+
disabled = false,
|
|
36
|
+
iconOnly = false,
|
|
37
|
+
rel,
|
|
38
|
+
class: className,
|
|
39
|
+
...rest
|
|
40
|
+
} = Astro.props;
|
|
41
|
+
|
|
42
|
+
const relSet = new Set(String(rel ?? '').split(/\s+/).filter(Boolean));
|
|
43
|
+
if (newTab) relSet.add('noopener');
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
<a
|
|
47
|
+
href={disabled ? undefined : href}
|
|
48
|
+
role={disabled ? 'link' : undefined}
|
|
49
|
+
aria-disabled={disabled ? 'true' : undefined}
|
|
50
|
+
class:list={['sinn-button', className]}
|
|
51
|
+
data-variant={variant}
|
|
52
|
+
data-tone={tone}
|
|
53
|
+
data-size={size}
|
|
54
|
+
data-full-width={fullWidth ? '' : undefined}
|
|
55
|
+
data-icon-only={iconOnly ? '' : undefined}
|
|
56
|
+
target={newTab && !disabled ? '_blank' : undefined}
|
|
57
|
+
rel={relSet.size ? [...relSet].join(' ') : undefined}
|
|
58
|
+
{...rest}
|
|
59
|
+
>
|
|
60
|
+
<span class="sinn-button__content">
|
|
61
|
+
<slot name="icon-start" />
|
|
62
|
+
<slot />
|
|
63
|
+
<slot name="icon-end" />
|
|
64
|
+
</span>
|
|
65
|
+
{newTab && <span class="sinn-sr-only"> ({newTabLabel})</span>}
|
|
66
|
+
</a>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* List — a list of structured entries (ListItem). Renders `<ul role="list">`
|
|
4
|
+
* (or `<ol>` when order matters, e.g. a ranked list).
|
|
5
|
+
*
|
|
6
|
+
* - `divided` (default): hairlines between items.
|
|
7
|
+
* - `inset`: inside a bordered surface, like a settings group or a card list.
|
|
8
|
+
* - `plain`: no rules.
|
|
9
|
+
*
|
|
10
|
+
* Give it `aria-label` (or `aria-labelledby` pointing at a heading) when several lists share a page.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <List aria-labelledby="upcoming-title">
|
|
14
|
+
* <ListItem title="Design review" description="Ana Ruiz · Fort Worth" value="Nov 18" valueDetail="9:30 AM" href="/meetings/123" />
|
|
15
|
+
* </List>
|
|
16
|
+
*/
|
|
17
|
+
import type { HTMLAttributes } from 'astro/types';
|
|
18
|
+
import './styles/utilities.css';
|
|
19
|
+
import './styles/data.css';
|
|
20
|
+
|
|
21
|
+
type Props = HTMLAttributes<'ul'> & {
|
|
22
|
+
ordered?: boolean;
|
|
23
|
+
variant?: 'divided' | 'inset' | 'plain';
|
|
24
|
+
density?: 'compact' | 'default' | 'comfortable';
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const { ordered = false, variant = 'divided', density = 'default', class: className, ...rest } = Astro.props;
|
|
28
|
+
const Tag = ordered ? 'ol' : 'ul';
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
<Tag
|
|
32
|
+
role="list"
|
|
33
|
+
class:list={['sinn-list', className]}
|
|
34
|
+
data-variant={variant}
|
|
35
|
+
data-density={density === 'default' ? undefined : density}
|
|
36
|
+
{...rest}
|
|
37
|
+
>
|
|
38
|
+
<slot />
|
|
39
|
+
</Tag>
|