PluginProbe ʕ •ᴥ•ʔ
Presto Player / 2.0.3
Presto Player v2.0.3
4.3.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 4 years ago Behavior.js 4 years ago CTA.js 4 years ago Controls.js 5 years ago Edit.js 3 years ago Email.js 4 years ago Preset.js 4 years ago Search.js 3 years ago Style.js 5 years ago Watermark.js 4 years ago index.js 4 years ago
CTA.js
332 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 className="presto-player__control--percentage-watched">
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 />
122 </BaseControl>
123
124 {email_collection?.enabled &&
125 email_collection?.percentage === cta?.percentage && (
126 <Notice
127 css={css`
128 margin: 0 0 30px 0 !important;
129 `}
130 status="warning"
131 isDismissible={false}
132 >
133 {__(
134 "You already have an email capture set display at the same time.",
135 "presto-player"
136 )}
137 <Button
138 onClick={disableEmailCapture}
139 isLink
140 css={css`
141 margin-top: 10px !important;
142 `}
143 >
144 {__("Disable Email Capture", "presto-player")}
145 </Button>
146 </Notice>
147 )}
148
149 {cta?.percentage === 100 ? (
150 <BaseControl className="presto-player__control--show-rewatch">
151 <ToggleControl
152 label={__("Show Rewatch Button", "presto-player")}
153 help={__(
154 "Show a rewatch button at the end of the player.",
155 "presto-player"
156 )}
157 onChange={(show_rewatch) => {
158 updateCTAState({
159 show_rewatch,
160 });
161 }}
162 checked={cta?.show_rewatch}
163 />
164 </BaseControl>
165 ) : (
166 <BaseControl className="presto-player__control--show-skip">
167 <ToggleControl
168 label={__("Allow Skipping", "presto-player")}
169 help={__(
170 "Let the user continue watching the player.",
171 "presto-player"
172 )}
173 onChange={(show_skip) => {
174 updateCTAState({
175 show_skip,
176 });
177 }}
178 checked={cta?.show_skip}
179 />
180 </BaseControl>
181 )}
182
183 <BaseControl className="presto-player__control--button-link">
184 <BaseControl.VisualLabel>
185 <p> {__("Link", "presto-player")}</p>
186 </BaseControl.VisualLabel>
187 <UrlSelect
188 setSettings={(val) => {
189 updateCTAState({
190 button_link: val,
191 });
192 }}
193 settings={cta?.button_link || {}}
194 />
195 </BaseControl>
196
197 <BaseControl className="presto-player__control--headline">
198 <TextareaControl
199 label={__("Headline", "presto-player")}
200 help={__("The headline for your form.", "presto-player")}
201 value={cta?.headline}
202 onChange={(headline) => {
203 updateCTAState({
204 headline,
205 });
206 }}
207 />
208 </BaseControl>
209
210 <BaseControl className="presto-player__control--bottom-text">
211 <TextareaControl
212 label={__("Bottom Text", "presto-player")}
213 help={__(
214 "Text displayed below the form. HTML allowed.",
215 "presto-player"
216 )}
217 value={cta?.bottom_text}
218 onChange={(bottom_text) => {
219 updateCTAState({
220 bottom_text,
221 });
222 }}
223 />
224 </BaseControl>
225
226 <BaseControl className="presto-player__control--show-button">
227 <ToggleControl
228 label={__("Show Button", "presto-player")}
229 help={__("Show a call to action button.", "presto-player")}
230 onChange={(show_button) => {
231 updateCTAState({
232 show_button,
233 });
234 }}
235 checked={cta?.show_button}
236 />
237 </BaseControl>
238
239 {!!cta?.show_button && (
240 <div>
241 <BaseControl className="presto-player__control--button-text">
242 <TextControl
243 label={__("Button Text", "presto-player")}
244 help={
245 <p>
246 {__(
247 "Button text for the Call To Action",
248 "presto-player"
249 )}
250 </p>
251 }
252 value={cta?.button_text}
253 onChange={(button_text) => updateCTAState({ button_text })}
254 />
255 </BaseControl>
256
257 <h3>{__("Style", "presto-player")}</h3>
258
259 <BaseControl>
260 <RangeControl
261 label={__("Round Corners", "presto-player")}
262 help={__("Border radius of form elements.", "presto-player")}
263 value={cta?.button_radius || 0}
264 onChange={(button_radius) =>
265 updateCTAState({ button_radius })
266 }
267 min={0}
268 max={25}
269 />
270 </BaseControl>
271
272 <BaseControl className="presto-player__control--button-color">
273 <Flex>
274 <BaseControl.VisualLabel>
275 {__("Button Color", "presto-player")}
276 </BaseControl.VisualLabel>
277 <ColorPopup
278 color={cta?.button_color || branding?.color}
279 setColor={(value) =>
280 updateCTAState({
281 button_color: value && value.hex,
282 })
283 }
284 />
285 </Flex>
286 </BaseControl>
287 <BaseControl className="presto-player__control--button-text-color">
288 <Flex>
289 <BaseControl.VisualLabel>
290 {__("Button Text Color", "presto-player")}
291 </BaseControl.VisualLabel>
292 <ColorPopup
293 color={cta?.button_text_color || "#ffffff"}
294 setColor={(value) =>
295 updateCTAState({
296 button_text_color: value && value.hex,
297 })
298 }
299 />
300 </Flex>
301 </BaseControl>
302 </div>
303 )}
304 <BaseControl>
305 <RangeControl
306 label={__("Background Opacity", "presto-player")}
307 help={__(
308 "Opacity percentage of the cover background.",
309 "presto-player"
310 )}
311 value={cta?.background_opacity || 75}
312 onChange={(background_opacity) =>
313 updateCTAState({ background_opacity })
314 }
315 min={0}
316 max={100}
317 />
318 </BaseControl>
319 </>
320 )}
321 </div>
322 );
323 }
324
325 CTA.defaultProps = {
326 catName: "Sandy",
327 eyeColor: "deepblue",
328 age: "120",
329 };
330
331 export default CTA;
332