mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 08:51:11 -05:00
27 lines
564 B
PHP
27 lines
564 B
PHP
<?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');
|
|
}
|
|
} |