PluginProbe ʕ •ᴥ•ʔ
Presto Player / 2.2.2
Presto Player v2.2.2
4.3.1 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 3 years ago ActionBar.js 2 years ago Behavior.js 2 years ago CTA.js 2 years ago Controls.js 5 years ago Edit.js 2 years ago Email.js 2 years ago Preset.js 4 years ago Search.js 3 years ago Style.js 2 years ago Watermark.js 4 years ago index.js 4 years ago
CTA.js
358 lines
1 /** @jsx jsx */
2
3 /**
4 * WordPress dependencies
5 */
6 import { __ } from "@wordpress/i18n";
7 import {
8 ToggleControl,
9 BaseControl,
10 RangeControl,
11 TextControl,
12 Flex,
13 Button,
14 TextareaControl,
15 Notice,
16 } from "@wordpress/components";
17 import { useEffect } from "@wordpress/element";
18 import { useSelect } from "@wordpress/data";
19
20 import UrlSelect from "../components/UrlSelect";
21 import ColorPopup from "../components/ColorPopup";
22
23 import { css, jsx } from "@emotion/core";
24
25 function CTA({ state, updateState, className }) {
26 const { cta, email_collection } = state;
27
28 const branding = useSelect((select) => {
29 return select("presto-player/player").branding();
30 });
31
32 // set defaults
33 const defaults = {
34 percentage: 100,
35 show_rewatch: true,
36 show_skip: true,
37 headline: __("Want to learn more?", "presto-player"),
38 show_button: true,
39 button_text: __("Click Here", "presto-player"),
40 button_link: {
41 opensInNewTab: true,
42 },
43 };
44 useEffect(() => {
45 Object.keys(defaults).forEach((key) => {
46 if (state?.cta?.[key] === undefined) {
47 updateCTAState({
48 [key]: defaults[key],
49 });
50 }
51 });
52 }, [state]);
53
54 const updateCTAState = (updated) => {
55 updateState({
56 ...state,
57 cta: {
58 ...cta,
59 ...updated,
60 },
61 });
62 };
63
64 const disableEmailCapture = () => {
65 updateState({
66 ...state,
67 email_collection: {
68 ...email_collection,
69 ...{ enabled: false },
70 },
71 });
72 };
73
74 return (
75 <div className={className}>
76 <BaseControl>
77 <h3>{__("Call To Action", "presto-player")}</h3>
78 </BaseControl>
79 <BaseControl className="presto-player__control--large-play">
80 <ToggleControl
81 label={__("Enable", "presto-player")}
82 help={__(
83 "Show an email collection form and message over your player.",
84 "presto-player"
85 )}
86 onChange={(enabled) => {
87 updateCTAState({
88 enabled,
89 });
90 }}
91 checked={cta?.enabled}
92 />
93 </BaseControl>
94 {!!cta?.enabled && (
95 <>
96 <BaseControl
97 className="presto-player__control--percentage-watched"
98 css={css`
99 padding-left: 8px;
100 margin-bottom: 34px !important;
101 .components-range-control__root {
102 align-items: flex-start;
103 }
104 `}
105 >
106 <RangeControl
107 label={__("Display At (Percentage)", "presto-player")}
108 labelPosition="top"
109 onChange={(percentage) => {
110 updateCTAState({
111 percentage,
112 });
113 }}
114 marks={[
115 {
116 value: 0,
117 label: __("Start", "presto-player"),
118 },
119 {
120 value: 50,
121 label: __("50% Watched", "presto-player"),
122 },
123 {
124 value: 100,
125 label: __("End", "presto-player"),
126 },
127 ]}
128 shiftStep={5}
129 value={cta?.percentage}
130 css={css`
131 .components-range-control__slider {
132 position: relative !important;
133 }
134 `}
135 />
136 </BaseControl>
137
138 {email_collection?.enabled &&
139 email_collection?.percentage === cta?.percentage && (
140 <Notice
141 css={css`
142 margin: 0 0 30px 0 !important;
143 `}
144 status="warning"
145 isDismissible={false}
146 >
147 {__(
148 "You already have an email capture set display at the same time.",
149 "presto-player"
150 )}
151 <Button
152 onClick={disableEmailCapture}
153 isLink
154 css={css`
155 margin-top: 10px !important;
156 `}
157 >
158 {__("Disable Email Capture", "presto-player")}
159 </Button>
160 </Notice>
161 )}
162
163 {cta?.percentage === 100 ? (
164 <BaseControl className="presto-player__control--show-rewatch">
165 <ToggleControl
166 label={__("Show Rewatch Button", "presto-player")}
167 help={__(
168 "Show a rewatch button at the end of the player.",
169 "presto-player"
170 )}
171 onChange={(show_rewatch) => {
172 updateCTAState({
173 show_rewatch,
174 });
175 }}
176 checked={cta?.show_rewatch}
177 />
178 </BaseControl>
179 ) : (
180 <BaseControl className="presto-player__control--show-skip">
181 <ToggleControl
182 label={__("Allow Skipping", "presto-player")}
183 help={__(
184 "Let the user continue watching the player.",
185 "presto-player"
186 )}
187 onChange={(show_skip) => {
188 updateCTAState({
189 show_skip,
190 });
191 }}
192 checked={cta?.show_skip}
193 />
194 </BaseControl>
195 )}
196
197 <BaseControl className="presto-player__control--button-link">
198 <BaseControl.VisualLabel>
199 <p> {__("Link", "presto-player")}</p>
200 </BaseControl.VisualLabel>
201 <UrlSelect
202 setSettings={(val) => {
203 updateCTAState({
204 button_link: val,
205 });
206 }}
207 settings={cta?.button_link || {}}
208 />
209 </BaseControl>
210
211 <BaseControl className="presto-player__control--headline">
212 <TextareaControl
213 label={__("Headline", "presto-player")}
214 help={__("The headline for your form.", "presto-player")}
215 value={cta?.headline}
216 onChange={(headline) => {
217 updateCTAState({
218 headline,
219 });
220 }}
221 />
222 </BaseControl>
223
224 <BaseControl className="presto-player__control--bottom-text">
225 <TextareaControl
226 label={__("Bottom Text", "presto-player")}
227 help={__(
228 "Text displayed below the form. HTML allowed.",
229 "presto-player"
230 )}
231 value={cta?.bottom_text}
232 onChange={(bottom_text) => {
233 updateCTAState({
234 bottom_text,
235 });
236 }}
237 />
238 </BaseControl>
239
240 <BaseControl className="presto-player__control--show-button">
241 <ToggleControl
242 label={__("Show Button", "presto-player")}
243 help={__("Show a call to action button.", "presto-player")}
244 onChange={(show_button) => {
245 updateCTAState({
246 show_button,
247 });
248 }}
249 checked={cta?.show_button}
250 />
251 </BaseControl>
252
253 {!!cta?.show_button && (
254 <div>
255 <BaseControl className="presto-player__control--button-text">
256 <TextControl
257 label={__("Button Text", "presto-player")}
258 help={
259 <p>
260 {__(
261 "Button text for the Call To Action",
262 "presto-player"
263 )}
264 </p>
265 }
266 value={cta?.button_text}
267 onChange={(button_text) => updateCTAState({ button_text })}
268 />
269 </BaseControl>
270
271 <h3>{__("Style", "presto-player")}</h3>
272
273 <BaseControl>
274 <RangeControl
275 label={__("Round Corners", "presto-player")}
276 help={__("Border radius of form elements.", "presto-player")}
277 value={cta?.button_radius || 0}
278 onChange={(button_radius) =>
279 updateCTAState({ button_radius })
280 }
281 min={0}
282 max={25}
283 css={css`
284 padding-left: 4px;
285 .components-range-control__root {
286 align-items: flex-start;
287 }
288 `}
289 />
290 </BaseControl>
291
292 <BaseControl className="presto-player__control--button-color">
293 <Flex>
294 <BaseControl.VisualLabel>
295 {__("Button Color", "presto-player")}
296 </BaseControl.VisualLabel>
297 <ColorPopup
298 color={cta?.button_color || branding?.color}
299 setColor={(value) =>
300 updateCTAState({
301 button_color: value && value.hex,
302 })
303 }
304 />
305 </Flex>
306 </BaseControl>
307 <BaseControl className="presto-player__control--button-text-color">
308 <Flex>
309 <BaseControl.VisualLabel>
310 {__("Button Text Color", "presto-player")}
311 </BaseControl.VisualLabel>
312 <ColorPopup
313 color={cta?.button_text_color || "#ffffff"}
314 setColor={(value) =>
315 updateCTAState({
316 button_text_color: value && value.hex,
317 })
318 }
319 />
320 </Flex>
321 </BaseControl>
322 </div>
323 )}
324 <BaseControl>
325 <RangeControl
326 label={__("Background Opacity", "presto-player")}
327 help={__(
328 "Opacity percentage of the cover background.",
329 "presto-player"
330 )}
331 value={cta?.background_opacity || 75}
332 onChange={(background_opacity) =>
333 updateCTAState({ background_opacity })
334 }
335 min={0}
336 max={100}
337 css={css`
338 padding-left: 4px;
339 .components-range-control__root {
340 align-items: flex-start;
341 }
342 `}
343 />
344 </BaseControl>
345 </>
346 )}
347 </div>
348 );
349 }
350
351 CTA.defaultProps = {
352 catName: "Sandy",
353 eyeColor: "deepblue",
354 age: "120",
355 };
356
357 export default CTA;
358