add color theme with dark and light mode!
This commit is contained in:
parent
08b505c145
commit
23081d8685
5 changed files with 184 additions and 127 deletions
38
src/components/ThemeToggle.vue
Normal file
38
src/components/ThemeToggle.vue
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { Moon, Sun } from 'lucide-vue-next'
|
||||
import { Button } from '@/components/ui/button'
|
||||
|
||||
const isDark = ref(false)
|
||||
|
||||
const toggleTheme = () => {
|
||||
isDark.value = !isDark.value
|
||||
updateTheme()
|
||||
}
|
||||
|
||||
const updateTheme = () => {
|
||||
if (isDark.value) {
|
||||
document.documentElement.classList.add('dark')
|
||||
localStorage.setItem('theme', 'dark')
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark')
|
||||
localStorage.setItem('theme', 'light')
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const savedTheme = localStorage.getItem('theme')
|
||||
isDark.value =
|
||||
savedTheme === 'dark' ||
|
||||
(!savedTheme && window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||
updateTheme()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Button variant="ghost" size="icon" @click="toggleTheme">
|
||||
<Sun v-if="isDark" class="h-5 w-5" />
|
||||
<Moon v-else class="h-5 w-5" />
|
||||
<span class="sr-only">Toggle theme</span>
|
||||
</Button>
|
||||
</template>
|
||||
|
|
@ -3,9 +3,9 @@ const currentYear = new Date().getFullYear()
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<footer class="border-t mt-auto">
|
||||
<div class="container mx-auto px-4 py-6">
|
||||
<div class="flex flex-col sm:flex-row items-center justify-between gap-4">
|
||||
<footer class="bg-card border-t border-border">
|
||||
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
||||
<div class="flex h-16 items-center justify-between">
|
||||
<!-- Powered by section -->
|
||||
<div class="flex items-center space-x-2 text-sm text-muted-foreground">
|
||||
<span>Powered by</span>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { Menu, X } from 'lucide-vue-next'
|
||||
import ThemeToggle from '@/components/ThemeToggle.vue'
|
||||
|
||||
const isOpen = ref(false)
|
||||
|
||||
|
|
@ -16,14 +17,14 @@ const toggleMenu = () => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<nav class="bg-white shadow-sm">
|
||||
<nav class="bg-card border-b border-border">
|
||||
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
||||
<div class="flex h-16 justify-between">
|
||||
<!-- Logo and Desktop Navigation -->
|
||||
<div class="flex">
|
||||
<div class="flex flex-shrink-0 items-center">
|
||||
<!-- Replace with your logo -->
|
||||
<router-link to="/" class="text-xl font-bold">
|
||||
<router-link to="/" class="text-xl font-bold text-card-foreground">
|
||||
⚡️ Lightning Directory
|
||||
</router-link>
|
||||
</div>
|
||||
|
|
@ -37,8 +38,8 @@ const toggleMenu = () => {
|
|||
class="inline-flex items-center px-1 pt-1 text-sm font-medium"
|
||||
:class="[
|
||||
$route.path === item.href
|
||||
? 'border-b-2 border-primary text-gray-900'
|
||||
: 'text-gray-500 hover:border-b-2 hover:border-gray-300 hover:text-gray-700'
|
||||
? 'border-b-2 border-primary text-card-foreground'
|
||||
: 'text-muted-foreground hover:border-b-2 hover:border-muted hover:text-card-foreground'
|
||||
]"
|
||||
>
|
||||
{{ item.name }}
|
||||
|
|
@ -46,6 +47,11 @@ const toggleMenu = () => {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Theme Toggle -->
|
||||
<div class="flex items-center">
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
|
||||
<!-- Mobile menu button -->
|
||||
<div class="flex items-center sm:hidden">
|
||||
<button
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue