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