-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
158 lines (130 loc) · 3.68 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
let liList = document.querySelectorAll('.list');
let container = document.querySelector('.container');
let list_cont = document.querySelector('.list_cont');
let main_anime = document.querySelector('.main_anime');
let darkMode = document.querySelector('.darkMode');
let buttonColor = document.querySelector('.buttonColor');
let text = document.querySelectorAll('.list .text')
let light = "M65 32.5C65 50.4493 50.4493 65 32.5 65C14.5507 65 0 50.4493 0 32.5C0 14.5507 14.5507 0 32.5 0C50.4493 0 65 14.5507 65 32.5Z";
let dark = "M18.5 32.5C18.5 50.4493 32.5 65 32.5 65C14.5507 65 0 50.4493 0 32.5C0 14.5507 14.5507 0 32.5 0C32.5 0 18.5 14.5507 18.5 32.5Z";
let toggle = ''
darkMode.addEventListener('click', () => {
const darkline = anime.timeline({
duration: 500,
easing: 'easeOutExpo'
})
darkline
.add({
targets: '#logo path',
d: [{ value: toggle ? light : dark }],
fill: toggle ? '#FFB800' : '#FFFFFF'
})
.add({
targets: '#logo',
rotate: toggle ? 0 : 320,
})
// .add({
// targets: '#logo path',
// fill: toggle ? '#FFB800' : '#FFFFFF'
// })
// .add({
// targets: '#logo',
// rotate: toggle ? 0 : 320,
// scale: 1
// })
toggle = !toggle
switchTheme(toggle)
})
const switchTheme = data => {
if (data)
document.documentElement.setAttribute('data-theme', 'dark');
else
document.documentElement.setAttribute('data-theme', 'light');
}
anime({
targets: '#outline_text path',
strokeDashoffset: [anime.setDashoffset, 0],
easing: 'easeInOutSine',
duration: 1000,
delay: function(el, i) { return i * 200 }
});
let timeline = anime.timeline({
easing: 'easeOutExpo',
duration: 750
});
timeline.
add({
targets: '.main_anime',
opacity: 1,
delay: 2800,
complete: () => main_anime.remove()
})
.add({
targets: '.list_cont, .generate',
opacity: 1
})
const randomColor = () => {
return `#${randomNumber()}${randomNumber()}${randomNumber()}`
}
const randomNumber = () => {
return rgbToHex(Math.floor( Math.random() * 255 ) + 1);
}
const fillColor = () => {
for(let i=0; i< liList.length; i++){
let color = randomColor()
liList[i].style.background = color
text[i].innerHTML = color
}
}
const rgbToHex = rgb => {
let hex = Number(rgb).toString(16);
if (hex.length < 2) {
hex = "0" + hex;
}
return hex;
};
for(let i=0; i< liList.length; i++){
liList[i].addEventListener('click', () => {
container.style.background = `linear-gradient(45deg, ${liList[i].style.background} 10%, rgba(0, 0, 0, 0) 10%, rgba(0, 0, 0, 0) 90%, ${liList[i].style.background} 90%)`
let aux = document.createElement("input");
// Get the text from the element passed into the input
aux.setAttribute("value", (liList[i].innerText || liList[i].textContent));
// Append the aux input to the body
document.body.appendChild(aux);
// Highlight the content
aux.select();
// Execute the copy command
document.execCommand("copy");
// Remove the input from the body
document.body.removeChild(aux);
let timeline = anime.timeline({
duration: 800,
easing: 'easeOutExpo'
})
timeline
.add({
targets: '.snackbar',
opacity: 1
})
.add({
targets: '.snackbar',
opacity: 0
})
})
}
buttonColor.addEventListener('click', fillColor)
fillColor()
const copyToClipboard = elementId => {
// Create an auxiliary hidden input
var aux = document.createElement("input");
// Get the text from the element passed into the input
aux.setAttribute("value", document.getElementById(elementId).innerHTML);
// Append the aux input to the body
document.body.appendChild(aux);
// Highlight the content
aux.select();
// Execute the copy command
document.execCommand("copy");
// Remove the input from the body
document.body.removeChild(aux);
}