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