@styleflow.app/flowpress-astro-core 1.0.0-beta.22 → 1.0.0-beta.24
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 +10 -0
- package/dist/accessibility-panel.d.ts +2 -0
- package/dist/accessibility-panel.d.ts.map +1 -0
- package/dist/accessibility-panel.js +66 -0
- package/dist/accessibility-panel.js.map +1 -0
- package/dist/astro/BaseLayout.astro +6 -1
- package/dist/astro/ThemeRuntime.astro +3 -1
- package/dist/astro/blocks/ThemeToggleBlock.astro +7 -17
- package/dist/astro/preferences/AccessibilityPanel.astro +117 -0
- package/dist/astro/preferences/ColorModeToggle.astro +26 -0
- package/dist/astro/preferences/MotionToggle.astro +27 -0
- package/dist/astro/preferences/PreferencesRuntime.astro +9 -0
- package/dist/astro/preferences/ThemeToggle.astro +30 -0
- package/dist/astro/preferences/Toggle.astro +50 -0
- package/dist/astro/preferences/preferences.css +124 -0
- package/dist/motion-preference.d.ts +50 -0
- package/dist/motion-preference.d.ts.map +1 -0
- package/dist/motion-preference.js +132 -0
- package/dist/motion-preference.js.map +1 -0
- package/dist/preferences-runtime.d.ts +3 -0
- package/dist/preferences-runtime.d.ts.map +1 -0
- package/dist/preferences-runtime.js +23 -0
- package/dist/preferences-runtime.js.map +1 -0
- package/dist/preferences-styleflow.d.ts +3 -0
- package/dist/preferences-styleflow.d.ts.map +1 -0
- package/dist/preferences-styleflow.js +14 -0
- package/dist/preferences-styleflow.js.map +1 -0
- package/dist/preferences.d.ts +4 -0
- package/dist/preferences.d.ts.map +1 -0
- package/dist/preferences.js +4 -0
- package/dist/preferences.js.map +1 -0
- package/dist/theme-runtime.d.ts.map +1 -1
- package/dist/theme-runtime.js +29 -6
- package/dist/theme-runtime.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/vivid-colors-preference.d.ts +31 -0
- package/dist/vivid-colors-preference.d.ts.map +1 -0
- package/dist/vivid-colors-preference.js +102 -0
- package/dist/vivid-colors-preference.js.map +1 -0
- package/package.json +14 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.24 — 2026-10-08
|
|
4
|
+
|
|
5
|
+
- Validate the accessibility trigger intensity against the current project contract, including Starter designs with only main/base.
|
|
6
|
+
- [Canonical verification](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-10-08-pannello-accessibilita-default.md).
|
|
7
|
+
|
|
8
|
+
## 1.0.0-beta.23 — 2026-10-08
|
|
9
|
+
|
|
10
|
+
- Promote the pilot accessibility panel and theme/motion/vivid-color switches to public, styled defaults. Preserve visitor preferences and keyboard behavior; ship geometry without consumer Tailwind scanning.
|
|
11
|
+
- [Canonical verification](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-10-08-pannello-accessibilita-default.md).
|
|
12
|
+
|
|
3
13
|
## 1.0.0-beta.22 — 2026-10-08
|
|
4
14
|
|
|
5
15
|
- Expose shared site defaults and initialize BaseLayout without locking nested themes. Complete default adapter catalog v4 from both pilots and restore active grid bleed for container items.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessibility-panel.d.ts","sourceRoot":"","sources":["../src/accessibility-panel.ts"],"names":[],"mappings":"AAWA,wBAAgB,4BAA4B,CAAC,KAAK,GAAE,UAAqB,GAAG,MAAM,IAAI,CAGrF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Behaviour of the floating accessibility panel: a round button that opens a
|
|
3
|
+
* small non-modal dialog. Escape closes it and returns focus to the button;
|
|
4
|
+
* a press or focus outside closes it without stealing focus.
|
|
5
|
+
*/
|
|
6
|
+
const ROOT_SELECTOR = "[data-sf-a11y]";
|
|
7
|
+
const TRIGGER_SELECTOR = "[data-sf-a11y-trigger]";
|
|
8
|
+
const PANEL_SELECTOR = "[data-sf-a11y-panel]";
|
|
9
|
+
const FOCUSABLE_SELECTOR = "button:not([disabled]), [href], input:not([disabled]), [tabindex]:not([tabindex='-1'])";
|
|
10
|
+
const BOUND = "sfA11yBound";
|
|
11
|
+
export function initializeAccessibilityPanel(scope = document) {
|
|
12
|
+
const disposers = [...scope.querySelectorAll(ROOT_SELECTOR)].map(bindPanel);
|
|
13
|
+
return () => disposers.forEach((dispose) => dispose());
|
|
14
|
+
}
|
|
15
|
+
function bindPanel(root) {
|
|
16
|
+
const documentObject = root.ownerDocument;
|
|
17
|
+
const trigger = root?.querySelector(TRIGGER_SELECTOR);
|
|
18
|
+
const panel = root?.querySelector(PANEL_SELECTOR);
|
|
19
|
+
if (!root || !trigger || !panel || root.dataset[BOUND] === "true")
|
|
20
|
+
return () => { };
|
|
21
|
+
root.dataset[BOUND] = "true";
|
|
22
|
+
const isOpen = () => trigger.getAttribute("aria-expanded") === "true";
|
|
23
|
+
const label = (state) => trigger.dataset[state === "open" ? "openLabel" : "closeLabel"] ?? trigger.getAttribute("aria-label") ?? "";
|
|
24
|
+
const setOpen = (open, restoreFocus = false) => {
|
|
25
|
+
trigger.setAttribute("aria-expanded", String(open));
|
|
26
|
+
trigger.setAttribute("aria-label", label(open ? "close" : "open"));
|
|
27
|
+
panel.dataset.state = open ? "open" : "closed";
|
|
28
|
+
panel.inert = !open;
|
|
29
|
+
if (open)
|
|
30
|
+
panel.querySelector(FOCUSABLE_SELECTOR)?.focus();
|
|
31
|
+
else if (restoreFocus)
|
|
32
|
+
trigger.focus();
|
|
33
|
+
};
|
|
34
|
+
const onTrigger = () => setOpen(!isOpen());
|
|
35
|
+
const onKeydown = (event) => {
|
|
36
|
+
if (event.key !== "Escape" || !isOpen())
|
|
37
|
+
return;
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
setOpen(false, true);
|
|
40
|
+
};
|
|
41
|
+
const onPointerDown = (event) => {
|
|
42
|
+
if (isOpen() && event.target instanceof Node && !root.contains(event.target))
|
|
43
|
+
setOpen(false);
|
|
44
|
+
};
|
|
45
|
+
const onFocusOut = (event) => {
|
|
46
|
+
if (isOpen() && event.relatedTarget instanceof Node && !root.contains(event.relatedTarget))
|
|
47
|
+
setOpen(false);
|
|
48
|
+
};
|
|
49
|
+
trigger.addEventListener("click", onTrigger);
|
|
50
|
+
root.addEventListener("keydown", onKeydown);
|
|
51
|
+
root.addEventListener("focusout", onFocusOut);
|
|
52
|
+
documentObject.addEventListener("pointerdown", onPointerDown);
|
|
53
|
+
setOpen(false);
|
|
54
|
+
// Without scripts the controls cannot work, so the markup ships hidden.
|
|
55
|
+
root.hidden = false;
|
|
56
|
+
return () => {
|
|
57
|
+
setOpen(false);
|
|
58
|
+
root.hidden = true;
|
|
59
|
+
trigger.removeEventListener("click", onTrigger);
|
|
60
|
+
root.removeEventListener("keydown", onKeydown);
|
|
61
|
+
root.removeEventListener("focusout", onFocusOut);
|
|
62
|
+
documentObject.removeEventListener("pointerdown", onPointerDown);
|
|
63
|
+
delete root.dataset[BOUND];
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=accessibility-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessibility-panel.js","sourceRoot":"","sources":["../src/accessibility-panel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,aAAa,GAAG,gBAAgB,CAAC;AACvC,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAClD,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAC9C,MAAM,kBAAkB,GAAG,wFAAwF,CAAC;AACpH,MAAM,KAAK,GAAG,aAAa,CAAC;AAE5B,MAAM,UAAU,4BAA4B,CAAC,QAAoB,QAAQ;IACvE,MAAM,SAAS,GAAG,CAAC,GAAG,KAAK,CAAC,gBAAgB,CAAc,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACzF,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAA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E,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IAEpB,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,OAAO,CAAC,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAChD,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC/C,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACjD,cAAc,CAAC,mBAAmB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Behaviour of the floating accessibility panel: a round button that opens a\n * small non-modal dialog. Escape closes it and returns focus to the button;\n * a press or focus outside closes it without stealing focus.\n */\nconst ROOT_SELECTOR = \"[data-sf-a11y]\";\nconst TRIGGER_SELECTOR = \"[data-sf-a11y-trigger]\";\nconst PANEL_SELECTOR = \"[data-sf-a11y-panel]\";\nconst FOCUSABLE_SELECTOR = \"button:not([disabled]), [href], input:not([disabled]), [tabindex]:not([tabindex='-1'])\";\nconst BOUND = \"sfA11yBound\";\n\nexport function initializeAccessibilityPanel(scope: ParentNode = document): () => void {\n const disposers = [...scope.querySelectorAll<HTMLElement>(ROOT_SELECTOR)].map(bindPanel);\n return () => disposers.forEach((dispose) => dispose());\n}\n\nfunction bindPanel(root: HTMLElement): () => void {\n const documentObject = root.ownerDocument;\n const trigger = root?.querySelector<HTMLButtonElement>(TRIGGER_SELECTOR);\n const panel = root?.querySelector<HTMLElement>(PANEL_SELECTOR);\n if (!root || !trigger || !panel || root.dataset[BOUND] === \"true\") return () => {};\n root.dataset[BOUND] = \"true\";\n\n const isOpen = () => trigger.getAttribute(\"aria-expanded\") === \"true\";\n const label = (state: \"open\" | \"close\") =>\n trigger.dataset[state === \"open\" ? \"openLabel\" : \"closeLabel\"] ?? trigger.getAttribute(\"aria-label\") ?? \"\";\n\n const setOpen = (open: boolean, restoreFocus = false) => {\n trigger.setAttribute(\"aria-expanded\", String(open));\n trigger.setAttribute(\"aria-label\", label(open ? \"close\" : \"open\"));\n panel.dataset.state = open ? \"open\" : \"closed\";\n panel.inert = !open;\n if (open) panel.querySelector<HTMLElement>(FOCUSABLE_SELECTOR)?.focus();\n else if (restoreFocus) trigger.focus();\n };\n\n const onTrigger = () => setOpen(!isOpen());\n const onKeydown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || !isOpen()) return;\n event.preventDefault();\n setOpen(false, true);\n };\n const onPointerDown = (event: PointerEvent) => {\n if (isOpen() && event.target instanceof Node && !root.contains(event.target)) setOpen(false);\n };\n const onFocusOut = (event: FocusEvent) => {\n if (isOpen() && event.relatedTarget instanceof Node && !root.contains(event.relatedTarget)) setOpen(false);\n };\n\n trigger.addEventListener(\"click\", onTrigger);\n root.addEventListener(\"keydown\", onKeydown);\n root.addEventListener(\"focusout\", onFocusOut);\n documentObject.addEventListener(\"pointerdown\", onPointerDown);\n setOpen(false);\n // Without scripts the controls cannot work, so the markup ships hidden.\n root.hidden = false;\n\n return () => {\n setOpen(false);\n root.hidden = true;\n trigger.removeEventListener(\"click\", onTrigger);\n root.removeEventListener(\"keydown\", onKeydown);\n root.removeEventListener(\"focusout\", onFocusOut);\n documentObject.removeEventListener(\"pointerdown\", onPointerDown);\n delete root.dataset[BOUND];\n };\n}\n"]}
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
import type { SfSeo } from "../types.js";
|
|
3
3
|
import S from "@styleflow.app/astro/S.astro";
|
|
4
4
|
import ThemeRuntime from "./ThemeRuntime.astro";
|
|
5
|
+
import AccessibilityPanel from "./preferences/AccessibilityPanel.astro";
|
|
6
|
+
import PreferencesRuntime from "./preferences/PreferencesRuntime.astro";
|
|
5
7
|
import { flowpressSiteDesignAttributes, type FlowpressSiteDesign } from "@styleflow.app/flowpress-components/site-design";
|
|
6
8
|
|
|
7
9
|
interface Props {
|
|
10
|
+
showPreferences?: boolean;
|
|
8
11
|
lang?: string | undefined;
|
|
9
12
|
seo?: SfSeo | null | undefined;
|
|
10
13
|
siteName?: string | undefined;
|
|
@@ -13,7 +16,7 @@ interface Props {
|
|
|
13
16
|
siteDesign?: FlowpressSiteDesign | undefined;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
const {
|
|
19
|
+
const { showPreferences = true,
|
|
17
20
|
lang = "it",
|
|
18
21
|
seo = null,
|
|
19
22
|
siteName = import.meta.env.PROJECT_NAME ?? "FlowPress",
|
|
@@ -35,6 +38,7 @@ const jsonLd = seo?.jsonLd ? JSON.stringify(seo.jsonLd) : null;
|
|
|
35
38
|
<html lang={lang} {...documentAttributes.html}>
|
|
36
39
|
<head>
|
|
37
40
|
<meta charset="UTF-8" />
|
|
41
|
+
{showPreferences && <PreferencesRuntime />}
|
|
38
42
|
<meta name="viewport" content="width=device-width" />
|
|
39
43
|
{defaultTheme && themes.length ? <ThemeRuntime themes={themes} defaultTheme={defaultTheme} /> : null}
|
|
40
44
|
<title>{title}</title>
|
|
@@ -64,5 +68,6 @@ const jsonLd = seo?.jsonLd ? JSON.stringify(seo.jsonLd) : null;
|
|
|
64
68
|
<S.main surface={siteDesign?.defaults.surface || "default"} layoutRole="none" density={siteDesign?.defaults.density || "regular"}>
|
|
65
69
|
<slot />
|
|
66
70
|
</S.main>
|
|
71
|
+
{showPreferences && <AccessibilityPanel themes={themes} />}
|
|
67
72
|
</body>
|
|
68
73
|
</html>
|
|
@@ -14,11 +14,13 @@ const bootstrap = styleflowThemeBootstrapScript(themes, defaultTheme);
|
|
|
14
14
|
<script>
|
|
15
15
|
import { initializeStyleflowThemeRuntime } from "../theme-runtime.js";
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
let cleanup = () => {};
|
|
18
|
+
const initialize = () => { cleanup(); cleanup = initializeStyleflowThemeRuntime(); };
|
|
18
19
|
if (document.readyState === "loading") {
|
|
19
20
|
document.addEventListener("DOMContentLoaded", initialize, { once: true });
|
|
20
21
|
} else {
|
|
21
22
|
initialize();
|
|
22
23
|
}
|
|
23
24
|
document.addEventListener("astro:page-load", initialize);
|
|
25
|
+
document.addEventListener("astro:before-swap", () => cleanup());
|
|
24
26
|
</script>
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import ThemeToggle from "../preferences/ThemeToggle.astro";
|
|
3
4
|
import type { FlowpressBlockRendererProps } from "../../block-renderers.js";
|
|
4
|
-
|
|
5
|
-
const { block, styleflowProps, htmlProps, composition } = Astro.props as FlowpressBlockRendererProps;
|
|
5
|
+
const { block, styleflowProps, htmlProps } = Astro.props as FlowpressBlockRendererProps;
|
|
6
6
|
const label = typeof block.attributes.label === "string" && block.attributes.label.trim()
|
|
7
|
-
? block.attributes.label.trim()
|
|
8
|
-
: "Change color theme";
|
|
7
|
+
? block.attributes.label.trim() : "Change color theme";
|
|
9
8
|
const showThemeName = block.attributes.showThemeName !== false;
|
|
10
|
-
const themeName = "Theme";
|
|
11
9
|
---
|
|
12
|
-
|
|
13
|
-
<
|
|
14
|
-
{
|
|
15
|
-
|
|
16
|
-
type="button"
|
|
17
|
-
aria-label={label}
|
|
18
|
-
data-styleflow-theme-toggle
|
|
19
|
-
>
|
|
20
|
-
<span data-styleflow-theme-label aria-hidden="true">
|
|
21
|
-
{showThemeName ? String(themeName) : "Theme"}
|
|
22
|
-
</span>
|
|
23
|
-
</S.button>
|
|
10
|
+
<S.span {...styleflowProps} class="flowpress-theme-control">
|
|
11
|
+
<ThemeToggle {...htmlProps} label={label} />
|
|
12
|
+
{showThemeName && <S.span data-styleflow-theme-label aria-hidden="true" />}
|
|
13
|
+
</S.span>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import MotionToggle from "./MotionToggle.astro";
|
|
4
|
+
import ThemeToggle from "./ThemeToggle.astro";
|
|
5
|
+
import ColorModeToggle from "./ColorModeToggle.astro";
|
|
6
|
+
import { preferencesStyleflow } from "../../preferences-styleflow.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Floating accessibility controls: a round button, fixed bottom-right, that
|
|
10
|
+
* opens a small panel with the theme (dark/light) and animations (on/off)
|
|
11
|
+
* switches. Astro only; it ships hidden and is revealed by its script, since
|
|
12
|
+
* nothing in it works without JavaScript. Mount it once, in the layout.
|
|
13
|
+
*/
|
|
14
|
+
interface Props {
|
|
15
|
+
/** Panel title and its accessible name. */
|
|
16
|
+
title?: string;
|
|
17
|
+
openLabel?: string;
|
|
18
|
+
closeLabel?: string;
|
|
19
|
+
themeLabel?: string;
|
|
20
|
+
motionLabel?: string;
|
|
21
|
+
vividColorLabel?: string;
|
|
22
|
+
/** Show the light/dark switch; hide it while a project has no designed dark theme. */
|
|
23
|
+
showTheme?: boolean;
|
|
24
|
+
themes?: string[];
|
|
25
|
+
class?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
title = "Accessibilità",
|
|
30
|
+
openLabel = "Apri le impostazioni di accessibilità",
|
|
31
|
+
closeLabel = "Chiudi le impostazioni di accessibilità",
|
|
32
|
+
themeLabel = "Tema scuro",
|
|
33
|
+
motionLabel = "Animazioni",
|
|
34
|
+
vividColorLabel = "Colori vividi",
|
|
35
|
+
themes = ["light", "dark"],
|
|
36
|
+
showTheme = themes.includes("dark") && themes.some((theme) => theme !== "dark"),
|
|
37
|
+
class: className,
|
|
38
|
+
} = Astro.props;
|
|
39
|
+
const triggerColors = preferencesStyleflow({tone:"main",intensity:"strong-1",surface:"raised"},{tone:"main",intensity:"base",surface:"raised"});
|
|
40
|
+
const panelColors = preferencesStyleflow({tone:"neutral",intensity:"soft-3",surface:"raised"},{tone:"neutral",intensity:"soft-2",surface:"raised"},{tone:"neutral",intensity:"base",surface:"default"});
|
|
41
|
+
const titleTypography = preferencesStyleflow({ty:"body",v:"lg",w:"strong"},{ty:"body",v:"md",w:"strong"});
|
|
42
|
+
const labelTypography = preferencesStyleflow({ty:"body",v:"md",w:"default"});
|
|
43
|
+
const id = `sf-a11y-${crypto.randomUUID()}`;
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
<!-- Hidden until its script runs; the wrapper only positions the controls. -->
|
|
47
|
+
<S.div
|
|
48
|
+
data-sf-a11y
|
|
49
|
+
hidden
|
|
50
|
+
layoutRole="none"
|
|
51
|
+
density="compact"
|
|
52
|
+
noBackground
|
|
53
|
+
noBorder
|
|
54
|
+
noForeground
|
|
55
|
+
noGap
|
|
56
|
+
noPadding
|
|
57
|
+
noRadius
|
|
58
|
+
class:list={["sf-a11y", className]}
|
|
59
|
+
>
|
|
60
|
+
<S.button
|
|
61
|
+
type="button"
|
|
62
|
+
data-sf-a11y-trigger
|
|
63
|
+
data-open-label={openLabel}
|
|
64
|
+
data-close-label={closeLabel}
|
|
65
|
+
aria-label={openLabel}
|
|
66
|
+
aria-haspopup="dialog"
|
|
67
|
+
aria-expanded="false"
|
|
68
|
+
aria-controls={`${id}-panel`}
|
|
69
|
+
{...triggerColors}
|
|
70
|
+
foreground="primary"
|
|
71
|
+
layoutRole="control"
|
|
72
|
+
density="compact"
|
|
73
|
+
interactivePriority="primary"
|
|
74
|
+
noPadding
|
|
75
|
+
class="sf-a11y__trigger"
|
|
76
|
+
>
|
|
77
|
+
<svg class="sf-a11y__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
|
|
78
|
+
<circle cx="12" cy="5" r="1.75" fill="currentColor" stroke="none"></circle>
|
|
79
|
+
<path d="M5.5 9.5h13M12 9.5v4.5M12 14l-3 6M12 14l3 6"></path>
|
|
80
|
+
</svg>
|
|
81
|
+
</S.button>
|
|
82
|
+
|
|
83
|
+
<S.div
|
|
84
|
+
id={`${id}-panel`}
|
|
85
|
+
role="dialog"
|
|
86
|
+
aria-modal="false"
|
|
87
|
+
aria-labelledby={`${id}-title`}
|
|
88
|
+
data-sf-a11y-panel
|
|
89
|
+
data-state="closed"
|
|
90
|
+
inert
|
|
91
|
+
{...panelColors}
|
|
92
|
+
layoutRole="panel"
|
|
93
|
+
density="regular"
|
|
94
|
+
class="sf-a11y__panel"
|
|
95
|
+
>
|
|
96
|
+
<S.h2 id={`${id}-title`} {...titleTypography}>{title}</S.h2>
|
|
97
|
+
{showTheme ? (
|
|
98
|
+
<S.div layoutRole="none" class="sf-a11y__row">
|
|
99
|
+
<S.span id={`${id}-theme-label`} {...labelTypography}>{themeLabel}</S.span>
|
|
100
|
+
<ThemeToggle labelledby={`${id}-theme-label`} />
|
|
101
|
+
</S.div>
|
|
102
|
+
) : null}
|
|
103
|
+
<S.div layoutRole="none" class="sf-a11y__row">
|
|
104
|
+
<S.span id={`${id}-motion-label`} {...labelTypography}>{motionLabel}</S.span>
|
|
105
|
+
<MotionToggle labelledby={`${id}-motion-label`} />
|
|
106
|
+
</S.div>
|
|
107
|
+
<S.div layoutRole="none" class="sf-a11y__row">
|
|
108
|
+
<S.span id={`${id}-color-mode-vivid-label`} {...labelTypography}>{vividColorLabel}</S.span>
|
|
109
|
+
<ColorModeToggle labelledby={`${id}-color-mode-vivid-label`} />
|
|
110
|
+
</S.div>
|
|
111
|
+
</S.div>
|
|
112
|
+
</S.div>
|
|
113
|
+
|
|
114
|
+
<script>
|
|
115
|
+
import { startFlowpressPreferencesRuntime } from "../../preferences-runtime.js";
|
|
116
|
+
startFlowpressPreferencesRuntime();
|
|
117
|
+
</script>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Toggle from "./Toggle.astro";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Vivid-colors switch (checked means full saturation). State and persistence
|
|
6
|
+
* live in vivid-colors-preference.ts and are mirrored on
|
|
7
|
+
* `<html data-sf-vivid-colors>`.
|
|
8
|
+
*/
|
|
9
|
+
interface Props {
|
|
10
|
+
label?: string | undefined;
|
|
11
|
+
/** Id of a visible label; it then names the switch instead of `label`. */
|
|
12
|
+
labelledby?: string | undefined;
|
|
13
|
+
class?: string | undefined;
|
|
14
|
+
[attribute: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { label = "Vivid colors", labelledby, class: className, ...attributes } = Astro.props;
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
<Toggle {...attributes} label={label} labelledby={labelledby} class={className} data-sf-vivid-colors-toggle />
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<script>
|
|
24
|
+
import { startFlowpressPreferencesRuntime } from "../../preferences-runtime.js";
|
|
25
|
+
startFlowpressPreferencesRuntime();
|
|
26
|
+
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Toggle from "./Toggle.astro";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Animations on/off switch (checked means animations on). State and
|
|
6
|
+
* persistence live in motion-preference.ts: the choice is stored, mirrored on
|
|
7
|
+
* `<html data-sf-motion-preference>` and picked up live by blobs, reveals and
|
|
8
|
+
* the navigation drawer.
|
|
9
|
+
*/
|
|
10
|
+
interface Props {
|
|
11
|
+
label?: string | undefined;
|
|
12
|
+
/** Id of a visible label; it then names the switch instead of `label`. */
|
|
13
|
+
labelledby?: string | undefined;
|
|
14
|
+
class?: string | undefined;
|
|
15
|
+
[attribute: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { label = "Animations", labelledby, class: className, ...attributes } = Astro.props;
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
<Toggle {...attributes} label={label} labelledby={labelledby} class={className} data-sf-motion-toggle />
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import { startFlowpressPreferencesRuntime } from "../../preferences-runtime.js";
|
|
26
|
+
startFlowpressPreferencesRuntime();
|
|
27
|
+
</script>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { motionPreferenceBootstrapScript, vividColorsBootstrapScript } from "../../preferences.js";
|
|
3
|
+
---
|
|
4
|
+
<script is:inline set:html={motionPreferenceBootstrapScript()}></script>
|
|
5
|
+
<script is:inline set:html={vividColorsBootstrapScript()}></script>
|
|
6
|
+
<script>
|
|
7
|
+
import { startFlowpressPreferencesRuntime } from "../../preferences-runtime.js";
|
|
8
|
+
startFlowpressPreferencesRuntime();
|
|
9
|
+
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Toggle from "./Toggle.astro";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Dark/light switch. The theme itself belongs to the FlowPress theme runtime,
|
|
6
|
+
* which binds every `[data-styleflow-theme-toggle]` and flips
|
|
7
|
+
* `<html data-styleflow-theme>`; this component only renders the switch and
|
|
8
|
+
* keeps `aria-checked` in step (checked means the dark theme).
|
|
9
|
+
*/
|
|
10
|
+
interface Props {
|
|
11
|
+
label?: string | undefined;
|
|
12
|
+
/** Id of a visible label; it then names the switch instead of `label`. */
|
|
13
|
+
labelledby?: string | undefined;
|
|
14
|
+
class?: string | undefined;
|
|
15
|
+
[attribute: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { label = "Change color theme", labelledby, class: className, ...attributes } = Astro.props;
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
<Toggle {...attributes} label={label} labelledby={labelledby} class={className} data-styleflow-theme-toggle data-styleflow-theme-toggle-target="dark">
|
|
22
|
+
<svg slot="thumb" class="sf-toggle__glyph sf-toggle__glyph--off" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
|
|
23
|
+
<circle cx="12" cy="12" r="4.5"></circle>
|
|
24
|
+
<path d="M12 2.5v2M12 19.5v2M4.6 4.6l1.4 1.4M18 18l1.4 1.4M2.5 12h2M19.5 12h2M4.6 19.4L6 18M18 6l1.4-1.4"></path>
|
|
25
|
+
</svg>
|
|
26
|
+
<svg slot="thumb" class="sf-toggle__glyph sf-toggle__glyph--on" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
|
|
27
|
+
<path d="M20.5 13.2A8.5 8.5 0 1 1 10.8 3.5a6.7 6.7 0 0 0 9.7 9.7z"></path>
|
|
28
|
+
</svg>
|
|
29
|
+
</Toggle>
|
|
30
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import "./preferences.css";
|
|
4
|
+
import { preferencesStyleflow } from "../../preferences-styleflow.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* iOS-style switch: a track that cross-fades from neutral to the main tone and a
|
|
8
|
+
* thumb that slides across. It owns semantics (`role="switch"`, `aria-checked`)
|
|
9
|
+
* and looks, not state: whoever uses it flips `aria-checked` (see ThemeToggle,
|
|
10
|
+
* MotionToggle). Colours come from Styleflow props only; the "on" look lives
|
|
11
|
+
* in toggle.css so a toggle can also mirror document state before scripts run.
|
|
12
|
+
*
|
|
13
|
+
* Name it with `label` (aria-label) or, when a visible label sits next to it,
|
|
14
|
+
* with `labelledby` (id of that label).
|
|
15
|
+
*/
|
|
16
|
+
interface Props {
|
|
17
|
+
label?: string | undefined;
|
|
18
|
+
labelledby?: string | undefined;
|
|
19
|
+
checked?: boolean | undefined;
|
|
20
|
+
class?: string | undefined;
|
|
21
|
+
[attribute: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const { label, labelledby, checked = false, class: className, ...attributes } = Astro.props;
|
|
25
|
+
const off = preferencesStyleflow({tone:"neutral",intensity:"soft-1",surface:"sunken"},{tone:"neutral",intensity:"base",surface:"default"});
|
|
26
|
+
const on = preferencesStyleflow({tone:"main",intensity:"strong-2",surface:"default"},{tone:"main",intensity:"base",surface:"default"});
|
|
27
|
+
const thumb = preferencesStyleflow({tone:"neutral",intensity:"soft-3",surface:"raised"},{tone:"neutral",intensity:"soft-2",surface:"raised"},{tone:"neutral",intensity:"base",surface:"default"});
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
<S.button
|
|
31
|
+
{...attributes}
|
|
32
|
+
type="button"
|
|
33
|
+
role="switch"
|
|
34
|
+
aria-checked={checked ? "true" : "false"}
|
|
35
|
+
aria-label={labelledby ? undefined : label}
|
|
36
|
+
aria-labelledby={labelledby}
|
|
37
|
+
foreground="primary"
|
|
38
|
+
layoutRole="none"
|
|
39
|
+
density="compact"
|
|
40
|
+
interactivePriority="tertiary"
|
|
41
|
+
noPadding
|
|
42
|
+
noBackground
|
|
43
|
+
class:list={["sf-toggle", className]}
|
|
44
|
+
>
|
|
45
|
+
<S.span aria-hidden="true" {...off} layoutRole="none" class="sf-toggle__track"></S.span>
|
|
46
|
+
<S.span aria-hidden="true" {...on} layoutRole="none" class="sf-toggle__track sf-toggle__track--on"></S.span>
|
|
47
|
+
<S.span aria-hidden="true" {...thumb} layoutRole="none" class="sf-toggle__thumb">
|
|
48
|
+
<slot name="thumb" />
|
|
49
|
+
</S.span>
|
|
50
|
+
</S.button>
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Toggle: the on/off state machine. Geometry lives in the markup (Tailwind),
|
|
3
|
+
* colours in Styleflow props; here only what changes with the state.
|
|
4
|
+
*
|
|
5
|
+
* `--sf-toggle-on` is 1 when the switch reads "on". Besides `aria-checked`, the
|
|
6
|
+
* theme and motion switches mirror the document (`<html>` attributes set by the
|
|
7
|
+
* head bootstrap scripts), so they are right from first paint and never slide
|
|
8
|
+
* into place after the page loads.
|
|
9
|
+
*/
|
|
10
|
+
.sf-toggle {
|
|
11
|
+
--sf-toggle-on: 0;
|
|
12
|
+
--sf-toggle-travel: 1.25rem;
|
|
13
|
+
--sf-toggle-direction: 1;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.sf-toggle:dir(rtl) {
|
|
17
|
+
--sf-toggle-direction: -1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.sf-toggle[aria-checked="true"],
|
|
21
|
+
html[data-styleflow-theme="dark"] .sf-toggle[data-styleflow-theme-toggle],
|
|
22
|
+
html[data-sf-motion-preference="full"] .sf-toggle[data-sf-motion-toggle],
|
|
23
|
+
html[data-sf-vivid-colors="true"] .sf-toggle[data-sf-vivid-colors-toggle] {
|
|
24
|
+
--sf-toggle-on: 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.sf-toggle__track--on {
|
|
28
|
+
opacity: var(--sf-toggle-on);
|
|
29
|
+
transition: opacity var(--sf-motion-duration-default, 180ms) var(--sf-motion-ease-standard, ease);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* A ring keeps the "off" track readable against the panel in both themes. */
|
|
33
|
+
.sf-toggle__track:not(.sf-toggle__track--on) {
|
|
34
|
+
box-shadow: inset 0 0 0 0.0625rem var(--sf-border);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.sf-toggle__thumb {
|
|
38
|
+
box-shadow: 0 0.0625rem 0.25rem color-mix(in srgb, var(--sf-foreground-primary) 45%, transparent);
|
|
39
|
+
transform: translateX(calc(var(--sf-toggle-on) * var(--sf-toggle-travel) * var(--sf-toggle-direction)));
|
|
40
|
+
transition:
|
|
41
|
+
transform var(--sf-motion-duration-default, 180ms) var(--sf-motion-ease-out, ease-out),
|
|
42
|
+
scale var(--sf-motion-duration-fast, 120ms) var(--sf-motion-ease-out, ease-out);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.sf-toggle:active .sf-toggle__thumb {
|
|
46
|
+
scale: 1.08 1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Optional thumb glyphs: one per state, cross-fading with the thumb. */
|
|
50
|
+
.sf-toggle__glyph {
|
|
51
|
+
position: absolute;
|
|
52
|
+
inline-size: 1rem;
|
|
53
|
+
block-size: 1rem;
|
|
54
|
+
transition: opacity var(--sf-motion-duration-default, 180ms) var(--sf-motion-ease-standard, ease);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sf-toggle__glyph--off {
|
|
58
|
+
opacity: calc(1 - var(--sf-toggle-on));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.sf-toggle__glyph--on {
|
|
62
|
+
opacity: var(--sf-toggle-on);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* Accessibility panel: the closed/open states and the lift under the round
|
|
67
|
+
* button. Colours are Styleflow tokens (set by the S props in the markup); the
|
|
68
|
+
* shadow is derived from the foreground token so it follows the theme.
|
|
69
|
+
* Transitions stop on their own when animations are off (motion.css).
|
|
70
|
+
*/
|
|
71
|
+
html[data-sf-vivid-colors="false"] {
|
|
72
|
+
filter: saturate(30%);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.sf-a11y__trigger {
|
|
76
|
+
box-shadow: 0 0.375rem 1.25rem color-mix(in srgb, var(--sf-surface-default-foreground-primary) 28%, transparent);
|
|
77
|
+
transition: transform var(--sf-motion-duration-default, 180ms) var(--sf-motion-ease-out, ease-out);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.sf-a11y__trigger:active {
|
|
81
|
+
transform: scale(0.94);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.sf-a11y__panel {
|
|
85
|
+
box-shadow: 0 0.75rem 2rem color-mix(in srgb, var(--sf-surface-default-foreground-primary) 22%, transparent);
|
|
86
|
+
transform-origin: bottom right;
|
|
87
|
+
transition:
|
|
88
|
+
opacity var(--sf-motion-duration-fast, 120ms) var(--sf-motion-ease-soft, ease),
|
|
89
|
+
transform var(--sf-motion-duration-default, 180ms) var(--sf-motion-ease-out, ease-out),
|
|
90
|
+
visibility 0s linear var(--sf-motion-duration-default, 180ms);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.sf-a11y__panel[data-state="closed"] {
|
|
94
|
+
opacity: 0;
|
|
95
|
+
transform: translateY(0.5rem) scale(0.96);
|
|
96
|
+
visibility: hidden;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.sf-a11y__panel[data-state="open"] {
|
|
100
|
+
opacity: 1;
|
|
101
|
+
transform: none;
|
|
102
|
+
transition-delay: 0s;
|
|
103
|
+
visibility: visible;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.sf-a11y__panel[data-state="open"]:dir(rtl) {
|
|
107
|
+
transform-origin: bottom left;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* Geometry formerly supplied by the pilot Tailwind classes. */
|
|
111
|
+
.sf-toggle { position: relative; display: inline-block; block-size: 2rem; inline-size: 3.25rem; flex-shrink: 0; cursor: pointer; border-radius: 9999px !important; }
|
|
112
|
+
.sf-toggle__track { position: absolute; inset: 0; border-radius: 9999px !important; }
|
|
113
|
+
.sf-toggle__thumb { position: absolute; inset-inline-start: .125rem; inset-block-start: .125rem; display: grid; inline-size: 1.75rem; block-size: 1.75rem; place-items: center; border-radius: 9999px !important; }
|
|
114
|
+
.sf-a11y { position: fixed; inset-inline-end: var(--fp-preferences-inset, 1rem); inset-block-end: var(--fp-preferences-inset, 1rem); z-index: var(--fp-preferences-z-index, var(--z-floating, 50)); display: flex; flex-direction: column-reverse; align-items: flex-end; gap: .75rem; }
|
|
115
|
+
.sf-a11y[hidden] { display: none !important; }
|
|
116
|
+
.sf-a11y__trigger { display: grid; inline-size: 3.5rem; block-size: 3.5rem; flex-shrink: 0; place-items: center; cursor: pointer; border-radius: 9999px !important; }
|
|
117
|
+
.sf-a11y__icon { inline-size: 1.75rem; block-size: 1.75rem; }
|
|
118
|
+
.sf-a11y__panel { display: flex; flex-direction: column; inline-size: var(--fp-preferences-width, 18rem); max-inline-size: calc(100vw - 2rem); gap: 1rem; }
|
|
119
|
+
.sf-a11y__row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
|
|
120
|
+
.sf-toggle:focus-visible, .sf-a11y__trigger:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
|
|
121
|
+
html[data-sf-motion-preference="reduce"] :is(.sf-toggle, .sf-toggle *, .sf-a11y__trigger, .sf-a11y__panel) { transition: none !important; }
|
|
122
|
+
@media print { .sf-a11y { display: none !important; } }
|
|
123
|
+
|
|
124
|
+
.flowpress-theme-control { display: inline-flex; align-items: center; gap: .5rem; }
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single source of truth for "may this page animate?".
|
|
3
|
+
*
|
|
4
|
+
* The default follows the OS (`prefers-reduced-motion`). A visitor's explicit
|
|
5
|
+
* choice from the accessibility panel wins in both directions and is stored in
|
|
6
|
+
* localStorage. The resolved value is mirrored on
|
|
7
|
+
* `<html data-sf-motion-preference="full|reduce">`, so CSS and scripts read the
|
|
8
|
+
* same state, and every change is announced with `sf:motion-change`.
|
|
9
|
+
*
|
|
10
|
+
* Do not read `matchMedia("(prefers-reduced-motion)")` or write a bare
|
|
11
|
+
* `@media (prefers-reduced-motion)` rule elsewhere: neither can be overridden
|
|
12
|
+
* by the visitor.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MOTION_STORAGE_KEY = "sf:motion";
|
|
15
|
+
export declare const MOTION_ATTRIBUTE = "data-sf-motion-preference";
|
|
16
|
+
export declare const MOTION_CHANGE_EVENT = "sf:motion-change";
|
|
17
|
+
export declare const MOTION_TOGGLE_SELECTOR = "[data-sf-motion-toggle]";
|
|
18
|
+
export declare const REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";
|
|
19
|
+
/** `full` animates, `reduce` keeps everything still. */
|
|
20
|
+
export type MotionPreference = "full" | "reduce";
|
|
21
|
+
export declare function isMotionPreference(value: unknown): value is MotionPreference;
|
|
22
|
+
/** An explicit choice beats the OS; without one the OS decides. */
|
|
23
|
+
export declare function resolveMotionPreference(stored: unknown, systemReduces: boolean): MotionPreference;
|
|
24
|
+
/**
|
|
25
|
+
* Inline script for `<head>`: mirrors the resolved preference on `<html>`
|
|
26
|
+
* before first paint, so nothing starts animating and then snaps to a stop.
|
|
27
|
+
*/
|
|
28
|
+
export declare function motionPreferenceBootstrapScript(): string;
|
|
29
|
+
/** The browser surface this module needs, injectable for tests. */
|
|
30
|
+
export interface MotionEnvironment {
|
|
31
|
+
document: Pick<Document, "documentElement" | "dispatchEvent" | "addEventListener" | "removeEventListener">;
|
|
32
|
+
storage: Pick<Storage, "getItem" | "setItem"> | null;
|
|
33
|
+
media: Pick<MediaQueryList, "matches" | "addEventListener" | "removeEventListener"> | null;
|
|
34
|
+
}
|
|
35
|
+
export declare function browserMotionEnvironment(): MotionEnvironment;
|
|
36
|
+
/** The mirrored value when the bootstrap ran, otherwise resolved from storage and OS. */
|
|
37
|
+
export declare function getMotionPreference(env?: MotionEnvironment): MotionPreference;
|
|
38
|
+
/** Store an explicit choice and announce it. */
|
|
39
|
+
export declare function setMotionPreference(preference: MotionPreference, env?: MotionEnvironment): void;
|
|
40
|
+
/**
|
|
41
|
+
* Call `listener` whenever the effective preference changes: an explicit
|
|
42
|
+
* choice, or the OS setting while the visitor has not made one.
|
|
43
|
+
*/
|
|
44
|
+
export declare function subscribeMotionPreference(listener: (preference: MotionPreference) => void, env?: MotionEnvironment): () => void;
|
|
45
|
+
/**
|
|
46
|
+
* Wire every server-rendered `[data-sf-motion-toggle]` switch: a click flips
|
|
47
|
+
* the preference, `aria-checked` mirrors it (checked means animations on).
|
|
48
|
+
*/
|
|
49
|
+
export declare function initializeMotionToggles(scope?: ParentNode, env?: MotionEnvironment): () => void;
|
|
50
|
+
//# sourceMappingURL=motion-preference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-preference.d.ts","sourceRoot":"","sources":["../src/motion-preference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,kBAAkB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,wBAAgB,uBAAuB,CACrC,KAAK,GAAE,UAAqB,EAC5B,GAAG,GAAE,iBAA8C,GAClD,MAAM,IAAI,CAsBZ"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single source of truth for "may this page animate?".
|
|
3
|
+
*
|
|
4
|
+
* The default follows the OS (`prefers-reduced-motion`). A visitor's explicit
|
|
5
|
+
* choice from the accessibility panel wins in both directions and is stored in
|
|
6
|
+
* localStorage. The resolved value is mirrored on
|
|
7
|
+
* `<html data-sf-motion-preference="full|reduce">`, so CSS and scripts read the
|
|
8
|
+
* same state, and every change is announced with `sf:motion-change`.
|
|
9
|
+
*
|
|
10
|
+
* Do not read `matchMedia("(prefers-reduced-motion)")` or write a bare
|
|
11
|
+
* `@media (prefers-reduced-motion)` rule elsewhere: neither can be overridden
|
|
12
|
+
* by the visitor.
|
|
13
|
+
*/
|
|
14
|
+
export const MOTION_STORAGE_KEY = "sf:motion";
|
|
15
|
+
export const MOTION_ATTRIBUTE = "data-sf-motion-preference";
|
|
16
|
+
export const MOTION_CHANGE_EVENT = "sf:motion-change";
|
|
17
|
+
export const MOTION_TOGGLE_SELECTOR = "[data-sf-motion-toggle]";
|
|
18
|
+
export const REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";
|
|
19
|
+
export function isMotionPreference(value) {
|
|
20
|
+
return value === "full" || value === "reduce";
|
|
21
|
+
}
|
|
22
|
+
/** An explicit choice beats the OS; without one the OS decides. */
|
|
23
|
+
export function resolveMotionPreference(stored, systemReduces) {
|
|
24
|
+
if (isMotionPreference(stored))
|
|
25
|
+
return stored;
|
|
26
|
+
return systemReduces ? "reduce" : "full";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Inline script for `<head>`: mirrors the resolved preference on `<html>`
|
|
30
|
+
* before first paint, so nothing starts animating and then snaps to a stop.
|
|
31
|
+
*/
|
|
32
|
+
export function motionPreferenceBootstrapScript() {
|
|
33
|
+
const key = JSON.stringify(MOTION_STORAGE_KEY);
|
|
34
|
+
const query = JSON.stringify(REDUCED_MOTION_QUERY);
|
|
35
|
+
const attribute = JSON.stringify(MOTION_ATTRIBUTE);
|
|
36
|
+
return `(()=>{let s=null,r=false;try{s=localStorage.getItem(${key})}catch{}try{r=matchMedia(${query}).matches}catch{}document.documentElement.setAttribute(${attribute},s==="full"||s==="reduce"?s:r?"reduce":"full")})()`;
|
|
37
|
+
}
|
|
38
|
+
export function browserMotionEnvironment() {
|
|
39
|
+
let storage = null;
|
|
40
|
+
try {
|
|
41
|
+
storage = localStorage;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Blocked storage keeps the preference in memory for the page only.
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
document,
|
|
48
|
+
storage,
|
|
49
|
+
media: typeof matchMedia === "function" ? matchMedia(REDUCED_MOTION_QUERY) : null,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function readStored(env) {
|
|
53
|
+
try {
|
|
54
|
+
return env.storage?.getItem(MOTION_STORAGE_KEY) ?? null;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function mirrored(env) {
|
|
61
|
+
const value = env.document.documentElement.getAttribute(MOTION_ATTRIBUTE);
|
|
62
|
+
return isMotionPreference(value) ? value : null;
|
|
63
|
+
}
|
|
64
|
+
/** The mirrored value when the bootstrap ran, otherwise resolved from storage and OS. */
|
|
65
|
+
export function getMotionPreference(env = browserMotionEnvironment()) {
|
|
66
|
+
return mirrored(env) ?? resolveMotionPreference(readStored(env), env.media?.matches ?? false);
|
|
67
|
+
}
|
|
68
|
+
function apply(preference, env) {
|
|
69
|
+
if (mirrored(env) === preference)
|
|
70
|
+
return;
|
|
71
|
+
env.document.documentElement.setAttribute(MOTION_ATTRIBUTE, preference);
|
|
72
|
+
env.document.dispatchEvent(new CustomEvent(MOTION_CHANGE_EVENT, { detail: { preference } }));
|
|
73
|
+
}
|
|
74
|
+
/** Store an explicit choice and announce it. */
|
|
75
|
+
export function setMotionPreference(preference, env = browserMotionEnvironment()) {
|
|
76
|
+
try {
|
|
77
|
+
env.storage?.setItem(MOTION_STORAGE_KEY, preference);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// The choice still applies to this page.
|
|
81
|
+
}
|
|
82
|
+
apply(preference, env);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Call `listener` whenever the effective preference changes: an explicit
|
|
86
|
+
* choice, or the OS setting while the visitor has not made one.
|
|
87
|
+
*/
|
|
88
|
+
export function subscribeMotionPreference(listener, env = browserMotionEnvironment()) {
|
|
89
|
+
const onChange = (event) => {
|
|
90
|
+
const preference = event.detail?.preference;
|
|
91
|
+
if (isMotionPreference(preference))
|
|
92
|
+
listener(preference);
|
|
93
|
+
};
|
|
94
|
+
// Every subscriber may see the OS change; `apply` announces it only once.
|
|
95
|
+
const onSystemChange = () => {
|
|
96
|
+
if (!isMotionPreference(readStored(env)))
|
|
97
|
+
apply(resolveMotionPreference(null, env.media?.matches ?? false), env);
|
|
98
|
+
};
|
|
99
|
+
env.document.addEventListener(MOTION_CHANGE_EVENT, onChange);
|
|
100
|
+
env.media?.addEventListener("change", onSystemChange);
|
|
101
|
+
return () => {
|
|
102
|
+
env.document.removeEventListener(MOTION_CHANGE_EVENT, onChange);
|
|
103
|
+
env.media?.removeEventListener("change", onSystemChange);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const TOGGLE_BOUND = "sfMotionToggleBound";
|
|
107
|
+
/**
|
|
108
|
+
* Wire every server-rendered `[data-sf-motion-toggle]` switch: a click flips
|
|
109
|
+
* the preference, `aria-checked` mirrors it (checked means animations on).
|
|
110
|
+
*/
|
|
111
|
+
export function initializeMotionToggles(scope = document, env = browserMotionEnvironment()) {
|
|
112
|
+
const toggles = [...scope.querySelectorAll(MOTION_TOGGLE_SELECTOR)]
|
|
113
|
+
.filter((toggle) => toggle.dataset[TOGGLE_BOUND] !== "true");
|
|
114
|
+
const sync = (preference) => {
|
|
115
|
+
toggles.forEach((toggle) => toggle.setAttribute("aria-checked", String(preference === "full")));
|
|
116
|
+
};
|
|
117
|
+
const flip = () => setMotionPreference(getMotionPreference(env) === "full" ? "reduce" : "full", env);
|
|
118
|
+
toggles.forEach((toggle) => {
|
|
119
|
+
toggle.dataset[TOGGLE_BOUND] = "true";
|
|
120
|
+
toggle.addEventListener("click", flip);
|
|
121
|
+
});
|
|
122
|
+
sync(getMotionPreference(env));
|
|
123
|
+
const unsubscribe = subscribeMotionPreference(sync, env);
|
|
124
|
+
return () => {
|
|
125
|
+
unsubscribe();
|
|
126
|
+
toggles.forEach((toggle) => {
|
|
127
|
+
toggle.removeEventListener("click", flip);
|
|
128
|
+
delete toggle.dataset[TOGGLE_BOUND];
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=motion-preference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-preference.js","sourceRoot":"","sources":["../src/motion-preference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAC5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAChE,MAAM,CAAC,MAAM,oBAAoB,GAAG,kCAAkC,CAAC;AAKvE,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,QAAQ,CAAC;AAChD,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,uBAAuB,CAAC,MAAe,EAAE,aAAsB;IAC7E,IAAI,kBAAkB,CAAC,MAAM,CAAC;QAAE,OAA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MAAM,EAAE,EAAE;QACzB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;QACtC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,MAAM,WAAW,GAAG,yBAAyB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAEzD,OAAO,GAAG,EAAE;QACV,WAAW,EAAE,CAAC;QACd,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC1C,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Single source of truth for \"may this page animate?\".\n *\n * The default follows the OS (`prefers-reduced-motion`). A visitor's explicit\n * choice from the accessibility panel wins in both directions and is stored in\n * localStorage. The resolved value is mirrored on\n * `<html data-sf-motion-preference=\"full|reduce\">`, so CSS and scripts read the\n * same state, and every change is announced with `sf:motion-change`.\n *\n * Do not read `matchMedia(\"(prefers-reduced-motion)\")` or write a bare\n * `@media (prefers-reduced-motion)` rule elsewhere: neither can be overridden\n * by the visitor.\n */\n\nexport const MOTION_STORAGE_KEY = \"sf:motion\";\nexport const MOTION_ATTRIBUTE = \"data-sf-motion-preference\";\nexport const MOTION_CHANGE_EVENT = \"sf:motion-change\";\nexport const MOTION_TOGGLE_SELECTOR = \"[data-sf-motion-toggle]\";\nexport const REDUCED_MOTION_QUERY = \"(prefers-reduced-motion: reduce)\";\n\n/** `full` animates, `reduce` keeps everything still. */\nexport type MotionPreference = \"full\" | \"reduce\";\n\nexport function isMotionPreference(value: unknown): value is MotionPreference {\n return value === \"full\" || value === \"reduce\";\n}\n\n/** An explicit choice beats the OS; without one the OS decides. */\nexport function resolveMotionPreference(stored: unknown, systemReduces: boolean): MotionPreference {\n if (isMotionPreference(stored)) return stored;\n return systemReduces ? \"reduce\" : \"full\";\n}\n\n/**\n * Inline script for `<head>`: mirrors the resolved preference on `<html>`\n * before first paint, so nothing starts animating and then snaps to a stop.\n */\nexport function motionPreferenceBootstrapScript(): string {\n const key = JSON.stringify(MOTION_STORAGE_KEY);\n const query = JSON.stringify(REDUCED_MOTION_QUERY);\n const attribute = JSON.stringify(MOTION_ATTRIBUTE);\n return `(()=>{let s=null,r=false;try{s=localStorage.getItem(${key})}catch{}try{r=matchMedia(${query}).matches}catch{}document.documentElement.setAttribute(${attribute},s===\"full\"||s===\"reduce\"?s:r?\"reduce\":\"full\")})()`;\n}\n\n/** The browser surface this module needs, injectable for tests. */\nexport interface MotionEnvironment {\n document: Pick<Document, \"documentElement\" | \"dispatchEvent\" | \"addEventListener\" | \"removeEventListener\">;\n storage: Pick<Storage, \"getItem\" | \"setItem\"> | null;\n media: Pick<MediaQueryList, \"matches\" | \"addEventListener\" | \"removeEventListener\"> | null;\n}\n\nexport function browserMotionEnvironment(): MotionEnvironment {\n let storage: MotionEnvironment[\"storage\"] = null;\n try {\n storage = localStorage;\n } catch {\n // Blocked storage keeps the preference in memory for the page only.\n }\n return {\n document,\n storage,\n media: typeof matchMedia === \"function\" ? matchMedia(REDUCED_MOTION_QUERY) : null,\n };\n}\n\nfunction readStored(env: MotionEnvironment): string | null {\n try {\n return env.storage?.getItem(MOTION_STORAGE_KEY) ?? null;\n } catch {\n return null;\n }\n}\n\nfunction mirrored(env: MotionEnvironment): MotionPreference | null {\n const value = env.document.documentElement.getAttribute(MOTION_ATTRIBUTE);\n return isMotionPreference(value) ? value : null;\n}\n\n/** The mirrored value when the bootstrap ran, otherwise resolved from storage and OS. */\nexport function getMotionPreference(env: MotionEnvironment = browserMotionEnvironment()): MotionPreference {\n return mirrored(env) ?? resolveMotionPreference(readStored(env), env.media?.matches ?? false);\n}\n\nfunction apply(preference: MotionPreference, env: MotionEnvironment): void {\n if (mirrored(env) === preference) return;\n env.document.documentElement.setAttribute(MOTION_ATTRIBUTE, preference);\n env.document.dispatchEvent(new CustomEvent(MOTION_CHANGE_EVENT, { detail: { preference } }));\n}\n\n/** Store an explicit choice and announce it. */\nexport function setMotionPreference(\n preference: MotionPreference,\n env: MotionEnvironment = browserMotionEnvironment(),\n): void {\n try {\n env.storage?.setItem(MOTION_STORAGE_KEY, preference);\n } catch {\n // The choice still applies to this page.\n }\n apply(preference, env);\n}\n\n/**\n * Call `listener` whenever the effective preference changes: an explicit\n * choice, or the OS setting while the visitor has not made one.\n */\nexport function subscribeMotionPreference(\n listener: (preference: MotionPreference) => void,\n env: MotionEnvironment = browserMotionEnvironment(),\n): () => void {\n const onChange = (event: Event) => {\n const preference = (event as CustomEvent<{ preference?: unknown }>).detail?.preference;\n if (isMotionPreference(preference)) listener(preference);\n };\n // Every subscriber may see the OS change; `apply` announces it only once.\n const onSystemChange = () => {\n if (!isMotionPreference(readStored(env))) apply(resolveMotionPreference(null, env.media?.matches ?? false), env);\n };\n env.document.addEventListener(MOTION_CHANGE_EVENT, onChange);\n env.media?.addEventListener(\"change\", onSystemChange);\n return () => {\n env.document.removeEventListener(MOTION_CHANGE_EVENT, onChange);\n env.media?.removeEventListener(\"change\", onSystemChange);\n };\n}\n\nconst TOGGLE_BOUND = \"sfMotionToggleBound\";\n\n/**\n * Wire every server-rendered `[data-sf-motion-toggle]` switch: a click flips\n * the preference, `aria-checked` mirrors it (checked means animations on).\n */\nexport function initializeMotionToggles(\n scope: ParentNode = document,\n env: MotionEnvironment = browserMotionEnvironment(),\n): () => void {\n const toggles = [...scope.querySelectorAll<HTMLElement>(MOTION_TOGGLE_SELECTOR)]\n .filter((toggle) => toggle.dataset[TOGGLE_BOUND] !== \"true\");\n const sync = (preference: MotionPreference) => {\n toggles.forEach((toggle) => toggle.setAttribute(\"aria-checked\", String(preference === \"full\")));\n };\n const flip = () => setMotionPreference(getMotionPreference(env) === \"full\" ? \"reduce\" : \"full\", env);\n\n toggles.forEach((toggle) => {\n toggle.dataset[TOGGLE_BOUND] = \"true\";\n toggle.addEventListener(\"click\", flip);\n });\n sync(getMotionPreference(env));\n const unsubscribe = subscribeMotionPreference(sync, env);\n\n return () => {\n unsubscribe();\n toggles.forEach((toggle) => {\n toggle.removeEventListener(\"click\", flip);\n delete toggle.dataset[TOGGLE_BOUND];\n });\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferences-runtime.d.ts","sourceRoot":"","sources":["../src/preferences-runtime.ts"],"names":[],"mappings":"AAKA,yEAAyE;AACzE,wBAAgB,gCAAgC,IAAI,IAAI,CAYvD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { initializeAccessibilityPanel } from "./accessibility-panel.js";
|
|
2
|
+
import { initializeMotionToggles } from "./motion-preference.js";
|
|
3
|
+
import { initializeVividColorsToggles } from "./vivid-colors-preference.js";
|
|
4
|
+
let started = false;
|
|
5
|
+
let cleanup = () => { };
|
|
6
|
+
/** One owner for all preference controls, including Astro navigation. */
|
|
7
|
+
export function startFlowpressPreferencesRuntime() {
|
|
8
|
+
if (started)
|
|
9
|
+
return;
|
|
10
|
+
started = true;
|
|
11
|
+
const initialize = () => {
|
|
12
|
+
cleanup();
|
|
13
|
+
const disposers = [initializeAccessibilityPanel(), initializeMotionToggles(), initializeVividColorsToggles()];
|
|
14
|
+
cleanup = () => disposers.forEach((dispose) => dispose());
|
|
15
|
+
};
|
|
16
|
+
if (document.readyState === "loading")
|
|
17
|
+
document.addEventListener("DOMContentLoaded", initialize, { once: true });
|
|
18
|
+
else
|
|
19
|
+
initialize();
|
|
20
|
+
document.addEventListener("astro:page-load", initialize);
|
|
21
|
+
document.addEventListener("astro:before-swap", () => cleanup());
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=preferences-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferences-runtime.js","sourceRoot":"","sources":["../src/preferences-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,IAAI,OAAO,GAAG,KAAK,CAAC;AACpB,IAAI,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AACvB,yEAAyE;AACzE,MAAM,UAAU,gCAAgC;IAC9C,IAAI,OAAO;QAAE,OAAO;IACpB,OAAO,GAAG,IAAI,CAAC;IACf,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,OAAO,EAAE,CAAC;QACV,MAAM,SAAS,GAAG,CAAC,4BAA4B,EAAE,EAAE,uBAAuB,EAAE,EAAE,4BAA4B,EAAE,CAAC,CAAC;QAC9G,OAAO,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC;IACF,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS;QAAE,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;;QAC5G,UAAU,EAAE,CAAC;IAClB,QAAQ,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;IACzD,QAAQ,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { initializeAccessibilityPanel } from \"./accessibility-panel.js\";\nimport { initializeMotionToggles } from \"./motion-preference.js\";\nimport { initializeVividColorsToggles } from \"./vivid-colors-preference.js\";\nlet started = false;\nlet cleanup = () => {};\n/** One owner for all preference controls, including Astro navigation. */\nexport function startFlowpressPreferencesRuntime(): void {\n if (started) return;\n started = true;\n const initialize = () => {\n cleanup();\n const disposers = [initializeAccessibilityPanel(), initializeMotionToggles(), initializeVividColorsToggles()];\n cleanup = () => disposers.forEach((dispose) => dispose());\n };\n if (document.readyState === \"loading\") document.addEventListener(\"DOMContentLoaded\", initialize, { once: true });\n else initialize();\n document.addEventListener(\"astro:page-load\", initialize);\n document.addEventListener(\"astro:before-swap\", () => cleanup());\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferences-styleflow.d.ts","sourceRoot":"","sources":["../src/preferences-styleflow.ts"],"names":[],"mappings":"AACA,wFAAwF;AACxF,wBAAgB,oBAAoB,CAAC,GAAG,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOtG"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resolveStyleFlowAstroPrimitive } from "@styleflow.app/astro";
|
|
2
|
+
/** Keep the pilot appearance where available, using only public contract validation. */
|
|
3
|
+
export function preferencesStyleflow(...candidates) {
|
|
4
|
+
for (const candidate of candidates) {
|
|
5
|
+
try {
|
|
6
|
+
resolveStyleFlowAstroPrimitive({ as: "div", ...candidate });
|
|
7
|
+
return candidate;
|
|
8
|
+
}
|
|
9
|
+
catch { /* The next preset uses fewer optional project coordinates. */ }
|
|
10
|
+
}
|
|
11
|
+
resolveStyleFlowAstroPrimitive({ as: "div" });
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=preferences-styleflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferences-styleflow.js","sourceRoot":"","sources":["../src/preferences-styleflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,wFAAwF;AACxF,MAAM,UAAU,oBAAoB,CAAC,GAAG,UAAqC;IAC3E,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC;YAAC,8BAA8B,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;YAAC,OAAO,SAAS,CAAC;QAAC,CAAC;QACtF,MAAM,CAAC,CAAC,8DAA8D,CAAC,CAAC;IAC1E,CAAC;IACD,8BAA8B,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9C,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import { resolveStyleFlowAstroPrimitive } from \"@styleflow.app/astro\";\n/** Keep the pilot appearance where available, using only public contract validation. */\nexport function preferencesStyleflow(...candidates: Record<string, unknown>[]): Record<string, unknown> {\n for (const candidate of candidates) {\n try { resolveStyleFlowAstroPrimitive({ as: \"div\", ...candidate }); return candidate; }\n catch { /* The next preset uses fewer optional project coordinates. */ }\n }\n resolveStyleFlowAstroPrimitive({ as: \"div\" });\n return {};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferences.d.ts","sourceRoot":"","sources":["../src/preferences.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preferences.js","sourceRoot":"","sources":["../src/preferences.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC","sourcesContent":["export * from \"./motion-preference.js\";\nexport * from \"./vivid-colors-preference.js\";\nexport * from \"./accessibility-panel.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-runtime.d.ts","sourceRoot":"","sources":["../src/theme-runtime.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAE7D,MAAM,WAAW,2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W,CAAC,EAAE,MAAM,GAAG,IAAI,GAC1B,MAAM,CAKR;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,YAAY,EAAE,MAAM,GACnB,MAAM,CAIR;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,YAAY,EAAE,MAAM,GACnB,MAAM,CAIR;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,GAAE,2BAC6B,EACrC,cAAc,GAAE,QAAmB,EACnC,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC,GAAG,IAAI,GACpD,MAAM,IAAI,CAkEZ"}
|
package/dist/theme-runtime.js
CHANGED
|
@@ -24,10 +24,19 @@ export function styleflowThemeBootstrapScript(themes, defaultTheme) {
|
|
|
24
24
|
return `(()=>{const c=${json};window.__FLOWPRESS_STYLEFLOW_THEME_RUNTIME__=c;if(!c.themes.length)return;let s=null;try{s=localStorage.getItem(${JSON.stringify(STYLEFLOW_THEME_STORAGE_KEY)})}catch{}const t=c.themes.includes(s)?s:c.defaultTheme;document.documentElement.setAttribute("data-styleflow-theme",t)})()`;
|
|
25
25
|
}
|
|
26
26
|
export function initializeStyleflowThemeRuntime(config = window.__FLOWPRESS_STYLEFLOW_THEME_RUNTIME__
|
|
27
|
-
?? { themes: [], defaultTheme: "" }, documentObject = document, storage
|
|
27
|
+
?? { themes: [], defaultTheme: "" }, documentObject = document, storage) {
|
|
28
28
|
const normalized = normalizeStyleflowThemes(config.themes, config.defaultTheme);
|
|
29
29
|
if (normalized.themes.length === 0)
|
|
30
30
|
return () => undefined;
|
|
31
|
+
let storageObject = storage;
|
|
32
|
+
if (storageObject === undefined) {
|
|
33
|
+
try {
|
|
34
|
+
storageObject = globalThis.localStorage;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
storageObject = null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
31
40
|
const root = documentObject.documentElement;
|
|
32
41
|
let current = initialStyleflowTheme(normalized.themes, normalized.defaultTheme, root.getAttribute("data-styleflow-theme"));
|
|
33
42
|
const buttons = [...documentObject.querySelectorAll("[data-styleflow-theme-toggle]")];
|
|
@@ -37,8 +46,14 @@ export function initializeStyleflowThemeRuntime(config = window.__FLOWPRESS_STYL
|
|
|
37
46
|
|| button.getAttribute("aria-label")
|
|
38
47
|
|| "Change color theme";
|
|
39
48
|
button.dataset.styleflowThemeToggleLabel = baseLabel.replace(/: .+$/, "");
|
|
40
|
-
button.
|
|
41
|
-
|
|
49
|
+
if (button.getAttribute("role") === "switch") {
|
|
50
|
+
button.setAttribute("aria-checked", String(current === (button.dataset.styleflowThemeToggleTarget || "dark")));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
button.setAttribute("aria-label", `${button.dataset.styleflowThemeToggleLabel}: ${current}`);
|
|
54
|
+
}
|
|
55
|
+
const label = button.querySelector("[data-styleflow-theme-label]")
|
|
56
|
+
?? button.closest(".flowpress-theme-control")?.querySelector("[data-styleflow-theme-label]");
|
|
42
57
|
if (label)
|
|
43
58
|
label.textContent = current;
|
|
44
59
|
}
|
|
@@ -46,9 +61,9 @@ export function initializeStyleflowThemeRuntime(config = window.__FLOWPRESS_STYL
|
|
|
46
61
|
const apply = (theme, persist) => {
|
|
47
62
|
current = theme;
|
|
48
63
|
root.setAttribute("data-styleflow-theme", theme);
|
|
49
|
-
if (persist &&
|
|
64
|
+
if (persist && storageObject) {
|
|
50
65
|
try {
|
|
51
|
-
|
|
66
|
+
storageObject.setItem(STYLEFLOW_THEME_STORAGE_KEY, theme);
|
|
52
67
|
}
|
|
53
68
|
catch { /* noop */ }
|
|
54
69
|
}
|
|
@@ -61,7 +76,15 @@ export function initializeStyleflowThemeRuntime(config = window.__FLOWPRESS_STYL
|
|
|
61
76
|
for (const button of buttons) {
|
|
62
77
|
if (button.dataset.styleflowThemeToggleBound === "true")
|
|
63
78
|
continue;
|
|
64
|
-
const listener = () =>
|
|
79
|
+
const listener = () => {
|
|
80
|
+
const target = button.dataset.styleflowThemeToggleTarget;
|
|
81
|
+
const alternative = normalized.defaultTheme !== target
|
|
82
|
+
? normalized.defaultTheme : normalized.themes.find((theme) => theme !== target);
|
|
83
|
+
const theme = target && alternative && normalized.themes.includes(target)
|
|
84
|
+
? (current === target ? alternative : target)
|
|
85
|
+
: nextStyleflowTheme(normalized.themes, current);
|
|
86
|
+
apply(theme, true);
|
|
87
|
+
};
|
|
65
88
|
button.dataset.styleflowThemeToggleBound = "true";
|
|
66
89
|
button.addEventListener("click", listener);
|
|
67
90
|
listeners.set(button, listener);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-runtime.js","sourceRoot":"","sources":["../src/theme-runtime.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,2BAA2B,GAAG,iBAAiB,CAAC;AAa7D,MAAM,UAAU,wBAAwB,CACtC,MAAyB,EACzB,YAAoB;IAEpB,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACtD,OAAO,KAAK,KAAK,QAAQ,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAC5D,CAAC,CAAC,CAAC,CAAC;IACL,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC;QAChD,CAAC,CAAC,YAAY;QACd,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,MAAyB,EACzB,YAAoB,EACpB,WAA2B;IAE3B,MAAM,MAAM,GAAG,wBAAwB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC9D,OAAO,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC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StyleflowThemeRuntimeConfig {\n themes: string[];\n defaultTheme: string;\n}\n\ndeclare global {\n interface Window {\n __FLOWPRESS_STYLEFLOW_THEME_RUNTIME__?: StyleflowThemeRuntimeConfig;\n }\n}\n\nexport function normalizeStyleflowThemes(\n themes: readonly string[],\n defaultTheme: string\n): StyleflowThemeRuntimeConfig {\n const normalized = [...new Set(themes.filter((theme) => (\n typeof theme === \"string\" && /^[a-zA-Z0-9_-]+$/.test(theme)\n )))];\n const fallback = normalized.includes(defaultTheme)\n ? defaultTheme\n : normalized[0] ?? \"\";\n return { themes: normalized, defaultTheme: fallback };\n}\n\nexport function initialStyleflowTheme(\n themes: readonly string[],\n defaultTheme: string,\n storedTheme?: string | null\n): string {\n const config = normalizeStyleflowThemes(themes, defaultTheme);\n return storedTheme && config.themes.includes(storedTheme)\n ? storedTheme\n : config.defaultTheme;\n}\n\nexport function nextStyleflowTheme(\n themes: readonly string[],\n currentTheme: string\n): string {\n if (themes.length === 0) return \"\";\n const index = themes.indexOf(currentTheme);\n return themes[(index + 1 + themes.length) % themes.length] ?? themes[0] ?? \"\";\n}\n\nexport function styleflowThemeBootstrapScript(\n themes: readonly string[],\n defaultTheme: string\n): string {\n const config = normalizeStyleflowThemes(themes, defaultTheme);\n const json = JSON.stringify(config).replaceAll(\"<\", \"\\\\u003c\");\n return `(()=>{const c=${json};window.__FLOWPRESS_STYLEFLOW_THEME_RUNTIME__=c;if(!c.themes.length)return;let s=null;try{s=localStorage.getItem(${JSON.stringify(STYLEFLOW_THEME_STORAGE_KEY)})}catch{}const t=c.themes.includes(s)?s:c.defaultTheme;document.documentElement.setAttribute(\"data-styleflow-theme\",t)})()`;\n}\n\nexport function initializeStyleflowThemeRuntime(\n config: StyleflowThemeRuntimeConfig = window.__FLOWPRESS_STYLEFLOW_THEME_RUNTIME__\n ?? { themes: [], defaultTheme: \"\" },\n documentObject: Document = document,\n storage?: Pick<Storage, \"getItem\" | \"setItem\"> | null\n): () => void {\n const normalized = normalizeStyleflowThemes(config.themes, config.defaultTheme);\n if (normalized.themes.length === 0) return () => undefined;\n let storageObject = storage;\n if (storageObject === undefined) {\n try { storageObject = globalThis.localStorage; } catch { storageObject = null; }\n }\n const root = documentObject.documentElement;\n let current = initialStyleflowTheme(\n normalized.themes,\n normalized.defaultTheme,\n root.getAttribute(\"data-styleflow-theme\")\n );\n const buttons = [...documentObject.querySelectorAll<HTMLElement>(\n \"[data-styleflow-theme-toggle]\"\n )];\n const updateButtons = () => {\n for (const button of buttons) {\n const baseLabel = button.dataset.styleflowThemeToggleLabel\n || button.getAttribute(\"aria-label\")\n || \"Change color theme\";\n button.dataset.styleflowThemeToggleLabel = baseLabel.replace(/: .+$/, \"\");\n if (button.getAttribute(\"role\") === \"switch\") {\n button.setAttribute(\"aria-checked\", String(current === (button.dataset.styleflowThemeToggleTarget || \"dark\")));\n } else {\n button.setAttribute(\"aria-label\", `${button.dataset.styleflowThemeToggleLabel}: ${current}`);\n }\n const label = button.querySelector<HTMLElement>(\"[data-styleflow-theme-label]\")\n ?? button.closest(\".flowpress-theme-control\")?.querySelector<HTMLElement>(\"[data-styleflow-theme-label]\");\n if (label) label.textContent = current;\n }\n };\n const apply = (theme: string, persist: boolean) => {\n current = theme;\n root.setAttribute(\"data-styleflow-theme\", theme);\n if (persist && storageObject) {\n try { storageObject.setItem(STYLEFLOW_THEME_STORAGE_KEY, theme); } catch { /* noop */ }\n }\n updateButtons();\n documentObject.dispatchEvent(new CustomEvent(\"styleflow:theme-change\", {\n detail: { theme }\n }));\n };\n const listeners = new Map<HTMLElement, EventListener>();\n for (const button of buttons) {\n if (button.dataset.styleflowThemeToggleBound === \"true\") continue;\n const listener = () => {\n const target = button.dataset.styleflowThemeToggleTarget;\n const alternative = normalized.defaultTheme !== target\n ? normalized.defaultTheme : normalized.themes.find((theme) => theme !== target);\n const theme = target && alternative && normalized.themes.includes(target)\n ? (current === target ? alternative : target)\n : nextStyleflowTheme(normalized.themes, current);\n apply(theme, true);\n };\n button.dataset.styleflowThemeToggleBound = \"true\";\n button.addEventListener(\"click\", listener);\n listeners.set(button, listener);\n }\n updateButtons();\n return () => {\n for (const [button, listener] of listeners) {\n button.removeEventListener(\"click\", listener);\n delete button.dataset.styleflowThemeToggleBound;\n }\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/astro.d.ts","../src/block-renderers.ts","../src/carousel.ts","../src/client.ts","../src/composition.ts","../src/default-blocks.ts","../src/env.ts","../src/index.ts","../src/links.ts","../src/media.ts","../src/number-spinner.ts","../src/style-classes.ts","../src/styleflow.ts","../src/template-hierarchy.ts","../src/templates.ts","../src/theme-runtime.ts","../src/types.ts","../src/astro/blocks/cover.ts","../src/astro/blocks/helpers.ts","../src/astro/native/button.ts","../src/astro/native/flowpress-navigation-controller.ts","../src/astro/native/grid.ts","../src/astro/native/html.ts","../src/astro/native/icon.ts","../src/astro/native/map.ts","../src/astro/native/motion-preference.ts","../src/astro/native/motion.ts","../src/astro/native/query-loop.ts","../src/astro/native/registry.ts","../src/astro/native/timeline.ts","../src/astro/native/blob/blob-shapes.generated.ts","../src/astro/native/blob/config.ts","../src/astro/native/blob/controller.ts","../src/astro/native/blob/geometry.ts","../src/astro/native/blob/ids.ts"],"version":"5.9.3"}
|
|
1
|
+
{"root":["../src/accessibility-panel.ts","../src/astro.d.ts","../src/block-renderers.ts","../src/carousel.ts","../src/client.ts","../src/composition.ts","../src/default-blocks.ts","../src/env.ts","../src/index.ts","../src/links.ts","../src/media.ts","../src/motion-preference.ts","../src/number-spinner.ts","../src/preferences-runtime.ts","../src/preferences-styleflow.ts","../src/preferences.ts","../src/style-classes.ts","../src/styleflow.ts","../src/template-hierarchy.ts","../src/templates.ts","../src/theme-runtime.ts","../src/types.ts","../src/vivid-colors-preference.ts","../src/astro/blocks/cover.ts","../src/astro/blocks/helpers.ts","../src/astro/native/button.ts","../src/astro/native/flowpress-navigation-controller.ts","../src/astro/native/grid.ts","../src/astro/native/html.ts","../src/astro/native/icon.ts","../src/astro/native/map.ts","../src/astro/native/motion-preference.ts","../src/astro/native/motion.ts","../src/astro/native/query-loop.ts","../src/astro/native/registry.ts","../src/astro/native/timeline.ts","../src/astro/native/blob/blob-shapes.generated.ts","../src/astro/native/blob/config.ts","../src/astro/native/blob/controller.ts","../src/astro/native/blob/geometry.ts","../src/astro/native/blob/ids.ts"],"version":"5.9.3"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single source of truth for the vivid-colors accessibility preference.
|
|
3
|
+
*
|
|
4
|
+
* Vivid colors are on by default. A visitor can turn them off from the
|
|
5
|
+
* accessibility panel; the explicit choice is stored in localStorage and
|
|
6
|
+
* mirrored on `<html data-sf-vivid-colors="true|false">`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const VIVID_COLORS_STORAGE_KEY = "sf:vivid-colors";
|
|
9
|
+
export declare const VIVID_COLORS_ATTRIBUTE = "data-sf-vivid-colors";
|
|
10
|
+
export declare const VIVID_COLORS_CHANGE_EVENT = "sf:vivid-colors-change";
|
|
11
|
+
export declare const VIVID_COLORS_TOGGLE_SELECTOR = "[data-sf-vivid-colors-toggle]";
|
|
12
|
+
export type VividColorsPreference = "true" | "false";
|
|
13
|
+
export declare function isVividColorsPreference(value: unknown): value is VividColorsPreference;
|
|
14
|
+
/** Missing or invalid values intentionally fall back to vivid colors. */
|
|
15
|
+
export declare function resolveVividColorsPreference(stored: unknown): VividColorsPreference;
|
|
16
|
+
/**
|
|
17
|
+
* Inline script for `<head>`: applies a saved reduced-saturation choice before
|
|
18
|
+
* first paint. Visitors without a saved choice always start with vivid colors.
|
|
19
|
+
*/
|
|
20
|
+
export declare function vividColorsBootstrapScript(): string;
|
|
21
|
+
export interface VividColorsEnvironment {
|
|
22
|
+
document: Pick<Document, "documentElement" | "dispatchEvent" | "addEventListener" | "removeEventListener">;
|
|
23
|
+
storage: Pick<Storage, "getItem" | "setItem"> | null;
|
|
24
|
+
}
|
|
25
|
+
export declare function browserVividColorsEnvironment(): VividColorsEnvironment;
|
|
26
|
+
export declare function getVividColorsPreference(env?: VividColorsEnvironment): VividColorsPreference;
|
|
27
|
+
export declare function setVividColorsPreference(preference: VividColorsPreference, env?: VividColorsEnvironment): void;
|
|
28
|
+
export declare function subscribeVividColorsPreference(listener: (preference: VividColorsPreference) => void, env?: VividColorsEnvironment): () => void;
|
|
29
|
+
/** Checked means vivid colors are on. */
|
|
30
|
+
export declare function initializeVividColorsToggles(scope?: ParentNode, env?: VividColorsEnvironment): () => void;
|
|
31
|
+
//# sourceMappingURL=vivid-colors-preference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vivid-colors-preference.d.ts","sourceRoot":"","sources":["../src/vivid-colors-preference.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAC1D,eAAO,MAAM,sBAAsB,yBAAyB,CAAC;AAC7D,eAAO,MAAM,yBAAyB,2BAA2B,CAAC;AAClE,eAAO,MAAM,4BAA4B,kCAAkC,CAAC;AAE5E,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,OAAO,CAAC;AAErD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB,CAEtF;AAED,yEAAyE;AACzE,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,OAAO,GAAG,qBAAqB,CAEnF;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAInD;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,iBAAiB,GAAG,eAAe,GAAG,kBAAkB,GAAG,qBAAqB,CAAC,CAAC;IAC3G,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC;CACtD;AAED,wBAAgB,6BAA6B,IAAI,sBAAsB,CAQtE;AAeD,wBAAgB,wBAAwB,CACtC,GAAG,GAAE,sBAAwD,GAC5D,qBAAqB,CAEvB;AAUD,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,qBAAqB,EACjC,GAAG,GAAE,sBAAwD,GAC5D,IAAI,CAON;AAED,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,CAAC,UAAU,EAAE,qBAAqB,KAAK,IAAI,EACrD,GAAG,GAAE,sBAAwD,GAC5D,MAAM,IAAI,CAOZ;AAID,yCAAyC;AACzC,wBAAgB,4BAA4B,CAC1C,KAAK,GAAE,UAAqB,EAC5B,GAAG,GAAE,sBAAwD,GAC5D,MAAM,IAAI,CAwBZ"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single source of truth for the vivid-colors accessibility preference.
|
|
3
|
+
*
|
|
4
|
+
* Vivid colors are on by default. A visitor can turn them off from the
|
|
5
|
+
* accessibility panel; the explicit choice is stored in localStorage and
|
|
6
|
+
* mirrored on `<html data-sf-vivid-colors="true|false">`.
|
|
7
|
+
*/
|
|
8
|
+
export const VIVID_COLORS_STORAGE_KEY = "sf:vivid-colors";
|
|
9
|
+
export const VIVID_COLORS_ATTRIBUTE = "data-sf-vivid-colors";
|
|
10
|
+
export const VIVID_COLORS_CHANGE_EVENT = "sf:vivid-colors-change";
|
|
11
|
+
export const VIVID_COLORS_TOGGLE_SELECTOR = "[data-sf-vivid-colors-toggle]";
|
|
12
|
+
export function isVividColorsPreference(value) {
|
|
13
|
+
return value === "true" || value === "false";
|
|
14
|
+
}
|
|
15
|
+
/** Missing or invalid values intentionally fall back to vivid colors. */
|
|
16
|
+
export function resolveVividColorsPreference(stored) {
|
|
17
|
+
return isVividColorsPreference(stored) ? stored : "true";
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Inline script for `<head>`: applies a saved reduced-saturation choice before
|
|
21
|
+
* first paint. Visitors without a saved choice always start with vivid colors.
|
|
22
|
+
*/
|
|
23
|
+
export function vividColorsBootstrapScript() {
|
|
24
|
+
const key = JSON.stringify(VIVID_COLORS_STORAGE_KEY);
|
|
25
|
+
const attribute = JSON.stringify(VIVID_COLORS_ATTRIBUTE);
|
|
26
|
+
return `(()=>{let s=null;try{s=localStorage.getItem(${key})}catch{}document.documentElement.setAttribute(${attribute},s==="false"?"false":"true")})()`;
|
|
27
|
+
}
|
|
28
|
+
export function browserVividColorsEnvironment() {
|
|
29
|
+
let storage = null;
|
|
30
|
+
try {
|
|
31
|
+
storage = localStorage;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// Blocked storage keeps the preference in memory for the page only.
|
|
35
|
+
}
|
|
36
|
+
return { document, storage };
|
|
37
|
+
}
|
|
38
|
+
function readStored(env) {
|
|
39
|
+
try {
|
|
40
|
+
return env.storage?.getItem(VIVID_COLORS_STORAGE_KEY) ?? null;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function mirrored(env) {
|
|
47
|
+
const value = env.document.documentElement.getAttribute(VIVID_COLORS_ATTRIBUTE);
|
|
48
|
+
return isVividColorsPreference(value) ? value : null;
|
|
49
|
+
}
|
|
50
|
+
export function getVividColorsPreference(env = browserVividColorsEnvironment()) {
|
|
51
|
+
return mirrored(env) ?? resolveVividColorsPreference(readStored(env));
|
|
52
|
+
}
|
|
53
|
+
function apply(preference, env) {
|
|
54
|
+
if (mirrored(env) === preference)
|
|
55
|
+
return;
|
|
56
|
+
env.document.documentElement.setAttribute(VIVID_COLORS_ATTRIBUTE, preference);
|
|
57
|
+
env.document.dispatchEvent(new CustomEvent(VIVID_COLORS_CHANGE_EVENT, { detail: { preference } }));
|
|
58
|
+
}
|
|
59
|
+
export function setVividColorsPreference(preference, env = browserVividColorsEnvironment()) {
|
|
60
|
+
try {
|
|
61
|
+
env.storage?.setItem(VIVID_COLORS_STORAGE_KEY, preference);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// The choice still applies to this page.
|
|
65
|
+
}
|
|
66
|
+
apply(preference, env);
|
|
67
|
+
}
|
|
68
|
+
export function subscribeVividColorsPreference(listener, env = browserVividColorsEnvironment()) {
|
|
69
|
+
const onChange = (event) => {
|
|
70
|
+
const preference = event.detail?.preference;
|
|
71
|
+
if (isVividColorsPreference(preference))
|
|
72
|
+
listener(preference);
|
|
73
|
+
};
|
|
74
|
+
env.document.addEventListener(VIVID_COLORS_CHANGE_EVENT, onChange);
|
|
75
|
+
return () => env.document.removeEventListener(VIVID_COLORS_CHANGE_EVENT, onChange);
|
|
76
|
+
}
|
|
77
|
+
const TOGGLE_BOUND = "sfVividColorsToggleBound";
|
|
78
|
+
/** Checked means vivid colors are on. */
|
|
79
|
+
export function initializeVividColorsToggles(scope = document, env = browserVividColorsEnvironment()) {
|
|
80
|
+
const toggles = [...scope.querySelectorAll(VIVID_COLORS_TOGGLE_SELECTOR)]
|
|
81
|
+
.filter((toggle) => toggle.dataset[TOGGLE_BOUND] !== "true");
|
|
82
|
+
const sync = (preference) => {
|
|
83
|
+
toggles.forEach((toggle) => toggle.setAttribute("aria-checked", preference));
|
|
84
|
+
};
|
|
85
|
+
const flip = () => {
|
|
86
|
+
setVividColorsPreference(getVividColorsPreference(env) === "true" ? "false" : "true", env);
|
|
87
|
+
};
|
|
88
|
+
toggles.forEach((toggle) => {
|
|
89
|
+
toggle.dataset[TOGGLE_BOUND] = "true";
|
|
90
|
+
toggle.addEventListener("click", flip);
|
|
91
|
+
});
|
|
92
|
+
sync(getVividColorsPreference(env));
|
|
93
|
+
const unsubscribe = subscribeVividColorsPreference(sync, env);
|
|
94
|
+
return () => {
|
|
95
|
+
unsubscribe();
|
|
96
|
+
toggles.forEach((toggle) => {
|
|
97
|
+
toggle.removeEventListener("click", flip);
|
|
98
|
+
delete toggle.dataset[TOGGLE_BOUND];
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=vivid-colors-preference.js.map
|
|
@@ -0,0 +1 @@
|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AC;IACpC,MAAM,WAAW,GAAG,8BAA8B,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAE9D,OAAO,GAAG,EAAE;QACV,WAAW,EAAE,CAAC;QACd,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC1C,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Single source of truth for the vivid-colors accessibility preference.\n *\n * Vivid colors are on by default. A visitor can turn them off from the\n * accessibility panel; the explicit choice is stored in localStorage and\n * mirrored on `<html data-sf-vivid-colors=\"true|false\">`.\n */\n\nexport const VIVID_COLORS_STORAGE_KEY = \"sf:vivid-colors\";\nexport const VIVID_COLORS_ATTRIBUTE = \"data-sf-vivid-colors\";\nexport const VIVID_COLORS_CHANGE_EVENT = \"sf:vivid-colors-change\";\nexport const VIVID_COLORS_TOGGLE_SELECTOR = \"[data-sf-vivid-colors-toggle]\";\n\nexport type VividColorsPreference = \"true\" | \"false\";\n\nexport function isVividColorsPreference(value: unknown): value is VividColorsPreference {\n return value === \"true\" || value === \"false\";\n}\n\n/** Missing or invalid values intentionally fall back to vivid colors. */\nexport function resolveVividColorsPreference(stored: unknown): VividColorsPreference {\n return isVividColorsPreference(stored) ? stored : \"true\";\n}\n\n/**\n * Inline script for `<head>`: applies a saved reduced-saturation choice before\n * first paint. Visitors without a saved choice always start with vivid colors.\n */\nexport function vividColorsBootstrapScript(): string {\n const key = JSON.stringify(VIVID_COLORS_STORAGE_KEY);\n const attribute = JSON.stringify(VIVID_COLORS_ATTRIBUTE);\n return `(()=>{let s=null;try{s=localStorage.getItem(${key})}catch{}document.documentElement.setAttribute(${attribute},s===\"false\"?\"false\":\"true\")})()`;\n}\n\nexport interface VividColorsEnvironment {\n document: Pick<Document, \"documentElement\" | \"dispatchEvent\" | \"addEventListener\" | \"removeEventListener\">;\n storage: Pick<Storage, \"getItem\" | \"setItem\"> | null;\n}\n\nexport function browserVividColorsEnvironment(): VividColorsEnvironment {\n let storage: VividColorsEnvironment[\"storage\"] = null;\n try {\n storage = localStorage;\n } catch {\n // Blocked storage keeps the preference in memory for the page only.\n }\n return { document, storage };\n}\n\nfunction readStored(env: VividColorsEnvironment): string | null {\n try {\n return env.storage?.getItem(VIVID_COLORS_STORAGE_KEY) ?? null;\n } catch {\n return null;\n }\n}\n\nfunction mirrored(env: VividColorsEnvironment): VividColorsPreference | null {\n const value = env.document.documentElement.getAttribute(VIVID_COLORS_ATTRIBUTE);\n return isVividColorsPreference(value) ? value : null;\n}\n\nexport function getVividColorsPreference(\n env: VividColorsEnvironment = browserVividColorsEnvironment(),\n): VividColorsPreference {\n return mirrored(env) ?? resolveVividColorsPreference(readStored(env));\n}\n\nfunction apply(preference: VividColorsPreference, env: VividColorsEnvironment): void {\n if (mirrored(env) === preference) return;\n env.document.documentElement.setAttribute(VIVID_COLORS_ATTRIBUTE, preference);\n env.document.dispatchEvent(\n new CustomEvent(VIVID_COLORS_CHANGE_EVENT, { detail: { preference } }),\n );\n}\n\nexport function setVividColorsPreference(\n preference: VividColorsPreference,\n env: VividColorsEnvironment = browserVividColorsEnvironment(),\n): void {\n try {\n env.storage?.setItem(VIVID_COLORS_STORAGE_KEY, preference);\n } catch {\n // The choice still applies to this page.\n }\n apply(preference, env);\n}\n\nexport function subscribeVividColorsPreference(\n listener: (preference: VividColorsPreference) => void,\n env: VividColorsEnvironment = browserVividColorsEnvironment(),\n): () => void {\n const onChange = (event: Event) => {\n const preference = (event as CustomEvent<{ preference?: unknown }>).detail?.preference;\n if (isVividColorsPreference(preference)) listener(preference);\n };\n env.document.addEventListener(VIVID_COLORS_CHANGE_EVENT, onChange);\n return () => env.document.removeEventListener(VIVID_COLORS_CHANGE_EVENT, onChange);\n}\n\nconst TOGGLE_BOUND = \"sfVividColorsToggleBound\";\n\n/** Checked means vivid colors are on. */\nexport function initializeVividColorsToggles(\n scope: ParentNode = document,\n env: VividColorsEnvironment = browserVividColorsEnvironment(),\n): () => void {\n const toggles = [...scope.querySelectorAll<HTMLElement>(VIVID_COLORS_TOGGLE_SELECTOR)]\n .filter((toggle) => toggle.dataset[TOGGLE_BOUND] !== \"true\");\n const sync = (preference: VividColorsPreference) => {\n toggles.forEach((toggle) => toggle.setAttribute(\"aria-checked\", preference));\n };\n const flip = () => {\n setVividColorsPreference(getVividColorsPreference(env) === \"true\" ? \"false\" : \"true\", env);\n };\n\n toggles.forEach((toggle) => {\n toggle.dataset[TOGGLE_BOUND] = \"true\";\n toggle.addEventListener(\"click\", flip);\n });\n sync(getVividColorsPreference(env));\n const unsubscribe = subscribeVividColorsPreference(sync, env);\n\n return () => {\n unsubscribe();\n toggles.forEach((toggle) => {\n toggle.removeEventListener(\"click\", flip);\n delete toggle.dataset[TOGGLE_BOUND];\n });\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@styleflow.app/flowpress-astro-core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.24",
|
|
4
4
|
"description": "Project-agnostic WordPress routing, templates, SEO and GraphQL runtime for FlowPress Astro apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -34,7 +34,19 @@
|
|
|
34
34
|
"./blocks/ThemeToggleBlock.astro": "./dist/astro/blocks/ThemeToggleBlock.astro",
|
|
35
35
|
"./blocks/CoverBlock.astro": "./dist/astro/blocks/CoverBlock.astro",
|
|
36
36
|
"./blocks/SiteLogoBlock.astro": "./dist/astro/blocks/SiteLogoBlock.astro",
|
|
37
|
-
"./native/*": "./dist/astro/native/*"
|
|
37
|
+
"./native/*": "./dist/astro/native/*",
|
|
38
|
+
"./preferences": {
|
|
39
|
+
"types": "./dist/preferences.d.ts",
|
|
40
|
+
"import": "./dist/preferences.js",
|
|
41
|
+
"default": "./dist/preferences.js"
|
|
42
|
+
},
|
|
43
|
+
"./Toggle.astro": "./dist/astro/preferences/Toggle.astro",
|
|
44
|
+
"./ThemeToggle.astro": "./dist/astro/preferences/ThemeToggle.astro",
|
|
45
|
+
"./MotionToggle.astro": "./dist/astro/preferences/MotionToggle.astro",
|
|
46
|
+
"./ColorModeToggle.astro": "./dist/astro/preferences/ColorModeToggle.astro",
|
|
47
|
+
"./AccessibilityPanel.astro": "./dist/astro/preferences/AccessibilityPanel.astro",
|
|
48
|
+
"./PreferencesRuntime.astro": "./dist/astro/preferences/PreferencesRuntime.astro",
|
|
49
|
+
"./preferences.css": "./dist/astro/preferences/preferences.css"
|
|
38
50
|
},
|
|
39
51
|
"files": [
|
|
40
52
|
"dist",
|