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 / smart-search / edit.js

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

92 lines 2.8 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 { InspectorControl } from "../../components";
3 import { panelBodyRightIcon, panelBodyTitleIcon } from "../../icons/icons";
4 import Render from "./render";
5 import dynamicCss from "./dynamicCss";
6 import { Inspector } from "./inspector";
7 import { TogglePanelBodyProvider } from "../../context";
8 import { useEffect, useMemo } from "@wordpress/element";
9 import classNames from "classnames";
10 import { googleFonts } from "../../controls/controls";
11 import { select } from "@wordpress/data";
12 import { compose } from "@wordpress/compose";
13 import addInitialAttr from "../shared/addInitialAttr";
14 import { jsonStringify, ProTopBar } from "../shared/helpFn";
15
16 const SmartSearchEdit = ({ attributes, setAttributes }) => {
17 const blockProps = useBlockProps();
18 const {
19 blockName,
20 uniqueId,
21 additionalCssClass,
22 fontListsEditPage,
23 inputPlaceholderTypography,
24 inputPlaceHolderGlobalTypography,
25 searchBtnLabelTypography,
26 searchResultTitleTypography,
27 searchResultMetaTypography,
28 searchResultTitleGlobalTypography,
29 searchResultMetaGlobalTypography,
30 moreResultTypography,
31 moreResultGlobalTypography,
32 popupHeadingTypography,
33 popupHeadingGlobalTypography,
34 } = attributes;
35
36 // set typography.
37 const googleFontLists = [
38 inputPlaceholderTypography,
39 inputPlaceHolderGlobalTypography,
40 searchBtnLabelTypography,
41 searchResultTitleTypography,
42 searchResultMetaTypography,
43 searchResultTitleGlobalTypography,
44 searchResultMetaGlobalTypography,
45 moreResultTypography,
46 moreResultGlobalTypography,
47 popupHeadingTypography,
48 popupHeadingGlobalTypography,
49 ];
50 useEffect(() => {
51 setAttributes({
52 fontLists: jsonStringify(googleFonts(googleFontLists, "frontend")),
53 fontListsEditPage: googleFonts(googleFontLists, "edit"),
54 });
55 }, googleFontLists);
56
57 // set breakpoint
58 const getGlobalBreakpoint = select("smartpost/global-settings").getCategory("breakpoint");
59 useEffect(() => {
60 if (typeof getGlobalBreakpoint === "object") {
61 setAttributes({ globalBreakPointData: getGlobalBreakpoint });
62 }
63 }, [getGlobalBreakpoint]);
64
65 const blockStyling = useMemo(() => dynamicCss(attributes, "frontend"), [attributes]);
66 return (
67 <div {...blockProps}>
68 <style>{blockStyling}</style>
69 <style>{fontListsEditPage}</style>
70 <TogglePanelBodyProvider>
71 <InspectorControl
72 TitleIcon={panelBodyTitleIcon}
73 RightIcon={panelBodyRightIcon}
74 attributes={attributes}
75 setAttributes={setAttributes}
76 Inspector={Inspector}
77 />
78
79 <div id={uniqueId} className={classNames("sp-smart-post-wrapper", additionalCssClass)}>
80 <ProTopBar
81 blockName={blockName}
82 title="Smart Search"
83 />
84 <Render attributes={attributes} setAttributes={setAttributes} />
85 </div>
86 </TogglePanelBodyProvider>
87 </div>
88 );
89 };
90
91 export default compose(addInitialAttr)(SmartSearchEdit);
92