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 / taxonomy / excerpt.js

excerpt.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.7, at src/blocks/taxonomy/excerpt.js

131 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useState } from "@wordpress/element";
2 import { Spacing, SpColorPicker, SPRangeControl, SPToggleGroupControl, Toggle, TypographyNew } from "../../components";
3 import { __ } from "@wordpress/i18n";
4 export const ExcerptTab = ({ attributes, setAttributes }) => {
5 const [colorState, setColorState] = useState("normal");
6 const {
7 blockName,
8 excerptMargin,
9 excerptShow,
10 excerptLineHeight,
11 excerptLatterSpacing,
12 excerptFontSize,
13 excerptTypography,
14 excerptColor,
15 excerptLength,
16 excerptWordSpacing,
17 excerptGlobalTypography,
18 } = attributes;
19
20 return (
21 <>
22 <Toggle
23 label={__("Show Excerpt", "post-carousel")}
24 attributes={excerptShow}
25 attributesKey={"excerptShow"}
26 setAttributes={setAttributes}
27 />
28
29 {excerptShow && (
30 <>
31 <SPRangeControl
32 label={__("Excerpt Length", "post-carousel")}
33 attributes={excerptLength}
34 attributesKey={"excerptLength"}
35 setAttributes={setAttributes}
36 units={[]}
37 defaultValue={{
38 unit: "words",
39 value: 10,
40 }}
41 max={200}
42 className="sp-smart-post-ranger-length"
43 />
44
45 <TypographyNew
46 attributes={{
47 family: excerptTypography,
48 familyKey: "excerptTypography",
49 fontSize: excerptFontSize,
50 fontSizeKey: "excerptFontSize",
51 fontSpacing: excerptLatterSpacing,
52 fontSpacingKey: "excerptLatterSpacing",
53 lineHeight: excerptLineHeight,
54 lineHeightKey: "excerptLineHeight",
55 wordSpacing: excerptWordSpacing,
56 wordSpacingKey: "excerptWordSpacing",
57 globalTypo: excerptGlobalTypography,
58 globalTypoKey: "excerptGlobalTypography",
59 }}
60 setAttributes={setAttributes}
61 spacingDefaultValue={{ unit: "px", value: 0 }}
62 fontSizeDefault={{
63 unit: "px",
64 value: 14,
65 }}
66 lineDefaultValue={1.2}
67 typographyLabel={
68 blockName === "taxonomy"
69 ? __("Typography", "post-carousel")
70 : __("Typography", "post-carousel")
71 }
72 />
73
74 <SPToggleGroupControl
75 attributes={colorState}
76 items={[
77 { label: "Normal", value: "normal" },
78 { label: "Hover", value: "hover" },
79 ]}
80 onClick={(newColor) => setColorState(newColor)}
81 />
82 {"normal" === colorState ? (
83 <SpColorPicker
84 label={__("Color", "post-carousel")}
85 value={excerptColor.color}
86 onChange={(newColor) =>
87 setAttributes({
88 excerptColor: {
89 ...excerptColor,
90 color: newColor,
91 },
92 })
93 }
94 defaultColor="#FFFFFF"
95 />
96 ) : (
97 <SpColorPicker
98 label={__("Color", "post-carousel")}
99 value={excerptColor.hoverColor}
100 onChange={(newColor) =>
101 setAttributes({
102 excerptColor: {
103 ...excerptColor,
104 hoverColor: newColor,
105 },
106 })
107 }
108 />
109 )}
110 <Spacing
111 label={__("Margin", "post-carousel")}
112 attributes={excerptMargin}
113 attributesKey={"excerptMargin"}
114 setAttributes={setAttributes}
115 units={["px", "%", "em"]}
116 defaultValue={{
117 unit: "px",
118 value: {
119 top: "0",
120 right: "0",
121 bottom: "0",
122 left: "0",
123 },
124 }}
125 />
126 </>
127 )}
128 </>
129 );
130 };
131