@styleflow.app/flowpress-astro-core 1.0.0-beta.2 → 1.0.0-beta.20
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 +146 -1
- package/README.md +111 -3
- package/dist/astro/BaseLayout.astro +10 -6
- package/dist/astro/CompositionRenderer.astro +148 -0
- package/dist/astro/DefaultBlockAdapter.astro +35 -0
- package/dist/astro/DefaultTemplate.astro +6 -1
- package/dist/astro/GutenbergRenderer.astro +231 -72
- package/dist/astro/ThemeRuntime.astro +24 -0
- package/dist/astro/blocks/CarouselBlock.astro +7 -9
- package/dist/astro/blocks/CarouselItemBlock.astro +3 -3
- package/dist/astro/blocks/ColumnBlock.astro +3 -4
- package/dist/astro/blocks/CoverBlock.astro +155 -0
- package/dist/astro/blocks/FormBlock.astro +18 -16
- package/dist/astro/blocks/GridBlock.astro +3 -3
- package/dist/astro/blocks/HeroBlock.astro +3 -4
- package/dist/astro/blocks/ImageBlock.astro +3 -4
- package/dist/astro/blocks/ListItemFallback.astro +7 -5
- package/dist/astro/blocks/NumberSpinnerBlock.astro +25 -19
- package/dist/astro/blocks/SemanticElement.astro +35 -0
- package/dist/astro/blocks/SiteLogoBlock.astro +53 -0
- package/dist/astro/blocks/TextBlock.astro +29 -25
- package/dist/astro/blocks/ThemeToggleBlock.astro +23 -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 +51 -41
- package/dist/astro/blocks/helpers.js.map +1 -1
- package/dist/astro/blocks/helpers.ts +63 -45
- package/dist/astro/native/Blob.astro +113 -0
- package/dist/astro/native/BlobBlock.astro +52 -0
- package/dist/astro/native/CustomFieldValue.astro +86 -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 +33 -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 +37 -0
- package/dist/astro/native/Timeline.astro +20 -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 +11 -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 +70 -0
- package/dist/astro/native/core-navigation-submenu.astro +32 -0
- package/dist/astro/native/core-navigation.astro +94 -0
- package/dist/astro/native/core-page-list-data-item.astro +18 -0
- package/dist/astro/native/core-page-list-item.astro +7 -0
- package/dist/astro/native/core-page-list.astro +40 -0
- package/dist/astro/native/core-post-date.astro +20 -0
- package/dist/astro/native/core-post-excerpt.astro +25 -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 +46 -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-site-title.astro +15 -0
- package/dist/astro/native/core-term-description.astro +12 -0
- package/dist/astro/native/core-term-name.astro +20 -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/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 +72 -0
- package/dist/astro/native/registry.js.map +1 -0
- package/dist/astro/native/registry.ts +72 -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/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 +107 -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 +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -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/styleflow.d.ts +16 -1
- package/dist/styleflow.d.ts.map +1 -1
- package/dist/styleflow.js +67 -7
- package/dist/styleflow.js.map +1 -1
- package/dist/templates.d.ts +16 -16
- package/dist/theme-runtime.d.ts +16 -0
- package/dist/theme-runtime.d.ts.map +1 -0
- package/dist/theme-runtime.js +77 -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/package.json +13 -4
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
import "./blob.css";
|
|
3
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
4
|
+
import { BLOB_BOX, BLOB_VARIANTS } from "./blob/blob-shapes.generated.js";
|
|
5
|
+
import {
|
|
6
|
+
morphDataAttributes,
|
|
7
|
+
resolveAspectRatio,
|
|
8
|
+
resolveContentFit,
|
|
9
|
+
resolveMorphConfig,
|
|
10
|
+
resolveOutlineWidth,
|
|
11
|
+
type BlobAspectRatio,
|
|
12
|
+
type BlobContentFit,
|
|
13
|
+
type BlobMorphMode,
|
|
14
|
+
} from "./blob/config.js";
|
|
15
|
+
import { shapeToPath } from "./blob/geometry.js";
|
|
16
|
+
import { nextBlobClipId } from "./blob/ids.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Organic mask that crops its slot. The fill takes the Styleflow props passed
|
|
20
|
+
* to the component (tone, intensity, surface, layoutRole, density, no*); the
|
|
21
|
+
* outline has its own tone/intensity. Variants 1-13 can morph into each other.
|
|
22
|
+
*/
|
|
23
|
+
interface Props {
|
|
24
|
+
/** 1-13. */
|
|
25
|
+
variant?: number | string | undefined;
|
|
26
|
+
/** `cover` stretches children over the whole shape, `center` keeps their size. */
|
|
27
|
+
contentFit?: BlobContentFit | undefined;
|
|
28
|
+
aspectRatio?: BlobAspectRatio | undefined;
|
|
29
|
+
/** Outline thickness in px; 0 hides it. */
|
|
30
|
+
outlineWidth?: number | string | undefined;
|
|
31
|
+
outlineTone?: string | undefined;
|
|
32
|
+
outlineIntensity?: string | undefined;
|
|
33
|
+
morph?: BlobMorphMode | undefined;
|
|
34
|
+
/** Variants to morph between, e.g. "2,5,9" or [2, 5, 9]; empty means all. */
|
|
35
|
+
morphTargets?: string | number[] | undefined;
|
|
36
|
+
morphDuration?: number | string | undefined;
|
|
37
|
+
/** Pause in ms between two automatic morphs. */
|
|
38
|
+
morphInterval?: number | string | undefined;
|
|
39
|
+
/** Attributes for the root element: id, class, aria-*, data-*. */
|
|
40
|
+
rootProps?: Record<string, unknown> | undefined;
|
|
41
|
+
[styleflowProp: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const {
|
|
45
|
+
variant,
|
|
46
|
+
contentFit,
|
|
47
|
+
aspectRatio,
|
|
48
|
+
outlineWidth,
|
|
49
|
+
outlineTone = "inherit",
|
|
50
|
+
outlineIntensity = "inherit",
|
|
51
|
+
morph,
|
|
52
|
+
morphTargets,
|
|
53
|
+
morphDuration,
|
|
54
|
+
morphInterval,
|
|
55
|
+
rootProps = {},
|
|
56
|
+
...fillProps
|
|
57
|
+
} = Astro.props;
|
|
58
|
+
|
|
59
|
+
const morphConfig = resolveMorphConfig(
|
|
60
|
+
{ variant, morph, targets: morphTargets, duration: morphDuration, interval: morphInterval },
|
|
61
|
+
BLOB_VARIANTS.length,
|
|
62
|
+
);
|
|
63
|
+
const base = BLOB_VARIANTS[morphConfig.base] ?? BLOB_VARIANTS[0]!;
|
|
64
|
+
const fillPath = shapeToPath(base.fill, BLOB_BOX);
|
|
65
|
+
const ringPath = shapeToPath(base.ring, BLOB_BOX);
|
|
66
|
+
const strokeWidth = resolveOutlineWidth(outlineWidth);
|
|
67
|
+
const clipId = nextBlobClipId();
|
|
68
|
+
|
|
69
|
+
// Authors leaving a Styleflow axis on "inherit" send nothing: keep a visible fill.
|
|
70
|
+
const authoredFill = Object.fromEntries(
|
|
71
|
+
Object.entries(fillProps).filter(([, value]) => value !== undefined && value !== null && value !== ""),
|
|
72
|
+
);
|
|
73
|
+
const shapeProps = { surface: "default", layoutRole: "none", ...authoredFill };
|
|
74
|
+
|
|
75
|
+
const { class: rootClassName, ...rootAttributes } = rootProps as Record<string, unknown> & { class?: string };
|
|
76
|
+
const rootClass = ["sf-blob", typeof rootClassName === "string" ? rootClassName : ""]
|
|
77
|
+
.filter(Boolean)
|
|
78
|
+
.join(" ");
|
|
79
|
+
const clipStyle = `clip-path:url(#${clipId})`;
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
<S.div
|
|
83
|
+
{...rootAttributes}
|
|
84
|
+
class={rootClass}
|
|
85
|
+
layoutRole="none"
|
|
86
|
+
data-sf-blob
|
|
87
|
+
{...morphDataAttributes(morphConfig)}
|
|
88
|
+
data-blob-fit={resolveContentFit(contentFit)}
|
|
89
|
+
data-blob-aspect={resolveAspectRatio(aspectRatio)}
|
|
90
|
+
>
|
|
91
|
+
<svg class="sf-blob__defs" width="0" height="0" aria-hidden="true" focusable="false">
|
|
92
|
+
<clipPath id={clipId} clipPathUnits="objectBoundingBox">
|
|
93
|
+
<path data-blob-clip-path d={fillPath}></path>
|
|
94
|
+
</clipPath>
|
|
95
|
+
</svg>
|
|
96
|
+
<!-- styleflow-ignore-next-line rule=sf-inline-style reason="Per-instance reference to the blob's SVG clip path" scope="project" -->
|
|
97
|
+
<S.div class="sf-blob__shape" {...shapeProps} data-blob-shape style={clipStyle}><slot /></S.div>
|
|
98
|
+
{strokeWidth > 0 ? (
|
|
99
|
+
<S.span class="sf-blob__ring" {...(outlineTone !== "inherit" ? {tone:outlineTone} : {})} {...(outlineIntensity !== "inherit" ? {intensity:outlineIntensity} : {})} aria-hidden="true">
|
|
100
|
+
<svg viewBox="0 0 1 1" preserveAspectRatio="none" focusable="false">
|
|
101
|
+
<path data-blob-ring-path d={ringPath} fill="none" stroke-width={strokeWidth} vector-effect="non-scaling-stroke"></path>
|
|
102
|
+
</svg>
|
|
103
|
+
</S.span>
|
|
104
|
+
) : null}
|
|
105
|
+
</S.div>
|
|
106
|
+
|
|
107
|
+
<script>
|
|
108
|
+
// The static shape is complete without JavaScript: load the controller only
|
|
109
|
+
// when a blob on this page actually morphs.
|
|
110
|
+
if (document.querySelector('[data-sf-blob]:not([data-blob-morph="none"])')) {
|
|
111
|
+
void import("./blob/controller.js").then(({ initializeSfBlobs }) => initializeSfBlobs());
|
|
112
|
+
}
|
|
113
|
+
</script>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Blob from "./Blob.astro";
|
|
3
|
+
import {
|
|
4
|
+
flowpressBlockHtmlProps,
|
|
5
|
+
resolveFlowpressBlockStyleflowProps,
|
|
6
|
+
resolvePrefixedFlowpressBlockStyleflowProps,
|
|
7
|
+
} from "../../index.js";
|
|
8
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
9
|
+
|
|
10
|
+
// Renders `sf/blob` wherever the semantic renderer meets it: as a top-level
|
|
11
|
+
// composition block and nested inside any other sf/* block. Called from both
|
|
12
|
+
// paths, so it must work with only `block` and `contract` (like CoverBlock).
|
|
13
|
+
type Props = Pick<FlowpressBlockRendererProps, "block"> & Partial<FlowpressBlockRendererProps>;
|
|
14
|
+
const { block, contract, styleflowProps, htmlProps } = Astro.props as Props;
|
|
15
|
+
const attributes = block.attributes;
|
|
16
|
+
const options = {
|
|
17
|
+
strict: process.env.NODE_ENV === "production" || process.env.STYLEFLOW_STRICT === "1",
|
|
18
|
+
onDiagnostic: (diagnostic: { code: string; message: string }) =>
|
|
19
|
+
console.warn(`[${diagnostic.code}] ${diagnostic.message}`),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Fill: the block's own Styleflow coordinates. Blob keeps a visible default
|
|
23
|
+
// when the author leaves tone/intensity on "inherit".
|
|
24
|
+
const fill = styleflowProps ?? resolveFlowpressBlockStyleflowProps(attributes, contract, {}, options);
|
|
25
|
+
// Outline: the same validated contract under the `outline*` attribute prefix.
|
|
26
|
+
const outline = resolvePrefixedFlowpressBlockStyleflowProps(
|
|
27
|
+
attributes,
|
|
28
|
+
"outline",
|
|
29
|
+
contract,
|
|
30
|
+
{},
|
|
31
|
+
options,
|
|
32
|
+
);
|
|
33
|
+
const text = (value: unknown): string | undefined =>
|
|
34
|
+
typeof value === "string" && value !== "" ? value : undefined;
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
<Blob
|
|
38
|
+
{...fill}
|
|
39
|
+
variant={text(attributes.variant) ?? (typeof attributes.variant === "number" ? attributes.variant : undefined)}
|
|
40
|
+
contentFit={text(attributes.contentFit) as "cover" | "center" | undefined}
|
|
41
|
+
aspectRatio={text(attributes.aspectRatio) as "natural" | "square" | "portrait" | "landscape" | undefined}
|
|
42
|
+
outlineWidth={attributes.outlineWidth as number | string | undefined}
|
|
43
|
+
outlineTone={text(outline.tone)}
|
|
44
|
+
outlineIntensity={text(outline.intensity)}
|
|
45
|
+
morph={text(attributes.morph) as "none" | "auto" | "hover" | undefined}
|
|
46
|
+
morphTargets={text(attributes.morphTargets)}
|
|
47
|
+
morphDuration={attributes.morphDuration as number | string | undefined}
|
|
48
|
+
morphInterval={attributes.morphInterval as number | string | undefined}
|
|
49
|
+
rootProps={htmlProps ?? flowpressBlockHtmlProps(attributes)}
|
|
50
|
+
>
|
|
51
|
+
<slot />
|
|
52
|
+
</Blob>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import LevelTag from "./LevelTag.astro";
|
|
5
|
+
import { classNames, text, type ResolvedImage } from "./query-loop.js";
|
|
6
|
+
|
|
7
|
+
// Output of the project "Custom field" blocks. The value arrives already
|
|
8
|
+
// normalized for the chosen output (apps/cms/project/src/custom-fields.php);
|
|
9
|
+
// keep the output map in sync with it and with custom-field-editor.js.
|
|
10
|
+
type Props = Pick<FlowpressBlockRendererProps, "block" | "htmlProps" | "styleflowProps"> & {
|
|
11
|
+
baseClass: string;
|
|
12
|
+
};
|
|
13
|
+
const { block, htmlProps, styleflowProps, baseClass } = Astro.props;
|
|
14
|
+
const attributes = block.attributes;
|
|
15
|
+
const resolved = (block.resolvedData ?? {}) as { as?: string | undefined; value?: unknown | undefined; href?: string | undefined; isFallback?: boolean };
|
|
16
|
+
const options = (attributes.options && typeof attributes.options === "object" ? attributes.options : {}) as Record<string, unknown>;
|
|
17
|
+
const as = text(resolved.as);
|
|
18
|
+
const authoredAs = text(attributes.as) || "text";
|
|
19
|
+
const prefix = text(attributes.prefix);
|
|
20
|
+
const suffix = text(attributes.suffix);
|
|
21
|
+
const TEXT_TAGS = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6"];
|
|
22
|
+
const textTag = authoredAs === "text" && TEXT_TAGS.includes(text(options.tag)) ? text(options.tag) : "p";
|
|
23
|
+
const rootProps = {
|
|
24
|
+
...htmlProps,
|
|
25
|
+
class: classNames(baseClass, `project-field--${as || authoredAs}`, as === "image" ? "project-field__image" : "", htmlProps.class),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const image = as === "image" ? (resolved.value ?? {}) as ResolvedImage : {};
|
|
29
|
+
const aspectRatio = text(options.aspectRatio);
|
|
30
|
+
const imageProps = {
|
|
31
|
+
src: text(image.url),
|
|
32
|
+
srcset: image.srcSet || undefined,
|
|
33
|
+
sizes: image.srcSet ? image.sizes || undefined : undefined,
|
|
34
|
+
width: image.width,
|
|
35
|
+
height: image.height,
|
|
36
|
+
alt: image.alt ?? "",
|
|
37
|
+
class: image.id ? `wp-image-${image.id}` : undefined,
|
|
38
|
+
loading: "lazy" as const,
|
|
39
|
+
decoding: "async" as const,
|
|
40
|
+
};
|
|
41
|
+
const link = as === "link" ? (resolved.value ?? {}) as { url?: string | undefined; label?: string | undefined; target?: string } : {};
|
|
42
|
+
const date = as === "date" ? (resolved.value ?? {}) as { datetime?: string | undefined; formatted?: string } : {};
|
|
43
|
+
const list = as === "list" && Array.isArray(resolved.value) ? resolved.value.map(text) : [];
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
{as === "" ? null
|
|
47
|
+
: as === "image" ? (
|
|
48
|
+
imageProps.src ? (
|
|
49
|
+
<S.figure {...rootProps} {...styleflowProps} data-aspect-ratio={aspectRatio || undefined}>
|
|
50
|
+
{resolved.href ? <S.a href={resolved.href}><S.img {...imageProps} /></S.a> : <S.img {...imageProps} />}
|
|
51
|
+
</S.figure>
|
|
52
|
+
) : null
|
|
53
|
+
)
|
|
54
|
+
: as === "richtext" ? (
|
|
55
|
+
<S.div {...rootProps} {...styleflowProps}>
|
|
56
|
+
{prefix ? <S.span class="project-field__prefix">{prefix}</S.span> : null}
|
|
57
|
+
<Fragment set:html={text(resolved.value)} />
|
|
58
|
+
{suffix ? <S.span class="project-field__suffix">{suffix}</S.span> : null}
|
|
59
|
+
</S.div>
|
|
60
|
+
)
|
|
61
|
+
: as === "link" ? (
|
|
62
|
+
<S.p {...rootProps} {...styleflowProps}>
|
|
63
|
+
{prefix ? <S.span class="project-field__prefix">{prefix}</S.span> : null}
|
|
64
|
+
<S.a
|
|
65
|
+
href={link.url}
|
|
66
|
+
class={options.variant === "button" ? "wp-element-button" : undefined}
|
|
67
|
+
target={link.target === "_blank" ? "_blank" : undefined}
|
|
68
|
+
rel={link.target === "_blank" ? "noopener noreferrer" : undefined}
|
|
69
|
+
>{link.label || link.url}</S.a>
|
|
70
|
+
{suffix ? <S.span class="project-field__suffix">{suffix}</S.span> : null}
|
|
71
|
+
</S.p>
|
|
72
|
+
)
|
|
73
|
+
: as === "list" ? (
|
|
74
|
+
<S.div {...rootProps} {...styleflowProps}>
|
|
75
|
+
{prefix ? <S.span class="project-field__prefix">{prefix}</S.span> : null}
|
|
76
|
+
{options.ordered
|
|
77
|
+
? <S.ol class="wp-block-list">{list.map((item) => <S.li>{item}</S.li>)}</S.ol>
|
|
78
|
+
: <S.ul class="wp-block-list">{list.map((item) => <S.li>{item}</S.li>)}</S.ul>}
|
|
79
|
+
{suffix ? <S.span class="project-field__suffix">{suffix}</S.span> : null}
|
|
80
|
+
</S.div>
|
|
81
|
+
)
|
|
82
|
+
: (
|
|
83
|
+
<LevelTag tag={textTag} {...rootProps} {...styleflowProps}>
|
|
84
|
+
{prefix}{as === "date" ? <S.time datetime={date.datetime}>{date.formatted}</S.time> : text(resolved.value)}{suffix}
|
|
85
|
+
</LevelTag>
|
|
86
|
+
)}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
|
|
4
|
+
// Heading (h1–h6), paragraph (0 / "p") or inline span, with Styleflow props.
|
|
5
|
+
interface Props {
|
|
6
|
+
tag: string;
|
|
7
|
+
[attribute: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
const { tag, ...rest } = Astro.props;
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
{tag === "h1" ? <S.h1 {...rest}><slot /></S.h1>
|
|
13
|
+
: tag === "h2" ? <S.h2 {...rest}><slot /></S.h2>
|
|
14
|
+
: tag === "h3" ? <S.h3 {...rest}><slot /></S.h3>
|
|
15
|
+
: tag === "h4" ? <S.h4 {...rest}><slot /></S.h4>
|
|
16
|
+
: tag === "h5" ? <S.h5 {...rest}><slot /></S.h5>
|
|
17
|
+
: tag === "h6" ? <S.h6 {...rest}><slot /></S.h6>
|
|
18
|
+
: tag === "span" ? <S.span {...rest}><slot /></S.span>
|
|
19
|
+
: tag === "div" ? <S.div {...rest}><slot /></S.div>
|
|
20
|
+
: <S.p {...rest}><slot /></S.p>}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import {
|
|
4
|
+
flowpressBlockHtmlProps,
|
|
5
|
+
resolveFlowpressBlockStyleflowProps,
|
|
6
|
+
} from "../../index.js";
|
|
7
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
8
|
+
import { resolveMap } from "./map.js";
|
|
9
|
+
|
|
10
|
+
type Props = Pick<FlowpressBlockRendererProps, "block"> & Partial<FlowpressBlockRendererProps>;
|
|
11
|
+
const { block, contract, htmlProps, styleflowProps } = Astro.props as Props;
|
|
12
|
+
const html = htmlProps ?? flowpressBlockHtmlProps(block.attributes);
|
|
13
|
+
const semantic = styleflowProps ?? resolveFlowpressBlockStyleflowProps(block.attributes, contract);
|
|
14
|
+
const map = resolveMap(block.attributes as import("./map.js").MapAttributes, import.meta.env.GOOGLE_MAPS_API_KEY ?? "");
|
|
15
|
+
const label = map.address || `Mappa: ${map.query}`;
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
{map.query ? (
|
|
19
|
+
<S.div {...semantic} {...html}>
|
|
20
|
+
{map.iframeSrc ? (
|
|
21
|
+
<S.iframe
|
|
22
|
+
class="sf-map-frame"
|
|
23
|
+
title={label}
|
|
24
|
+
src={map.iframeSrc}
|
|
25
|
+
loading="lazy"
|
|
26
|
+
referrerpolicy="no-referrer-when-downgrade"
|
|
27
|
+
allowfullscreen
|
|
28
|
+
/>
|
|
29
|
+
) : null}
|
|
30
|
+
<S.a href={map.linkHref} target="_blank" rel="noopener noreferrer" layoutRole="control" density="compact" interactivePriority="tertiary">Apri la mappa</S.a>
|
|
31
|
+
</S.div>
|
|
32
|
+
) : null}
|
|
33
|
+
|
|
34
|
+
<style>
|
|
35
|
+
.sf-map-frame {
|
|
36
|
+
display: block;
|
|
37
|
+
width: 100%;
|
|
38
|
+
min-height: var(--fp-map-min-height, 22rem);
|
|
39
|
+
border: 0;
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import { nativeHtmlData } from "./html.js";
|
|
5
|
+
|
|
6
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
7
|
+
const { html, hidden } = nativeHtmlData(block.resolvedData, block.innerHtml);
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
{!hidden && html ? (
|
|
11
|
+
<S.div {...htmlProps} {...styleflowProps} data-project-native-html set:html={html} />
|
|
12
|
+
) : null}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
4
|
+
import { nativeIconSvg, nativeIconWidth } from "./icon.js";
|
|
5
|
+
|
|
6
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
7
|
+
const svg = nativeIconSvg(block.attributes.icon, block.resolvedData, `fp-icon-${crypto.randomUUID()}`);
|
|
8
|
+
const dimensions = (block.attributes.style as { dimensions?: { width?: unknown } } | undefined)?.dimensions;
|
|
9
|
+
const width = nativeIconWidth(dimensions?.width) ?? "24px";
|
|
10
|
+
const label = typeof block.attributes.ariaLabel === "string" ? block.attributes.ariaLabel.trim() : "";
|
|
11
|
+
const align = ["left", "center", "right"].includes(String(block.attributes.align)) ? `align${block.attributes.align}` : "";
|
|
12
|
+
const semantic = {
|
|
13
|
+
...styleflowProps,
|
|
14
|
+
...(!block.attributes.layoutRole ? { layoutRole: "none" as const } : {}),
|
|
15
|
+
};
|
|
16
|
+
const rootProps = {
|
|
17
|
+
...htmlProps,
|
|
18
|
+
class: ["wp-block-icon", align, htmlProps.class].filter(Boolean).join(" "),
|
|
19
|
+
style: [htmlProps.style, `--fp-core-icon-width:${width}`].filter(Boolean).join(";"),
|
|
20
|
+
};
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
<!-- styleflow-ignore-start rule=SF_INLINE_STYLE reason="Validated structural icon width from the native Gutenberg control" scope="Native icon pilot" -->
|
|
24
|
+
{svg ? <S.div
|
|
25
|
+
{...rootProps}
|
|
26
|
+
{...semantic}
|
|
27
|
+
data-icon={block.attributes.icon}
|
|
28
|
+
role={label ? "img" : undefined}
|
|
29
|
+
aria-label={label || undefined}
|
|
30
|
+
aria-hidden={label ? undefined : "true"}
|
|
31
|
+
set:html={svg}
|
|
32
|
+
/> : null}
|
|
33
|
+
<!-- styleflow-ignore-end -->
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type {
|
|
3
|
+
FlowpressBlockRendererProps
|
|
4
|
+
} from "../../index.js";
|
|
5
|
+
import Timeline from "./Timeline.astro";
|
|
6
|
+
import {
|
|
7
|
+
normalizeTimelineIntensity,
|
|
8
|
+
normalizeTimelineTone,
|
|
9
|
+
timelineItemsFromBlocks
|
|
10
|
+
} from "./timeline.js";
|
|
11
|
+
|
|
12
|
+
const { block, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;
|
|
13
|
+
|
|
14
|
+
function optionalAttribute(
|
|
15
|
+
attributes: Record<string, unknown>,
|
|
16
|
+
name: string
|
|
17
|
+
): string | undefined {
|
|
18
|
+
const value = String(attributes[name] ?? "").trim();
|
|
19
|
+
return value || undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const tone = normalizeTimelineTone(block.attributes.tone);
|
|
23
|
+
const intensity = normalizeTimelineIntensity(block.attributes.intensity);
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
<Timeline
|
|
27
|
+
rootProps={htmlProps}
|
|
28
|
+
styleflowProps={styleflowProps}
|
|
29
|
+
items={timelineItemsFromBlocks(block.innerBlocks ?? [])}
|
|
30
|
+
tone={tone}
|
|
31
|
+
intensity={intensity}
|
|
32
|
+
id={optionalAttribute(block.attributes, "anchor")}
|
|
33
|
+
class={optionalAttribute(block.attributes, "className")}
|
|
34
|
+
/>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import CompositionRenderer from "../CompositionRenderer.astro";
|
|
4
|
+
import GutenbergRenderer from "../GutenbergRenderer.astro";
|
|
5
|
+
import type {
|
|
6
|
+
FlowpressBlock,
|
|
7
|
+
FlowpressBlockRendererProps,
|
|
8
|
+
FlowpressCompositionV1,
|
|
9
|
+
} from "../../index.js";
|
|
10
|
+
import type { NestedPass } from "./query-loop.js";
|
|
11
|
+
import { decorateGridBlocks } from "./grid.js";
|
|
12
|
+
|
|
13
|
+
// Blocks resolved by a project resolver in a nested composition pass (Query
|
|
14
|
+
// Loop, Terms Query, one loop item). That pass cannot write into the outer
|
|
15
|
+
// composition, so it exports its own block types, stylesheets and
|
|
16
|
+
// diagnostics: merge them here, as SyncedPatternContent does for patterns.
|
|
17
|
+
|
|
18
|
+
type Props = Pick<
|
|
19
|
+
FlowpressBlockRendererProps,
|
|
20
|
+
"block" | "composition" | "contract" | "context" | "adapters"
|
|
21
|
+
> & {
|
|
22
|
+
blocks: FlowpressBlock[];
|
|
23
|
+
pass: NestedPass;
|
|
24
|
+
// Stylesheets and diagnostics belong to the whole pass: render them once,
|
|
25
|
+
// not once per loop item.
|
|
26
|
+
renderPassOutput?: boolean | undefined;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const { block, blocks, pass, composition, contract, context, adapters, renderPassOutput = true } = Astro.props;
|
|
30
|
+
|
|
31
|
+
const stylesheets = renderPassOutput ? pass.stylesheets ?? [] : [];
|
|
32
|
+
const blocking = renderPassOutput ? (pass.diagnostics ?? []).filter((diagnostic) => diagnostic.blocking) : [];
|
|
33
|
+
if (blocking.length > 0 && context.production) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
`FlowPress ${block.name} is not renderable:\n`
|
|
36
|
+
+ blocking.map(({ code, message }) => `- ${code}: ${message}`).join("\n"),
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Composition path: the parent chain was rendered through the adapter registry.
|
|
41
|
+
// Semantic-renderer path (inside sf/* blocks): no registry, so use the project
|
|
42
|
+
// renderers, which register every loop adapter.
|
|
43
|
+
// block-renderers.ts imports the loop adapters, which import this component:
|
|
44
|
+
// a static import would close that cycle, and Vite's SSR loader then hands
|
|
45
|
+
// block-renderers.ts undefined adapters (core/query rendered as a plain
|
|
46
|
+
// container, with the page-context pass). Load the registry at render time.
|
|
47
|
+
const { nativeBlockRenderers } = await import("./registry.js");
|
|
48
|
+
const nestedComposition: FlowpressCompositionV1 | undefined = composition && adapters && Object.keys(adapters).length > 0
|
|
49
|
+
? {
|
|
50
|
+
...composition,
|
|
51
|
+
blockTypes: [...composition.blockTypes, ...(pass.blockTypes ?? [])],
|
|
52
|
+
diagnostics: pass.diagnostics ?? [],
|
|
53
|
+
stylesheets: [],
|
|
54
|
+
}
|
|
55
|
+
: undefined;
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
{stylesheets.map((stylesheet) => (
|
|
59
|
+
<style data-flowpress-composition-style={stylesheet.id} set:html={stylesheet.css} />
|
|
60
|
+
))}
|
|
61
|
+
{blocking.length > 0 ? (
|
|
62
|
+
<S.aside data-flowpress-composition-diagnostics role="status">
|
|
63
|
+
<S.ul>
|
|
64
|
+
{blocking.map(({ code, message }) => <S.li data-diagnostic-code={code}>{message}</S.li>)}
|
|
65
|
+
</S.ul>
|
|
66
|
+
</S.aside>
|
|
67
|
+
) : null}
|
|
68
|
+
{blocks.length > 0 ? (
|
|
69
|
+
nestedComposition ? (
|
|
70
|
+
<CompositionRenderer
|
|
71
|
+
composition={nestedComposition}
|
|
72
|
+
adapters={adapters!}
|
|
73
|
+
blocks={decorateGridBlocks(blocks)}
|
|
74
|
+
contract={contract}
|
|
75
|
+
parentBlockName={block.name}
|
|
76
|
+
production={context.production}
|
|
77
|
+
depth={context.depth + 1}
|
|
78
|
+
/>
|
|
79
|
+
) : (
|
|
80
|
+
<GutenbergRenderer
|
|
81
|
+
blocks={decorateGridBlocks(blocks)}
|
|
82
|
+
contract={contract}
|
|
83
|
+
blockRenderers={nativeBlockRenderers}
|
|
84
|
+
parentBlockName={block.name}
|
|
85
|
+
production={context.production}
|
|
86
|
+
depth={context.depth + 1}
|
|
87
|
+
/>
|
|
88
|
+
)
|
|
89
|
+
) : null}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import CompositionRenderer from "../CompositionRenderer.astro";
|
|
4
|
+
import GutenbergRenderer from "../GutenbergRenderer.astro";
|
|
5
|
+
import type {
|
|
6
|
+
FlowpressBlock,
|
|
7
|
+
FlowpressBlockRenderer,
|
|
8
|
+
FlowpressBlockRendererProps,
|
|
9
|
+
FlowpressBlockTypeDescriptor,
|
|
10
|
+
FlowpressCompositionDiagnostic,
|
|
11
|
+
FlowpressCompositionStylesheet,
|
|
12
|
+
FlowpressCompositionV1,
|
|
13
|
+
} from "../../index.js";
|
|
14
|
+
import { decorateGridBlocks } from "./grid.js";
|
|
15
|
+
|
|
16
|
+
// Content of a synced pattern (core/block). The pattern's blocks arrive either
|
|
17
|
+
// as `innerBlocks` (the default slot, once FlowPress resolves core/block) or as
|
|
18
|
+
// `resolvedData` from the project resolver, which exports the block types,
|
|
19
|
+
// stylesheets and diagnostics of its own nested pass because that pass cannot
|
|
20
|
+
// write into the outer composition.
|
|
21
|
+
interface SyncedPatternData {
|
|
22
|
+
ref?: number | undefined;
|
|
23
|
+
blocks?: FlowpressBlock[] | undefined;
|
|
24
|
+
blockTypes?: FlowpressBlockTypeDescriptor[] | undefined;
|
|
25
|
+
stylesheets?: FlowpressCompositionStylesheet[] | undefined;
|
|
26
|
+
diagnostics?: FlowpressCompositionDiagnostic[] | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// `selfRenderer` lets the semantic renderer resolve patterns nested in patterns.
|
|
30
|
+
const { block, composition, contract, context, adapters, selfRenderer } = Astro.props as Pick<
|
|
31
|
+
FlowpressBlockRendererProps,
|
|
32
|
+
"block" | "composition" | "contract" | "context" | "adapters"
|
|
33
|
+
> & { selfRenderer?: FlowpressBlockRenderer };
|
|
34
|
+
|
|
35
|
+
const pattern = (block.resolvedData ?? {}) as SyncedPatternData;
|
|
36
|
+
const patternBlocks = pattern.blocks ?? [];
|
|
37
|
+
const stylesheets = pattern.stylesheets ?? [];
|
|
38
|
+
const blocking = (pattern.diagnostics ?? []).filter((diagnostic) => diagnostic.blocking);
|
|
39
|
+
if (blocking.length > 0 && context.production) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`FlowPress synced pattern ${pattern.ref ?? block.attributes.ref} is not renderable:\n`
|
|
42
|
+
+ blocking.map(({ code, message }) => `- ${code}: ${message}`).join("\n"),
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Composition path: the parent chain was rendered through the adapter registry.
|
|
47
|
+
// Semantic-renderer path (inside sf/* blocks): use the project renderers so
|
|
48
|
+
// resolved blocks inside patterns keep their adapters too.
|
|
49
|
+
const { nativeBlockRenderers } = await import("./registry.js");
|
|
50
|
+
const patternComposition: FlowpressCompositionV1 | undefined = composition && adapters && Object.keys(adapters).length > 0
|
|
51
|
+
? {
|
|
52
|
+
...composition,
|
|
53
|
+
blockTypes: [...composition.blockTypes, ...(pattern.blockTypes ?? [])],
|
|
54
|
+
diagnostics: pattern.diagnostics ?? [],
|
|
55
|
+
stylesheets: [],
|
|
56
|
+
}
|
|
57
|
+
: undefined;
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
{stylesheets.map((stylesheet) => (
|
|
61
|
+
<style data-flowpress-composition-style={stylesheet.id} set:html={stylesheet.css} />
|
|
62
|
+
))}
|
|
63
|
+
{blocking.length > 0 ? (
|
|
64
|
+
<S.aside data-flowpress-composition-diagnostics role="status">
|
|
65
|
+
<S.ul>
|
|
66
|
+
{blocking.map(({ code, message }) => <S.li data-diagnostic-code={code}>{message}</S.li>)}
|
|
67
|
+
</S.ul>
|
|
68
|
+
</S.aside>
|
|
69
|
+
) : null}
|
|
70
|
+
{patternBlocks.length > 0 ? (
|
|
71
|
+
patternComposition ? (
|
|
72
|
+
<CompositionRenderer
|
|
73
|
+
composition={patternComposition}
|
|
74
|
+
adapters={adapters!}
|
|
75
|
+
blocks={decorateGridBlocks(patternBlocks)}
|
|
76
|
+
contract={contract}
|
|
77
|
+
parentBlockName={block.name}
|
|
78
|
+
production={context.production}
|
|
79
|
+
depth={context.depth + 1}
|
|
80
|
+
/>
|
|
81
|
+
) : (
|
|
82
|
+
<GutenbergRenderer
|
|
83
|
+
blocks={decorateGridBlocks(patternBlocks)}
|
|
84
|
+
contract={contract}
|
|
85
|
+
blockRenderers={{ ...nativeBlockRenderers, ...(selfRenderer ? { [block.name]: selfRenderer } : {}) }}
|
|
86
|
+
parentBlockName={block.name}
|
|
87
|
+
production={context.production}
|
|
88
|
+
depth={context.depth + 1}
|
|
89
|
+
/>
|
|
90
|
+
)
|
|
91
|
+
) : null}
|
|
92
|
+
<slot />
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import { classNames, text, type ResolvedImage } from "./query-loop.js";
|
|
4
|
+
|
|
5
|
+
// Value of a term custom field inside the link of a Post Terms item
|
|
6
|
+
// (apps/cms/project/src/custom-fields.php, FLOWPRESS_PROJECT_TERM_LIST_OUTPUTS).
|
|
7
|
+
// Inline outputs only: the block-level ones (rich text, list, link) are never
|
|
8
|
+
// resolved for this block, and none of them would be valid inside an <a>.
|
|
9
|
+
interface Props {
|
|
10
|
+
field: { as?: string | undefined; value?: unknown };
|
|
11
|
+
// Accessible name of an image that is the only content of the term link.
|
|
12
|
+
fallbackAlt?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
const { field, fallbackAlt = "" } = Astro.props;
|
|
15
|
+
const as = text(field.as);
|
|
16
|
+
const image = (as === "image" ? field.value ?? {} : {}) as ResolvedImage;
|
|
17
|
+
const date = (as === "date" ? field.value ?? {} : {}) as { datetime?: string | undefined; formatted?: string };
|
|
18
|
+
const imageProps = {
|
|
19
|
+
src: text(image.url),
|
|
20
|
+
srcset: image.srcSet || undefined,
|
|
21
|
+
sizes: image.srcSet ? image.sizes || undefined : undefined,
|
|
22
|
+
width: image.width,
|
|
23
|
+
height: image.height,
|
|
24
|
+
alt: image.alt || fallbackAlt,
|
|
25
|
+
class: classNames("wp-block-post-terms__field", image.id ? `wp-image-${image.id}` : undefined),
|
|
26
|
+
loading: "lazy" as const,
|
|
27
|
+
decoding: "async" as const,
|
|
28
|
+
};
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
{as === "image" ? (
|
|
32
|
+
imageProps.src ? <S.img {...imageProps} /> : null
|
|
33
|
+
) : as === "date" ? (
|
|
34
|
+
<S.time class="wp-block-post-terms__field" datetime={date.datetime}>{date.formatted}</S.time>
|
|
35
|
+
) : (
|
|
36
|
+
<S.span class="wp-block-post-terms__field">{text(field.value)}</S.span>
|
|
37
|
+
)}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
import S from "@styleflow.app/astro/S.astro";
|
|
3
|
+
import type { TimelineItem } from "./timeline.js";
|
|
4
|
+
import "./timeline.css";
|
|
5
|
+
interface Props { items:TimelineItem[]; tone?:string | undefined; intensity?:string | undefined; id?:string | undefined; class?:string | undefined; ariaLabel?:string | undefined; rootProps?:Record<string,unknown> | undefined; styleflowProps?:Record<string,unknown> | undefined; }
|
|
6
|
+
const {items,tone="inherit",intensity="inherit",id,class:className="",ariaLabel="Timeline",rootProps={},styleflowProps={}}=Astro.props;
|
|
7
|
+
---
|
|
8
|
+
<S.section {...rootProps} {...styleflowProps} id={id ?? (typeof rootProps.id === "string" ? rootProps.id : undefined)} {...(tone !== "inherit" ? {tone} : {})} {...(intensity !== "inherit" ? {intensity} : {})} layoutRole="stack" density="regular" aria-label={ariaLabel} class:list={["flowpress-timeline",rootProps.class,className]} data-flowpress-timeline>
|
|
9
|
+
<S.ol layoutRole="stack" density="regular" class="flowpress-timeline__list">
|
|
10
|
+
{items.map(item=>(
|
|
11
|
+
<S.li {...(item.tone && item.tone !== "inherit" ? {tone:item.tone} : {})} {...(item.intensity && item.intensity !== "inherit" ? {intensity:item.intensity} : {})} layoutRole="stack" density="regular" surface="default" class="flowpress-timeline__item" data-flowpress-timeline-item>
|
|
12
|
+
{item.year && <S.h3>{item.year}</S.h3>}
|
|
13
|
+
{item.image && <S.img src={item.image.url ?? item.image.sourceUrl} alt={item.image.alt ?? item.image.altText ?? ""} width={item.image.width} height={item.image.height} loading="lazy" />}
|
|
14
|
+
{item.description && <S.p>{item.description}</S.p>}
|
|
15
|
+
{item.metric && <S.p>{item.metric}</S.p>}
|
|
16
|
+
{(item.statisticValue || item.statisticLabel) && <S.p><S.strong>{item.statisticValue}</S.strong> {item.statisticLabel}</S.p>}
|
|
17
|
+
</S.li>
|
|
18
|
+
))}
|
|
19
|
+
</S.ol>
|
|
20
|
+
</S.section>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
3
|
+
import Timeline from "./Timeline.astro";
|
|
4
|
+
import { timelineItemsFromBlocks } from "./timeline.js";
|
|
5
|
+
const {block,htmlProps,styleflowProps} = Astro.props as FlowpressBlockRendererProps;
|
|
6
|
+
---
|
|
7
|
+
<Timeline items={timelineItemsFromBlocks([block])} rootProps={htmlProps} styleflowProps={styleflowProps} />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blob-shapes.generated.d.ts","sourceRoot":"","sources":["../../../../src/astro/native/blob/blob-shapes.generated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blob-shapes.generated.js","sourceRoot":"","sources":["../../../../src/astro/native/blob/blob-shapes.generated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC","sourcesContent":["export { BLOB_BOX, BLOB_VARIANTS } from \"@styleflow.app/flowpress-components/organic-shapes\";\n"]}
|