@styleflow.app/flowpress-astro-core 1.0.0-beta.3 → 1.0.0-beta.30
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 +190 -1
- package/README.md +111 -3
- package/dist/accessibility-panel.d.ts +2 -0
- package/dist/accessibility-panel.d.ts.map +1 -0
- package/dist/accessibility-panel.js +81 -0
- package/dist/accessibility-panel.js.map +1 -0
- package/dist/astro/BaseLayout.astro +34 -17
- package/dist/astro/CompositionRenderer.astro +157 -0
- package/dist/astro/DefaultBlockAdapter.astro +35 -0
- package/dist/astro/DefaultTemplate.astro +12 -7
- package/dist/astro/GutenbergRenderer.astro +240 -80
- package/dist/astro/StyleflowElement.astro +23 -0
- package/dist/astro/ThemeRuntime.astro +26 -0
- package/dist/astro/blocks/CarouselBlock.astro +8 -10
- package/dist/astro/blocks/CarouselItemBlock.astro +4 -4
- package/dist/astro/blocks/ColumnBlock.astro +4 -5
- package/dist/astro/blocks/CoverBlock.astro +155 -0
- package/dist/astro/blocks/FormBlock.astro +23 -20
- package/dist/astro/blocks/GridBlock.astro +4 -4
- package/dist/astro/blocks/HeroBlock.astro +4 -5
- package/dist/astro/blocks/ImageBlock.astro +4 -5
- package/dist/astro/blocks/ListItemFallback.astro +10 -7
- package/dist/astro/blocks/NumberSpinnerBlock.astro +29 -22
- package/dist/astro/blocks/SemanticElement.astro +35 -0
- package/dist/astro/blocks/SiteLogoBlock.astro +53 -0
- package/dist/astro/blocks/TextBlock.astro +33 -28
- package/dist/astro/blocks/ThemeToggleBlock.astro +13 -0
- package/dist/astro/blocks/cover.d.ts +13 -0
- package/dist/astro/blocks/cover.d.ts.map +1 -0
- package/dist/astro/blocks/cover.js +105 -0
- package/dist/astro/blocks/cover.js.map +1 -0
- package/dist/astro/blocks/cover.ts +119 -0
- package/dist/astro/blocks/helpers.d.ts +7 -0
- package/dist/astro/blocks/helpers.d.ts.map +1 -1
- package/dist/astro/blocks/helpers.js +52 -41
- package/dist/astro/blocks/helpers.js.map +1 -1
- package/dist/astro/blocks/helpers.ts +64 -45
- package/dist/astro/native/Blob.astro +113 -0
- package/dist/astro/native/BlobBlock.astro +52 -0
- package/dist/astro/native/CustomFieldValue.astro +87 -0
- package/dist/astro/native/LevelTag.astro +20 -0
- package/dist/astro/native/MapBlock.astro +41 -0
- package/dist/astro/native/NativeHtmlBlock.astro +12 -0
- package/dist/astro/native/NativeIconBlock.astro +42 -0
- package/dist/astro/native/ProjectTimelineBlock.astro +34 -0
- package/dist/astro/native/ResolvedBlocks.astro +89 -0
- package/dist/astro/native/SyncedPatternContent.astro +92 -0
- package/dist/astro/native/TermFieldValue.astro +38 -0
- package/dist/astro/native/Timeline.astro +21 -0
- package/dist/astro/native/TimelineCardBlock.astro +7 -0
- package/dist/astro/native/blob/blob-shapes.generated.d.ts +2 -0
- package/dist/astro/native/blob/blob-shapes.generated.d.ts.map +1 -0
- package/dist/astro/native/blob/blob-shapes.generated.js +2 -0
- package/dist/astro/native/blob/blob-shapes.generated.js.map +1 -0
- package/dist/astro/native/blob/blob-shapes.generated.ts +1 -0
- package/dist/astro/native/blob/config.d.ts +49 -0
- package/dist/astro/native/blob/config.d.ts.map +1 -0
- package/dist/astro/native/blob/config.js +86 -0
- package/dist/astro/native/blob/config.js.map +1 -0
- package/dist/astro/native/blob/config.ts +132 -0
- package/dist/astro/native/blob/controller.d.ts +11 -0
- package/dist/astro/native/blob/controller.d.ts.map +1 -0
- package/dist/astro/native/blob/controller.js +240 -0
- package/dist/astro/native/blob/controller.js.map +1 -0
- package/dist/astro/native/blob/controller.ts +248 -0
- package/dist/astro/native/blob/geometry.d.ts +2 -0
- package/dist/astro/native/blob/geometry.d.ts.map +1 -0
- package/dist/astro/native/blob/geometry.js +2 -0
- package/dist/astro/native/blob/geometry.js.map +1 -0
- package/dist/astro/native/blob/geometry.ts +1 -0
- package/dist/astro/native/blob/ids.d.ts +7 -0
- package/dist/astro/native/blob/ids.d.ts.map +1 -0
- package/dist/astro/native/blob/ids.js +11 -0
- package/dist/astro/native/blob/ids.js.map +1 -0
- package/dist/astro/native/blob/ids.ts +11 -0
- package/dist/astro/native/blob.css +83 -0
- package/dist/astro/native/button.d.ts +13 -0
- package/dist/astro/native/button.d.ts.map +1 -0
- package/dist/astro/native/button.js +26 -0
- package/dist/astro/native/button.js.map +1 -0
- package/dist/astro/native/button.ts +26 -0
- package/dist/astro/native/core-block.astro +18 -0
- package/dist/astro/native/core-button.astro +43 -0
- package/dist/astro/native/core-buttons.astro +14 -0
- package/dist/astro/native/core-group.astro +23 -0
- package/dist/astro/native/core-home-link.astro +12 -0
- package/dist/astro/native/core-html.astro +8 -0
- package/dist/astro/native/core-icon.astro +7 -0
- package/dist/astro/native/core-image.astro +124 -0
- package/dist/astro/native/core-navigation-link.astro +71 -0
- package/dist/astro/native/core-navigation-submenu.astro +33 -0
- package/dist/astro/native/core-navigation.astro +94 -0
- package/dist/astro/native/core-page-list-data-item.astro +19 -0
- package/dist/astro/native/core-page-list-item.astro +8 -0
- package/dist/astro/native/core-page-list.astro +40 -0
- package/dist/astro/native/core-post-date.astro +21 -0
- package/dist/astro/native/core-post-excerpt.astro +26 -0
- package/dist/astro/native/core-post-featured-image.astro +37 -0
- package/dist/astro/native/core-post-template.astro +30 -0
- package/dist/astro/native/core-post-terms.astro +47 -0
- package/dist/astro/native/core-post-title.astro +23 -0
- package/dist/astro/native/core-query-no-results.astro +12 -0
- package/dist/astro/native/core-query.astro +22 -0
- package/dist/astro/native/core-separator.astro +20 -0
- package/dist/astro/native/core-site-title.astro +16 -0
- package/dist/astro/native/core-term-description.astro +12 -0
- package/dist/astro/native/core-term-name.astro +21 -0
- package/dist/astro/native/core-term-template.astro +30 -0
- package/dist/astro/native/core-terms-query.astro +19 -0
- package/dist/astro/native/core-transparent.astro +11 -0
- package/dist/astro/native/flowpress-navigation-controller.d.ts +2 -0
- package/dist/astro/native/flowpress-navigation-controller.d.ts.map +1 -0
- package/dist/astro/native/flowpress-navigation-controller.js +217 -0
- package/dist/astro/native/flowpress-navigation-controller.js.map +1 -0
- package/dist/astro/native/flowpress-navigation-controller.ts +215 -0
- package/dist/astro/native/flowpress-navigation.css +17 -0
- package/dist/astro/native/grid-bleed.js +106 -0
- package/dist/astro/native/grid.css +180 -0
- package/dist/astro/native/grid.d.ts +17 -0
- package/dist/astro/native/grid.d.ts.map +1 -0
- package/dist/astro/native/grid.js +103 -0
- package/dist/astro/native/grid.js.map +1 -0
- package/dist/astro/native/grid.ts +118 -0
- package/dist/astro/native/html.d.ts +6 -0
- package/dist/astro/native/html.d.ts.map +1 -0
- package/dist/astro/native/html.js +10 -0
- package/dist/astro/native/html.js.map +1 -0
- package/dist/astro/native/html.ts +9 -0
- package/dist/astro/native/icon.d.ts +3 -0
- package/dist/astro/native/icon.d.ts.map +1 -0
- package/dist/astro/native/icon.js +23 -0
- package/dist/astro/native/icon.js.map +1 -0
- package/dist/astro/native/icon.ts +21 -0
- package/dist/astro/native/map.d.ts +14 -0
- package/dist/astro/native/map.d.ts.map +1 -0
- package/dist/astro/native/map.js +60 -0
- package/dist/astro/native/map.js.map +1 -0
- package/dist/astro/native/map.ts +70 -0
- package/dist/astro/native/motion-preference.d.ts +50 -0
- package/dist/astro/native/motion-preference.d.ts.map +1 -0
- package/dist/astro/native/motion-preference.js +132 -0
- package/dist/astro/native/motion-preference.js.map +1 -0
- package/dist/astro/native/motion-preference.ts +158 -0
- package/dist/astro/native/motion.d.ts +101 -0
- package/dist/astro/native/motion.d.ts.map +1 -0
- package/dist/astro/native/motion.js +168 -0
- package/dist/astro/native/motion.js.map +1 -0
- package/dist/astro/native/motion.ts +312 -0
- package/dist/astro/native/query-loop.d.ts +38 -0
- package/dist/astro/native/query-loop.d.ts.map +1 -0
- package/dist/astro/native/query-loop.js +20 -0
- package/dist/astro/native/query-loop.js.map +1 -0
- package/dist/astro/native/query-loop.ts +67 -0
- package/dist/astro/native/registry.d.ts +3 -0
- package/dist/astro/native/registry.d.ts.map +1 -0
- package/dist/astro/native/registry.js +81 -0
- package/dist/astro/native/registry.js.map +1 -0
- package/dist/astro/native/registry.ts +81 -0
- package/dist/astro/native/sf-block-binding.astro +20 -0
- package/dist/astro/native/sf-post-field.astro +9 -0
- package/dist/astro/native/sf-term-field.astro +9 -0
- package/dist/astro/native/timeline.css +4 -0
- package/dist/astro/native/timeline.d.ts +28 -0
- package/dist/astro/native/timeline.d.ts.map +1 -0
- package/dist/astro/native/timeline.js +43 -0
- package/dist/astro/native/timeline.js.map +1 -0
- package/dist/astro/native/timeline.ts +79 -0
- package/dist/astro/preferences/AccessibilityPanel.astro +118 -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 +125 -0
- package/dist/block-renderers.d.ts +20 -3
- package/dist/block-renderers.d.ts.map +1 -1
- package/dist/block-renderers.js.map +1 -1
- package/dist/client.d.ts +17 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +63 -9
- package/dist/client.js.map +1 -1
- package/dist/composition.d.ts +14 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +124 -0
- package/dist/composition.js.map +1 -0
- package/dist/default-blocks.d.ts +9 -0
- package/dist/default-blocks.d.ts.map +1 -0
- package/dist/default-blocks.js +118 -0
- package/dist/default-blocks.js.map +1 -0
- package/dist/env.d.ts +9 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +20 -0
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/links.d.ts +5 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +32 -0
- package/dist/links.js.map +1 -0
- package/dist/media.d.ts +28 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +212 -0
- package/dist/media.js.map +1 -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/styleflow.d.ts +16 -1
- package/dist/styleflow.d.ts.map +1 -1
- package/dist/styleflow.js +76 -7
- package/dist/styleflow.js.map +1 -1
- package/dist/templates.d.ts +16 -16
- package/dist/text.d.ts +3 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +6 -0
- package/dist/text.js.map +1 -0
- package/dist/theme-runtime.d.ts +16 -0
- package/dist/theme-runtime.d.ts.map +1 -0
- package/dist/theme-runtime.js +100 -0
- package/dist/theme-runtime.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +84 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +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 +26 -4
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { SF_MOTION_DRAWER_EXIT_MS } from "./motion.js";
|
|
2
|
+
import { getMotionPreference } from "./motion-preference.js";
|
|
3
|
+
|
|
4
|
+
const DEFAULT_OVERLAY_BREAKPOINT = "64rem";
|
|
5
|
+
const FOCUSABLE = "a, button, summary, [tabindex]:not([tabindex='-1'])";
|
|
6
|
+
const scrollLocks = new Set<HTMLElement>();
|
|
7
|
+
let previousRootOverflow = "";
|
|
8
|
+
|
|
9
|
+
/** `64rem` becomes `(max-width: 63.999rem)`, the exact complement of `min-width: 64rem`. */
|
|
10
|
+
function overlayQuery(breakpoint: string) {
|
|
11
|
+
const match = /^(\d+(?:\.\d+)?)rem$/.exec(breakpoint.trim());
|
|
12
|
+
const rem = match ? Number(match[1]) : Number.parseFloat(DEFAULT_OVERLAY_BREAKPOINT);
|
|
13
|
+
return `(max-width: ${(rem - 0.001).toFixed(3)}rem)`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class FlowpressNavigation extends HTMLElement {
|
|
17
|
+
private toggleButton: HTMLButtonElement | null = null;
|
|
18
|
+
private panel: HTMLElement | null = null;
|
|
19
|
+
private backdrop: HTMLElement | null = null;
|
|
20
|
+
private media!: MediaQueryList;
|
|
21
|
+
private closeTimer: number | undefined;
|
|
22
|
+
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
if (this.dataset.ready === "true") return;
|
|
25
|
+
this.toggleButton = this.querySelector<HTMLButtonElement>("[data-navigation-toggle]");
|
|
26
|
+
this.panel = this.querySelector<HTMLElement>("[data-navigation-panel]");
|
|
27
|
+
this.backdrop = this.querySelector<HTMLElement>("[data-navigation-backdrop]");
|
|
28
|
+
if (!this.toggleButton || !this.panel) return;
|
|
29
|
+
this.media = window.matchMedia(
|
|
30
|
+
overlayQuery(this.dataset.overlayBreakpoint || DEFAULT_OVERLAY_BREAKPOINT),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
this.toggleButton.addEventListener("click", this.handleToggle);
|
|
34
|
+
this.backdrop?.addEventListener("click", this.handleBackdrop);
|
|
35
|
+
this.panel.addEventListener("click", this.handlePanelClick);
|
|
36
|
+
this.addEventListener("keydown", this.handleKeydown);
|
|
37
|
+
this.media.addEventListener("change", this.syncMode);
|
|
38
|
+
document.addEventListener("pointerdown", this.handleOutsidePointer);
|
|
39
|
+
this.querySelectorAll<HTMLDetailsElement>("details[data-navigation-disclosure]")
|
|
40
|
+
.forEach((details) => details.addEventListener("toggle", this.handleDisclosure));
|
|
41
|
+
this.syncMode();
|
|
42
|
+
this.dataset.ready = "true";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
disconnectedCallback() {
|
|
46
|
+
this.toggleButton?.removeEventListener("click", this.handleToggle);
|
|
47
|
+
this.backdrop?.removeEventListener("click", this.handleBackdrop);
|
|
48
|
+
this.panel?.removeEventListener("click", this.handlePanelClick);
|
|
49
|
+
this.removeEventListener("keydown", this.handleKeydown);
|
|
50
|
+
this.media?.removeEventListener("change", this.syncMode);
|
|
51
|
+
document.removeEventListener("pointerdown", this.handleOutsidePointer);
|
|
52
|
+
this.querySelectorAll<HTMLDetailsElement>("details[data-navigation-disclosure]")
|
|
53
|
+
.forEach((details) => details.removeEventListener("toggle", this.handleDisclosure));
|
|
54
|
+
this.unlockDocumentScroll();
|
|
55
|
+
window.clearTimeout(this.closeTimer);
|
|
56
|
+
delete this.dataset.ready;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private usesOverlay = () => {
|
|
60
|
+
const mode = this.dataset.overlay || "mobile";
|
|
61
|
+
return mode === "always" || (mode === "mobile" && this.media.matches);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
private isOpen = () => this.toggleButton?.getAttribute("aria-expanded") === "true";
|
|
65
|
+
private label = (state: "open" | "close") =>
|
|
66
|
+
this.dataset[state === "open" ? "openLabel" : "closeLabel"] ??
|
|
67
|
+
(state === "open" ? "Open menu" : "Close menu");
|
|
68
|
+
|
|
69
|
+
private setToggleState = (expanded: boolean) => {
|
|
70
|
+
if (!this.toggleButton) return;
|
|
71
|
+
const label = this.label(expanded ? "close" : "open");
|
|
72
|
+
this.toggleButton.setAttribute("aria-expanded", String(expanded));
|
|
73
|
+
this.toggleButton.setAttribute("aria-label", label);
|
|
74
|
+
const accessibleLabel = this.toggleButton.querySelector<HTMLElement>(".sr-only");
|
|
75
|
+
if (accessibleLabel) accessibleLabel.textContent = label;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Locked on <html>, not <body>: with a non-visible overflow on <html> (the site clips it
|
|
79
|
+
// horizontally) a locked <body> becomes a scroll container of its own, and the sticky
|
|
80
|
+
// header stops sticking and jumps away from the open menu.
|
|
81
|
+
private lockDocumentScroll = () => {
|
|
82
|
+
if (scrollLocks.has(this)) return;
|
|
83
|
+
if (scrollLocks.size === 0) {
|
|
84
|
+
previousRootOverflow = document.documentElement.style.overflow;
|
|
85
|
+
document.documentElement.style.overflow = "hidden";
|
|
86
|
+
}
|
|
87
|
+
scrollLocks.add(this);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
private unlockDocumentScroll = () => {
|
|
91
|
+
if (!scrollLocks.delete(this)) return;
|
|
92
|
+
if (scrollLocks.size === 0) document.documentElement.style.overflow = previousRootOverflow;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
private open = () => {
|
|
96
|
+
if (!this.toggleButton || !this.panel) return;
|
|
97
|
+
window.clearTimeout(this.closeTimer);
|
|
98
|
+
this.panel.hidden = false;
|
|
99
|
+
this.panel.inert = false;
|
|
100
|
+
if (this.backdrop) this.backdrop.hidden = false;
|
|
101
|
+
this.setToggleState(true);
|
|
102
|
+
this.lockDocumentScroll();
|
|
103
|
+
// Commit the closed styles once the panel is displayed, so the open state transitions.
|
|
104
|
+
void this.panel.offsetWidth;
|
|
105
|
+
requestAnimationFrame(() => {
|
|
106
|
+
this.panel?.setAttribute("data-sf-motion-state", "open");
|
|
107
|
+
this.backdrop?.setAttribute("data-sf-motion-state", "open");
|
|
108
|
+
// The panel only becomes focusable once the open state has been rendered.
|
|
109
|
+
requestAnimationFrame(() => {
|
|
110
|
+
if (this.isOpen()) this.panel?.querySelector<HTMLElement>(FOCUSABLE)?.focus();
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
private close = (restoreFocus = false, immediate = false) => {
|
|
116
|
+
if (!this.toggleButton || !this.panel) return;
|
|
117
|
+
this.setToggleState(false);
|
|
118
|
+
this.panel.inert = true;
|
|
119
|
+
this.panel.setAttribute("data-sf-motion-state", "closed");
|
|
120
|
+
this.backdrop?.setAttribute("data-sf-motion-state", "closed");
|
|
121
|
+
this.querySelectorAll("details[open]").forEach((details) => details.removeAttribute("open"));
|
|
122
|
+
this.unlockDocumentScroll();
|
|
123
|
+
|
|
124
|
+
const reducedMotion = getMotionPreference() === "reduce";
|
|
125
|
+
const delay = immediate || reducedMotion ? 0 : SF_MOTION_DRAWER_EXIT_MS;
|
|
126
|
+
window.clearTimeout(this.closeTimer);
|
|
127
|
+
this.closeTimer = window.setTimeout(() => {
|
|
128
|
+
if (!this.isOpen() && this.usesOverlay()) {
|
|
129
|
+
if (this.panel) this.panel.hidden = true;
|
|
130
|
+
if (this.backdrop) this.backdrop.hidden = true;
|
|
131
|
+
}
|
|
132
|
+
}, delay);
|
|
133
|
+
if (restoreFocus) this.toggleButton.focus();
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
private syncMode = () => {
|
|
137
|
+
if (!this.toggleButton || !this.panel) return;
|
|
138
|
+
const overlay = this.usesOverlay();
|
|
139
|
+
this.dataset.overlayActive = String(overlay);
|
|
140
|
+
this.toggleButton.hidden = !overlay;
|
|
141
|
+
if (overlay) {
|
|
142
|
+
this.close(false, true);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
window.clearTimeout(this.closeTimer);
|
|
147
|
+
this.setToggleState(false);
|
|
148
|
+
this.panel.hidden = false;
|
|
149
|
+
this.panel.inert = false;
|
|
150
|
+
this.panel.setAttribute("data-sf-motion-state", "open");
|
|
151
|
+
if (this.backdrop) {
|
|
152
|
+
this.backdrop.hidden = true;
|
|
153
|
+
this.backdrop.setAttribute("data-sf-motion-state", "closed");
|
|
154
|
+
}
|
|
155
|
+
this.unlockDocumentScroll();
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
private handleToggle = () => this.isOpen() ? this.close(true) : this.open();
|
|
159
|
+
private handleBackdrop = () => this.close(true);
|
|
160
|
+
private handlePanelClick = (event: Event) => {
|
|
161
|
+
if (this.usesOverlay() && event.target instanceof Element && event.target.closest("a")) {
|
|
162
|
+
this.close(false);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
private handleDisclosure = (event: Event) => {
|
|
166
|
+
const current = event.currentTarget;
|
|
167
|
+
if (!(current instanceof HTMLDetailsElement) || !current.open) return;
|
|
168
|
+
current.closest("ul")?.querySelectorAll<HTMLDetailsElement>(":scope > li > details[open]")
|
|
169
|
+
.forEach((details) => {
|
|
170
|
+
if (details !== current) details.removeAttribute("open");
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
private handleOutsidePointer = (event: PointerEvent) => {
|
|
174
|
+
if (this.usesOverlay() || this.contains(event.target as Node)) return;
|
|
175
|
+
this.querySelectorAll("details[open]").forEach((details) => details.removeAttribute("open"));
|
|
176
|
+
};
|
|
177
|
+
private handleKeydown = (event: KeyboardEvent) => {
|
|
178
|
+
if (event.key === "Escape") {
|
|
179
|
+
if (this.usesOverlay() && this.isOpen()) {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
this.close(true);
|
|
182
|
+
} else {
|
|
183
|
+
const disclosure = this.querySelector<HTMLDetailsElement>("details[open]");
|
|
184
|
+
if (disclosure) {
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
disclosure.removeAttribute("open");
|
|
187
|
+
disclosure.querySelector<HTMLElement>("summary")?.focus();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (event.key !== "Tab" || !this.usesOverlay() || !this.isOpen() || !this.panel || !this.toggleButton) return;
|
|
193
|
+
// The toggle closes the menu, so it belongs to the same tab cycle as the links.
|
|
194
|
+
const focusable = [this.toggleButton, ...this.panel.querySelectorAll<HTMLElement>(FOCUSABLE)]
|
|
195
|
+
.filter((element): element is HTMLElement => element instanceof HTMLElement)
|
|
196
|
+
.filter((element) => !element.hasAttribute("disabled") && !element.closest("[inert]"));
|
|
197
|
+
const visibleFocusable = focusable.filter((element) => element.getClientRects().length > 0);
|
|
198
|
+
const first = visibleFocusable[0];
|
|
199
|
+
const last = visibleFocusable[visibleFocusable.length - 1];
|
|
200
|
+
if (!first || !last) return;
|
|
201
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
last.focus();
|
|
204
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
205
|
+
event.preventDefault();
|
|
206
|
+
first.focus();
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function registerFlowpressNavigation() {
|
|
212
|
+
if (!customElements.get("flowpress-navigation")) {
|
|
213
|
+
customElements.define("flowpress-navigation", FlowpressNavigation);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* Scoped structural navigation. StyleFlow supplies its colors, spacing and type. */
|
|
2
|
+
flowpress-navigation { display: block; position: relative; }
|
|
3
|
+
flowpress-navigation .site-nav__list { list-style: none; }
|
|
4
|
+
flowpress-navigation .site-nav__toggle[hidden], flowpress-navigation [hidden] { display: none; }
|
|
5
|
+
flowpress-navigation .site-nav__toggle { min-inline-size: 2.75rem; min-block-size: 2.75rem; }
|
|
6
|
+
flowpress-navigation .site-nav__panel { position: relative; }
|
|
7
|
+
flowpress-navigation[data-ready="true"][data-overlay-active="true"] .site-nav__panel { position: absolute; inset-block-start: 100%; inset-inline: 0; z-index: var(--fp-navigation-z, 20); }
|
|
8
|
+
flowpress-navigation .site-nav__sheet { position: absolute; inset: 0; z-index: -1; }
|
|
9
|
+
flowpress-navigation .site-nav__backdrop { position: fixed; inset: 0; z-index: var(--fp-navigation-backdrop-z, -1); }
|
|
10
|
+
flowpress-navigation[data-overlay-active="false"][data-orientation="horizontal"] .site-nav__list { flex-direction: row; flex-wrap: wrap; }
|
|
11
|
+
flowpress-navigation .site-nav__summary { cursor: pointer; }
|
|
12
|
+
flowpress-navigation .site-nav__link:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
|
|
13
|
+
flowpress-navigation .sf-motion-menu-toggle__icon { display: block; inline-size: 1.25rem; block-size: 1.25rem; position: relative; }
|
|
14
|
+
flowpress-navigation .sf-motion-menu-toggle__line { position: absolute; inset-inline: 0; block-size: 2px; background: currentColor; inset-block-start: 35%; }
|
|
15
|
+
flowpress-navigation .sf-motion-menu-toggle__line + .sf-motion-menu-toggle__line { inset-block-start: 65%; }
|
|
16
|
+
flowpress-navigation [aria-expanded="true"] .sf-motion-menu-toggle__line { inset-block-start: 50%; transform: rotate(45deg); }
|
|
17
|
+
flowpress-navigation [aria-expanded="true"] .sf-motion-menu-toggle__line + .sf-motion-menu-toggle__line { transform: rotate(-45deg); }
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/* Exact logical viewport offset for grid items inside nested Styleflow containers. */
|
|
2
|
+
(function () {
|
|
3
|
+
const breakpoints = ["base", "sm", "md", "lg", "xl", "2xl"];
|
|
4
|
+
const thresholds = [0, 640, 768, 1024, 1280, 1536];
|
|
5
|
+
const installed = new WeakSet();
|
|
6
|
+
const resizeObservers = new WeakMap();
|
|
7
|
+
const resizeObserved = new WeakMap();
|
|
8
|
+
|
|
9
|
+
const setOffset = (element, property, value) => {
|
|
10
|
+
if (element.style.getPropertyValue(property) !== value) {
|
|
11
|
+
element.style.setProperty(property, value);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const update = (doc) => {
|
|
16
|
+
if (!doc?.defaultView) return;
|
|
17
|
+
const win = doc.defaultView;
|
|
18
|
+
const viewportWidth = doc.documentElement.clientWidth;
|
|
19
|
+
const breakpoint = breakpoints.reduce((current, name, index) =>
|
|
20
|
+
win.innerWidth >= thresholds[index] ? name : current, "base");
|
|
21
|
+
for (const item of doc.querySelectorAll(".fp-grid > .fp-bleed-managed")) {
|
|
22
|
+
const grid = item.parentElement;
|
|
23
|
+
const container = grid.closest('[data-layout-role="container"], .sf-container');
|
|
24
|
+
const resizeObserver = resizeObservers.get(doc);
|
|
25
|
+
const observed = resizeObserved.get(doc);
|
|
26
|
+
for (const element of [grid, container]) {
|
|
27
|
+
if (element && !observed?.has(element)) {
|
|
28
|
+
resizeObserver?.observe(element);
|
|
29
|
+
observed?.add(element);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (!container) {
|
|
33
|
+
item.style.removeProperty("--fp-bleed-start-offset");
|
|
34
|
+
item.style.removeProperty("--fp-bleed-end-offset");
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const active = item.classList.contains(`fp-bleed-${breakpoint}-start`) ||
|
|
38
|
+
item.classList.contains(`fp-bleed-${breakpoint}-end`);
|
|
39
|
+
if (!active) continue;
|
|
40
|
+
const rect = grid.getBoundingClientRect();
|
|
41
|
+
const style = win.getComputedStyle(grid);
|
|
42
|
+
const rtl = style.direction === "rtl";
|
|
43
|
+
const insetStart = (Number.parseFloat(style.paddingInlineStart) || 0) +
|
|
44
|
+
(Number.parseFloat(style.borderInlineStartWidth) || 0);
|
|
45
|
+
const insetEnd = (Number.parseFloat(style.paddingInlineEnd) || 0) +
|
|
46
|
+
(Number.parseFloat(style.borderInlineEndWidth) || 0);
|
|
47
|
+
const start = rtl ? viewportWidth - rect.right + insetStart : rect.left + insetStart;
|
|
48
|
+
const end = rtl ? rect.left + insetEnd : viewportWidth - rect.right + insetEnd;
|
|
49
|
+
setOffset(item, "--fp-bleed-start-offset", `${-Math.max(0, start)}px`);
|
|
50
|
+
setOffset(item, "--fp-bleed-end-offset", `${-Math.max(0, end)}px`);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const install = (doc) => {
|
|
55
|
+
if (!doc?.body || installed.has(doc)) return;
|
|
56
|
+
installed.add(doc);
|
|
57
|
+
let scheduled = false;
|
|
58
|
+
const schedule = () => {
|
|
59
|
+
if (scheduled) return;
|
|
60
|
+
scheduled = true;
|
|
61
|
+
doc.defaultView.requestAnimationFrame(() => {
|
|
62
|
+
scheduled = false;
|
|
63
|
+
update(doc);
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const observer = new MutationObserver((mutations) => {
|
|
67
|
+
if (mutations.some((mutation) => mutation.type === "childList" ||
|
|
68
|
+
(mutation.type === "attributes" &&
|
|
69
|
+
(mutation.target.classList.contains("fp-grid") ||
|
|
70
|
+
mutation.target.classList.contains("fp-bleed-managed") ||
|
|
71
|
+
["data-layout-role", "data-layout-density", "dir"].includes(mutation.attributeName))))) {
|
|
72
|
+
schedule();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
observer.observe(doc.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["class", "data-layout-role", "data-layout-density", "dir"] });
|
|
76
|
+
doc.defaultView.addEventListener("resize", schedule, { passive: true });
|
|
77
|
+
const resizeObserver = new ResizeObserver(schedule);
|
|
78
|
+
resizeObservers.set(doc, resizeObserver);
|
|
79
|
+
resizeObserved.set(doc, new WeakSet());
|
|
80
|
+
resizeObserver.observe(doc.documentElement);
|
|
81
|
+
update(doc);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const installCanvas = () => {
|
|
85
|
+
install(document);
|
|
86
|
+
for (const frame of document.querySelectorAll('iframe[name="editor-canvas"]')) {
|
|
87
|
+
try {
|
|
88
|
+
install(frame.contentDocument);
|
|
89
|
+
if (!frame.dataset.fpGridBleedListener) {
|
|
90
|
+
frame.addEventListener("load", installCanvas);
|
|
91
|
+
frame.dataset.fpGridBleedListener = "true";
|
|
92
|
+
}
|
|
93
|
+
} catch {
|
|
94
|
+
// The WordPress canvas is same-origin; ignore unrelated frames.
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
window.flowpressGridBleedUpdate = update;
|
|
100
|
+
if (document.readyState === "loading") {
|
|
101
|
+
document.addEventListener("DOMContentLoaded", installCanvas, { once: true });
|
|
102
|
+
} else {
|
|
103
|
+
installCanvas();
|
|
104
|
+
}
|
|
105
|
+
new MutationObserver(installCanvas).observe(document.documentElement, { childList: true, subtree: true });
|
|
106
|
+
})();
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/* Shared by Gutenberg, WordPress output and Astro. Geometry only; Styleflow owns spacing. */
|
|
2
|
+
[data-layout-role="container"], .sf-container { container: sf-container / inline-size; }
|
|
3
|
+
.fp-grid { display: grid !important; --fp-current-cols: 1; grid-template-columns: repeat(var(--fp-current-cols), minmax(0, 1fr)) !important; }
|
|
4
|
+
.fp-grid > .fp-grid-item { min-width: 0; --fp-used-span: 1; grid-column: span var(--fp-used-span) !important; }
|
|
5
|
+
.fp-align-start { align-items: start; }
|
|
6
|
+
.fp-align-center { align-items: center; }
|
|
7
|
+
.fp-align-end { align-items: end; }
|
|
8
|
+
.fp-align-stretch { align-items: stretch; }
|
|
9
|
+
.fp-grid > .fp-bleed-managed { margin-inline-start: 0; margin-inline-end: 0; }
|
|
10
|
+
.fp-cols-base-1 { --fp-current-cols: 1; }
|
|
11
|
+
.fp-grid > .fp-used-span-base-1 { --fp-used-span: 1; }
|
|
12
|
+
.fp-cols-base-2 { --fp-current-cols: 2; }
|
|
13
|
+
.fp-grid > .fp-used-span-base-2 { --fp-used-span: 2; }
|
|
14
|
+
.fp-cols-base-3 { --fp-current-cols: 3; }
|
|
15
|
+
.fp-grid > .fp-used-span-base-3 { --fp-used-span: 3; }
|
|
16
|
+
.fp-cols-base-4 { --fp-current-cols: 4; }
|
|
17
|
+
.fp-grid > .fp-used-span-base-4 { --fp-used-span: 4; }
|
|
18
|
+
.fp-cols-base-5 { --fp-current-cols: 5; }
|
|
19
|
+
.fp-grid > .fp-used-span-base-5 { --fp-used-span: 5; }
|
|
20
|
+
.fp-cols-base-6 { --fp-current-cols: 6; }
|
|
21
|
+
.fp-grid > .fp-used-span-base-6 { --fp-used-span: 6; }
|
|
22
|
+
.fp-cols-base-7 { --fp-current-cols: 7; }
|
|
23
|
+
.fp-grid > .fp-used-span-base-7 { --fp-used-span: 7; }
|
|
24
|
+
.fp-cols-base-8 { --fp-current-cols: 8; }
|
|
25
|
+
.fp-grid > .fp-used-span-base-8 { --fp-used-span: 8; }
|
|
26
|
+
.fp-cols-base-9 { --fp-current-cols: 9; }
|
|
27
|
+
.fp-grid > .fp-used-span-base-9 { --fp-used-span: 9; }
|
|
28
|
+
.fp-cols-base-10 { --fp-current-cols: 10; }
|
|
29
|
+
.fp-grid > .fp-used-span-base-10 { --fp-used-span: 10; }
|
|
30
|
+
.fp-cols-base-11 { --fp-current-cols: 11; }
|
|
31
|
+
.fp-grid > .fp-used-span-base-11 { --fp-used-span: 11; }
|
|
32
|
+
.fp-cols-base-12 { --fp-current-cols: 12; }
|
|
33
|
+
.fp-grid > .fp-used-span-base-12 { --fp-used-span: 12; }
|
|
34
|
+
@media (width < 640px) { @container sf-container (min-width: 0px) { .fp-grid > .fp-bleed-base-start { margin-inline-start: var(--fp-bleed-start-offset, 0px); inline-size: auto; max-inline-size: none; justify-self: stretch; } } }
|
|
35
|
+
@media (width < 640px) { @container sf-container (min-width: 0px) { .fp-grid > .fp-bleed-base-end { margin-inline-end: var(--fp-bleed-end-offset, 0px); inline-size: auto; max-inline-size: none; justify-self: stretch; } } }
|
|
36
|
+
@media (min-width: 640px) {
|
|
37
|
+
.fp-cols-sm-1 { --fp-current-cols: 1; }
|
|
38
|
+
.fp-grid > .fp-used-span-sm-1 { --fp-used-span: 1; }
|
|
39
|
+
.fp-cols-sm-2 { --fp-current-cols: 2; }
|
|
40
|
+
.fp-grid > .fp-used-span-sm-2 { --fp-used-span: 2; }
|
|
41
|
+
.fp-cols-sm-3 { --fp-current-cols: 3; }
|
|
42
|
+
.fp-grid > .fp-used-span-sm-3 { --fp-used-span: 3; }
|
|
43
|
+
.fp-cols-sm-4 { --fp-current-cols: 4; }
|
|
44
|
+
.fp-grid > .fp-used-span-sm-4 { --fp-used-span: 4; }
|
|
45
|
+
.fp-cols-sm-5 { --fp-current-cols: 5; }
|
|
46
|
+
.fp-grid > .fp-used-span-sm-5 { --fp-used-span: 5; }
|
|
47
|
+
.fp-cols-sm-6 { --fp-current-cols: 6; }
|
|
48
|
+
.fp-grid > .fp-used-span-sm-6 { --fp-used-span: 6; }
|
|
49
|
+
.fp-cols-sm-7 { --fp-current-cols: 7; }
|
|
50
|
+
.fp-grid > .fp-used-span-sm-7 { --fp-used-span: 7; }
|
|
51
|
+
.fp-cols-sm-8 { --fp-current-cols: 8; }
|
|
52
|
+
.fp-grid > .fp-used-span-sm-8 { --fp-used-span: 8; }
|
|
53
|
+
.fp-cols-sm-9 { --fp-current-cols: 9; }
|
|
54
|
+
.fp-grid > .fp-used-span-sm-9 { --fp-used-span: 9; }
|
|
55
|
+
.fp-cols-sm-10 { --fp-current-cols: 10; }
|
|
56
|
+
.fp-grid > .fp-used-span-sm-10 { --fp-used-span: 10; }
|
|
57
|
+
.fp-cols-sm-11 { --fp-current-cols: 11; }
|
|
58
|
+
.fp-grid > .fp-used-span-sm-11 { --fp-used-span: 11; }
|
|
59
|
+
.fp-cols-sm-12 { --fp-current-cols: 12; }
|
|
60
|
+
.fp-grid > .fp-used-span-sm-12 { --fp-used-span: 12; }
|
|
61
|
+
.fp-grid > .fp-bleed-managed { margin-inline-start: 0; margin-inline-end: 0; }
|
|
62
|
+
@media (width < 768px) { @container sf-container (min-width: 0px) { .fp-grid > .fp-bleed-sm-start { margin-inline-start: var(--fp-bleed-start-offset, 0px); inline-size: auto; max-inline-size: none; justify-self: stretch; } } }
|
|
63
|
+
@media (width < 768px) { @container sf-container (min-width: 0px) { .fp-grid > .fp-bleed-sm-end { margin-inline-end: var(--fp-bleed-end-offset, 0px); inline-size: auto; max-inline-size: none; justify-self: stretch; } } }
|
|
64
|
+
}
|
|
65
|
+
@media (min-width: 768px) {
|
|
66
|
+
.fp-cols-md-1 { --fp-current-cols: 1; }
|
|
67
|
+
.fp-grid > .fp-used-span-md-1 { --fp-used-span: 1; }
|
|
68
|
+
.fp-cols-md-2 { --fp-current-cols: 2; }
|
|
69
|
+
.fp-grid > .fp-used-span-md-2 { --fp-used-span: 2; }
|
|
70
|
+
.fp-cols-md-3 { --fp-current-cols: 3; }
|
|
71
|
+
.fp-grid > .fp-used-span-md-3 { --fp-used-span: 3; }
|
|
72
|
+
.fp-cols-md-4 { --fp-current-cols: 4; }
|
|
73
|
+
.fp-grid > .fp-used-span-md-4 { --fp-used-span: 4; }
|
|
74
|
+
.fp-cols-md-5 { --fp-current-cols: 5; }
|
|
75
|
+
.fp-grid > .fp-used-span-md-5 { --fp-used-span: 5; }
|
|
76
|
+
.fp-cols-md-6 { --fp-current-cols: 6; }
|
|
77
|
+
.fp-grid > .fp-used-span-md-6 { --fp-used-span: 6; }
|
|
78
|
+
.fp-cols-md-7 { --fp-current-cols: 7; }
|
|
79
|
+
.fp-grid > .fp-used-span-md-7 { --fp-used-span: 7; }
|
|
80
|
+
.fp-cols-md-8 { --fp-current-cols: 8; }
|
|
81
|
+
.fp-grid > .fp-used-span-md-8 { --fp-used-span: 8; }
|
|
82
|
+
.fp-cols-md-9 { --fp-current-cols: 9; }
|
|
83
|
+
.fp-grid > .fp-used-span-md-9 { --fp-used-span: 9; }
|
|
84
|
+
.fp-cols-md-10 { --fp-current-cols: 10; }
|
|
85
|
+
.fp-grid > .fp-used-span-md-10 { --fp-used-span: 10; }
|
|
86
|
+
.fp-cols-md-11 { --fp-current-cols: 11; }
|
|
87
|
+
.fp-grid > .fp-used-span-md-11 { --fp-used-span: 11; }
|
|
88
|
+
.fp-cols-md-12 { --fp-current-cols: 12; }
|
|
89
|
+
.fp-grid > .fp-used-span-md-12 { --fp-used-span: 12; }
|
|
90
|
+
.fp-grid > .fp-bleed-managed { margin-inline-start: 0; margin-inline-end: 0; }
|
|
91
|
+
@media (width < 1024px) { @container sf-container (min-width: 0px) { .fp-grid > .fp-bleed-md-start { margin-inline-start: var(--fp-bleed-start-offset, 0px); inline-size: auto; max-inline-size: none; justify-self: stretch; } } }
|
|
92
|
+
@media (width < 1024px) { @container sf-container (min-width: 0px) { .fp-grid > .fp-bleed-md-end { margin-inline-end: var(--fp-bleed-end-offset, 0px); inline-size: auto; max-inline-size: none; justify-self: stretch; } } }
|
|
93
|
+
}
|
|
94
|
+
@media (min-width: 1024px) {
|
|
95
|
+
.fp-cols-lg-1 { --fp-current-cols: 1; }
|
|
96
|
+
.fp-grid > .fp-used-span-lg-1 { --fp-used-span: 1; }
|
|
97
|
+
.fp-cols-lg-2 { --fp-current-cols: 2; }
|
|
98
|
+
.fp-grid > .fp-used-span-lg-2 { --fp-used-span: 2; }
|
|
99
|
+
.fp-cols-lg-3 { --fp-current-cols: 3; }
|
|
100
|
+
.fp-grid > .fp-used-span-lg-3 { --fp-used-span: 3; }
|
|
101
|
+
.fp-cols-lg-4 { --fp-current-cols: 4; }
|
|
102
|
+
.fp-grid > .fp-used-span-lg-4 { --fp-used-span: 4; }
|
|
103
|
+
.fp-cols-lg-5 { --fp-current-cols: 5; }
|
|
104
|
+
.fp-grid > .fp-used-span-lg-5 { --fp-used-span: 5; }
|
|
105
|
+
.fp-cols-lg-6 { --fp-current-cols: 6; }
|
|
106
|
+
.fp-grid > .fp-used-span-lg-6 { --fp-used-span: 6; }
|
|
107
|
+
.fp-cols-lg-7 { --fp-current-cols: 7; }
|
|
108
|
+
.fp-grid > .fp-used-span-lg-7 { --fp-used-span: 7; }
|
|
109
|
+
.fp-cols-lg-8 { --fp-current-cols: 8; }
|
|
110
|
+
.fp-grid > .fp-used-span-lg-8 { --fp-used-span: 8; }
|
|
111
|
+
.fp-cols-lg-9 { --fp-current-cols: 9; }
|
|
112
|
+
.fp-grid > .fp-used-span-lg-9 { --fp-used-span: 9; }
|
|
113
|
+
.fp-cols-lg-10 { --fp-current-cols: 10; }
|
|
114
|
+
.fp-grid > .fp-used-span-lg-10 { --fp-used-span: 10; }
|
|
115
|
+
.fp-cols-lg-11 { --fp-current-cols: 11; }
|
|
116
|
+
.fp-grid > .fp-used-span-lg-11 { --fp-used-span: 11; }
|
|
117
|
+
.fp-cols-lg-12 { --fp-current-cols: 12; }
|
|
118
|
+
.fp-grid > .fp-used-span-lg-12 { --fp-used-span: 12; }
|
|
119
|
+
.fp-grid > .fp-bleed-managed { margin-inline-start: 0; margin-inline-end: 0; }
|
|
120
|
+
@media (width < 1280px) { @container sf-container (min-width: 0px) { .fp-grid > .fp-bleed-lg-start { margin-inline-start: var(--fp-bleed-start-offset, 0px); inline-size: auto; max-inline-size: none; justify-self: stretch; } } }
|
|
121
|
+
@media (width < 1280px) { @container sf-container (min-width: 0px) { .fp-grid > .fp-bleed-lg-end { margin-inline-end: var(--fp-bleed-end-offset, 0px); inline-size: auto; max-inline-size: none; justify-self: stretch; } } }
|
|
122
|
+
}
|
|
123
|
+
@media (min-width: 1280px) {
|
|
124
|
+
.fp-cols-xl-1 { --fp-current-cols: 1; }
|
|
125
|
+
.fp-grid > .fp-used-span-xl-1 { --fp-used-span: 1; }
|
|
126
|
+
.fp-cols-xl-2 { --fp-current-cols: 2; }
|
|
127
|
+
.fp-grid > .fp-used-span-xl-2 { --fp-used-span: 2; }
|
|
128
|
+
.fp-cols-xl-3 { --fp-current-cols: 3; }
|
|
129
|
+
.fp-grid > .fp-used-span-xl-3 { --fp-used-span: 3; }
|
|
130
|
+
.fp-cols-xl-4 { --fp-current-cols: 4; }
|
|
131
|
+
.fp-grid > .fp-used-span-xl-4 { --fp-used-span: 4; }
|
|
132
|
+
.fp-cols-xl-5 { --fp-current-cols: 5; }
|
|
133
|
+
.fp-grid > .fp-used-span-xl-5 { --fp-used-span: 5; }
|
|
134
|
+
.fp-cols-xl-6 { --fp-current-cols: 6; }
|
|
135
|
+
.fp-grid > .fp-used-span-xl-6 { --fp-used-span: 6; }
|
|
136
|
+
.fp-cols-xl-7 { --fp-current-cols: 7; }
|
|
137
|
+
.fp-grid > .fp-used-span-xl-7 { --fp-used-span: 7; }
|
|
138
|
+
.fp-cols-xl-8 { --fp-current-cols: 8; }
|
|
139
|
+
.fp-grid > .fp-used-span-xl-8 { --fp-used-span: 8; }
|
|
140
|
+
.fp-cols-xl-9 { --fp-current-cols: 9; }
|
|
141
|
+
.fp-grid > .fp-used-span-xl-9 { --fp-used-span: 9; }
|
|
142
|
+
.fp-cols-xl-10 { --fp-current-cols: 10; }
|
|
143
|
+
.fp-grid > .fp-used-span-xl-10 { --fp-used-span: 10; }
|
|
144
|
+
.fp-cols-xl-11 { --fp-current-cols: 11; }
|
|
145
|
+
.fp-grid > .fp-used-span-xl-11 { --fp-used-span: 11; }
|
|
146
|
+
.fp-cols-xl-12 { --fp-current-cols: 12; }
|
|
147
|
+
.fp-grid > .fp-used-span-xl-12 { --fp-used-span: 12; }
|
|
148
|
+
.fp-grid > .fp-bleed-managed { margin-inline-start: 0; margin-inline-end: 0; }
|
|
149
|
+
@media (width < 1536px) { @container sf-container (min-width: 0px) { .fp-grid > .fp-bleed-xl-start { margin-inline-start: var(--fp-bleed-start-offset, 0px); inline-size: auto; max-inline-size: none; justify-self: stretch; } } }
|
|
150
|
+
@media (width < 1536px) { @container sf-container (min-width: 0px) { .fp-grid > .fp-bleed-xl-end { margin-inline-end: var(--fp-bleed-end-offset, 0px); inline-size: auto; max-inline-size: none; justify-self: stretch; } } }
|
|
151
|
+
}
|
|
152
|
+
@media (min-width: 1536px) {
|
|
153
|
+
.fp-cols-2xl-1 { --fp-current-cols: 1; }
|
|
154
|
+
.fp-grid > .fp-used-span-2xl-1 { --fp-used-span: 1; }
|
|
155
|
+
.fp-cols-2xl-2 { --fp-current-cols: 2; }
|
|
156
|
+
.fp-grid > .fp-used-span-2xl-2 { --fp-used-span: 2; }
|
|
157
|
+
.fp-cols-2xl-3 { --fp-current-cols: 3; }
|
|
158
|
+
.fp-grid > .fp-used-span-2xl-3 { --fp-used-span: 3; }
|
|
159
|
+
.fp-cols-2xl-4 { --fp-current-cols: 4; }
|
|
160
|
+
.fp-grid > .fp-used-span-2xl-4 { --fp-used-span: 4; }
|
|
161
|
+
.fp-cols-2xl-5 { --fp-current-cols: 5; }
|
|
162
|
+
.fp-grid > .fp-used-span-2xl-5 { --fp-used-span: 5; }
|
|
163
|
+
.fp-cols-2xl-6 { --fp-current-cols: 6; }
|
|
164
|
+
.fp-grid > .fp-used-span-2xl-6 { --fp-used-span: 6; }
|
|
165
|
+
.fp-cols-2xl-7 { --fp-current-cols: 7; }
|
|
166
|
+
.fp-grid > .fp-used-span-2xl-7 { --fp-used-span: 7; }
|
|
167
|
+
.fp-cols-2xl-8 { --fp-current-cols: 8; }
|
|
168
|
+
.fp-grid > .fp-used-span-2xl-8 { --fp-used-span: 8; }
|
|
169
|
+
.fp-cols-2xl-9 { --fp-current-cols: 9; }
|
|
170
|
+
.fp-grid > .fp-used-span-2xl-9 { --fp-used-span: 9; }
|
|
171
|
+
.fp-cols-2xl-10 { --fp-current-cols: 10; }
|
|
172
|
+
.fp-grid > .fp-used-span-2xl-10 { --fp-used-span: 10; }
|
|
173
|
+
.fp-cols-2xl-11 { --fp-current-cols: 11; }
|
|
174
|
+
.fp-grid > .fp-used-span-2xl-11 { --fp-used-span: 11; }
|
|
175
|
+
.fp-cols-2xl-12 { --fp-current-cols: 12; }
|
|
176
|
+
.fp-grid > .fp-used-span-2xl-12 { --fp-used-span: 12; }
|
|
177
|
+
.fp-grid > .fp-bleed-managed { margin-inline-start: 0; margin-inline-end: 0; }
|
|
178
|
+
@container sf-container (min-width: 0px) { .fp-grid > .fp-bleed-2xl-start { margin-inline-start: var(--fp-bleed-start-offset, 0px); inline-size: auto; max-inline-size: none; justify-self: stretch; } }
|
|
179
|
+
@container sf-container (min-width: 0px) { .fp-grid > .fp-bleed-2xl-end { margin-inline-end: var(--fp-bleed-end-offset, 0px); inline-size: auto; max-inline-size: none; justify-self: stretch; } }
|
|
180
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FlowpressBlock } from "../../index.js";
|
|
2
|
+
export declare const gridBreakpoints: readonly ["base", "sm", "md", "lg", "xl", "2xl"];
|
|
3
|
+
export type GridBreakpoint = typeof gridBreakpoints[number];
|
|
4
|
+
type Values = Partial<Record<GridBreakpoint, number>>;
|
|
5
|
+
type GridAttributes = Record<string, any>;
|
|
6
|
+
export declare const isGrid: (name: string, attributes?: GridAttributes) => boolean;
|
|
7
|
+
export declare const gridValues: (attributes: GridAttributes) => Values;
|
|
8
|
+
export declare const spanValues: (attributes: GridAttributes) => Values;
|
|
9
|
+
export declare const effectiveValues: (values: Values) => Record<GridBreakpoint, number>;
|
|
10
|
+
export declare const gridClasses: (attributes: GridAttributes) => string[];
|
|
11
|
+
export declare const spanClasses: (attributes: GridAttributes) => string[];
|
|
12
|
+
export declare const usedSpanClasses: (parent: GridAttributes, child: GridAttributes) => string[];
|
|
13
|
+
export declare const bleedClasses: (parent: GridAttributes, children: GridAttributes[]) => string[][];
|
|
14
|
+
/** Adds render-only classes. Gutenberg's serialized block HTML is never changed. */
|
|
15
|
+
export declare const decorateGridBlocks: (blocks: FlowpressBlock[]) => FlowpressBlock[];
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../src/astro/native/grid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,eAAO,MAAM,eAAe,kDAAmD,CAAC;AAChF,MAAM,MAAM,cAAc,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AAC5D,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AACtD,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAO1C,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,EAAE,aAAY,cAAmB,KAAG,OAEhC,CAAC;AAExC,eAAO,MAAM,UAAU,GAAI,YAAY,cAAc,KAAG,MAQvD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,YAAY,cAAc,KAAG,MAQvD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,MAAM,CAAC,cAAc,EAAE,MAAM,CAM7E,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,YAAY,cAAc,KAAG,MAAM,EAQ9D,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,YAAY,cAAc,KAAG,MAAM,EAK9D,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,QAAQ,cAAc,EAAE,OAAO,cAAc,KAAG,MAAM,EAMrF,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,QAAQ,cAAc,EAAE,UAAU,cAAc,EAAE,KAAG,MAAM,EAAE,EAsBzF,CAAC;AAOF,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,GAAI,QAAQ,cAAc,EAAE,KAAG,cAAc,EAkB1E,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export const gridBreakpoints = ["base", "sm", "md", "lg", "xl", "2xl"];
|
|
2
|
+
const count = (value, fallback) => {
|
|
3
|
+
const n = Number(value);
|
|
4
|
+
return Number.isInteger(n) && n >= 1 && n <= 12 ? n : fallback;
|
|
5
|
+
};
|
|
6
|
+
export const isGrid = (name, attributes = {}) => (name === "core/group" || name === "core/post-template" || name === "core/term-template")
|
|
7
|
+
&& attributes.layout?.type === "grid";
|
|
8
|
+
export const gridValues = (attributes) => {
|
|
9
|
+
const layout = attributes.layout || {};
|
|
10
|
+
const values = { base: count(layout.columnCount, 1) };
|
|
11
|
+
for (const breakpoint of gridBreakpoints.slice(1)) {
|
|
12
|
+
const value = layout.flowpressColumns?.[breakpoint];
|
|
13
|
+
if (value !== undefined)
|
|
14
|
+
values[breakpoint] = count(value, values.base);
|
|
15
|
+
}
|
|
16
|
+
return values;
|
|
17
|
+
};
|
|
18
|
+
export const spanValues = (attributes) => {
|
|
19
|
+
const layout = attributes.style?.layout || {};
|
|
20
|
+
const values = { base: count(layout.columnSpan, 1) };
|
|
21
|
+
for (const breakpoint of gridBreakpoints.slice(1)) {
|
|
22
|
+
const value = layout.flowpressGridSpan?.[breakpoint];
|
|
23
|
+
if (value !== undefined)
|
|
24
|
+
values[breakpoint] = count(value, values.base);
|
|
25
|
+
}
|
|
26
|
+
return values;
|
|
27
|
+
};
|
|
28
|
+
export const effectiveValues = (values) => {
|
|
29
|
+
let current = values.base ?? 1;
|
|
30
|
+
return Object.fromEntries(gridBreakpoints.map((breakpoint) => {
|
|
31
|
+
current = values[breakpoint] ?? current;
|
|
32
|
+
return [breakpoint, current];
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
export const gridClasses = (attributes) => {
|
|
36
|
+
const values = gridValues(attributes);
|
|
37
|
+
const align = attributes.layout?.flowpressAlign;
|
|
38
|
+
return [
|
|
39
|
+
"fp-grid",
|
|
40
|
+
...gridBreakpoints.flatMap((breakpoint) => values[breakpoint] ? [`fp-cols-${breakpoint}-${values[breakpoint]}`] : []),
|
|
41
|
+
...(["start", "center", "end", "stretch"].includes(align) ? [`fp-align-${align}`] : []),
|
|
42
|
+
];
|
|
43
|
+
};
|
|
44
|
+
export const spanClasses = (attributes) => {
|
|
45
|
+
const values = spanValues(attributes);
|
|
46
|
+
return ["fp-grid-item", ...gridBreakpoints.flatMap((breakpoint) => values[breakpoint] ? [`fp-span-${breakpoint}-${values[breakpoint]}`] : [])];
|
|
47
|
+
};
|
|
48
|
+
export const usedSpanClasses = (parent, child) => {
|
|
49
|
+
const columns = effectiveValues(gridValues(parent));
|
|
50
|
+
const spans = effectiveValues(spanValues(child));
|
|
51
|
+
return gridBreakpoints.map((breakpoint) => `fp-used-span-${breakpoint}-${Math.min(spans[breakpoint], columns[breakpoint])}`);
|
|
52
|
+
};
|
|
53
|
+
export const bleedClasses = (parent, children) => {
|
|
54
|
+
const columns = effectiveValues(gridValues(parent));
|
|
55
|
+
const spans = children.map((child) => effectiveValues(spanValues(child)));
|
|
56
|
+
const result = children.map((child) => child.style?.layout?.flowpressGridBleed ? ["fp-bleed-managed"] : []);
|
|
57
|
+
for (const breakpoint of gridBreakpoints) {
|
|
58
|
+
let position = 0;
|
|
59
|
+
children.forEach((child, index) => {
|
|
60
|
+
const width = Math.min(spans[index][breakpoint], columns[breakpoint]);
|
|
61
|
+
if (position + width > columns[breakpoint])
|
|
62
|
+
position = 0;
|
|
63
|
+
const start = position === 0;
|
|
64
|
+
const end = position + width === columns[breakpoint];
|
|
65
|
+
const bleed = child.style?.layout?.flowpressGridBleed;
|
|
66
|
+
const from = gridBreakpoints.indexOf(bleed?.from || "base");
|
|
67
|
+
if (bleed && gridBreakpoints.indexOf(breakpoint) >= from &&
|
|
68
|
+
((bleed.side === "start" && start) || (bleed.side === "end" && end))) {
|
|
69
|
+
result[index].push(`fp-bleed-${breakpoint}-${bleed.side}`);
|
|
70
|
+
}
|
|
71
|
+
position += width;
|
|
72
|
+
if (position === columns[breakpoint])
|
|
73
|
+
position = 0;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
};
|
|
78
|
+
const appendClasses = (attributes, classes) => ({
|
|
79
|
+
...attributes,
|
|
80
|
+
className: [...new Set([...(attributes.className || "").split(/\s+/), ...classes].filter(Boolean))].join(" "),
|
|
81
|
+
});
|
|
82
|
+
/** Adds render-only classes. Gutenberg's serialized block HTML is never changed. */
|
|
83
|
+
export const decorateGridBlocks = (blocks) => blocks.map((block) => {
|
|
84
|
+
const innerBlocks = block.innerBlocks ? decorateGridBlocks(block.innerBlocks) : undefined;
|
|
85
|
+
const attributes = (block.attributes || {});
|
|
86
|
+
if (!isGrid(block.name, attributes))
|
|
87
|
+
return innerBlocks ? { ...block, innerBlocks } : block;
|
|
88
|
+
const children = innerBlocks ?? [];
|
|
89
|
+
const bleed = bleedClasses(attributes, children.map((child) => child.attributes || {}));
|
|
90
|
+
return {
|
|
91
|
+
...block,
|
|
92
|
+
attributes: appendClasses({ layoutRole: "stack", density: "regular", ...attributes }, gridClasses(attributes)),
|
|
93
|
+
innerBlocks: children.map((child, index) => ({
|
|
94
|
+
...child,
|
|
95
|
+
attributes: appendClasses(child.attributes || {}, [
|
|
96
|
+
...spanClasses(child.attributes || {}),
|
|
97
|
+
...usedSpanClasses(attributes, child.attributes || {}),
|
|
98
|
+
...(bleed[index] ?? []),
|
|
99
|
+
]),
|
|
100
|
+
})),
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=grid.js.map
|