Created
July 17, 2023 12:56
-
-
Save Tracer1337/1866b7f6b649bd769306b0a5cb6e3141 to your computer and use it in GitHub Desktop.
Visualize theme palette in jsfiddle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const colors = { | |
green: { | |
100: '#00ff00', | |
}, | |
} | |
Object.entries(colors).map(([color, shades]) => | |
Object.entries(shades).map(([shade, colorCode]) => renderShade(color, shade, colorCode)) | |
) | |
function renderShade(color, shade, colorCode) { | |
let container = getContainer(color) | |
const box = document.createElement("div") | |
box.textContent = color + ':' + shade | |
box.style.display = "flex" | |
box.style.justifyContent = "center" | |
box.style.alignItems = "center" | |
box.style.width = "100px" | |
box.style.height = "100px" | |
box.style.backgroundColor = colorCode | |
container.appendChild(box) | |
} | |
function getContainer(color) { | |
let container = document.querySelector("#" + color) | |
if (!container) { | |
container = document.createElement("div") | |
container.style.display = "flex" | |
container.style.flexWrap = "wrap" | |
container.setAttribute("id", color) | |
const headline = document.createElement("h3") | |
headline.textContent = color | |
headline.style.textTransform = "uppercase" | |
document.body.appendChild(headline) | |
document.body.appendChild(container) | |
} | |
return container | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment