PluginProbe ʕ •ᴥ•ʔ
Presto Player / trunk
Presto Player vtrunk
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 1 week ago ActionBar.js 1 week ago ActionBar.scss 1 week ago Behavior.js 2 years ago CTA.js 1 week ago CTA.scss 1 week ago Controls.js 5 years ago Edit.js 1 week ago Edit.scss 1 week ago Email.js 1 week ago Email.scss 1 week ago Preset.js 4 years ago Search.js 3 years ago Style.js 1 week ago Style.scss 1 week ago Watermark.js 4 years ago index.js 1 week ago index.scss 1 week ago
ActionBar.js
294 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 "./ActionBar.scss";
23
24 export default function ActionBar({ 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 presto-action-bar__range"
119 >
120 <RangeControl
121 label={__("Display At (Percentage)", "presto-player")}
122 labelPosition="top"
123 onChange={(percentage_start) => {
124 updateActionBar({
125 percentage_start,
126 });
127 }}
128 marks={[
129 {
130 value: 0,
131 label: __("Start", "presto-player"),
132 },
133 {
134 value: 50,
135 label: __("50% Watched", "presto-player"),
136 },
137 {
138 value: 100,
139 label: __("End", "presto-player"),
140 },
141 ]}
142 shiftStep={5}
143 value={action_bar?.percentage_start || 0}
144 className="presto-action-bar__slider-fix"
145 />
146 </BaseControl>
147
148 <BaseControl className="presto-player__control--large-play">
149 <TextareaControl
150 label={__("Text", "presto-player")}
151 help={__("Action bar text.", "presto-player")}
152 value={action_bar?.text}
153 onChange={(text) =>
154 updateActionBar({
155 text,
156 })
157 }
158 />
159 </BaseControl>
160
161 <BaseControl className="presto-player__control--large-play">
162 <Flex>
163 <BaseControl.VisualLabel>
164 {__("Action Bar Background", "presto-player")}
165 </BaseControl.VisualLabel>
166 <ColorPopup
167 color={action_bar?.background_color || "#1d1d1d"}
168 setColor={(value) =>
169 updateActionBar({
170 background_color: value && value.hex,
171 })
172 }
173 />
174 </Flex>
175 </BaseControl>
176
177 <BaseControl>
178 <h3>{__("Button", "presto-player")}</h3>
179 </BaseControl>
180
181 <BaseControl className="presto-player__control--button-type">
182 <SelectControl
183 label={__("Button Type", "presto-player")}
184 value={action_bar?.button_type}
185 options={[
186 {
187 value: "custom",
188 label: __("Custom", "presto-player"),
189 },
190 {
191 value: "youtube",
192 label: __("YouTube Subscribe", "presto-player"),
193 },
194 {
195 value: "none",
196 label: __("None", "presto-player"),
197 },
198 ]}
199 onChange={(button_type) =>
200 updateActionBar({
201 button_type,
202 })
203 }
204 />
205 </BaseControl>
206
207 {action_bar?.button_type === "youtube" && youtube?.channel_id && (
208 <ToggleControl
209 label={__("Show Count", "presto-player")}
210 help={__("Show your follower count.", "presto-player")}
211 onChange={(button_count) => {
212 updateActionBar({
213 button_count,
214 });
215 }}
216 checked={action_bar?.button_count}
217 />
218 )}
219
220 {renderYoutubeChannelForm()}
221
222 {action_bar?.button_type === "custom" && (
223 <div>
224 <BaseControl className="presto-player__control--button-text">
225 <TextControl
226 label={__("Button Text", "presto-player")}
227 help={<p>{__("Submit button text", "presto-player")}</p>}
228 value={action_bar?.button_text}
229 onChange={(button_text) => updateActionBar({ button_text })}
230 />
231 </BaseControl>
232 <BaseControl className="presto-player__control--button-text">
233 <BaseControl.VisualLabel>
234 <p> {__("Button Link", "presto-player")}</p>
235 </BaseControl.VisualLabel>
236 <UrlSelect
237 setSettings={(val) => {
238 updateActionBar({
239 button_link: val,
240 });
241 }}
242 settings={action_bar?.button_link || {}}
243 />
244 </BaseControl>
245 <BaseControl className="presto-player__control--button-radius">
246 <RangeControl
247 label={__("Round Corners", "presto-player")}
248 help={__("Border radius of the button", "presto-player")}
249 value={action_bar?.button_radius || 0}
250 onChange={(button_radius) =>
251 updateActionBar({ button_radius })
252 }
253 min={0}
254 max={25}
255 />
256 </BaseControl>
257 <BaseControl className="presto-player__control--button-color">
258 <Flex>
259 <BaseControl.VisualLabel>
260 {__("Button Color", "presto-player")}
261 </BaseControl.VisualLabel>
262 <ColorPopup
263 color={action_bar?.button_color || branding?.color}
264 setColor={(value) =>
265 updateActionBar({
266 button_color: value && value.hex,
267 })
268 }
269 />
270 </Flex>
271 </BaseControl>
272 <BaseControl className="presto-player__control--button-text-color">
273 <Flex>
274 <BaseControl.VisualLabel>
275 {__("Button Text Color", "presto-player")}
276 </BaseControl.VisualLabel>
277 <ColorPopup
278 color={action_bar?.button_text_color || "#ffffff"}
279 setColor={(value) =>
280 updateActionBar({
281 button_text_color: value && value.hex,
282 })
283 }
284 />
285 </Flex>
286 </BaseControl>
287 </div>
288 )}
289 </>
290 )}
291 </div>
292 );
293 }
294