Skip to content

Commit

Permalink
Updated: Dark mode component preview.
Browse files Browse the repository at this point in the history
  • Loading branch information
moshiur01 committed Dec 20, 2024
1 parent 5c400ad commit bfefebb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import {
NuxtModuleAddCode,
nuxtThemeSwitcherCode,
} from "./darkModeCodes";
import ThemeSwitcherForDoc from "./ThemeSwitcherForDoc.vue";
const colorMode = useColorMode();
const toggleTheme = () => {
colorMode.preference = colorMode.preference === "dark" ? "light" : "dark";
};
</script>

<template>
Expand Down Expand Up @@ -80,7 +84,23 @@ import ThemeSwitcherForDoc from "./ThemeSwitcherForDoc.vue";
</p>
<div class="!my-4">
<CodeHighlightWithPreview :code="nuxtThemeSwitcherCode">
<ThemeSwitcherForDoc />
<div class="flex items-center justify-center">
<ClientOnly>
<Button
class="rounded-lg bg-primary-25 p-2.5 hover:bg-primary-50 dark:bg-metal-600 dark:hover:bg-metal-700"
@click="() => toggleTheme()">
<PhosphorIconMoon
v-if="colorMode.preference === 'dark'"
:size="21"
class="transition duration-300 ease-in-out" />
<PhosphorIconSunDim
v-else
color="black"
:size="21"
class="transition duration-300 ease-in-out" />
</Button>
</ClientOnly>
</div>
</CodeHighlightWithPreview>
</div>
</TimelineContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
vueThemeSwitcherComponentCode,
vueUseInstallForVue,
} from "./darkModeCodes";
import ThemeSwitcherForDoc from "./ThemeSwitcherForDoc.vue";
const colorMode = useColorMode();
const toggleTheme = () => {
colorMode.preference = colorMode.preference === "dark" ? "light" : "dark";
};
</script>

<template>
Expand Down Expand Up @@ -44,7 +49,23 @@ import ThemeSwitcherForDoc from "./ThemeSwitcherForDoc.vue";
</p>
<div class="!my-4">
<CodeHighlightWithPreview :code="vueThemeSwitcherComponentCode">
<ThemeSwitcherForDoc />
<div class="flex items-center justify-center">
<ClientOnly>
<Button
class="rounded-lg bg-primary-25 p-2.5 hover:bg-primary-50 dark:bg-metal-600 dark:hover:bg-metal-700"
@click="() => toggleTheme()">
<PhosphorIconMoon
v-if="colorMode.preference === 'dark'"
:size="21"
class="transition duration-300 ease-in-out" />
<PhosphorIconSunDim
v-else
color="black"
:size="21"
class="transition duration-300 ease-in-out" />
</Button>
</ClientOnly>
</div>
</CodeHighlightWithPreview>
</div>
</TimelineContent>
Expand Down

0 comments on commit bfefebb

Please sign in to comment.