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-grid-five / 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-grid-five/edit.js

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