@subfloor/astro 0.0.0-stage → 0.1.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 ADDED
@@ -0,0 +1,16 @@
1
+ # @subfloor/astro
2
+
3
+ ## 0.1.0
4
+
5
+ First release. All `@subfloor/*` packages have the same version.
6
+
7
+ Components for Astro 5 and later, shipped as source:
8
+
9
+ - Dialogs: `Dialog`, `Modal`, `Sidepanel` (also a bottom sheet that can be swiped down on touch devices) and `MobileNav`.
10
+ - `Popover`, `Menu` and `Snackbar`.
11
+ - Form fields: `Select`, `TextField`, `TextArea`, `DateField` with its own calendar, `Checkbox`, `CheckboxGroup`, `RadioGroup` and `Switch`.
12
+ - `Segmented` and `SegmentedLinks`, `Button` and `ButtonLink`.
13
+
14
+ Import `@subfloor/core/base.css` once. Each component brings its own styles.
15
+
16
+ Known limits are in the [specification](https://github.com/Phunkhouse/subfloor/blob/main/docs/SPEC.md). `TextField type="time"` uses the browser's own picker. It is planned to be replaced by a `TimeField`, which will be a breaking change.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 David Krapka
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,24 @@
1
- # Temporary Holding Version
1
+ # @subfloor/astro
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Accessible, native-first UI components for Astro: dialogs, menus, popovers, form fields, buttons and more. They are shipped as source. The behaviour is in [`@subfloor/core`](https://www.npmjs.com/package/@subfloor/core).
4
+
5
+ ```sh
6
+ pnpm add @subfloor/core @subfloor/astro
7
+ ```
8
+
9
+ Import the base styles once, for example in the layout. Each component brings its own styles.
10
+
11
+ ```astro
12
+ ---
13
+ import '@subfloor/core/base.css'
14
+ import DateField from '@subfloor/astro/DateField.astro'
15
+ ---
16
+
17
+ <DateField id="until" name="until" label="Valid until" />
18
+ ```
19
+
20
+ Documentation, live demos and tokens: https://phunkhouse.github.io/subfloor/
21
+
22
+ All `@subfloor/*` packages share one version: update them together. Before 1.0, a new minor version (such as 0.2.0) can contain breaking changes, so read the changelog first.
23
+
24
+ MIT
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@subfloor/astro",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Astro components for @subfloor/core, shipped as source.",
5
+ "license": "MIT",
6
+ "homepage": "https://phunkhouse.github.io/subfloor/",
7
+ "bugs": "https://github.com/Phunkhouse/subfloor/issues",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/Phunkhouse/subfloor.git",
11
+ "directory": "packages/astro"
12
+ },
13
+ "type": "module",
14
+ "exports": {
15
+ "./Dialog.astro": "./src/Dialog.astro",
16
+ "./Modal.astro": "./src/Modal.astro",
17
+ "./Sidepanel.astro": "./src/Sidepanel.astro",
18
+ "./MobileNav.astro": "./src/MobileNav.astro",
19
+ "./Popover.astro": "./src/Popover.astro",
20
+ "./Menu.astro": "./src/Menu.astro",
21
+ "./Snackbar.astro": "./src/Snackbar.astro",
22
+ "./Select.astro": "./src/Select.astro",
23
+ "./TextField.astro": "./src/TextField.astro",
24
+ "./DateField.astro": "./src/DateField.astro",
25
+ "./TextArea.astro": "./src/TextArea.astro",
26
+ "./Checkbox.astro": "./src/Checkbox.astro",
27
+ "./CheckboxGroup.astro": "./src/CheckboxGroup.astro",
28
+ "./RadioGroup.astro": "./src/RadioGroup.astro",
29
+ "./Switch.astro": "./src/Switch.astro",
30
+ "./Segmented.astro": "./src/Segmented.astro",
31
+ "./SegmentedLinks.astro": "./src/SegmentedLinks.astro",
32
+ "./Button.astro": "./src/Button.astro",
33
+ "./ButtonLink.astro": "./src/ButtonLink.astro",
34
+ "./package.json": "./package.json"
35
+ },
36
+ "files": [
37
+ "src",
38
+ "CHANGELOG.md"
39
+ ],
40
+ "keywords": [
41
+ "astro-component"
42
+ ],
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "dependencies": {
47
+ "@subfloor/core": "0.1.0"
48
+ },
49
+ "peerDependencies": {
50
+ "astro": ">=5.0.0"
51
+ }
6
52
  }
@@ -0,0 +1,68 @@
1
+ ---
2
+ /**
3
+ * A native `<button>`, prepared for work in progress (decision 0011). Never a link: ButtonLink.
4
+ * Make it busy from script with the core's `setButtonBusy(button, true)`, or with `busyOnSubmit`
5
+ * while its form is sent the normal way. Both need the script; without it, it is a plain button.
6
+ */
7
+ // This component's styles (decision 0006); the project imports `@subfloor/core/base.css` once.
8
+ import '@subfloor/core/styles/button.css'
9
+ import type { HTMLAttributes } from 'astro/types'
10
+ import ButtonContent from './ButtonContent.astro'
11
+
12
+ type Base = HTMLAttributes<'button'> & {
13
+ /** `secondary` by default. One `primary` per screen or panel. */
14
+ variant?: 'primary' | 'secondary' | 'quiet' | 'danger' | undefined
15
+ /**
16
+ * Busy once its form is sent by the browser, not by your script. Usable again when the visitor
17
+ * comes back to the page, or after 10 seconds (for a download), or the number of milliseconds
18
+ * given here. Makes it a submit button, unless you set `type`.
19
+ */
20
+ busyOnSubmit?: boolean | number | undefined
21
+ }
22
+
23
+ /** A square button with only an icon needs a name of its own. */
24
+ export type Props = Base &
25
+ (
26
+ | {
27
+ iconOnly?: false | undefined
28
+ /** What is happening, such as "Saving…": shown while busy, without changing the width. */
29
+ busyLabel?: string | undefined
30
+ }
31
+ | { iconOnly: true; 'aria-label': string; busyLabel?: undefined }
32
+ )
33
+
34
+ const {
35
+ variant = 'secondary',
36
+ busyLabel,
37
+ busyOnSubmit = false,
38
+ iconOnly = false,
39
+ type = busyOnSubmit ? 'submit' : 'button',
40
+ class: className,
41
+ ...rest
42
+ } = Astro.props
43
+ ---
44
+
45
+ <button
46
+ {...rest}
47
+ type={type}
48
+ class:list={['sf-button', className]}
49
+ data-variant={variant}
50
+ data-icon-only={iconOnly ? '' : undefined}
51
+ data-sf-busy-on-submit={
52
+ busyOnSubmit === true
53
+ ? ''
54
+ : busyOnSubmit === false
55
+ ? undefined
56
+ : String(busyOnSubmit)
57
+ }
58
+ >
59
+ <ButtonContent busyLabel={busyLabel}>
60
+ <slot />
61
+ </ButtonContent>
62
+ </button>
63
+
64
+ <script>
65
+ import { initButtons } from '@subfloor/core'
66
+
67
+ initButtons()
68
+ </script>
@@ -0,0 +1,19 @@
1
+ ---
2
+ /**
3
+ * The words of a Button or ButtonLink and, always there to keep the width, what replaces them while
4
+ * it is busy (R-44): the @subfloor/core markup. Not exported from the package.
5
+ */
6
+ export interface Props {
7
+ busyLabel?: string | undefined
8
+ }
9
+
10
+ const { busyLabel } = Astro.props
11
+ ---
12
+
13
+ <span class="sf-button__label">
14
+ <slot />
15
+ </span>
16
+ <span class="sf-button__busy">
17
+ <span class="sf-button__spinner" aria-hidden="true"></span>
18
+ {busyLabel && <span class="sf-button__busy-label">{busyLabel}</span>}
19
+ </span>
@@ -0,0 +1,35 @@
1
+ ---
2
+ /** A real link that looks like a Button (decision 0011). It needs no script. */
3
+ // This component's styles (decision 0006); the project imports `@subfloor/core/base.css` once.
4
+ import '@subfloor/core/styles/button.css'
5
+ import type { HTMLAttributes } from 'astro/types'
6
+ import ButtonContent from './ButtonContent.astro'
7
+
8
+ type Base = HTMLAttributes<'a'> & {
9
+ href: string
10
+ /** `secondary` by default. */
11
+ variant?: 'primary' | 'secondary' | 'quiet' | 'danger' | undefined
12
+ }
13
+
14
+ /** A square link with only an icon needs a name of its own. */
15
+ export type Props = Base &
16
+ ({ iconOnly?: false | undefined } | { iconOnly: true; 'aria-label': string })
17
+
18
+ const {
19
+ variant = 'secondary',
20
+ iconOnly = false,
21
+ class: className,
22
+ ...rest
23
+ } = Astro.props
24
+ ---
25
+
26
+ <a
27
+ {...rest}
28
+ class:list={['sf-button', className]}
29
+ data-variant={variant}
30
+ data-icon-only={iconOnly ? '' : undefined}
31
+ >
32
+ <ButtonContent>
33
+ <slot />
34
+ </ButtonContent>
35
+ </a>
@@ -0,0 +1,39 @@
1
+ ---
2
+ /**
3
+ * A native checkbox (decision 0013). It works without JavaScript; the script only makes it partly
4
+ * ticked. Native attributes go to the `<input>`. Slot `hint`: a hint with links.
5
+ */
6
+ import Choice, { type InputProps, type RowProps } from './Choice.astro'
7
+
8
+ /** Without a visible label, a checkbox needs a name of its own, and has no hint or error. */
9
+ export type Props = InputProps & {
10
+ /**
11
+ * Partly ticked at first, such as for "all" when only some are. Only how it looks and what is
12
+ * read out: `checked` is still what a form sends. Later, use the core's `setIndeterminate()`.
13
+ */
14
+ indeterminate?: boolean | undefined
15
+ } & (
16
+ | RowProps
17
+ | {
18
+ id?: string | undefined
19
+ label?: undefined
20
+ 'aria-label': string
21
+ hint?: undefined
22
+ error?: undefined
23
+ fieldClass?: undefined
24
+ }
25
+ )
26
+
27
+ const { indeterminate = false, ...rest } = Astro.props
28
+ ---
29
+
30
+ <Choice {...rest} data-sf-indeterminate={indeterminate ? '' : undefined}>
31
+ <slot name="hint" slot="hint" />
32
+ </Choice>
33
+
34
+ <script>
35
+ import { initChoices } from '@subfloor/core'
36
+
37
+ initChoices()
38
+ document.addEventListener('astro:page-load', () => initChoices())
39
+ </script>
@@ -0,0 +1,13 @@
1
+ ---
2
+ /**
3
+ * Checkboxes that belong together, in a native `<fieldset>` (decision 0013). `disabled` disables
4
+ * all of them. Browsers cannot require "at least one": your project checks that and sets `error`.
5
+ */
6
+ import ChoiceGroup, { type GroupProps } from './ChoiceGroup.astro'
7
+
8
+ export type Props = GroupProps
9
+ ---
10
+
11
+ <ChoiceGroup {...Astro.props}>
12
+ <slot />
13
+ </ChoiceGroup>
@@ -0,0 +1,87 @@
1
+ ---
2
+ /**
3
+ * The native checkbox of Checkbox and Switch (decision 0013), in a row with its label, hint and
4
+ * error if it has a label: the @subfloor/core choice markup. Not exported from the package.
5
+ */
6
+ // This component's styles (decision 0006); the project imports `@subfloor/core/base.css` once.
7
+ import '@subfloor/core/styles/field.css'
8
+ import '@subfloor/core/styles/choice.css'
9
+ import type { HTMLAttributes } from 'astro/types'
10
+
11
+ export interface RowProps {
12
+ id: string
13
+ /** The control's name. */
14
+ label: string
15
+ /** A quiet line under the label: its description. For links, use the `hint` slot instead. */
16
+ hint?: string | undefined
17
+ /** What is wrong. While set, the control is `aria-invalid`, whatever you pass. */
18
+ error?: string | undefined
19
+ /** Classes for the row (`class` goes to the input). */
20
+ fieldClass?: string | undefined
21
+ }
22
+
23
+ export type InputProps = Omit<
24
+ HTMLAttributes<'input'>,
25
+ 'type' | 'role' | keyof RowProps
26
+ >
27
+
28
+ export type Props = InputProps &
29
+ Partial<RowProps> & {
30
+ role?: 'switch' | undefined
31
+ 'data-sf-indeterminate'?: '' | undefined
32
+ }
33
+
34
+ const {
35
+ id,
36
+ label,
37
+ hint,
38
+ error,
39
+ fieldClass,
40
+ role,
41
+ class: className,
42
+ 'aria-describedby': describedBy,
43
+ 'aria-invalid': invalid,
44
+ ...rest
45
+ } = Astro.props
46
+ // Rendered first: Checkbox and Switch always pass the slot on, also when it is empty.
47
+ const slot = Astro.slots.has('hint')
48
+ ? (await Astro.slots.render('hint')).trim()
49
+ : ''
50
+ const hasHint = Boolean(label && (slot || hint))
51
+ const described = [
52
+ hasHint && `${id}-hint`,
53
+ label && error && `${id}-error`,
54
+ describedBy,
55
+ ]
56
+ .filter(Boolean)
57
+ .join(' ')
58
+ const attributes = {
59
+ ...rest,
60
+ id,
61
+ type: 'checkbox',
62
+ role,
63
+ 'aria-describedby': described || undefined,
64
+ 'aria-invalid': error ? 'true' : invalid,
65
+ } as const
66
+ ---
67
+
68
+ {label ? (
69
+ <div class:list={['sf-choice', fieldClass]}>
70
+ <input {...attributes} class:list={['sf-choice__input', className]} />
71
+ <label class="sf-choice__label" for={id}>
72
+ {label}
73
+ </label>
74
+ {hasHint && (
75
+ <p class="sf-field__hint" id={`${id}-hint`}>
76
+ {slot ? <Fragment set:html={slot} /> : hint}
77
+ </p>
78
+ )}
79
+ {error && (
80
+ <p class="sf-field__error" id={`${id}-error`} role="alert">
81
+ {error}
82
+ </p>
83
+ )}
84
+ </div>
85
+ ) : (
86
+ <input {...attributes} class:list={['sf-choice__input', className]} />
87
+ )}
@@ -0,0 +1,58 @@
1
+ ---
2
+ /**
3
+ * The `<fieldset>` of CheckboxGroup and RadioGroup, with its title, hint and error: the
4
+ * @subfloor/core choice markup. Not exported from the package.
5
+ */
6
+ // This component's styles (decision 0006); the project imports `@subfloor/core/base.css` once.
7
+ import '@subfloor/core/styles/field.css'
8
+ import '@subfloor/core/styles/choice.css'
9
+ import type { HTMLAttributes } from 'astro/types'
10
+
11
+ export interface GroupProps extends Omit<HTMLAttributes<'fieldset'>, 'role'> {
12
+ /** The hint's and error's ids come from it. */
13
+ id: string
14
+ /** The group's title and name. */
15
+ label: string
16
+ hint?: string | undefined
17
+ /** What is wrong. It describes the group, and its controls get the error look. */
18
+ error?: string | undefined
19
+ }
20
+
21
+ export type Props = GroupProps & {
22
+ role?: 'radiogroup' | undefined
23
+ }
24
+
25
+ const {
26
+ id,
27
+ label,
28
+ hint,
29
+ error,
30
+ class: className,
31
+ 'aria-describedby': describedBy,
32
+ ...rest
33
+ } = Astro.props
34
+ const described = [hint && `${id}-hint`, error && `${id}-error`, describedBy]
35
+ .filter(Boolean)
36
+ .join(' ')
37
+ ---
38
+
39
+ <fieldset
40
+ {...rest}
41
+ id={id}
42
+ class:list={['sf-choice-group', className]}
43
+ aria-describedby={described || undefined}
44
+ data-invalid={error ? '' : undefined}
45
+ >
46
+ <legend class="sf-choice-group__label">{label}</legend>
47
+ {hint && (
48
+ <p class="sf-field__hint" id={`${id}-hint`}>
49
+ {hint}
50
+ </p>
51
+ )}
52
+ <slot />
53
+ {error && (
54
+ <p class="sf-field__error" id={`${id}-error`} role="alert">
55
+ {error}
56
+ </p>
57
+ )}
58
+ </fieldset>
@@ -0,0 +1,30 @@
1
+ ---
2
+ /**
3
+ * The clear button of a search field (R-60); the script that makes it work also shows it. Not
4
+ * exported from the package.
5
+ */
6
+ export interface Props {
7
+ label: string
8
+ }
9
+
10
+ const { label } = Astro.props
11
+ ---
12
+
13
+ <button type="button" class="sf-field__clear" aria-label={label}>
14
+ <svg width="20" height="20" viewBox="0 0 24 24" aria-hidden="true">
15
+ <path
16
+ d="M6 6l12 12M18 6 6 18"
17
+ fill="none"
18
+ stroke="currentColor"
19
+ stroke-width="2"
20
+ ></path>
21
+ </svg>
22
+ </button>
23
+
24
+ <script>
25
+ import { initClearButtons } from '@subfloor/core'
26
+
27
+ initClearButtons()
28
+ // A page swap replaces the root element's attributes.
29
+ document.addEventListener('astro:page-load', () => initClearButtons())
30
+ </script>
@@ -0,0 +1,85 @@
1
+ ---
2
+ /**
3
+ * A day, typed or chosen in the kit's calendar (decision 0015): a native `<input type="date">`, to
4
+ * which the core's `createDateField` adds the rest. Without the script, the native field and its
5
+ * picker stay. Native attributes go to the native field, which keeps the value; `class` also goes
6
+ * to the visible one.
7
+ */
8
+ // This component's styles (decision 0006); the project imports `@subfloor/core/base.css` once.
9
+ import '@subfloor/core/styles/popover.css'
10
+ import '@subfloor/core/styles/dialog.css'
11
+ import '@subfloor/core/styles/date.css'
12
+ import type { DateFieldLabels } from '@subfloor/core'
13
+ import type { ComponentProps, HTMLAttributes } from 'astro/types'
14
+ import Field from './Field.astro'
15
+
16
+ type FieldProps = Omit<ComponentProps<typeof Field>, 'suffix' | 'short'>
17
+
18
+ export type Props = FieldProps &
19
+ Omit<
20
+ HTMLAttributes<'input'>,
21
+ keyof FieldProps | 'type' | 'value' | 'min' | 'max' | 'step'
22
+ > & {
23
+ /** The day at first, as text such as `2026-11-30`. */
24
+ value?: string | undefined
25
+ /** The first day that can be chosen, such as `2026-11-01`. */
26
+ min?: string | undefined
27
+ /** The last day that can be chosen. */
28
+ max?: string | undefined
29
+ /** The first day of the week: 1 for Monday to 7 for Sunday. By default the page's language. */
30
+ weekStart?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | undefined
31
+ /** The kit's own words, in another language than English. */
32
+ labels?: Partial<DateFieldLabels> | undefined
33
+ }
34
+
35
+ const {
36
+ id,
37
+ label,
38
+ hideLabel,
39
+ hint,
40
+ error,
41
+ fieldClass,
42
+ weekStart,
43
+ labels,
44
+ class: className,
45
+ 'aria-describedby': describedBy,
46
+ 'aria-invalid': invalid,
47
+ ...rest
48
+ } = Astro.props
49
+ const described = [hint && `${id}-hint`, error && `${id}-error`, describedBy]
50
+ .filter(Boolean)
51
+ .join(' ')
52
+ ---
53
+
54
+ <Field
55
+ id={id}
56
+ label={label}
57
+ hideLabel={hideLabel}
58
+ hint={hint}
59
+ error={error}
60
+ fieldClass={fieldClass}
61
+ >
62
+ <div
63
+ class="sf-date"
64
+ data-sf-date=""
65
+ data-week-start={weekStart}
66
+ data-labels={labels ? JSON.stringify(labels) : undefined}
67
+ >
68
+ <input
69
+ {...rest}
70
+ type="date"
71
+ id={id}
72
+ class:list={['sf-field__control', className, 'sf-date__native']}
73
+ aria-describedby={described || undefined}
74
+ aria-invalid={error ? 'true' : invalid}
75
+ />
76
+ </div>
77
+ </Field>
78
+
79
+ <script>
80
+ import { destroyDateFields, initDateFields } from '@subfloor/core'
81
+
82
+ initDateFields()
83
+ document.addEventListener('astro:before-swap', () => destroyDateFields())
84
+ document.addEventListener('astro:page-load', () => initDateFields())
85
+ </script>
@@ -0,0 +1,82 @@
1
+ ---
2
+ /**
3
+ * Renders the @subfloor/core dialog markup; the behaviour is the core's `createDialog`, loaded by
4
+ * the script below. Open it with a button anywhere on the page:
5
+ * <button command="show-modal" commandfor="my-id">Open</button>
6
+ * That works without JavaScript in browsers with Invoker Commands.
7
+ */
8
+ // This component's styles (decision 0006); the project imports `@subfloor/core/base.css` once.
9
+ import '@subfloor/core/styles/dialog.css'
10
+ import type { HTMLAttributes } from 'astro/types'
11
+
12
+ export interface Props extends Omit<HTMLAttributes<'dialog'>, 'title'> {
13
+ id: string
14
+ title: string
15
+ /** `center` is a modal; `start` and `end` are sidepanels; `bottom` is a sheet. */
16
+ placement?: 'center' | 'start' | 'end' | 'bottom'
17
+ /**
18
+ * Sheets only (`bottom`): `false` turns off swiping it down to close, which is on by default on
19
+ * devices mainly used by touch.
20
+ */
21
+ swipeToClose?: boolean
22
+ /** Accessible name of the close button. */
23
+ closeLabel?: string
24
+ }
25
+
26
+ const {
27
+ id,
28
+ title,
29
+ placement = 'center',
30
+ swipeToClose = true,
31
+ closeLabel = 'Close',
32
+ class: className,
33
+ ...rest
34
+ } = Astro.props
35
+ const titleId = `${id}-title`
36
+ // Rendered first, so a footer slot forwarded empty by Modal or Sidepanel leaves no empty footer.
37
+ const footer = Astro.slots.has('footer')
38
+ ? (await Astro.slots.render('footer')).trim()
39
+ : ''
40
+ ---
41
+
42
+ <dialog
43
+ {...rest}
44
+ id={id}
45
+ class:list={['sf-dialog', className]}
46
+ data-sf-dialog=""
47
+ data-placement={placement}
48
+ data-swipe={swipeToClose ? undefined : 'off'}
49
+ aria-labelledby={titleId}
50
+ closedby="any"
51
+ >
52
+ <header class="sf-dialog__header">
53
+ <h2 id={titleId} class="sf-dialog__title">
54
+ {title}
55
+ </h2>
56
+ <form method="dialog" class="sf-dialog__close-form">
57
+ <button class="sf-dialog__close" value="close" aria-label={closeLabel}>
58
+ <svg width="20" height="20" viewBox="0 0 24 24" aria-hidden="true">
59
+ <path
60
+ d="M6 6l12 12M18 6 6 18"
61
+ fill="none"
62
+ stroke="currentColor"
63
+ stroke-width="2"
64
+ ></path>
65
+ </svg>
66
+ </button>
67
+ </form>
68
+ </header>
69
+ <div class="sf-dialog__body">
70
+ <slot />
71
+ </div>
72
+ {footer && <footer class="sf-dialog__footer" set:html={footer} />}
73
+ </dialog>
74
+
75
+ <script>
76
+ import { destroyDialogs, initDialogs } from '@subfloor/core'
77
+
78
+ initDialogs()
79
+ // With view transitions: release the page before a swap, pick up the new page's dialogs after.
80
+ document.addEventListener('astro:before-swap', () => destroyDialogs())
81
+ document.addEventListener('astro:page-load', () => initDialogs())
82
+ </script>