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 / components / layouts / layouts.js

layouts.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.8, at src/components/layouts/layouts.js

74 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { memo } from "@wordpress/element";
2 import { RightSymbolIcon } from "../../icons/icons";
3 import "./editor.scss";
4 import ProBtn from "../proBtn/proBtn";
5
6 const Layout = ({ layout, handleActive, activeLayout, displayActive, proBtnClass = ""}) => {
7 const { icon, value, label, type, demoLink } = layout;
8
9 return (
10 <div
11 onClick={ type !== "pro" ? () => handleActive(value) : null }
12 className={`sp-smart-post-layout-card ${type === "pro" ? "sp-smart-pro-layout" : ""} ${value === activeLayout ? "active" : "inactive"}`}
13 >
14 {value === activeLayout && displayActive && (
15 <span className="active-symbol">
16 <RightSymbolIcon />
17 </span>
18 )}
19 {type !== "pro" && <div className="sp-smart-layout-img">
20 {icon}
21 </div>}
22 {type === "pro" && <a href={demoLink} rel="noreferrer" target="_blank" className="sp-smart-layout-img">
23 {icon}
24 <ProBtn proBtnClass={proBtnClass} demoLink={demoLink} />
25 </a>}
26 {label && <p className="sp-smart-post-layout-title">{label}</p>}
27 </div>
28 );
29 };
30
31 const Layouts = ({
32 attributes,
33 setAttributes,
34 attributesKey,
35 displayActive = false,
36 label = "",
37 proBtnClass = "",
38 showDemoTitle = false,
39 grid = 2,
40 items,
41 onChange = false,
42 }) => {
43 const handleActive = (value) => {
44 if (value === attributes) {
45 return;
46 }
47 if (onChange) {
48 onChange(value);
49 }
50 setAttributes({ [attributesKey]: value });
51 };
52
53 return (
54 <div className="sp-smart-post-layout-picker sp-smart-post-panel-pb">
55 {label && <p className="sp-smart-post-component-title">{label}</p>}
56 <div className={`sp-smart-post-layouts grid-${grid}`}>
57 {items?.map((layout, index) => (
58 <Layout
59 key={index}
60 layout={layout}
61 displayActive={displayActive}
62 handleActive={handleActive}
63 proBtnClass={proBtnClass}
64 showDemoTitle={showDemoTitle}
65 activeLayout={attributes}
66 />
67 ))}
68 </div>
69 </div>
70 );
71 };
72
73 export default memo(Layouts);
74