PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.7
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.7
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / src / blocks / post-timeline-two / edit.js

edit.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.7, at src/blocks/post-timeline-two/edit.js

93 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useEffect, useState, useMemo } from "@wordpress/element";
2 import { useBlockProps } from "@wordpress/block-editor";
3 import InspectorControl from "../../components/inspectorControls/inspectorControls";
4 import { panelBodyRightIcon, panelBodyTitleIcon } from "../../icons/icons";
5 import { EditorWrapper } from "../shared/wrapper";
6 import dynamicCssFn from "./dynamicCss";
7 import Inspector from "./inspect";
8 import Render from "./render";
9 import { useDeviceType } from "../../controls/controls";
10 import { TogglePanelBodyProvider } from "../../context";
11 import { cssDependency } from "../shared/cssDependency";
12 import { compose } from "@wordpress/compose";
13 import addInitialAttr from "../shared/addInitialAttr";
14
15 const TimelineTwoEdit = ({ attributes, setAttributes, isSelected }) => {
16 const { blockName, fontListsEditPage, gapBetweenPosts, contentAreaPadding, smallItemHeight, customCss } =
17 attributes;
18 const blockProps = useBlockProps();
19 const [posts, setPosts] = useState([]);
20 const deviceType = useDeviceType();
21
22 useEffect(() => {
23 if (!blockName) {
24 setAttributes({
25 timelineLayout: "timeline-one-layout-one",
26 imageOverlayColor: "default",
27 gapBetweenPosts: {
28 ...gapBetweenPosts,
29 device: { ...gapBetweenPosts.device, Desktop: 32 },
30 },
31 imagePosition: "background",
32 contentAreaPadding: {
33 ...contentAreaPadding,
34 device: {
35 ...contentAreaPadding.device,
36 Desktop: {
37 top: "0",
38 right: "20",
39 bottom: "20",
40 left: "20",
41 },
42 },
43 },
44 smallItemHeight: {
45 ...smallItemHeight,
46 device: {
47 ...smallItemHeight.device,
48 Desktop: 372,
49 Tablet: 210,
50 },
51 },
52
53 contentVerticalPosition: "bottom",
54 });
55 }
56 }, []);
57
58 const blockStyling = useMemo(
59 () => dynamicCssFn(attributes, "frontend", deviceType),
60 [...cssDependency(attributes), deviceType, attributes]
61 );
62
63 useEffect(() => {
64 setAttributes({ currentScreen: deviceType });
65 }, [deviceType]);
66
67 return (
68 <div {...blockProps}>
69 <style>
70 {fontListsEditPage}
71 {blockStyling}
72 {customCss}
73 </style>
74 <TogglePanelBodyProvider>
75 <InspectorControl
76 TitleIcon={panelBodyTitleIcon}
77 RightIcon={panelBodyRightIcon}
78 Inspector={Inspector}
79 attributes={attributes}
80 setAttributes={setAttributes}
81 isSelected={isSelected}
82 />
83 {/* Render Html here */}
84 <EditorWrapper setPosts={setPosts} setAttributes={setAttributes}>
85 <Render posts={posts} attributes={attributes} page={"editor"} />
86 </EditorWrapper>
87 </TogglePanelBodyProvider>
88 </div>
89 );
90 };
91
92 export default compose(addInitialAttr)(TimelineTwoEdit);
93