-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (22 loc) · 860 Bytes
/
script.js
File metadata and controls
28 lines (22 loc) · 860 Bytes
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
let colorOne = document.getElementById('color-a');
let colorTwo = document.getElementById('color-b');
let currentDirection = 'to bottom';
let outputCode = document.getElementById('code');
function setDirection(value,_this){
let directions = document.querySelectorAll(".buttons button");
for(let i of directions){
i.classList.remove('active');
}
_this.classList.add('active');
currentDirection = value;
}
function generateCode(){
outputCode.value = `background-image: linear-gradient(${currentDirection}, ${colorOne.value}, ${colorTwo.value});`
document.getElementsByTagName("BODY")[0].style.backgroundImage = `linear-gradient(${currentDirection}, ${colorOne.value}, ${colorTwo.value})`;
}
function copyText(){
outputCode.select();
document.execCommand('copy');
alert('Gradient Copied!');
}
generateCode();