@styleflow.app/flowpress-astro-core 1.0.0-beta.5 → 1.0.0-beta.50
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 +307 -1
- package/README.md +121 -6
- 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 +170 -0
- package/dist/astro/DefaultBlockAdapter.astro +37 -0
- package/dist/astro/EditorialMedia.astro +47 -0
- package/dist/astro/FontStylesheets.astro +35 -0
- package/dist/astro/GutenbergRenderer.astro +270 -84
- package/dist/astro/Media.astro +27 -0
- package/dist/astro/StyleflowElement.astro +25 -0
- package/dist/astro/ThemeRuntime.astro +26 -0
- package/dist/astro/blocks/CarouselBlock.astro +72 -101
- package/dist/astro/blocks/CarouselItemBlock.astro +4 -4
- package/dist/astro/blocks/ColumnBlock.astro +4 -5
- package/dist/astro/blocks/CoverBlock.astro +158 -0
- package/dist/astro/blocks/FormBlock.astro +23 -20
- package/dist/astro/blocks/GridBlock.astro +5 -4
- package/dist/astro/blocks/HeroBlock.astro +6 -6
- package/dist/astro/blocks/ImageBlock.astro +6 -6
- package/dist/astro/blocks/ListItemFallback.astro +9 -7
- package/dist/astro/blocks/NumberSpinnerBlock.astro +29 -22
- package/dist/astro/blocks/SemanticElement.astro +35 -0
- package/dist/astro/blocks/SiteLogoBlock.astro +54 -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 +10 -1
- package/dist/astro/blocks/helpers.d.ts.map +1 -1
- package/dist/astro/blocks/helpers.js +55 -39
- package/dist/astro/blocks/helpers.js.map +1 -1
- package/dist/astro/blocks/helpers.ts +69 -44
- package/dist/astro/motion/AccordionRuntime.astro +9 -0
- package/dist/astro/motion/MotionBoot.astro +21 -0
- package/dist/astro/motion/MotionRuntime.astro +31 -0
- package/dist/astro/motion/accordion.css +163 -0
- package/dist/astro/motion/accordion.d.ts +3 -0
- package/dist/astro/motion/accordion.d.ts.map +1 -0
- package/dist/astro/motion/accordion.js +98 -0
- package/dist/astro/motion/accordion.js.map +1 -0
- package/dist/astro/motion/accordion.ts +109 -0
- package/dist/astro/motion/motion-controller.d.ts +12 -0
- package/dist/astro/motion/motion-controller.d.ts.map +1 -0
- package/dist/astro/motion/motion-controller.js +312 -0
- package/dist/astro/motion/motion-controller.js.map +1 -0
- package/dist/astro/motion/motion-controller.ts +393 -0
- package/dist/astro/motion/motion.css +600 -0
- package/dist/astro/motion/motion.d.ts +132 -0
- package/dist/astro/motion/motion.d.ts.map +1 -0
- package/dist/astro/motion/motion.js +265 -0
- package/dist/astro/motion/motion.js.map +1 -0
- package/dist/astro/motion/motion.ts +430 -0
- package/dist/astro/native/AccordionRuntime.astro +11 -0
- package/dist/astro/native/Blob.astro +113 -0
- package/dist/astro/native/BlobBlock.astro +52 -0
- package/dist/astro/native/CustomFieldValue.astro +88 -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/ReservedLogin.astro +107 -0
- package/dist/astro/native/ResolvedBlocks.astro +91 -0
- package/dist/astro/native/SyncedPatternContent.astro +94 -0
- package/dist/astro/native/TermFieldValue.astro +39 -0
- package/dist/astro/native/Timeline.astro +22 -0
- package/dist/astro/native/TimelineCardBlock.astro +7 -0
- package/dist/astro/native/accordion-controller.d.ts +3 -0
- package/dist/astro/native/accordion-controller.d.ts.map +1 -0
- package/dist/astro/native/accordion-controller.js +143 -0
- package/dist/astro/native/accordion-controller.js.map +1 -0
- package/dist/astro/native/accordion-controller.ts +108 -0
- package/dist/astro/native/accordion.css +36 -0
- package/dist/astro/native/accordion.d.ts +24 -0
- package/dist/astro/native/accordion.d.ts.map +1 -0
- package/dist/astro/native/accordion.js +82 -0
- package/dist/astro/native/accordion.js.map +1 -0
- package/dist/astro/native/accordion.ts +91 -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/block-sizing.css +34 -0
- package/dist/astro/native/button-template.d.ts +31 -0
- package/dist/astro/native/button-template.d.ts.map +1 -0
- package/dist/astro/native/button-template.js +54 -0
- package/dist/astro/native/button-template.js.map +1 -0
- package/dist/astro/native/button-template.ts +92 -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/carousel.css +323 -0
- package/dist/astro/native/core-accordion-heading.astro +23 -0
- package/dist/astro/native/core-accordion-item.astro +8 -0
- package/dist/astro/native/core-accordion-panel.astro +8 -0
- package/dist/astro/native/core-accordion.astro +8 -0
- package/dist/astro/native/core-block.astro +18 -0
- package/dist/astro/native/core-button-fallback.astro +43 -0
- package/dist/astro/native/core-button.astro +65 -0
- package/dist/astro/native/core-buttons.astro +14 -0
- package/dist/astro/native/core-group.astro +25 -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 +136 -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 +101 -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 +40 -0
- package/dist/astro/native/core-post-template-fallback.astro +30 -0
- package/dist/astro/native/core-post-template.astro +23 -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 +18 -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 +18 -0
- package/dist/astro/native/grid-bleed.d.ts +2 -0
- package/dist/astro/native/grid-bleed.d.ts.map +1 -0
- package/dist/astro/native/grid-bleed.js +123 -0
- package/dist/astro/native/grid-bleed.js.map +1 -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 +108 -0
- package/dist/astro/native/grid.js.map +1 -0
- package/dist/astro/native/grid.ts +132 -0
- package/dist/astro/native/group.css +36 -0
- package/dist/astro/native/group.d.ts +15 -0
- package/dist/astro/native/group.d.ts.map +1 -0
- package/dist/astro/native/group.js +66 -0
- package/dist/astro/native/group.js.map +1 -0
- package/dist/astro/native/group.ts +61 -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/image.d.ts +5 -0
- package/dist/astro/native/image.d.ts.map +1 -0
- package/dist/astro/native/image.js +65 -0
- package/dist/astro/native/image.js.map +1 -0
- package/dist/astro/native/image.ts +56 -0
- package/dist/astro/native/inline-text.css +15 -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-carousel.d.ts +13 -0
- package/dist/astro/native/query-carousel.d.ts.map +1 -0
- package/dist/astro/native/query-carousel.js +36 -0
- package/dist/astro/native/query-carousel.js.map +1 -0
- package/dist/astro/native/query-carousel.ts +60 -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 +91 -0
- package/dist/astro/native/registry.js.map +1 -0
- package/dist/astro/native/registry.ts +93 -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-slot.astro +6 -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 +105 -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 +23 -3
- package/dist/block-renderers.d.ts.map +1 -1
- package/dist/block-renderers.js.map +1 -1
- package/dist/build-cache.d.ts +8 -0
- package/dist/build-cache.d.ts.map +1 -0
- package/dist/build-cache.js +82 -0
- package/dist/build-cache.js.map +1 -0
- package/dist/carousel.d.ts +56 -6
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +183 -27
- package/dist/carousel.js.map +1 -1
- package/dist/client.d.ts +34 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +124 -42
- 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 +125 -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 +122 -0
- package/dist/default-blocks.js.map +1 -0
- package/dist/env.d.ts +21 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +53 -0
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/media.d.ts +20 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +106 -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/reserved-area.d.ts +10 -0
- package/dist/reserved-area.d.ts.map +1 -0
- package/dist/reserved-area.js +93 -0
- package/dist/reserved-area.js.map +1 -0
- package/dist/styleflow.d.ts +18 -1
- package/dist/styleflow.d.ts.map +1 -1
- package/dist/styleflow.js +82 -11
- package/dist/styleflow.js.map +1 -1
- package/dist/svg-media-runtime.d.ts +3 -0
- package/dist/svg-media-runtime.d.ts.map +1 -0
- package/dist/svg-media-runtime.js +33 -0
- package/dist/svg-media-runtime.js.map +1 -0
- package/dist/svg-media-types.d.ts +11 -0
- package/dist/svg-media-types.d.ts.map +1 -0
- package/dist/svg-media-types.js +2 -0
- package/dist/svg-media-types.js.map +1 -0
- package/dist/svg-media.d.ts +13 -0
- package/dist/svg-media.d.ts.map +1 -0
- package/dist/svg-media.js +47 -0
- package/dist/svg-media.js.map +1 -0
- package/dist/template-hierarchy.d.ts +0 -7
- package/dist/template-hierarchy.d.ts.map +1 -1
- package/dist/template-hierarchy.js +0 -21
- package/dist/template-hierarchy.js.map +1 -1
- 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 +75 -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 +58 -7
- package/dist/astro/DefaultTemplate.astro +0 -42
- package/dist/templates.d.ts +0 -19
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -20
- package/dist/templates.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import Media from "../Media.astro";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
4
|
import type { FlowpressBlock } from "../../types.js";
|
|
4
5
|
import type { StyleflowContract } from "../../styleflow.js";
|
|
5
6
|
import {
|
|
@@ -11,7 +12,7 @@ import {
|
|
|
11
12
|
|
|
12
13
|
interface Props {
|
|
13
14
|
block: FlowpressBlock;
|
|
14
|
-
contract?: StyleflowContract;
|
|
15
|
+
contract?: StyleflowContract | undefined;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
const { block, contract } = Astro.props;
|
|
@@ -34,8 +35,7 @@ const scrimEnabled = Boolean(attributes.scrimEnabled) && backgroundType !== "col
|
|
|
34
35
|
const scrimIntensity = Math.min(10, Math.max(1, Number(attributes.scrimIntensity) || 6));
|
|
35
36
|
---
|
|
36
37
|
|
|
37
|
-
<
|
|
38
|
-
as="section"
|
|
38
|
+
<StyleflowElement as="section"
|
|
39
39
|
{...semantic}
|
|
40
40
|
{...htmlAttributes}
|
|
41
41
|
style={[
|
|
@@ -44,7 +44,7 @@ const scrimIntensity = Math.min(10, Math.max(1, Number(attributes.scrimIntensity
|
|
|
44
44
|
].join(";")}
|
|
45
45
|
>
|
|
46
46
|
{backgroundType === "image" && imageSrc ? (
|
|
47
|
-
<
|
|
47
|
+
<Media
|
|
48
48
|
class="flowpress-hero__media"
|
|
49
49
|
src={imageSrc}
|
|
50
50
|
alt=""
|
|
@@ -71,7 +71,7 @@ const scrimIntensity = Math.min(10, Math.max(1, Number(attributes.scrimIntensity
|
|
|
71
71
|
<div class="flowpress-hero__content">
|
|
72
72
|
<slot />
|
|
73
73
|
</div>
|
|
74
|
-
</
|
|
74
|
+
</StyleflowElement>
|
|
75
75
|
|
|
76
76
|
<style>
|
|
77
77
|
.flowpress-hero {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import Media from "../EditorialMedia.astro";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
4
|
import type { StyleflowContract } from "../../styleflow.js";
|
|
4
5
|
import type { FlowpressBlock } from "../../types.js";
|
|
5
6
|
import {
|
|
@@ -9,7 +10,7 @@ import {
|
|
|
9
10
|
|
|
10
11
|
interface Props {
|
|
11
12
|
block: FlowpressBlock;
|
|
12
|
-
contract?: StyleflowContract;
|
|
13
|
+
contract?: StyleflowContract | undefined;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
type ImageLoading = "eager" | "lazy";
|
|
@@ -69,12 +70,11 @@ const fetchPriority = fetchPriorityValue(attributes.fetchPriority);
|
|
|
69
70
|
---
|
|
70
71
|
|
|
71
72
|
{src ? (
|
|
72
|
-
<
|
|
73
|
-
as="div"
|
|
73
|
+
<StyleflowElement as="div" data-flowpress-image
|
|
74
74
|
{...semanticProps(attributes, contract)}
|
|
75
75
|
{...blockHtmlAttributes(attributes)}
|
|
76
76
|
>
|
|
77
|
-
<
|
|
77
|
+
<Media
|
|
78
78
|
src={src}
|
|
79
79
|
srcset={srcSet || undefined}
|
|
80
80
|
sizes={sizes}
|
|
@@ -86,5 +86,5 @@ const fetchPriority = fetchPriorityValue(attributes.fetchPriority);
|
|
|
86
86
|
decoding={decoding}
|
|
87
87
|
fetchpriority={fetchPriority}
|
|
88
88
|
/>
|
|
89
|
-
</
|
|
89
|
+
</StyleflowElement>
|
|
90
90
|
) : null}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import Media from "../Media.astro";
|
|
3
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
4
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
5
|
import { flowpressLinkHref } from "../../links.js";
|
|
4
6
|
|
|
5
7
|
interface Props {
|
|
@@ -14,17 +16,17 @@ const href = flowpressLinkHref(item.uri);
|
|
|
14
16
|
---
|
|
15
17
|
|
|
16
18
|
{image.url ? (
|
|
17
|
-
<
|
|
19
|
+
<Media
|
|
18
20
|
src={String(image.url)}
|
|
19
|
-
alt={
|
|
21
|
+
alt={decodeFlowpressText(image.alt)}
|
|
20
22
|
loading="lazy"
|
|
21
23
|
decoding="async"
|
|
22
24
|
/>
|
|
23
25
|
) : null}
|
|
24
26
|
{href ? (
|
|
25
|
-
<
|
|
27
|
+
<StyleflowElement as="a" href={href}>{decodeFlowpressText(item.title)}</StyleflowElement>
|
|
26
28
|
) : (
|
|
27
|
-
<
|
|
29
|
+
<StyleflowElement as="span">{decodeFlowpressText(item.title)}</StyleflowElement>
|
|
28
30
|
)}
|
|
29
|
-
{item.excerpt ? <
|
|
30
|
-
{item.priceHtml ? <
|
|
31
|
+
{item.excerpt ? <StyleflowElement as="p">{decodeFlowpressText(item.excerpt)}</StyleflowElement> : null}
|
|
32
|
+
{item.priceHtml ? <StyleflowElement as="div" set:html={String(item.priceHtml)} /> : null}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
4
|
import {
|
|
4
5
|
clampSpinnerDuration,
|
|
5
6
|
spinnerFractionDigits
|
|
@@ -12,16 +13,17 @@ import {
|
|
|
12
13
|
semanticProps,
|
|
13
14
|
textHtmlTag
|
|
14
15
|
} from "./helpers.js";
|
|
16
|
+
import SemanticElement from "./SemanticElement.astro";
|
|
15
17
|
|
|
16
18
|
interface Props {
|
|
17
19
|
block: FlowpressBlock;
|
|
18
|
-
contract?: StyleflowContract;
|
|
20
|
+
contract?: StyleflowContract | undefined;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
const { block, contract } = Astro.props;
|
|
22
24
|
const attributes = block.attributes;
|
|
23
|
-
const prefix =
|
|
24
|
-
const suffix =
|
|
25
|
+
const prefix = decodeFlowpressText(attributes.prefix);
|
|
26
|
+
const suffix = decodeFlowpressText(attributes.suffix);
|
|
25
27
|
const candidateNumber = Number(attributes.number);
|
|
26
28
|
const number = Number.isFinite(candidateNumber) ? candidateNumber : 0;
|
|
27
29
|
const duration = clampSpinnerDuration(attributes.duration);
|
|
@@ -56,8 +58,7 @@ const numberTag = textHtmlTag(attributes.numberTag);
|
|
|
56
58
|
const suffixTag = textHtmlTag(attributes.suffixTag);
|
|
57
59
|
---
|
|
58
60
|
|
|
59
|
-
<
|
|
60
|
-
as="div"
|
|
61
|
+
<StyleflowElement as="div"
|
|
61
62
|
{...semantic}
|
|
62
63
|
{...htmlAttributes}
|
|
63
64
|
data-flowpress-number-spinner
|
|
@@ -67,18 +68,22 @@ const suffixTag = textHtmlTag(attributes.suffixTag);
|
|
|
67
68
|
data-spinner-locale={locale || undefined}
|
|
68
69
|
>
|
|
69
70
|
{prefix ? (
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
<SemanticElement
|
|
72
|
+
tag={prefixTag}
|
|
73
|
+
attributes={{
|
|
74
|
+
class: "flowpress-number-spinner__segment",
|
|
75
|
+
...prefixSemantic
|
|
76
|
+
}}
|
|
74
77
|
>
|
|
75
78
|
{prefix}
|
|
76
|
-
</
|
|
79
|
+
</SemanticElement>
|
|
77
80
|
) : null}
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
<SemanticElement
|
|
82
|
+
tag={numberTag}
|
|
83
|
+
attributes={{
|
|
84
|
+
class: "flowpress-number-spinner__segment flowpress-number-spinner__number",
|
|
85
|
+
...numberSemantic
|
|
86
|
+
}}
|
|
82
87
|
>
|
|
83
88
|
<span class="flowpress-number-spinner__accessible-value">
|
|
84
89
|
{numberText}
|
|
@@ -89,17 +94,19 @@ const suffixTag = textHtmlTag(attributes.suffixTag);
|
|
|
89
94
|
>
|
|
90
95
|
{numberText}
|
|
91
96
|
</span>
|
|
92
|
-
</
|
|
97
|
+
</SemanticElement>
|
|
93
98
|
{suffix ? (
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
<SemanticElement
|
|
100
|
+
tag={suffixTag}
|
|
101
|
+
attributes={{
|
|
102
|
+
class: "flowpress-number-spinner__segment",
|
|
103
|
+
...suffixSemantic
|
|
104
|
+
}}
|
|
98
105
|
>
|
|
99
106
|
{suffix}
|
|
100
|
-
</
|
|
107
|
+
</SemanticElement>
|
|
101
108
|
) : null}
|
|
102
|
-
</
|
|
109
|
+
</StyleflowElement>
|
|
103
110
|
|
|
104
111
|
<script>
|
|
105
112
|
import { initializeNumberSpinners } from "../../number-spinner.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
|
|
4
|
+
type SemanticElementTag =
|
|
5
|
+
| "div" | "span" | "p" | "a" | "li" | "ol" | "ul" | "blockquote"
|
|
6
|
+
| "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "strong" | "em"
|
|
7
|
+
| "small" | "mark";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
tag: SemanticElementTag;
|
|
11
|
+
attributes?: Record<string, unknown> | undefined;
|
|
12
|
+
html?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { tag, attributes = {}, html } = Astro.props;
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
{tag === "div" ? <StyleflowElement as="div" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
19
|
+
: tag === "span" ? <StyleflowElement as="span" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
20
|
+
: tag === "p" ? <StyleflowElement as="p" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
21
|
+
: tag === "a" ? <StyleflowElement as="a" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
22
|
+
: tag === "li" ? <StyleflowElement as="li" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
23
|
+
: tag === "ol" ? <StyleflowElement as="ol" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
24
|
+
: tag === "ul" ? <StyleflowElement as="ul" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
25
|
+
: tag === "blockquote" ? <StyleflowElement as="blockquote" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
26
|
+
: tag === "h1" ? <StyleflowElement as="h1" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
27
|
+
: tag === "h2" ? <StyleflowElement as="h2" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
28
|
+
: tag === "h3" ? <StyleflowElement as="h3" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
29
|
+
: tag === "h4" ? <StyleflowElement as="h4" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
30
|
+
: tag === "h5" ? <StyleflowElement as="h5" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
31
|
+
: tag === "h6" ? <StyleflowElement as="h6" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
32
|
+
: tag === "strong" ? <StyleflowElement as="strong" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
33
|
+
: tag === "em" ? <StyleflowElement as="em" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
34
|
+
: tag === "small" ? <StyleflowElement as="small" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>
|
|
35
|
+
: <StyleflowElement as="mark" {...attributes}>{html === undefined ? <slot /> : <Fragment set:html={html} />}</StyleflowElement>}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Media from "../Media.astro";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../block-renderers.js";
|
|
5
|
+
|
|
6
|
+
type LogoImage = { url?: string | undefined; width?: number | undefined; height?: number | undefined; alt?: string } | undefined;
|
|
7
|
+
type LogoData = {
|
|
8
|
+
images?: { positive?: LogoImage | undefined; negative?: LogoImage } | undefined;
|
|
9
|
+
homeUrl?: string | undefined;
|
|
10
|
+
override?: "auto" | "positive" | "negative" | undefined;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const { block, styleflowProps, htmlProps } = Astro.props as FlowpressBlockRendererProps;
|
|
14
|
+
const data = (block.resolvedData ?? {}) as LogoData;
|
|
15
|
+
const positive = data.images?.positive ?? {};
|
|
16
|
+
const negative = data.images?.negative ?? {};
|
|
17
|
+
const homeUrl = typeof data.homeUrl === "string" && data.homeUrl ? data.homeUrl : "/";
|
|
18
|
+
const override = data.override === "positive" || data.override === "negative"
|
|
19
|
+
? data.override
|
|
20
|
+
: "auto";
|
|
21
|
+
const rootHtmlProps = {
|
|
22
|
+
...htmlProps,
|
|
23
|
+
class: ["flowpress-site-logo", htmlProps.class].filter(Boolean).join(" ")
|
|
24
|
+
};
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
{positive.url || negative.url ? (
|
|
28
|
+
<StyleflowElement as="a"
|
|
29
|
+
{...rootHtmlProps}
|
|
30
|
+
{...styleflowProps}
|
|
31
|
+
href={homeUrl}
|
|
32
|
+
data-flowpress-logo-override={override === "auto" ? undefined : override}
|
|
33
|
+
aria-label="Home"
|
|
34
|
+
>
|
|
35
|
+
{positive.url ? (
|
|
36
|
+
<Media
|
|
37
|
+
class="flowpress-site-logo__image flowpress-site-logo__image--positive"
|
|
38
|
+
src={positive.url}
|
|
39
|
+
width={positive.width || undefined}
|
|
40
|
+
height={positive.height || undefined}
|
|
41
|
+
alt={positive.alt ?? ""}
|
|
42
|
+
/>
|
|
43
|
+
) : null}
|
|
44
|
+
{negative.url ? (
|
|
45
|
+
<Media
|
|
46
|
+
class="flowpress-site-logo__image flowpress-site-logo__image--negative"
|
|
47
|
+
src={negative.url}
|
|
48
|
+
width={negative.width || undefined}
|
|
49
|
+
height={negative.height || undefined}
|
|
50
|
+
alt={negative.alt ?? ""}
|
|
51
|
+
/>
|
|
52
|
+
) : null}
|
|
53
|
+
</StyleflowElement>
|
|
54
|
+
) : null}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import { decodeFlowpressText } from "../../text.js";
|
|
3
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
4
|
import type { FlowpressBlock } from "../../types.js";
|
|
4
5
|
import type { StyleflowContract } from "../../styleflow.js";
|
|
5
6
|
import {
|
|
@@ -7,15 +8,17 @@ import {
|
|
|
7
8
|
preserveEmptyTextBlock,
|
|
8
9
|
preserveRichTextSpacing,
|
|
9
10
|
semanticProps,
|
|
11
|
+
textBlockSemanticDefaults,
|
|
10
12
|
textAlignmentStyle,
|
|
11
13
|
textValue,
|
|
12
14
|
unwrapCoreHtml
|
|
13
15
|
} from "./helpers.js";
|
|
16
|
+
import SemanticElement from "./SemanticElement.astro";
|
|
14
17
|
|
|
15
18
|
interface Props {
|
|
16
19
|
block: FlowpressBlock;
|
|
17
|
-
contract?: StyleflowContract;
|
|
18
|
-
hasChildren?: boolean;
|
|
20
|
+
contract?: StyleflowContract | undefined;
|
|
21
|
+
hasChildren?: boolean | undefined;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
const { block, contract, hasChildren = false } = Astro.props;
|
|
@@ -24,21 +27,9 @@ const attributes = block.attributes;
|
|
|
24
27
|
const heading = name === "heading" || name === "core/heading";
|
|
25
28
|
const level = Math.min(6, Math.max(1, Number(attributes.level ?? 2)));
|
|
26
29
|
const headingTag = `h${level}` as "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
27
|
-
const defaults =
|
|
28
|
-
? {
|
|
29
|
-
ty: "heading",
|
|
30
|
-
v: String(attributes.v ?? attributes.variant ?? level),
|
|
31
|
-
w: String(attributes.w ?? attributes.weight ?? "strong"),
|
|
32
|
-
foreground: "primary"
|
|
33
|
-
}
|
|
34
|
-
: {
|
|
35
|
-
ty: "body",
|
|
36
|
-
v: String(attributes.v ?? (name.includes("quote") ? "lg" : "md")),
|
|
37
|
-
w: String(attributes.w ?? "default"),
|
|
38
|
-
foreground: "primary"
|
|
39
|
-
};
|
|
30
|
+
const defaults = textBlockSemanticDefaults(name, attributes, contract);
|
|
40
31
|
const semantic = semanticProps(attributes, contract, defaults);
|
|
41
|
-
const htmlAttributes = blockHtmlAttributes(attributes);
|
|
32
|
+
const htmlAttributes = blockHtmlAttributes(attributes, name === "core/list" ? "wp-block-list" : "");
|
|
42
33
|
const alignmentStyle = textAlignmentStyle(attributes);
|
|
43
34
|
const coreHtml = String(
|
|
44
35
|
attributes.content
|
|
@@ -60,24 +51,38 @@ const listTag = Boolean(attributes.ordered) ? "ol" : "ul";
|
|
|
60
51
|
---
|
|
61
52
|
|
|
62
53
|
{heading ? (
|
|
63
|
-
<
|
|
54
|
+
<SemanticElement
|
|
55
|
+
tag={headingTag}
|
|
56
|
+
attributes={{ ...semantic, ...htmlAttributes, style: alignmentStyle }}
|
|
57
|
+
html={html}
|
|
58
|
+
/>
|
|
64
59
|
) : name === "core/list" ? (
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
<SemanticElement
|
|
61
|
+
tag={listTag}
|
|
62
|
+
attributes={{ ...semantic, ...htmlAttributes, style: alignmentStyle }}
|
|
63
|
+
html={hasChildren ? undefined : html}
|
|
64
|
+
>
|
|
65
|
+
{hasChildren ? <slot /> : null}
|
|
66
|
+
</SemanticElement>
|
|
68
67
|
) : name === "core/list-item" ? (
|
|
69
|
-
<
|
|
68
|
+
<StyleflowElement as="li" {...semantic} {...htmlAttributes} style={alignmentStyle}>
|
|
70
69
|
<span set:html={html}></span>
|
|
71
70
|
{hasChildren ? <slot /> : null}
|
|
72
|
-
</
|
|
71
|
+
</StyleflowElement>
|
|
73
72
|
) : name === "quote" || name === "core/quote" ? (
|
|
74
|
-
<
|
|
73
|
+
<StyleflowElement as="blockquote" {...semantic} {...htmlAttributes} style={alignmentStyle}>
|
|
75
74
|
{hasChildren ? <slot /> : <div set:html={html}></div>}
|
|
76
|
-
{attributes.citation ? <cite>{
|
|
77
|
-
</
|
|
75
|
+
{attributes.citation ? <cite>{decodeFlowpressText(attributes.citation)}</cite> : null}
|
|
76
|
+
</StyleflowElement>
|
|
77
|
+
) : name === "core/paragraph" ? (
|
|
78
|
+
<StyleflowElement as="p"
|
|
79
|
+
{...semantic}
|
|
80
|
+
{...htmlAttributes}
|
|
81
|
+
style={alignmentStyle}
|
|
82
|
+
set:html={html}
|
|
83
|
+
/>
|
|
78
84
|
) : (
|
|
79
|
-
<
|
|
80
|
-
as={name === "core/paragraph" ? "p" : "div"}
|
|
85
|
+
<StyleflowElement as="div"
|
|
81
86
|
{...semantic}
|
|
82
87
|
{...htmlAttributes}
|
|
83
88
|
style={alignmentStyle}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
import StyleflowElement from "../StyleflowElement.astro";
|
|
3
|
+
import ThemeToggle from "../preferences/ThemeToggle.astro";
|
|
4
|
+
import type { FlowpressBlockRendererProps } from "../../block-renderers.js";
|
|
5
|
+
const { block, styleflowProps, htmlProps } = Astro.props as FlowpressBlockRendererProps;
|
|
6
|
+
const label = typeof block.attributes.label === "string" && block.attributes.label.trim()
|
|
7
|
+
? block.attributes.label.trim() : "Change color theme";
|
|
8
|
+
const showThemeName = block.attributes.showThemeName !== false;
|
|
9
|
+
---
|
|
10
|
+
<StyleflowElement as="span" {...styleflowProps} class="flowpress-theme-control">
|
|
11
|
+
<ThemeToggle {...htmlProps} label={label} />
|
|
12
|
+
{showThemeName && <StyleflowElement as="span" data-styleflow-theme-label aria-hidden="true" />}
|
|
13
|
+
</StyleflowElement>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FlowpressBlock } from "../../types.js";
|
|
2
|
+
export type CoverBackgroundType = "color" | "image" | "video";
|
|
3
|
+
export type CoverTagName = "article" | "aside" | "div" | "footer" | "header" | "main" | "section";
|
|
4
|
+
export declare function coverTagName(value: unknown): CoverTagName;
|
|
5
|
+
export declare function coverMediaSource(block: FlowpressBlock): string;
|
|
6
|
+
export declare function coverPosterSource(block: FlowpressBlock): string | undefined;
|
|
7
|
+
export declare function coverBackgroundType(block: FlowpressBlock): CoverBackgroundType;
|
|
8
|
+
export declare function coverObjectPosition(value: unknown): string;
|
|
9
|
+
export declare function coverMinimumHeight(value: unknown, unitValue: unknown): string | undefined;
|
|
10
|
+
export declare function coverContentPosition(value: unknown): [string, string];
|
|
11
|
+
export declare function coverScrimEnabled(attributes: Record<string, unknown>): boolean;
|
|
12
|
+
export declare function coverScrimOpacity(attributes: Record<string, unknown>): number;
|
|
13
|
+
//# sourceMappingURL=cover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cover.d.ts","sourceRoot":"","sources":["../../../src/astro/blocks/cover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAwC9D,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAClG,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAGzD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAE9D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAI3E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,mBAAmB,CAK9E;AAUD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQ1D;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,OAAO,GACjB,MAAM,GAAG,SAAS,CAMpB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAGrE;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAM9E;AAQD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAK7E"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const COVER_TAGS = new Set([
|
|
2
|
+
"article",
|
|
3
|
+
"aside",
|
|
4
|
+
"div",
|
|
5
|
+
"footer",
|
|
6
|
+
"header",
|
|
7
|
+
"main",
|
|
8
|
+
"section"
|
|
9
|
+
]);
|
|
10
|
+
const HEIGHT_UNITS = new Set([
|
|
11
|
+
"px",
|
|
12
|
+
"%",
|
|
13
|
+
"em",
|
|
14
|
+
"rem",
|
|
15
|
+
"vh",
|
|
16
|
+
"svh",
|
|
17
|
+
"lvh",
|
|
18
|
+
"dvh",
|
|
19
|
+
"vw"
|
|
20
|
+
]);
|
|
21
|
+
const CONTENT_POSITIONS = {
|
|
22
|
+
"top left": ["start", "start"],
|
|
23
|
+
"top center": ["start", "center"],
|
|
24
|
+
"top right": ["start", "end"],
|
|
25
|
+
"center left": ["center", "start"],
|
|
26
|
+
"center center": ["center", "center"],
|
|
27
|
+
"center right": ["center", "end"],
|
|
28
|
+
"bottom left": ["end", "start"],
|
|
29
|
+
"bottom center": ["end", "center"],
|
|
30
|
+
"bottom right": ["end", "end"]
|
|
31
|
+
};
|
|
32
|
+
function text(value) {
|
|
33
|
+
return typeof value === "string" ? value.trim() : "";
|
|
34
|
+
}
|
|
35
|
+
export function coverTagName(value) {
|
|
36
|
+
const candidate = text(value).toLowerCase();
|
|
37
|
+
return COVER_TAGS.has(candidate) ? candidate : "div";
|
|
38
|
+
}
|
|
39
|
+
export function coverMediaSource(block) {
|
|
40
|
+
return text(block.attributes.url) || text(block.resolvedData?.url);
|
|
41
|
+
}
|
|
42
|
+
export function coverPosterSource(block) {
|
|
43
|
+
return text(block.attributes.poster)
|
|
44
|
+
|| text(block.resolvedData?.poster)
|
|
45
|
+
|| undefined;
|
|
46
|
+
}
|
|
47
|
+
export function coverBackgroundType(block) {
|
|
48
|
+
const requested = text(block.attributes.backgroundType).toLowerCase();
|
|
49
|
+
if (requested === "video")
|
|
50
|
+
return "video";
|
|
51
|
+
if (requested === "color")
|
|
52
|
+
return "color";
|
|
53
|
+
return coverMediaSource(block) ? "image" : "color";
|
|
54
|
+
}
|
|
55
|
+
function percentage(value) {
|
|
56
|
+
const numeric = typeof value === "number" ? value : Number(value);
|
|
57
|
+
if (!Number.isFinite(numeric))
|
|
58
|
+
return undefined;
|
|
59
|
+
if (numeric >= 0 && numeric <= 1)
|
|
60
|
+
return numeric * 100;
|
|
61
|
+
if (numeric >= 0 && numeric <= 100)
|
|
62
|
+
return numeric;
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
export function coverObjectPosition(value) {
|
|
66
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
67
|
+
return "50% 50%";
|
|
68
|
+
}
|
|
69
|
+
const focalPoint = value;
|
|
70
|
+
const x = percentage(focalPoint.x);
|
|
71
|
+
const y = percentage(focalPoint.y);
|
|
72
|
+
return x === undefined || y === undefined ? "50% 50%" : `${x}% ${y}%`;
|
|
73
|
+
}
|
|
74
|
+
export function coverMinimumHeight(value, unitValue) {
|
|
75
|
+
const numeric = typeof value === "number" ? value : Number(value);
|
|
76
|
+
if (!Number.isFinite(numeric) || numeric < 0)
|
|
77
|
+
return undefined;
|
|
78
|
+
const requestedUnit = text(unitValue).toLowerCase();
|
|
79
|
+
const unit = HEIGHT_UNITS.has(requestedUnit) ? requestedUnit : "px";
|
|
80
|
+
return `${numeric}${unit}`;
|
|
81
|
+
}
|
|
82
|
+
export function coverContentPosition(value) {
|
|
83
|
+
return CONTENT_POSITIONS[text(value).toLowerCase()]
|
|
84
|
+
?? ["center", "center"];
|
|
85
|
+
}
|
|
86
|
+
export function coverScrimEnabled(attributes) {
|
|
87
|
+
if (typeof attributes.scrimEnabled === "boolean") {
|
|
88
|
+
return attributes.scrimEnabled;
|
|
89
|
+
}
|
|
90
|
+
const nativeDimRatio = Number(attributes.dimRatio);
|
|
91
|
+
return Number.isFinite(nativeDimRatio) && nativeDimRatio > 0;
|
|
92
|
+
}
|
|
93
|
+
function clampedPercentage(value) {
|
|
94
|
+
const numeric = typeof value === "number" ? value : Number(value);
|
|
95
|
+
if (!Number.isFinite(numeric))
|
|
96
|
+
return undefined;
|
|
97
|
+
return Math.min(100, Math.max(0, numeric));
|
|
98
|
+
}
|
|
99
|
+
export function coverScrimOpacity(attributes) {
|
|
100
|
+
const explicitOpacity = clampedPercentage(attributes.scrimOpacity);
|
|
101
|
+
if (explicitOpacity !== undefined)
|
|
102
|
+
return explicitOpacity;
|
|
103
|
+
return clampedPercentage(attributes.dimRatio) ?? 100;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=cover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cover.js","sourceRoot":"","sources":["../../../src/astro/blocks/cover.ts"],"names":[],"mappings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,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,cAAc,GAAG,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,MAAM,OAAO,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAChD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,UAAmC;IACnE,MAAM,eAAe,GAAG,iBAAiB,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACnE,IAAI,eAAe,KAAK,SAAS;QAAE,OAAO,eAAe,CAAC;IAE1D,OAAO,iBAAiB,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC;AACvD,CAAC","sourcesContent":["import type { FlowpressBlock } from \"../../types.js\";\n\nexport type CoverBackgroundType = \"color\" | \"image\" | \"video\";\n\nconst COVER_TAGS = new Set([\n \"article\",\n \"aside\",\n \"div\",\n \"footer\",\n \"header\",\n \"main\",\n \"section\"\n]);\n\nconst HEIGHT_UNITS = new Set([\n \"px\",\n \"%\",\n \"em\",\n \"rem\",\n \"vh\",\n \"svh\",\n \"lvh\",\n \"dvh\",\n \"vw\"\n]);\n\nconst CONTENT_POSITIONS: Record<string, [string, string]> = {\n \"top left\": [\"start\", \"start\"],\n \"top center\": [\"start\", \"center\"],\n \"top right\": [\"start\", \"end\"],\n \"center left\": [\"center\", \"start\"],\n \"center center\": [\"center\", \"center\"],\n \"center right\": [\"center\", \"end\"],\n \"bottom left\": [\"end\", \"start\"],\n \"bottom center\": [\"end\", \"center\"],\n \"bottom right\": [\"end\", \"end\"]\n};\n\nfunction text(value: unknown): string {\n return typeof value === \"string\" ? value.trim() : \"\";\n}\n\nexport type CoverTagName = \"article\" | \"aside\" | \"div\" | \"footer\" | \"header\" | \"main\" | \"section\";\nexport function coverTagName(value: unknown): CoverTagName {\n const candidate = text(value).toLowerCase();\n return COVER_TAGS.has(candidate) ? candidate as CoverTagName : \"div\";\n}\n\nexport function coverMediaSource(block: FlowpressBlock): string {\n return text(block.attributes.url) || text(block.resolvedData?.url);\n}\n\nexport function coverPosterSource(block: FlowpressBlock): string | undefined {\n return text(block.attributes.poster)\n || text(block.resolvedData?.poster)\n || undefined;\n}\n\nexport function coverBackgroundType(block: FlowpressBlock): CoverBackgroundType {\n const requested = text(block.attributes.backgroundType).toLowerCase();\n if (requested === \"video\") return \"video\";\n if (requested === \"color\") return \"color\";\n return coverMediaSource(block) ? \"image\" : \"color\";\n}\n\nfunction percentage(value: unknown): number | undefined {\n const numeric = typeof value === \"number\" ? value : Number(value);\n if (!Number.isFinite(numeric)) return undefined;\n if (numeric >= 0 && numeric <= 1) return numeric * 100;\n if (numeric >= 0 && numeric <= 100) return numeric;\n return undefined;\n}\n\nexport function coverObjectPosition(value: unknown): string {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return \"50% 50%\";\n }\n const focalPoint = value as Record<string, unknown>;\n const x = percentage(focalPoint.x);\n const y = percentage(focalPoint.y);\n return x === undefined || y === undefined ? \"50% 50%\" : `${x}% ${y}%`;\n}\n\nexport function coverMinimumHeight(\n value: unknown,\n unitValue: unknown\n): string | undefined {\n const numeric = typeof value === \"number\" ? value : Number(value);\n if (!Number.isFinite(numeric) || numeric < 0) return undefined;\n const requestedUnit = text(unitValue).toLowerCase();\n const unit = HEIGHT_UNITS.has(requestedUnit) ? requestedUnit : \"px\";\n return `${numeric}${unit}`;\n}\n\nexport function coverContentPosition(value: unknown): [string, string] {\n return CONTENT_POSITIONS[text(value).toLowerCase()]\n ?? [\"center\", \"center\"];\n}\n\nexport function coverScrimEnabled(attributes: Record<string, unknown>): boolean {\n if (typeof attributes.scrimEnabled === \"boolean\") {\n return attributes.scrimEnabled;\n }\n const nativeDimRatio = Number(attributes.dimRatio);\n return Number.isFinite(nativeDimRatio) && nativeDimRatio > 0;\n}\n\nfunction clampedPercentage(value: unknown): number | undefined {\n const numeric = typeof value === \"number\" ? value : Number(value);\n if (!Number.isFinite(numeric)) return undefined;\n return Math.min(100, Math.max(0, numeric));\n}\n\nexport function coverScrimOpacity(attributes: Record<string, unknown>): number {\n const explicitOpacity = clampedPercentage(attributes.scrimOpacity);\n if (explicitOpacity !== undefined) return explicitOpacity;\n\n return clampedPercentage(attributes.dimRatio) ?? 100;\n}\n"]}
|