Feat(fortune): Add colorPreviewContainer to encapsulate dots for improved clarity

This commit is contained in:
lifeadventurer
2024-11-01 22:36:35 +08:00
parent a345a61f25
commit 9b8fbe8809
2 changed files with 18 additions and 1 deletions

View File

@@ -126,6 +126,13 @@ button:hover {
color: var(--title-color);
}
.color-preview-container {
display: flex;
align-items: center;
padding: 3px;
border-radius: 25px;
}
.color-preview {
display: flex; /* Use flex to align dots in a row */
}

View File

@@ -27,16 +27,26 @@ document.addEventListener("DOMContentLoaded", () => {
themeName.textContent = theme.name;
themeItem.appendChild(themeName);
const colorPreivewContainer = document.createElement("div");
colorPreivewContainer.className = "color-preview-container";
const propertyKeys = Object.keys(theme.properties);
colorPreivewContainer.style.backgroundColor =
theme.properties[propertyKeys[3]];
// Add color dots for visual preview
const colorPreview = document.createElement("div");
colorPreview.className = "color-preview";
Object.values(theme.properties).slice(0, 3).forEach((color) => {
const colorDot = document.createElement("span");
colorDot.style.backgroundColor = color;
colorDot.className = "color-dot";
colorPreview.appendChild(colorDot);
});
themeItem.appendChild(colorPreview);
colorPreivewContainer.appendChild(colorPreview);
themeItem.appendChild(colorPreivewContainer);
// Apply theme on click
themeItem.addEventListener("click", () => applyTheme(theme.properties));