Added a dark mode theme

Added a dark mode theme with settings option
This commit is contained in:
cp6 2022-05-09 15:57:02 +10:00
parent 7b37eba517
commit 31f1faf8ee
6 changed files with 45 additions and 1 deletions

View File

@ -105,6 +105,7 @@ class HomeController extends Controller
->get();
});
Session::put('dark_mode', $settings[0]->dark_mode ?? 0);
Session::put('timer_version_footer', $settings[0]->show_versions_footer ?? 1);
Session::put('show_servers_public', $settings[0]->show_servers_public ?? 0);
Session::put('show_server_value_ip', $settings[0]->show_server_value_ip ?? 0);

View File

@ -22,6 +22,7 @@ class SettingsController extends Controller
public function update(Request $request, Settings $settings)
{
$request->validate([
'dark_mode' => 'required|boolean',
'show_versions_footer' => 'required|boolean',
'show_server_value_ip' => 'required|boolean',
'show_server_value_hostname' => 'required|boolean',
@ -38,6 +39,7 @@ class SettingsController extends Controller
DB::table('settings')
->where('id', 1)
->update([
'dark_mode' => $request->dark_mode,
'show_versions_footer' => $request->show_versions_footer,
'show_servers_public' => $request->show_servers_public,
'show_server_value_ip' => $request->show_server_value_ip,
@ -52,6 +54,7 @@ class SettingsController extends Controller
'recently_added_amount' => $request->recently_added_amount
]);
Session::put('dark_mode', $request->dark_mode ?? 1);
Session::put('timer_version_footer', $request->show_versions_footer);
Session::put('show_servers_public', $request->show_servers_public);
Session::put('show_server_value_ip', $request->show_server_value_ip);

View File

@ -0,0 +1,19 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddDarkModeSetting extends Migration
{
public function up()
{
Schema::table('settings', function (Blueprint $table) {
$table->boolean('dark_mode')->default(false);
});
}
public function down()
{
}
}

BIN
public/css/bootstrap-dark.min.css vendored Normal file

Binary file not shown.

View File

@ -10,7 +10,12 @@
<title>@yield('title') - @if (config()->has('app.name')) {{ config('app.name') }} @else My idlers @endif</title>
@if(Session::get('dark_mode'))
<link rel="stylesheet" href="{{ asset('css/bootstrap-dark.min.css') }}">
@else
<link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}">
@endif
<link rel="stylesheet" href="{{ asset('css/fa.min.css') }}">
@yield('css_links')

View File

@ -17,6 +17,22 @@
<form action="{{ route('settings.update', 1) }}" method="POST">
@csrf
@method('PUT')
<div class="row mt-2">
<div class="col-12 col-md-4 mb-3">
<div class="input-group">
<div class="input-group-prepend"><span
class="input-group-text">Use dark mode</span></div>
<select class="form-control" name="dark_mode">
<option value="1" {{ ($setting[0]->dark_mode === 1) ? 'selected' : '' }}>
Yes
</option>
<option value="0" {{ ($setting[0]->dark_mode === 0) ? 'selected' : '' }}>
No
</option>
</select>
</div>
</div>
</div>
<div class="row mt-2">
<div class="col-12 col-md-4 mb-3">
<div class="input-group">