-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
41 lines (35 loc) · 1.16 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const form = document.querySelector(".form");
const cssText = document.querySelector(".css");
const preview = document.querySelector(".preview");
form.addEventListener("input", handleInput);
const handleStyle = {
element: preview,
borderTopLeftRadius(value) {
this.element.style.borderTopLeftRadius = value;
},
borderTopRightRadius(value) {
this.element.style.borderTopRightRadius = value;
},
borderBottomLeftRadius(value) {
this.element.style.borderBottomLeftRadius = value;
},
borderBottomRightRadius(value) {
this.element.style.borderBottomRightRadius = value;
},
};
function handleInput(event) {
const name = event.target.name;
const value = event.target.value;
handleStyle[name](value);
showCSS();
}
function showCSS() {
const borderRadius = [
document.querySelector("#borderTopLeftRadius").value + "px",
document.querySelector("#borderTopRightRadius").value + "px",
document.querySelector("#borderBottomRightRadius").value + "px",
document.querySelector("#borderBottomLeftRadius").value + "px",
].join(" ");
preview.style.borderRadius = borderRadius;
cssText.innerHTML = "border-radius: " + borderRadius + ";";
}