PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.3
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.3
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 / button / save.js

save.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.3, at src/blocks/button/save.js

100 lines 2.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 { arrowIcons } from "../../controls/constants";
3 import classNames from "classnames";
4
5 const ButtonSave = ({ attributes }) => {
6 const {
7 uniqueId,
8 buttonLabel,
9 iconSource,
10 buttonStyle,
11 hoverEffects,
12 buttonLink,
13 openNewTab,
14 enableIcon,
15 additionalCssClass,
16 buttonLabelEnable,
17 buttonLabelGlobalTypography,
18 } = attributes;
19
20 const blockProps = useBlockProps.save({
21 className: additionalCssClass,
22 });
23
24 const BtnIcon = arrowIcons[iconSource];
25
26 return (
27 <div {...blockProps}>
28 <div
29 className={classNames(
30 "sp-smart-post-wrapper",
31 "sp-smart-post-button-editor-page",
32 "sp-smart-post-button-wrapper"
33 )}
34 id={uniqueId}
35 >
36 <a
37 href={buttonLink}
38 target={openNewTab ? "_blank" : undefined}
39 className={`sp-smart-post-btn btn-${buttonStyle} ${hoverEffects}`}
40 rel="noreferrer"
41 >
42 <div className="button-label">
43 <div className="front">
44 {enableIcon && (
45 <span
46 className="icon"
47 aria-label="button arrow icon"
48 style={{
49 lineHeight: "1",
50 }}
51 >
52 <i aria-hidden="true">
53 <BtnIcon />
54 </i>
55 </span>
56 )}
57 {buttonLabelEnable && (
58 <span
59 className={classNames(
60 "sp-rich-text",
61 "sp-btn-label",
62 buttonLabelGlobalTypography?.class ? buttonLabelGlobalTypography.class : ""
63 )}
64 >
65 {buttonLabel}
66 </span>
67 )}
68 </div>
69
70 {hoverEffects === "flip" && (
71 <div className="back">
72 {iconSource && (
73 <span className="icon" aria-label="flip on hover button arrow icon">
74 <i className={`sp-icon-${iconSource}`} aria-hidden="true">
75 <BtnIcon />
76 </i>
77 </span>
78 )}
79 {buttonLabelEnable && (
80 <span
81 className={classNames(
82 "sp-rich-text",
83 "sp-btn-label",
84 buttonLabelGlobalTypography?.class ? buttonLabelGlobalTypography.class : ""
85 )}
86 >
87 {buttonLabel}
88 </span>
89 )}
90 </div>
91 )}
92 </div>
93 </a>
94 </div>
95 </div>
96 );
97 };
98
99 export default ButtonSave;
100