Skip to content

Commit

Permalink
Theme with body class instead of document element (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManUtopiK authored Sep 24, 2024
1 parent e6492e9 commit d6146a9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ useSeoMeta({
});
useServerHead({
htmlAttrs: {
bodyAttrs: {
class: themeClass.value,
style: `--radius: ${radius.value}rem;`,
},
Expand Down
24 changes: 12 additions & 12 deletions assets/css/themes.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ html.dark {
--radius: 0.5rem;
}

.theme-zinc.dark {
.dark .theme-zinc {
--background: 240 10% 3.9%;
--foreground: 0 0% 98%;

Expand Down Expand Up @@ -103,7 +103,7 @@ html.dark {
--radius: 0.5rem;
}

.theme-slate.dark {
.dark .theme-slate {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;

Expand Down Expand Up @@ -167,7 +167,7 @@ html.dark {
--radius: 0.5rem;
}

.theme-stone.dark {
.dark .theme-stone {
--background: 20 14.3% 4.1%;
--foreground: 60 9.1% 97.8%;

Expand Down Expand Up @@ -231,7 +231,7 @@ html.dark {
--radius: 0.5rem;
}

.theme-gray.dark {
.dark .theme-gray {
--background: 224 71.4% 4.1%;
--foreground: 210 20% 98%;

Expand Down Expand Up @@ -295,7 +295,7 @@ html.dark {
--radius: 0.5rem;
}

.theme-neutral.dark {
.dark .theme-neutral {
--background: 0 0% 3.9%;
--foreground: 0 0% 98%;

Expand Down Expand Up @@ -359,7 +359,7 @@ html.dark {
--radius: 0.5rem;
}

.theme-red.dark {
.dark .theme-red {
--background: 0 0% 3.9%;
--foreground: 0 0% 98%;

Expand Down Expand Up @@ -423,7 +423,7 @@ html.dark {
--radius: 0.5rem;
}

.theme-rose.dark {
.dark .theme-rose {
--background: 20 14.3% 4.1%;
--foreground: 0 0% 95%;

Expand Down Expand Up @@ -487,7 +487,7 @@ html.dark {
--radius: 0.5rem;
}

.theme-orange.dark {
.dark .theme-orange {
--background: 20 14.3% 4.1%;
--foreground: 60 9.1% 97.8%;

Expand Down Expand Up @@ -551,7 +551,7 @@ html.dark {
--radius: 0.5rem;
}

.theme-green.dark {
.dark .theme-green {
--background: 20 14.3% 4.1%;
--foreground: 0 0% 95%;

Expand Down Expand Up @@ -615,7 +615,7 @@ html.dark {
--radius: 0.5rem;
}

.theme-blue.dark {
.dark .theme-blue {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;

Expand Down Expand Up @@ -679,7 +679,7 @@ html.dark {
--radius: 0.5rem;
}

.theme-yellow.dark {
.dark .theme-yellow {
--background: 20 14.3% 4.1%;
--foreground: 60 9.1% 97.8%;

Expand Down Expand Up @@ -743,7 +743,7 @@ html.dark {
--radius: 0.5rem;
}

.theme-violet.dark {
.dark .theme-violet {
--background: 224 71.4% 4.1%;
--foreground: 210 20% 98%;

Expand Down
6 changes: 3 additions & 3 deletions components/ThemeCustomizer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ watch(radius, () => {
});
function setClassTheme() {
document.documentElement.classList.remove(
document.body.classList.remove(
...allColors.map(color => `theme-${color}`),
);
document.documentElement.classList.add(themeClass.value);
document.body.classList.add(themeClass.value);
}
function setStyleRadius() {
document.documentElement.style.setProperty('--radius', `${radius.value}rem`);
document.body.style.setProperty('--radius', `${radius.value}rem`);
}
function backgroundColor(color: Color) {
Expand Down

0 comments on commit d6146a9

Please sign in to comment.