PluginProbe ʕ •ᴥ•ʔ
Presto Player / trunk
Presto Player vtrunk
4.3.0 4.2.4 4.2.3 4.2.2 4.2.0 4.2.1 trunk 1.10.0 1.10.1 1.10.2 1.11.0 1.12.0 1.13.0 1.14.0 1.14.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3-beta1 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.0-beta1 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1.0 3.1.1 3.1.2 3.1.3 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4
presto-player / src / admin / blocks / shared / presets / CTA.js
presto-player / src / admin / blocks / shared / presets Last commit date
parts 6 days ago ActionBar.js 6 days ago ActionBar.scss 6 days ago Behavior.js 2 years ago CTA.js 6 days ago CTA.scss 6 days ago Controls.js 5 years ago Edit.js 6 days ago Edit.scss 6 days ago Email.js 6 days ago Email.scss 6 days ago Preset.js 4 years ago Search.js 3 years ago Style.js 6 days ago Style.scss 6 days ago Watermark.js 4 years ago index.js 6 days ago index.scss 6 days ago
CTA.js
331 lines
1 /**
2 * WordPress dependencies
3 */
4 import { __ } from "@wordpress/i18n";
5 import {
6 ToggleControl,
7 BaseControl,
8 RangeControl,
9 TextControl,
10 Flex,
11 Button,
12 TextareaControl,
13 Notice,
14 } from "@wordpress/components";
15 import { useEffect } from "@wordpress/element";
16 import { useSelect } from "@wordpress/data";
17
18 import UrlSelect from "../components/UrlSelect";
19 import ColorPopup from "../components/ColorPopup";
20
21 import "./CTA.scss";
22
23 function CTA({ state, updateState, className }) {
24 const { cta, email_collection } = state;
25
26 const branding = useSelect((select) => {
27 return select("presto-player/player").branding();
28 });
29
30 // set defaults
31 const defaults = {
32 percentage: 100,
33 show_rewatch: true,
34 show_skip: true,
35 headline: __("Want to learn more?", "presto-player"),
36 show_button: true,
37 button_text: __("Click Here", "presto-player"),
38 button_link: {
39 opensInNewTab: true,
40 },
41 };
42 useEffect(() => {
43 Object.keys(defaults).forEach((key) => {
44 if (state?.cta?.[key] === undefined) {
45 updateCTAState({
46 [key]: defaults[key],
47 });
48 }
49 });
50 }, [state]);
51
52 const updateCTAState = (updated) => {
53 updateState({
54 ...state,
55 cta: {
56 ...cta,
57 ...updated,
58 },
59 });
60 };
61
62 const disableEmailCapture = () => {
63 updateState({
64 ...state,
65 email_collection: {
66 ...email_collection,
67 ...{ enabled: false },
68 },
69 });
70 };
71
72 return (
73 <div className={className}>
74 <BaseControl>
75 <h3>{__("Call To Action", "presto-player")}</h3>
76 </BaseControl>
77 <BaseControl className="presto-player__control--large-play">
78 <ToggleControl
79 label={__("Enable", "presto-player")}
80 help={__(
81 "Show a call to action message and button over your player.",
82 "presto-player"
83 )}
84 onChange={(enabled) => {
85 updateCTAState({
86 enabled,
87 });
88 }}
89 checked={cta?.enabled}
90 />
91 </BaseControl>
92 {!!cta?.enabled && (
93 <>
94 <BaseControl
95 className="presto-player__control--percentage-watched presto-cta__range"
96 >
97 <RangeControl
98 label={__("Display At (Percentage)", "presto-player")}
99 labelPosition="top"
100 onChange={(percentage) => {
101 updateCTAState({
102 percentage,
103 });
104 }}
105 marks={[
106 {
107 value: 0,
108 label: __("Start", "presto-player"),
109 },
110 {
111 value: 50,
112 label: __("50% Watched", "presto-player"),
113 },
114 {
115 value: 100,
116 label: __("End", "presto-player"),
117 },
118 ]}
119 shiftStep={5}
120 value={cta?.percentage}
121 className="presto-cta__slider-fix"
122 />
123 </BaseControl>
124
125 {email_collection?.enabled &&
126 email_collection?.percentage === cta?.percentage && (
127 <Notice
128 className="presto-cta__notice"
129 status="warning"
130 isDismissible={false}
131 >
132 {__(
133 "You already have an email capture set display at the same time.",
134 "presto-player"
135 )}
136 <Button
137 onClick={disableEmailCapture}
138 isLink
139 className="presto-cta__button"
140 >
141 {__("Disable Email Capture", "presto-player")}
142 </Button>
143 </Notice>
144 )}
145
146 {cta?.percentage === 100 ? (
147 <BaseControl className="presto-player__control--show-rewatch">
148 <ToggleControl
149 label={__("Show Rewatch Button", "presto-player")}
150 help={__(
151 "Show a rewatch button at the end of the player.",
152 "presto-player"
153 )}
154 onChange={(show_rewatch) => {
155 updateCTAState({
156 show_rewatch,
157 });
158 }}
159 checked={cta?.show_rewatch}
160 />
161 </BaseControl>
162 ) : (
163 <BaseControl className="presto-player__control--show-skip">
164 <ToggleControl
165 label={__("Allow Skipping", "presto-player")}
166 help={__(
167 "Let the user continue watching the player.",
168 "presto-player"
169 )}
170 onChange={(show_skip) => {
171 updateCTAState({
172 show_skip,
173 });
174 }}
175 checked={cta?.show_skip}
176 />
177 </BaseControl>
178 )}
179
180 <BaseControl className="presto-player__control--button-link">
181 <BaseControl.VisualLabel>
182 <p> {__("Link", "presto-player")}</p>
183 </BaseControl.VisualLabel>
184 <UrlSelect
185 setSettings={(val) => {
186 updateCTAState({
187 button_link: val,
188 });
189 }}
190 settings={cta?.button_link || {}}
191 />
192 </BaseControl>
193
194 <BaseControl className="presto-player__control--headline">
195 <TextareaControl
196 label={__("Headline", "presto-player")}
197 help={__("The headline for your form.", "presto-player")}
198 value={cta?.headline}
199 onChange={(headline) => {
200 updateCTAState({
201 headline,
202 });
203 }}
204 />
205 </BaseControl>
206
207 <BaseControl className="presto-player__control--bottom-text">
208 <TextareaControl
209 label={__("Bottom Text", "presto-player")}
210 help={__(
211 "Text displayed below the form. HTML allowed.",
212 "presto-player"
213 )}
214 value={cta?.bottom_text}
215 onChange={(bottom_text) => {
216 updateCTAState({
217 bottom_text,
218 });
219 }}
220 />
221 </BaseControl>
222
223 <BaseControl className="presto-player__control--show-button">
224 <ToggleControl
225 label={__("Show Button", "presto-player")}
226 help={__("Show a call to action button.", "presto-player")}
227 onChange={(show_button) => {
228 updateCTAState({
229 show_button,
230 });
231 }}
232 checked={cta?.show_button}
233 />
234 </BaseControl>
235
236 {!!cta?.show_button && (
237 <div>
238 <BaseControl className="presto-player__control--button-text">
239 <TextControl
240 label={__("Button Text", "presto-player")}
241 help={
242 <p>
243 {__(
244 "Button text for the Call To Action",
245 "presto-player"
246 )}
247 </p>
248 }
249 value={cta?.button_text}
250 onChange={(button_text) => updateCTAState({ button_text })}
251 />
252 </BaseControl>
253
254 <h3>{__("Style", "presto-player")}</h3>
255
256 <BaseControl>
257 <RangeControl
258 label={__("Round Corners", "presto-player")}
259 help={__("Border radius of form elements.", "presto-player")}
260 value={cta?.button_radius || 0}
261 onChange={(button_radius) =>
262 updateCTAState({ button_radius })
263 }
264 min={0}
265 max={25}
266 className="presto-cta__range-small"
267 />
268 </BaseControl>
269
270 <BaseControl className="presto-player__control--button-color">
271 <Flex>
272 <BaseControl.VisualLabel>
273 {__("Button Color", "presto-player")}
274 </BaseControl.VisualLabel>
275 <ColorPopup
276 color={cta?.button_color || branding?.color}
277 setColor={(value) =>
278 updateCTAState({
279 button_color: value && value.hex,
280 })
281 }
282 />
283 </Flex>
284 </BaseControl>
285 <BaseControl className="presto-player__control--button-text-color">
286 <Flex>
287 <BaseControl.VisualLabel>
288 {__("Button Text Color", "presto-player")}
289 </BaseControl.VisualLabel>
290 <ColorPopup
291 color={cta?.button_text_color || "#ffffff"}
292 setColor={(value) =>
293 updateCTAState({
294 button_text_color: value && value.hex,
295 })
296 }
297 />
298 </Flex>
299 </BaseControl>
300 </div>
301 )}
302 <BaseControl>
303 <RangeControl
304 label={__("Background Opacity", "presto-player")}
305 help={__(
306 "Opacity percentage of the cover background.",
307 "presto-player"
308 )}
309 value={cta?.background_opacity || 75}
310 onChange={(background_opacity) =>
311 updateCTAState({ background_opacity })
312 }
313 min={0}
314 max={100}
315 className="presto-cta__range-small"
316 />
317 </BaseControl>
318 </>
319 )}
320 </div>
321 );
322 }
323
324 CTA.defaultProps = {
325 catName: "Sandy",
326 eyeColor: "deepblue",
327 age: "120",
328 };
329
330 export default CTA;
331