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 / branding / index.js
presto-player / src / admin / blocks / shared / branding Last commit date
index.js 7 months ago
index.js
160 lines
1 /**
2 * WordPress dependencies
3 */
4 import { __, sprintf } from "@wordpress/i18n";
5 const { ColorPicker, Button, withNotices, BaseControl, RangeControl } =
6 wp.components;
7 const { MediaUpload, MediaUploadCheck } = wp.blockEditor;
8 const { useInstanceId } = wp.compose;
9 const { useState } = wp.element;
10 const { dispatch, useSelect } = wp.data;
11 import ProBadge from "@/admin/blocks/shared/components/ProBadge";
12
13 const VIDEO_LOGO_ALLOWED_MEDIA_TYPES = ["image"];
14
15 function PlayerSettings({ setAttributes, attributes, type }) {
16 const instanceId = useInstanceId(PlayerSettings);
17 const [pickerRender, setPickerRender] = useState(1);
18
19 // get branding options
20 const branding = useSelect((select) => {
21 return select("presto-player/player").branding();
22 });
23 // save options
24 const saveOptions = async () => {
25 await dispatch("presto-player/player").saveOptions({
26 branding,
27 });
28 wp.data.dispatch("core/notices").createNotice(
29 "success", // Can be one of: success, info, warning, error.
30 "Player branding saved.", // Text string to display.
31 {
32 type: "snackbar",
33 isDismissible: true, // Whether the user can dismiss the notice.
34 // Any actions the user can perform.
35 }
36 );
37 };
38
39 function onSelectLogo(image) {
40 dispatch("presto-player/player").updateBranding("logo", image.url);
41 }
42
43 function onRemoveLogo() {
44 dispatch("presto-player/player").updateBranding("logo", "");
45 }
46
47 return (
48 <div className="presto-player__panel--branding">
49 {type !== "audio" && (
50 <p>
51 {__(
52 "Here you can select the global player branding This will apply to all players on the site.",
53 "presto-player"
54 )}
55 </p>
56 )}
57
58 <MediaUploadCheck>
59 <BaseControl className="editor-video-poster-control">
60 {type !== "audio" && (
61 <>
62 <BaseControl.VisualLabel>
63 <p>
64 {__("Logo Overlay", "presto-player")}{" "}
65 {!prestoPlayer?.isPremium && <ProBadge />}
66 </p>
67 </BaseControl.VisualLabel>
68 <MediaUpload
69 title={__("Select logo overlay image", "presto-player")}
70 onSelect={onSelectLogo}
71 allowedTypes={VIDEO_LOGO_ALLOWED_MEDIA_TYPES}
72 render={({ open }) => (
73 <Button
74 className="presto-setting__logo"
75 isSecondary
76 onClick={() => {
77 if (!prestoPlayer?.isPremium) {
78 dispatch("presto-player/player").setProModal(true);
79 return;
80 }
81 open();
82 }}
83 aria-describedby={`video-block__logo-image-description-${instanceId}`}
84 >
85 {!branding?.logo
86 ? __("Select", "presto-player")
87 : __("Replace", "presto-player")}
88 </Button>
89 )}
90 />
91 </>
92 )}
93
94 <p id={`video-block__logo-image-description-${instanceId}`} hidden>
95 {branding?.logo
96 ? sprintf(
97 /* translators: %s: poster image URL. */
98 __("The current logo image url is %s", "presto-player"),
99 branding?.logo
100 )
101 : __(
102 "There is no logo image currently selected",
103 "presto-player"
104 )}
105 </p>
106 {!!branding?.logo && (
107 <Button onClick={onRemoveLogo} isTertiary>
108 {__("Remove", "presto-player")}
109 </Button>
110 )}
111 </BaseControl>
112 </MediaUploadCheck>
113
114 {!!branding?.logo && (
115 <RangeControl
116 label={__("Logo Max Width", "presto-player")}
117 value={branding?.logo_width || 150}
118 onChange={(width) =>
119 dispatch("presto-player/player").updateBranding("logo_width", width)
120 }
121 min={1}
122 max={400}
123 />
124 )}
125
126 <ColorPicker
127 color={branding?.color}
128 onChangeComplete={(value) => {
129 dispatch("presto-player/player").updateBranding("color", value.hex);
130 }}
131 key={pickerRender}
132 disableAlpha
133 />
134
135 {branding?.color && (
136 <BaseControl>
137 <Button
138 isSecondary
139 onClick={() => {
140 dispatch("presto-player/player").updateBranding(
141 "color",
142 prestoPlayer?.defaults?.color || "#00b3ff"
143 );
144 setPickerRender(pickerRender + 1);
145 }}
146 >
147 {__("Reset Color", "presto-player")}
148 </Button>
149 </BaseControl>
150 )}
151
152 <Button isPrimary onClick={saveOptions}>
153 {__("Save Branding", "presto-player")}
154 </Button>
155 </div>
156 );
157 }
158
159 export default withNotices(PlayerSettings);
160