-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfifty-shades-of-cold.js
More file actions
38 lines (36 loc) · 1.32 KB
/
Copy pathfifty-shades-of-cold.js
File metadata and controls
38 lines (36 loc) · 1.32 KB
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
import { colors } from './fifty-shades-of-cold.data.js';
export function generateClasses() {
let style = document.createElement('style')
style.innerHTML = ''
for (let i = 0; i < colors.length; i++) {
style.innerHTML += '.' + colors[i] + '{background:' + colors[i] + ';}'
}
document.getElementsByTagName('head')[0].appendChild(style);
}
export function generateColdShades() {
let view = ['aqua', 'blue', 'turquoise', 'green', 'cyan', 'navy', 'purple']
for (let i = 0; i < colors.length; i++) {
for (let j = 0; j < view.length; j++) {
let Regex = new RegExp(view[j])
let bol = colors[i].match(Regex)
if (bol !== null) {
let div = document.createElement('div')
// document.head.classList.add(colors[i])
div.className = colors[i]
div.textContent = colors[i]
document.body.append(div)
}
}
}
}
export function choseShade(d) {
let elem = document.querySelectorAll('div')
for (let i = 0; i < colors.length; i++) {
let style = elem[i].className
let flag = elem[i].classList.contains(d)
if (!flag) {
elem[i].classList.remove(style)
elem[i].classList.add(d)
}
}
}