-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
37 lines (33 loc) · 1.17 KB
/
Copy pathscript.js
File metadata and controls
37 lines (33 loc) · 1.17 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
import { extractColors } from "./js/colors.js";
import { createToast, renderSwatches } from "./js/ui.js";
import { initThemeToggle } from "./js/theme.js";
import { renderContrast } from "./js/contrast.js";
const input = document.querySelector("#input");
const swatches = document.querySelector("#swatches");
const count = document.querySelector("#count");
const empty = document.querySelector("#empty");
const themeToggle = document.querySelector("#theme-toggle");
const outputPanel = document.querySelector(".output");
const contrastContainer = document.querySelector("#contrast");
const contrastEmpty = document.querySelector("#contrast-empty");
const contrastCount = document.querySelector("#contrast-count");
const showToast = outputPanel ? createToast(outputPanel) : null;
function handleInput() {
const colors = extractColors(input.value);
renderSwatches({
colors,
swatchesEl: swatches,
emptyEl: empty,
countEl: count,
onCopy: showToast,
});
renderContrast({
colors,
containerEl: contrastContainer,
emptyEl: contrastEmpty,
countEl: contrastCount,
});
}
initThemeToggle(themeToggle);
input.addEventListener("input", handleInput);
handleInput();