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
Email.js
230 lines
| 1 | /** |
| 2 | * WordPress dependencies |
| 3 | */ |
| 4 | import { __ } from "@wordpress/i18n"; |
| 5 | import { |
| 6 | ToggleControl, |
| 7 | BaseControl, |
| 8 | RangeControl, |
| 9 | TextControl, |
| 10 | Button, |
| 11 | Flex, |
| 12 | TextareaControl, |
| 13 | Notice, |
| 14 | } from "@wordpress/components"; |
| 15 | import { useSelect } from "@wordpress/data"; |
| 16 | |
| 17 | import ChooseProvider from "./parts/ChooseProvider"; |
| 18 | import ColorPopup from "../components/ColorPopup"; |
| 19 | |
| 20 | import "./Email.scss"; |
| 21 | |
| 22 | export default function Email({ state, updateState, className }) { |
| 23 | const { email_collection, cta } = state; |
| 24 | |
| 25 | const branding = useSelect((select) => { |
| 26 | return select("presto-player/player").branding(); |
| 27 | }); |
| 28 | |
| 29 | const updateEmailState = (updated) => { |
| 30 | updateState({ |
| 31 | ...state, |
| 32 | email_collection: { |
| 33 | ...email_collection, |
| 34 | ...updated, |
| 35 | }, |
| 36 | }); |
| 37 | }; |
| 38 | |
| 39 | const disableCTA = () => { |
| 40 | updateState({ |
| 41 | ...state, |
| 42 | cta: { |
| 43 | ...cta, |
| 44 | ...{ enabled: false }, |
| 45 | }, |
| 46 | }); |
| 47 | }; |
| 48 | |
| 49 | return ( |
| 50 | <div className={className}> |
| 51 | <BaseControl> |
| 52 | <h3>{__("Email Capture", "presto-player")}</h3> |
| 53 | </BaseControl> |
| 54 | <BaseControl className="presto-player__control--large-play"> |
| 55 | <ToggleControl |
| 56 | label={__("Enable", "presto-player")} |
| 57 | help={__( |
| 58 | "Show an email collection form and message over your player.", |
| 59 | "presto-player" |
| 60 | )} |
| 61 | onChange={(enabled) => { |
| 62 | updateEmailState({ |
| 63 | enabled, |
| 64 | }); |
| 65 | }} |
| 66 | checked={email_collection?.enabled} |
| 67 | /> |
| 68 | </BaseControl> |
| 69 | {!!email_collection?.enabled && ( |
| 70 | <> |
| 71 | <BaseControl |
| 72 | className="presto-player__control--percentage-watched presto-email__range" |
| 73 | > |
| 74 | <RangeControl |
| 75 | label={__("Display At (Percentage)", "presto-player")} |
| 76 | labelPosition="top" |
| 77 | onChange={(percentage) => { |
| 78 | updateEmailState({ |
| 79 | percentage, |
| 80 | }); |
| 81 | }} |
| 82 | marks={[ |
| 83 | { |
| 84 | value: 0, |
| 85 | label: __("Start", "presto-player"), |
| 86 | }, |
| 87 | { |
| 88 | value: 50, |
| 89 | label: __("50% Watched", "presto-player"), |
| 90 | }, |
| 91 | { |
| 92 | value: 100, |
| 93 | label: __("End", "presto-player"), |
| 94 | }, |
| 95 | ]} |
| 96 | shiftStep={5} |
| 97 | value={email_collection?.percentage || 0} |
| 98 | className="presto-email__slider-fix" |
| 99 | /> |
| 100 | </BaseControl> |
| 101 | |
| 102 | {cta?.enabled && email_collection?.percentage === cta?.percentage && ( |
| 103 | <Notice |
| 104 | className="presto-email__notice" |
| 105 | status="warning" |
| 106 | isDismissible={false} |
| 107 | > |
| 108 | {__( |
| 109 | "You already have a Call To Action set display at the same time.", |
| 110 | "presto-player" |
| 111 | )} |
| 112 | <Button |
| 113 | onClick={disableCTA} |
| 114 | isLink |
| 115 | className="presto-email__button" |
| 116 | > |
| 117 | {__("Disable Call To Action", "presto-player")} |
| 118 | </Button> |
| 119 | </Notice> |
| 120 | )} |
| 121 | |
| 122 | <BaseControl className="presto-player__control--large-play"> |
| 123 | <ToggleControl |
| 124 | label={__("Allow Skipping", "presto-player")} |
| 125 | help={__("Let the viewer skip", "presto-player")} |
| 126 | onChange={(allow_skip) => { |
| 127 | updateEmailState({ |
| 128 | allow_skip, |
| 129 | }); |
| 130 | }} |
| 131 | checked={email_collection?.allow_skip} |
| 132 | /> |
| 133 | </BaseControl> |
| 134 | |
| 135 | <BaseControl className="presto-player__control--large-play"> |
| 136 | <TextareaControl |
| 137 | label={__("Headline", "presto-player")} |
| 138 | help={__("The headline for your form.", "presto-player")} |
| 139 | value={email_collection?.headline} |
| 140 | onChange={(headline) => { |
| 141 | updateEmailState({ |
| 142 | headline, |
| 143 | }); |
| 144 | }} |
| 145 | /> |
| 146 | </BaseControl> |
| 147 | |
| 148 | <BaseControl className="presto-player__control--large-play"> |
| 149 | <TextareaControl |
| 150 | label={__("Bottom Text", "presto-player")} |
| 151 | help={__( |
| 152 | "Text displayed below the form. HTML allowed.", |
| 153 | "presto-player" |
| 154 | )} |
| 155 | value={email_collection?.bottom_text} |
| 156 | onChange={(bottom_text) => { |
| 157 | updateEmailState({ |
| 158 | bottom_text, |
| 159 | }); |
| 160 | }} |
| 161 | /> |
| 162 | </BaseControl> |
| 163 | |
| 164 | <BaseControl className="presto-player__control--large-play"> |
| 165 | <TextControl |
| 166 | label={__("Play Button Text", "presto-player")} |
| 167 | help={<p>{__("Submit button text", "presto-player")}</p>} |
| 168 | value={email_collection?.button_text} |
| 169 | onChange={(button_text) => updateEmailState({ button_text })} |
| 170 | /> |
| 171 | </BaseControl> |
| 172 | |
| 173 | <BaseControl className="presto-player__control--button-color"> |
| 174 | <Flex> |
| 175 | <BaseControl.VisualLabel> |
| 176 | {__("Button Color", "presto-player")} |
| 177 | </BaseControl.VisualLabel> |
| 178 | <ColorPopup |
| 179 | color={cta?.button_color || branding?.color} |
| 180 | setColor={(value) => |
| 181 | updateEmailState({ |
| 182 | button_color: value && value.hex, |
| 183 | }) |
| 184 | } |
| 185 | /> |
| 186 | </Flex> |
| 187 | </BaseControl> |
| 188 | <BaseControl className="presto-player__control--button-text-color"> |
| 189 | <Flex> |
| 190 | <BaseControl.VisualLabel> |
| 191 | {__("Button Text Color", "presto-player")} |
| 192 | </BaseControl.VisualLabel> |
| 193 | <ColorPopup |
| 194 | color={cta?.button_text_color || "#ffffff"} |
| 195 | setColor={(value) => |
| 196 | updateEmailState({ |
| 197 | button_text_color: value && value.hex, |
| 198 | }) |
| 199 | } |
| 200 | /> |
| 201 | </Flex> |
| 202 | </BaseControl> |
| 203 | |
| 204 | <h3>{__("Integrate", "presto-player")}</h3> |
| 205 | <BaseControl> |
| 206 | <ChooseProvider |
| 207 | updateEmailState={updateEmailState} |
| 208 | options={email_collection} |
| 209 | /> |
| 210 | </BaseControl> |
| 211 | |
| 212 | <h3>{__("Style", "presto-player")}</h3> |
| 213 | |
| 214 | <BaseControl> |
| 215 | <RangeControl |
| 216 | label={__("Round Corners", "presto-player")} |
| 217 | help={__("Border radius of form elements.", "presto-player")} |
| 218 | value={email_collection?.border_radius || 0} |
| 219 | onChange={(border_radius) => updateEmailState({ border_radius })} |
| 220 | min={0} |
| 221 | max={25} |
| 222 | className="presto-email__range-small" |
| 223 | /> |
| 224 | </BaseControl> |
| 225 | </> |
| 226 | )} |
| 227 | </div> |
| 228 | ); |
| 229 | } |
| 230 |