PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.8
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.8
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-grid-four / edit.js

edit.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.8, at src/blocks/post-grid-four/edit.js

166 lines 4.1 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 InspectorControl from "../../components/inspectorControls/inspectorControls";
3 import { panelBodyRightIcon, panelBodyTitleIcon } from "../../icons/icons";
4 import { useBlockProps } from "@wordpress/block-editor";
5 import Inspector from "./inspect";
6 import dynamicCssFn from "./dynamicCss";
7 import { EditorWrapper } from "../shared/wrapper";
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 GridFourEdit = ({ attributes, setAttributes, isSelected }) => {
16 const [posts, setPosts] = useState([]);
17 const {
18 blockName,
19 postCardBg,
20 fontListsEditPage,
21 contentAreaPadding,
22 largeItemHeight,
23 smallItemHeight,
24 largeItemTitleFontSize,
25 customCss,
26 } = attributes;
27
28 const blockProps = useBlockProps();
29 const deviceType = useDeviceType();
30
31 useEffect(() => {
32 if (!blockName) {
33 setAttributes({
34 postLimit: 5,
35 imagePosition: "background",
36 postCardBg: {
37 ...postCardBg,
38 color: { ...postCardBg.color, style: "transparent" },
39 },
40 imageOverlayColor: "default",
41 // titleColor: { ...titleColor, color: '#FFFFFF' },
42 // metaColors: { ...metaColors, color: '#FFFFFF' },
43 // excerptColor: { ...excerptColor, color: '#EEEEEE' },
44 contentVerticalPosition: "bottom",
45 contentAreaPadding: {
46 ...contentAreaPadding,
47 device: {
48 ...contentAreaPadding.device,
49 Desktop: {
50 top: "0",
51 right: "20",
52 bottom: "20",
53 left: "20",
54 },
55 },
56 },
57 // paginationMargin: {
58 // ...paginationMargin,
59 // device: {
60 // ...paginationMargin.device,
61 // Desktop: {
62 // ...paginationMargin.device.Desktop,
63 // top: 48,
64 // },
65 // Tablet: {
66 // ...paginationMargin.device.Tablet,
67 // top: 30,
68 // },
69 // Mobile: {
70 // ...paginationMargin.device.Mobile,
71 // top: 30,
72 // },
73 // },
74 // },
75 largeItemHeight: {
76 ...largeItemHeight,
77 device: {
78 ...largeItemHeight.device,
79 Desktop: "560",
80 },
81 },
82 smallItemHeight: {
83 ...smallItemHeight,
84 device: {
85 ...smallItemHeight.device,
86 Desktop: 275,
87 Mobile: 210,
88 },
89 },
90 // titleFontSize: {
91 // ...titleFontSize,
92 // device: {
93 // ...titleFontSize.device,
94 // Desktop: 22,
95 // Tablet: 18,
96 // Mobile: 22,
97 // },
98 // },
99 largeItemTitleFontSize: {
100 ...largeItemTitleFontSize,
101 device: {
102 ...largeItemTitleFontSize.device,
103 Mobile: 22,
104 },
105 },
106 // catTabCategoryBg: {
107 // ...catTabCategoryBg,
108 // color: {
109 // ...catTabCategoryBg.color,
110 // solidColor: '#FFFFFF',
111 // },
112 // hover: {
113 // ...catTabCategoryBg.hover,
114 // solidColor: '#EF5D30',
115 // },
116 // },
117 // catTabCategoryColor: {
118 // ...catTabCategoryColor,
119 // color: '#222222',
120 // hoverColor: '#FFFFFF',
121 // },
122 });
123 }
124 }, []);
125
126 const blockStyling = useMemo(
127 () => dynamicCssFn(attributes, "frontend", deviceType),
128 [...cssDependency(attributes), deviceType, attributes]
129 );
130
131 useEffect(() => {
132 setAttributes({ currentScreen: deviceType });
133 }, [deviceType]);
134
135 // useEffect( () => {
136 // if ( gridFourMasonryEnable ) {
137 // setAttributes( { equalHeightEnable: false } );
138 // }
139 // }, [ gridFourMasonryEnable ] );
140
141 return (
142 <div {...blockProps}>
143 <style>
144 {fontListsEditPage}
145 {blockStyling}
146 {customCss}
147 </style>
148 <TogglePanelBodyProvider>
149 <InspectorControl
150 TitleIcon={panelBodyTitleIcon}
151 RightIcon={panelBodyRightIcon}
152 Inspector={Inspector}
153 attributes={attributes}
154 setAttributes={setAttributes}
155 isSelected={isSelected}
156 />
157 <EditorWrapper setPosts={setPosts} setAttributes={setAttributes}>
158 <Render posts={posts} attributes={attributes} page={"editor"} />
159 </EditorWrapper>
160 </TogglePanelBodyProvider>
161 </div>
162 );
163 };
164
165 export default compose(addInitialAttr)(GridFourEdit);
166