-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
43 lines (37 loc) · 1.15 KB
/
main.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
import './vite.css'
import './style.css'
import { generateColor } from './generate.js';
import { addToHistory } from './history.js';
import toolbar from './toolbar.js';
// TODO: add only most recent generation to output, leave history in table
const color = generateColor();
const colorHistory = [];
const optionsForm = document.forms.options;
document.querySelector('#app').innerHTML = `
<button id="generate-color" type="button" form="options">Generate color</button>
<form id="options">
${toolbar}
<output for="color-space grayscale">
<div class="history-wrapper">
<table id="color-history">
<thead>
<tr>
<th scope="col">Swatch</th>
<th scope="col">Code</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</output>
</form>
`;
document.querySelector("#generate-color").addEventListener("click", function(event) {
const color = generateColor({
grayscale: options.grayscale.checked
});
colorHistory.push(color);
document.body.style.setProperty("background-color", color.display());
addToHistory(color);
});