Skip to content

Commit c90729a

Browse files
committed
fix: dark mode and add toggle to footer
1 parent 06cf16e commit c90729a

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

app.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
</div>
139139
<div class="text-sm">Try improving your results by double checking your spelling or trying a more general keyword.</div>
140140
</div>
141+
<Footer />
141142
</div>
142143
</div>
143144
</template>
@@ -259,7 +260,7 @@ watch([selectedOption, searchTerm, selectedCategory], ([newSelectedOption, newSe
259260
</script>
260261
261262
<style lang="postcss">
262-
.dark-mode {
263+
.dark {
263264
@apply bg-black text-neutral-100;
264265
color-scheme: dark;
265266
}

components/footer/index.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<button @click="toggleDark" class="flex box-border items-center active:scale-95 dark:bg-white/10 hover:dark:bg-white/20 h-8 transition-all rounded-lg p-2">
3+
<Icon :name="colorModeIcon" size="16"></Icon>
4+
</button>
5+
</template>
6+
7+
<script setup lang="ts">
8+
const colorMode = useColorMode();
9+
10+
const toggleDark = () => {
11+
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark';
12+
};
13+
14+
const colorModeIcon = computed(() => (colorMode.preference === 'dark' ? 'solar:moon-bold' : 'solar:sun-bold'));
15+
</script>

nuxt.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
export default defineNuxtConfig({
22
modules: ['@nuxt/image-edge', '@nuxtjs/tailwindcss', '@nuxtjs/color-mode', '@nuxtjs/apollo', 'nuxt-icon'],
3+
colorMode: {
4+
classSuffix: '',
5+
},
36
apollo: {
47
clients: {
58
default: {

tailwind.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
2+
darkMode: 'class',
23
theme: {
34
extend: {
45
fontFamily: {

0 commit comments

Comments
 (0)