Skip to content

Commit 5664251

Browse files
committed
Fine-tune darkmode options
1 parent 2366006 commit 5664251

File tree

8 files changed

+82
-64
lines changed

8 files changed

+82
-64
lines changed

app/Filament/Pages/Colors.php

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Filament\Pages;
44

55
use App\Enums\UserRole;
6+
use Filament\Forms\Components\Toggle;
67
use Filament\Forms\Form;
78
use App\Settings\ColorSettings;
89
use Filament\Pages\SettingsPage;
@@ -53,55 +54,57 @@ public function form(Form $form): Form
5354
{
5455
return $form->schema(
5556
[
56-
Section::make()
57-
->schema(
58-
[
59-
FileUpload::make('logo')
60-
->label(trans('theme.logo'))
61-
->image()
62-
->helperText(trans('theme.logo-helper-text'))
63-
->disk('public')
64-
// ->imageResizeTargetHeight('64')
65-
->maxSize(1024)
66-
->getUploadedFileNameForStorageUsing(
67-
function (TemporaryUploadedFile $file): string {
68-
return (string) str($file->getClientOriginalName())->prepend('logo-');
69-
}
70-
)
71-
->getUploadedFileNameForStorageUsing(
72-
function ($record) {
73-
return storage_path('app/public/'.app(ColorSettings::class)->logo);
74-
}
75-
),
76-
FileUpload::make('favicon')
77-
->label(trans('theme.favicon'))
78-
->image()
79-
->disk('public')
80-
// ->imageResizeTargetHeight('64')
81-
// ->imageResizeTargetWidth('64')
82-
->maxSize(1024)
83-
->getUploadedFileNameForStorageUsing(
84-
function ($record) {
85-
return storage_path('app/public/favicon.png');
86-
}
87-
)
88-
->getUploadedFileNameForStorageUsing(
89-
function (TemporaryUploadedFile $file): string {
90-
return (string)'favicon.png';
91-
}
92-
),
93-
TextInput::make('fontFamily')
94-
->label(trans('theme.font-family'))
95-
->placeholder('e.g. Roboto')
96-
->required()
97-
->helperText(new HtmlString(trans('theme.font-family-helper-text'))),
57+
Section::make()
58+
->schema(
59+
[
60+
FileUpload::make('logo')
61+
->label(trans('theme.logo'))
62+
->image()
63+
->helperText(trans('theme.logo-helper-text'))
64+
->disk('public')
65+
// ->imageResizeTargetHeight('64')
66+
->maxSize(1024)
67+
->getUploadedFileNameForStorageUsing(
68+
function (TemporaryUploadedFile $file): string {
69+
return (string)str($file->getClientOriginalName())->prepend('logo-');
70+
}
71+
)
72+
->getUploadedFileNameForStorageUsing(
73+
function ($record) {
74+
return storage_path('app/public/' . app(ColorSettings::class)->logo);
75+
}
76+
),
77+
FileUpload::make('favicon')
78+
->label(trans('theme.favicon'))
79+
->image()
80+
->disk('public')
81+
// ->imageResizeTargetHeight('64')
82+
// ->imageResizeTargetWidth('64')
83+
->maxSize(1024)
84+
->getUploadedFileNameForStorageUsing(
85+
function ($record) {
86+
return storage_path('app/public/favicon.png');
87+
}
88+
)
89+
->getUploadedFileNameForStorageUsing(
90+
function (TemporaryUploadedFile $file): string {
91+
return (string)'favicon.png';
92+
}
93+
),
94+
TextInput::make('fontFamily')
95+
->label(trans('theme.font-family'))
96+
->placeholder('e.g. Roboto')
97+
->required()
98+
->helperText(new HtmlString(trans('theme.font-family-helper-text'))),
9899

99-
ColorPicker::make('primary')
100-
->label(trans('theme.primary-color'))
101-
->default('#2563EB'),
100+
ColorPicker::make('primary')
101+
->label(trans('theme.primary-color'))
102+
->default('#2563EB'),
102103

103-
]
104-
)->columns(),
104+
Toggle::make('darkmode')
105+
->helperText('Allow darkmode on the frontend')
106+
]
107+
)->columns(),
105108
]
106109
);
107110
}

app/Settings/ColorSettings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class ColorSettings extends Settings
1010
public string|null $favicon;
1111
public string|null $logo;
1212
public string|null $fontFamily;
13+
public bool $darkmode;
1314

1415
public static function group(): string
1516
{
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
use Spatie\LaravelSettings\Migrations\SettingsMigration;
4+
5+
return new class extends SettingsMigration
6+
{
7+
public function up(): void
8+
{
9+
$this->migrator->add('colors.darkmode', true);
10+
}
11+
};

resources/views/components/app.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function updateTheme() {
6767

6868
<main class="flex-1 h-full col-span-6 lg:col-span-5 lg:border-l lg:pl-5 dark:lg:border-white/10">
6969
<div class="pb-4">
70-
<ul class="flex items-center space-x-0.5 text-sm font-medium text-gray-600">
70+
<ul class="flex items-center space-x-0.5 text-sm font-medium text-gray-600 dark:text-gray-500">
7171
@foreach(array_filter($breadcrumbs) as $breadcrumb)
7272
@if(!$loop->first)
7373
<li>

resources/views/item.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class="float-right inline-flex items-center justify-center h-8 px-3 pt-1.5 pr-8
5555

5656
<div class="border-t dark:border-white/10"></div>
5757

58-
<div class="p-4 prose break-words dark:text-gray-600">
58+
<div class="p-4 prose break-words dark:text-gray-400">
5959
{!! str($item->content)->markdown()->sanitizeHtml() !!}
6060
</div>
6161
</x-card>
@@ -144,7 +144,7 @@ class="text-gray-500 fill-gray-500 float-right">
144144
@foreach($activities as $activity)
145145
<li class="flex space-x-3">
146146
<div
147-
class="relative flex items-center justify-center flex-shrink-0 w-8 h-8 text-gray-400 border border-gray-200 rounded-full bg-gray-50">
147+
class="relative flex items-center justify-center flex-shrink-0 w-8 h-8 text-gray-400 border border-gray-200 dark:border-gray-600 rounded-full bg-gray-50 dark:bg-gray-800">
148148
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
149149
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
150150
stroke-width="1.5"

resources/views/livewire/header.blade.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<a class="text-2xl font-semibold tracking-tight"
66
href="{{ route('home') }}">
77
@if(!is_null($logo) && file_exists($logoFile = storage_path('app/public/'.$logo)))
8-
<img src="{{ asset('storage/'.$logo) }}?v={{ md5_file($logoFile) }}" alt="{{ config('app.name') }}" class="h-8"/>
8+
<img src="{{ asset('storage/'.$logo) }}?v={{ md5_file($logoFile) }}" alt="{{ config('app.name') }}"
9+
class="h-8"/>
910
@else
1011
{{ config('app.name') }}
1112
@endif
@@ -58,17 +59,19 @@
5859
{{ $this->submitItemAction }}
5960
</li>
6061

61-
<li>
62-
<x-theme-toggle />
63-
</li>
62+
@if(app(\App\Settings\ColorSettings::class)->darkmode)
63+
<li>
64+
<x-theme-toggle/>
65+
</li>
66+
@endif
6467
</ul>
6568

6669
<!-- Hamburger -->
6770
<div class="lg:hidden">
6871
<button
69-
class="text-white flex items-center justify-center w-10 h-10 -mr-2 transition rounded-full focus:outline-none"
70-
x-on:click="open = !open"
71-
type="button">
72+
class="text-white flex items-center justify-center w-10 h-10 -mr-2 transition rounded-full focus:outline-none"
73+
x-on:click="open = !open"
74+
type="button">
7275
<svg class="w-7 h-7" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
7376
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
7477
d="M4.75 5.75H19.25"/>

resources/views/partials/navbar.blade.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<a
77
@class([
88
'flex items-center h-10 px-2 space-x-2 transition rounded-lg',
9-
'text-white bg-brand-500 dark:bg-white/5 dark:hover:bg-white/5 dark:text-brand-500' => request()->is('/'),
9+
'text-white bg-brand-500 dark:bg-white/5 dark:hover:bg-white/5 dark:text-brand-400' => request()->is('/'),
1010
'hover:bg-gray-500/5 focus:bg-brand-500/10 focus:text-brand-600 focus:outline-none dark:hover:bg-white/5 dark:text-brand-500' => !request()->is('/')
1111
])
1212
href="{{ route('home') }}">
@@ -22,7 +22,7 @@ class="font-normal {{ !request()->is('/') ? 'text-gray-900 dark:text-gray-200' :
2222
<a
2323
@class([
2424
'flex items-center h-10 px-2 space-x-2 transition rounded-lg',
25-
'text-white bg-brand-500 dark:bg-white/5 dark:hover:bg-white/5 dark:text-brand-500' => request()->is('my'),
25+
'text-white bg-brand-500 dark:bg-white/5 dark:hover:bg-white/5 dark:text-brand-400' => request()->is('my'),
2626
'hover:bg-gray-500/5 focus:bg-brand-500/10 focus:text-brand-600 focus:outline-none dark:hover:bg-white/5 dark:focus:text-gray-200 dark:text-gray-200' => !request()->is('my')
2727
])
2828
href="{{ route('my') }}">
@@ -36,7 +36,7 @@ class="font-normal {{ !request()->is('/') ? 'text-gray-900 dark:text-gray-200' :
3636
<a
3737
@class([
3838
'flex items-center h-10 px-2 space-x-2 transition rounded-lg',
39-
'text-white bg-brand-500 dark:bg-white/5 dark:hover:bg-white/5 dark:text-brand-500' => request()->is('profile'),
39+
'text-white bg-brand-500 dark:bg-white/5 dark:hover:bg-white/5 dark:text-brand-400' => request()->is('profile'),
4040
'hover:bg-gray-500/5 focus:bg-brand-500/10 focus:text-brand-600 focus:outline-none dark:hover:bg-white/5 dark:focus:text-gray-200 dark:text-gray-200' => !request()->is('profile')
4141
])
4242
href="{{ route('profile') }}">
@@ -51,7 +51,7 @@ class="font-normal {{ !request()->is('/') ? 'text-gray-900 dark:text-gray-200' :
5151
<a
5252
@class([
5353
'flex items-center h-10 px-2 space-x-2 transition rounded-lg',
54-
'text-white bg-brand-500 dark:bg-white/5 dark:hover:bg-white/5 dark:text-brand-500' => request()->is('changelog*'),
54+
'text-white bg-brand-500 dark:bg-white/5 dark:hover:bg-white/5 dark:text-brand-400' => request()->is('changelog*'),
5555
'hover:bg-gray-500/5 focus:bg-brand-500/10 focus:text-brand-600 focus:outline-none dark:hover:bg-white/5 dark:focus:text-gray-200 dark:text-gray-200' => !request()->is('changelog*')
5656
])
5757
href="{{ route('changelog') }}">
@@ -85,7 +85,7 @@ class="flex items-center h-2 px-2 space-x-2 transition rounded-lg mt-5"
8585
title="{{ $project->title }}"
8686
@class([
8787
'flex items-center h-10 px-2 space-x-2 transition rounded-lg',
88-
'text-white bg-brand-500 dark:bg-white/5 dark:hover:bg-white/5 dark:text-brand-500' => request()->segment(2) === $project->slug,
88+
'text-white bg-brand-500 dark:bg-white/5 dark:hover:bg-white/5 dark:text-brand-400' => request()->segment(2) === $project->slug,
8989
'hover:bg-gray-500/5 focus:bg-brand-500/10 focus:text-brand-600 focus:outline-none dark:hover:bg-white/5 dark:focus:text-gray-200 dark:text-gray-200' => request()->segment(2) !== $project->slug
9090
])
9191
href="{{ route('projects.show', $project) }}">
@@ -113,7 +113,7 @@ class="w-4 h-4 {{ request()->segment(2) == $project->slug ? '' : 'text-primary'
113113
</div>
114114

115115
<div id="dropdown-cta" class="p-4 mt-6 bg-gray-100 rounded-lg dark:bg-white/5" role="alert">
116-
<p class="text-sm text-gray-500">
116+
<p class="text-sm text-gray-500 dark:text-gray-400">
117117
<a href="https://github.com/ploi/roadmap" target="_blank"
118118
class="font-semibold border-b border-dotted">Open-source</a>
119119
roadmapping software by

resources/views/welcome.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<x-app>
44
@if($text = app(\App\Settings\GeneralSettings::class)->welcome_text)
5-
<div class="prose mb-4 dark:text-gray-600">{!! $text !!}</div>
5+
<div class="prose mb-4 dark:text-gray-500">{!! $text !!}</div>
66
@endif
77
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4">
88
@foreach(app(\App\Settings\GeneralSettings::class)->dashboard_items as $item)

0 commit comments

Comments
 (0)