-
Notifications
You must be signed in to change notification settings - Fork 4
/
preview.html
52 lines (45 loc) · 1.24 KB
/
preview.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Preview Persian Colors</title>
<style>
body {
font-size: 1rem;
padding: 0.5rem;
margin: 0;
display: flex;
justify-content: center;
}
main {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
div {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 1rem 2rem;
border-radius: 0.25rem;
}
</style>
</head>
<body>
<main id="palette"></main>
<script type="module">
import { PERSIAN_COLORS } from "./persian-colors.js";
const PALETTE = document.querySelector("#palette");
for (const COLOR of PERSIAN_COLORS) {
const BOX = document.createElement("DIV");
const [R, G, B] = COLOR.rgb;
const FOREGROUND = R * 0.299 + G * 0.587 + B * 0.114 > 186 ? "000000" : "ffffff";
BOX.style.backgroundColor = `#${COLOR.hex}`;
BOX.style.color = `#${FOREGROUND}b2`;
BOX.append(document.createTextNode(COLOR.name.toUpperCase()));
PALETTE.append(BOX);
}
</script>
</body>
</html>