-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfifty-shades-of-cold.js
33 lines (29 loc) · 978 Bytes
/
fifty-shades-of-cold.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
import { colors } from "./fifty-shades-of-cold.data.js";
function generateClasses() {
const head = document.getElementsByTagName("head")[0];
const style = document.createElement("style");
colors.forEach((color) => {
style.innerHTML += `.${color} {\n background: ${color};\n }\n\n`;
});
console.log(style.innerHTML);
head.appendChild(style);
}
function generateColdShades() {
const body = document.getElementsByTagName("body")[0];
colors.forEach((color) => {
if (
color.match(/(aqua|blue|turquoise|green|cyan|navy|purple)/) !== null
) {
const div = document.createElement("div");
div.classList.add(color);
div.innerHTML = color;
body.appendChild(div);
}
});
}
function choseShade(shade) {
document.querySelectorAll("div").forEach((div) => {
div.className = shade;
});
}
export { generateClasses, generateColdShades, choseShade };