mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 12:31:23 -05:00
Add placeholder images, enhance alert styles, and implement theme toggle component with dark mode support
This commit is contained in:
27
app/Livewire/ThemeToggleComponent.php
Normal file
27
app/Livewire/ThemeToggleComponent.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class ThemeToggleComponent extends Component
|
||||
{
|
||||
public bool $isDark = false;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->isDark = session('theme') === 'dark';
|
||||
}
|
||||
|
||||
public function toggleTheme()
|
||||
{
|
||||
$this->isDark = !$this->isDark;
|
||||
session(['theme' => $this->isDark ? 'dark' : 'light']);
|
||||
$this->dispatch('theme-changed', theme: $this->isDark ? 'dark' : 'light');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.theme-toggle-component');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user