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 / ActionBar.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
ActionBar.js
305 lines
1 /**
2 * WordPress dependencies
3 */
4 const { __ } = wp.i18n;
5 const {
6 ToggleControl,
7 Flex,
8 Button,
9 BaseControl,
10 RangeControl,
11 TextControl,
12 SelectControl,
13 TextareaControl,
14 } = wp.components;
15
16 const { useEffect, useState } = wp.element;
17 const { useSelect } = wp.data;
18
19 import ColorPopup from "../components/ColorPopup";
20 import UrlSelect from "../components/UrlSelect";
21 import YoutubeChannelId from "./parts/YoutubeChannelId";
22 import { css, jsx } from "@emotion/core";
23
24 export default function ({ state, updateState, className, value, setValue }) {
25 const { action_bar } = state;
26 const [editYoutube, setEditYoutube] = useState(false);
27
28 const branding = useSelect((select) => {
29 return select("presto-player/player").branding();
30 });
31 const youtube = useSelect((select) => {
32 return select("presto-player/player").youtube();
33 });
34
35 const updateActionBar = (updated) => {
36 updateState({
37 ...state,
38 action_bar: {
39 ...action_bar,
40 ...updated,
41 },
42 });
43 };
44
45 useEffect(() => {
46 if (!action_bar?.text) {
47 updateActionBar({
48 text: "Like this?",
49 });
50 }
51 if (!action_bar?.button_type) {
52 updateActionBar({
53 button_type: "custom",
54 });
55 }
56
57 if (!action_bar?.button_text) {
58 updateActionBar({
59 button_text: "Click Here",
60 });
61 }
62 }, [state]);
63
64 const renderYoutubeChannelForm = () => {
65 if (action_bar?.button_type !== "youtube") {
66 return;
67 }
68
69 return editYoutube ? (
70 <YoutubeChannelId
71 onClose={() => setEditYoutube(false)}
72 value={value}
73 setValue={setValue}
74 />
75 ) : (
76 <div>
77 <Button
78 isSecondary
79 onClick={(e) => {
80 e.preventDefault();
81 setEditYoutube(true);
82 }}
83 >
84 {youtube?.channel_id
85 ? __("Update Youtube Channel Id", "presto-player")
86 : __("Add Youtube Channel Id", "presto-player")}
87 </Button>
88 <br />
89 <br />
90 <br />
91 </div>
92 );
93 };
94
95 return (
96 <div className={className}>
97 <BaseControl>
98 <h3>{__("Action Bar", "presto-player")}</h3>
99 </BaseControl>
100 <BaseControl className="presto-player__control--large-play">
101 <ToggleControl
102 label={__("Enable", "presto-player")}
103 help={__(
104 "Show an action bar below your player while it's playing.",
105 "presto-player"
106 )}
107 onChange={(enabled) => {
108 updateActionBar({
109 enabled,
110 });
111 }}
112 checked={action_bar?.enabled}
113 />
114 </BaseControl>
115 {!!action_bar?.enabled && (
116 <>
117 <BaseControl
118 className="presto-player__control--percentage-watched"
119 css={css`
120 padding-left: 8px;
121 margin-bottom: 34px !important;
122 .components-range-control__root {
123 align-items: flex-start;
124 }
125 `}
126 >
127 <RangeControl
128 label={__("Display At (Percentage)", "presto-player")}
129 labelPosition="top"
130 onChange={(percentage_start) => {
131 updateActionBar({
132 percentage_start,
133 });
134 }}
135 marks={[
136 {
137 value: 0,
138 label: __("Start", "presto-player"),
139 },
140 {
141 value: 50,
142 label: __("50% Watched", "presto-player"),
143 },
144 {
145 value: 100,
146 label: __("End", "presto-player"),
147 },
148 ]}
149 shiftStep={5}
150 value={action_bar?.percentage_start || 0}
151 css={css`
152 .components-range-control__slider {
153 position: relative !important;
154 }
155 `}
156 />
157 </BaseControl>
158
159 <BaseControl className="presto-player__control--large-play">
160 <TextareaControl
161 label={__("Text", "presto-player")}
162 help={__("Action bar text.", "presto-player")}
163 value={action_bar?.text}
164 onChange={(text) =>
165 updateActionBar({
166 text,
167 })
168 }
169 />
170 </BaseControl>
171
172 <BaseControl className="presto-player__control--large-play">
173 <Flex>
174 <BaseControl.VisualLabel>
175 {__("Action Bar Background", "presto-player")}
176 </BaseControl.VisualLabel>
177 <ColorPopup
178 color={action_bar?.background_color || "#1d1d1d"}
179 setColor={(value) =>
180 updateActionBar({
181 background_color: value && value.hex,
182 })
183 }
184 />
185 </Flex>
186 </BaseControl>
187
188 <BaseControl>
189 <h3>{__("Button", "presto-player")}</h3>
190 </BaseControl>
191
192 <BaseControl className="presto-player__control--button-type">
193 <SelectControl
194 label={__("Button Type", "presto-player")}
195 value={action_bar?.button_type}
196 options={[
197 {
198 value: "custom",
199 label: __("Custom", "presto-player"),
200 },
201 {
202 value: "youtube",
203 label: __("YouTube Subscribe", "presto-player"),
204 },
205 {
206 value: "none",
207 label: __("None", "presto-player"),
208 },
209 ]}
210 onChange={(button_type) =>
211 updateActionBar({
212 button_type,
213 })
214 }
215 />
216 </BaseControl>
217
218 {action_bar?.button_type === "youtube" && youtube?.channel_id && (
219 <ToggleControl
220 label={__("Show Count", "presto-player")}
221 help={__("Show your follower count.", "presto-player")}
222 onChange={(button_count) => {
223 updateActionBar({
224 button_count,
225 });
226 }}
227 checked={action_bar?.button_count}
228 />
229 )}
230
231 {renderYoutubeChannelForm()}
232
233 {action_bar?.button_type === "custom" && (
234 <div>
235 <BaseControl className="presto-player__control--button-text">
236 <TextControl
237 label={__("Button Text", "presto-player")}
238 help={<p>{__("Submit button text", "presto-player")}</p>}
239 value={action_bar?.button_text}
240 onChange={(button_text) => updateActionBar({ button_text })}
241 />
242 </BaseControl>
243 <BaseControl className="presto-player__control--button-text">
244 <BaseControl.VisualLabel>
245 <p> {__("Button Link", "presto-player")}</p>
246 </BaseControl.VisualLabel>
247 <UrlSelect
248 setSettings={(val) => {
249 updateActionBar({
250 button_link: val,
251 });
252 }}
253 settings={action_bar?.button_link || {}}
254 />
255 </BaseControl>
256 <BaseControl className="presto-player__control--button-radius">
257 <RangeControl
258 label={__("Round Corners", "presto-player")}
259 help={__("Border radius of the button", "presto-player")}
260 value={action_bar?.button_radius || 0}
261 onChange={(button_radius) =>
262 updateActionBar({ button_radius })
263 }
264 min={0}
265 max={25}
266 />
267 </BaseControl>
268 <BaseControl className="presto-player__control--button-color">
269 <Flex>
270 <BaseControl.VisualLabel>
271 {__("Button Color", "presto-player")}
272 </BaseControl.VisualLabel>
273 <ColorPopup
274 color={action_bar?.button_color || branding?.color}
275 setColor={(value) =>
276 updateActionBar({
277 button_color: value && value.hex,
278 })
279 }
280 />
281 </Flex>
282 </BaseControl>
283 <BaseControl className="presto-player__control--button-text-color">
284 <Flex>
285 <BaseControl.VisualLabel>
286 {__("Button Text Color", "presto-player")}
287 </BaseControl.VisualLabel>
288 <ColorPopup
289 color={action_bar?.button_text_color || "#ffffff"}
290 setColor={(value) =>
291 updateActionBar({
292 button_text_color: value && value.hex,
293 })
294 }
295 />
296 </Flex>
297 </BaseControl>
298 </div>
299 )}
300 </>
301 )}
302 </div>
303 );
304 }
305