PluginProbe ʕ •ᴥ•ʔ
Presto Player / trunk
Presto Player vtrunk
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 / overlays / components / Overlay.js
presto-player / src / admin / blocks / shared / overlays / components Last commit date
DynamicText.js 4 years ago Overlay.js 2 weeks ago Overlay.scss 2 weeks ago
Overlay.js
201 lines
1 const { __ } = wp.i18n;
2 const {
3 Flex,
4 FlexItem,
5 TextControl,
6 Button,
7 BaseControl,
8 RadioControl,
9 RangeControl,
10 withFocusReturn,
11 } = wp.components;
12 const { useRef, useEffect } = wp.element;
13 import "./Overlay.scss";
14
15 import { sanitizeTime, timeToSeconds, secondsToTime } from "../../../util";
16 import UrlSelect from "../../components/UrlSelect";
17 import DynamicText from "./DynamicText";
18 import ColorPopup from "../../components/ColorPopup";
19
20 const { useState } = wp.element;
21
22 const Overlay = ({
23 overlayIndex,
24 update,
25 remove,
26 className,
27 startTime,
28 endTime,
29 text,
30 link,
31 position,
32 color,
33 backgroundColor,
34 opacity,
35 updateCurrentTime,
36 }) => {
37 const [draftStartTime, setDraftStartTime] = useState(startTime);
38 const [draftEndTime, setDraftEndTime] = useState(endTime);
39 const [draftPosition, setDraftPosition] = useState(position);
40 const startControl = useRef();
41
42 useEffect(() => {
43 if (timeToSeconds(startTime) >= timeToSeconds(endTime)) {
44 let endTime = sanitizeTime(startTime);
45 let seconds = timeToSeconds(endTime) + 1;
46 endTime = sanitizeTime(secondsToTime(seconds));
47 update({ endTime });
48 setDraftEndTime(endTime);
49 }
50 }, [startTime, endTime]);
51
52 const updateStartTime = () => {
53 const startTime = sanitizeTime(draftStartTime);
54 update({ startTime });
55 setDraftStartTime(startTime);
56 updateCurrentTime(startTime);
57 };
58
59 const updateEndTime = () => {
60 const endTime = sanitizeTime(draftEndTime);
61 update({ endTime });
62 setDraftEndTime(endTime);
63 };
64
65 return (
66 <div className="presto-overlay">
67 <Flex align="center" className={className}>
68 <FlexItem>
69 <TextControl
70 ref={startControl}
71 id={`start-time-${overlayIndex}`}
72 label={__("Start Time", "presto-player")}
73 className="presto-player__overlay--start-time"
74 value={draftStartTime}
75 onChange={(startTime) => setDraftStartTime(startTime)}
76 onBlur={updateStartTime}
77 onFocus={updateStartTime}
78 autoComplete="off"
79 placeholder="0:00"
80 />
81 </FlexItem>
82
83 <FlexItem>
84 <TextControl
85 label={__("End Time", "presto-player")}
86 className="presto-player__overlay--end-time"
87 value={draftEndTime}
88 onChange={setDraftEndTime}
89 onBlur={updateEndTime}
90 autoComplete="off"
91 placeholder="0:00"
92 />
93 </FlexItem>
94 </Flex>
95
96 <DynamicText
97 text={text}
98 update={update}
99 onFocus={() => {
100 updateCurrentTime(sanitizeTime(draftStartTime));
101 }}
102 />
103
104 <BaseControl style={{ width: "100%" }}>
105 <BaseControl.VisualLabel>
106 <p> {__("Link", "presto-player")}</p>
107 </BaseControl.VisualLabel>
108 <UrlSelect
109 onFocus={() => {
110 updateCurrentTime(sanitizeTime(draftStartTime));
111 }}
112 setSettings={(link) => update({ link })}
113 settings={link || {}}
114 />
115 </BaseControl>
116
117 <BaseControl className={className}>
118 <RadioControl
119 label={__("Position", "presto-player")}
120 options={[
121 { label: __("Top Right", "presto-player"), value: "top-right" },
122 { label: __("Top Left", "presto-player"), value: "top-left" },
123 ]}
124 selected={draftPosition || "right"}
125 onFocus={() => {
126 updateCurrentTime(sanitizeTime(draftStartTime));
127 }}
128 onChange={(position) => {
129 update({ position });
130 setDraftPosition(position);
131 updateCurrentTime(sanitizeTime(draftStartTime));
132 }}
133 />
134 </BaseControl>
135
136 <BaseControl className="presto-player__control--overlay-text-color">
137 <Flex>
138 <BaseControl.VisualLabel>
139 {__("Text Color", "presto-player")}
140 </BaseControl.VisualLabel>
141 <ColorPopup
142 onFocus={() => {
143 updateCurrentTime(sanitizeTime(draftStartTime));
144 }}
145 color={color}
146 setColor={(value) => {
147 update({
148 color: value && value.hex,
149 });
150 }}
151 />
152 </Flex>
153 </BaseControl>
154
155 <BaseControl className="presto-player__control--overlay-background-color">
156 <Flex>
157 <BaseControl.VisualLabel>
158 {__("Background Color", "presto-player")}
159 </BaseControl.VisualLabel>
160 <ColorPopup
161 onFocus={() => {
162 updateCurrentTime(sanitizeTime(draftStartTime));
163 }}
164 color={backgroundColor}
165 setColor={(value) => {
166 update({
167 backgroundColor: value && value.hex,
168 });
169 }}
170 />
171 </Flex>
172 </BaseControl>
173
174 <BaseControl>
175 <RangeControl
176 label={__("Opacity", "presto-player")}
177 help={__("Opacity percentage of the overlay.", "presto-player")}
178 value={opacity}
179 onChange={(opacity) => update({ opacity })}
180 min={0}
181 max={100}
182 />
183 </BaseControl>
184
185 {remove && (
186 <BaseControl className={className}>
187 <Flex justify="flex-end">
188 <Button isDestructive isSmall onClick={remove}>
189 {__("Remove Overlay", "presto-player")}
190 </Button>
191 </Flex>
192 </BaseControl>
193 )}
194
195 <hr />
196 </div>
197 );
198 };
199
200 export default Overlay;
201