Skip to content

Commit

Permalink
fix: update
Browse files Browse the repository at this point in the history
  • Loading branch information
elonehoo committed Oct 22, 2022
1 parent 1690881 commit f982715
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion components/DarkToggle.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script setup lang="ts">
<!-- <script setup lang="ts">
const color = useColorMode()

function toggleDark() {
Expand All @@ -10,4 +10,19 @@ function toggleDark() {
<button class="!outline-none" @click="toggleDark">
<div class="dark:i-carbon-moon i-carbon-sun" />
</button>
</template> -->


<script setup lang="ts">
const colorMode = useColorMode()
const onClick = () => (colorMode.value === 'light' ? (colorMode.preference = 'dark') : (colorMode.preference = 'light'))
</script>

<template>
<button aria-label="Color Mode" class="inline-block w-5" @click="onClick">
<ColorScheme placeholder="...">
<Icon v-if="colorMode.value === 'dark'" name="heroicons-outline:moon" class="w-5 h-5" />
<Icon v-else name="heroicons-outline:sun" class="w-5 h-5" />
</ColorScheme>
</button>
</template>

0 comments on commit f982715

Please sign in to comment.