- Implemented a button for toggling between dark and light modes in the navigation component. - Adjusted sidebar width and improved active link indicators with shadows for better visibility. - Updated layout colors for a more vibrant and cohesive theme, focusing on a "Pure Neutral Black + Neon" aesthetic. - Refined ambient gradient accents for improved content readability across devices. - Enhanced console layout for better responsiveness and user experience.
52 lines
1.8 KiB
PHP
52 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Paymenter\Extensions\Others\ForceTheme;
|
|
|
|
use App\Classes\Extension\Extension;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\HtmlString;
|
|
|
|
class ForceTheme extends Extension
|
|
{
|
|
public function getConfig($values = [])
|
|
{
|
|
return [
|
|
[
|
|
'name' => 'mode',
|
|
'label' => 'Theme Mode',
|
|
'type' => 'select',
|
|
'options' => ['light' => 'Light', 'dark' => 'Dark'],
|
|
'default' => 'light',
|
|
'required' => true,
|
|
'validation' => 'in:light,dark',
|
|
],
|
|
[
|
|
'name' => 'local_storage_key',
|
|
'label' => 'Local Storage Key',
|
|
'type' => 'text',
|
|
'default' => '_x_darkMode',
|
|
'required' => true,
|
|
'validation' => 'string',
|
|
],
|
|
];
|
|
}
|
|
|
|
public function boot()
|
|
{
|
|
View::prependLocation(__DIR__ . '/resources/views/overrides');
|
|
|
|
Event::listen('head', function () {
|
|
$mode = $this->config('mode') ?: 'light';
|
|
$key = $this->config('local_storage_key') ?: '_x_darkMode';
|
|
$modeJs = e($mode);
|
|
$keyJs = e($key);
|
|
// Only set the default when the user has not yet made a choice; respect any existing selection so toggles persist.
|
|
$script = "<script>(function(){try{var m='" . $modeJs . "';var k='" . $keyJs . "';var def='_x_darkMode';var v=(m==='dark')?'true':'false';if(localStorage.getItem(def)===null){localStorage.setItem(def, v);}if(k!==def&&localStorage.getItem(k)===null){localStorage.setItem(k, v);} }catch(e){}})();</script>";
|
|
return ['view' => new HtmlString($script)];
|
|
});
|
|
}
|
|
}
|
|
|
|
|