-
Notifications
You must be signed in to change notification settings - Fork 0
/
colors.html
74 lines (61 loc) · 2.44 KB
/
colors.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tailwind Custom Colors Visualization</title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
fetch('tailwind.theme.json')
.then(response => response.json())
.then(config => {
tailwind.config = { theme: config };
const colors = tailwind.config.theme.extend.colors;
const colorsContainer = document.getElementById('colors');
for (const [colorName, shades] of Object.entries(colors)) {
const colorGroup = document.createElement('div');
colorGroup.className = 'color-group';
const colorNameElement = document.createElement('div');
colorNameElement.className = 'color-name';
colorNameElement.textContent = colorName;
colorGroup.appendChild(colorNameElement);
for (const [shade, hex] of Object.entries(shades)) {
const colorBlock = document.createElement('div');
colorBlock.className = 'color-block';
colorBlock.style.backgroundColor = hex;
colorBlock.textContent = `${colorName}-${shade}`;
colorGroup.appendChild(colorBlock);
}
colorsContainer.appendChild(colorGroup);
}
})
.catch(error => console.error('Error loading Tailwind config:', error));
});
</script>
<style>
.color-block {
padding: 20px;
color: white;
font-size: 12px;
text-align: center;
border-radius: 4px;
margin: 5px;
display: inline-block;
width: 100px;
}
.color-group {
margin-bottom: 20px;
}
.color-name {
font-size: 18px;
font-weight: bold;
margin-bottom: 10px;
}
</style>
</head>
<body class="bg-gray-100 p-10">
<h1 class="text-3xl font-bold mb-10">Tailwind Custom Colors Visualization</h1>
<div id="colors"></div>
</body>
</html>