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