diff --git a/app/Filament/Pages/Colors.php b/app/Filament/Pages/Colors.php index 81159123..4fb65cd4 100644 --- a/app/Filament/Pages/Colors.php +++ b/app/Filament/Pages/Colors.php @@ -3,6 +3,7 @@ namespace App\Filament\Pages; use App\Enums\UserRole; +use Filament\Forms\Components\Toggle; use Filament\Forms\Form; use App\Settings\ColorSettings; use Filament\Pages\SettingsPage; @@ -53,55 +54,57 @@ public function form(Form $form): Form { return $form->schema( [ - Section::make() - ->schema( - [ - FileUpload::make('logo') - ->label(trans('theme.logo')) - ->image() - ->helperText(trans('theme.logo-helper-text')) - ->disk('public') - // ->imageResizeTargetHeight('64') - ->maxSize(1024) - ->getUploadedFileNameForStorageUsing( - function (TemporaryUploadedFile $file): string { - return (string) str($file->getClientOriginalName())->prepend('logo-'); - } - ) - ->getUploadedFileNameForStorageUsing( - function ($record) { - return storage_path('app/public/'.app(ColorSettings::class)->logo); - } - ), - FileUpload::make('favicon') - ->label(trans('theme.favicon')) - ->image() - ->disk('public') - // ->imageResizeTargetHeight('64') - // ->imageResizeTargetWidth('64') - ->maxSize(1024) - ->getUploadedFileNameForStorageUsing( - function ($record) { - return storage_path('app/public/favicon.png'); - } - ) - ->getUploadedFileNameForStorageUsing( - function (TemporaryUploadedFile $file): string { - return (string)'favicon.png'; - } - ), - TextInput::make('fontFamily') - ->label(trans('theme.font-family')) - ->placeholder('e.g. Roboto') - ->required() - ->helperText(new HtmlString(trans('theme.font-family-helper-text'))), + Section::make() + ->schema( + [ + FileUpload::make('logo') + ->label(trans('theme.logo')) + ->image() + ->helperText(trans('theme.logo-helper-text')) + ->disk('public') + // ->imageResizeTargetHeight('64') + ->maxSize(1024) + ->getUploadedFileNameForStorageUsing( + function (TemporaryUploadedFile $file): string { + return (string)str($file->getClientOriginalName())->prepend('logo-'); + } + ) + ->getUploadedFileNameForStorageUsing( + function ($record) { + return storage_path('app/public/' . app(ColorSettings::class)->logo); + } + ), + FileUpload::make('favicon') + ->label(trans('theme.favicon')) + ->image() + ->disk('public') + // ->imageResizeTargetHeight('64') + // ->imageResizeTargetWidth('64') + ->maxSize(1024) + ->getUploadedFileNameForStorageUsing( + function ($record) { + return storage_path('app/public/favicon.png'); + } + ) + ->getUploadedFileNameForStorageUsing( + function (TemporaryUploadedFile $file): string { + return (string)'favicon.png'; + } + ), + TextInput::make('fontFamily') + ->label(trans('theme.font-family')) + ->placeholder('e.g. Roboto') + ->required() + ->helperText(new HtmlString(trans('theme.font-family-helper-text'))), - ColorPicker::make('primary') - ->label(trans('theme.primary-color')) - ->default('#2563EB'), + ColorPicker::make('primary') + ->label(trans('theme.primary-color')) + ->default('#2563EB'), - ] - )->columns(), + Toggle::make('darkmode') + ->helperText('Allow darkmode on the frontend') + ] + )->columns(), ] ); } diff --git a/app/Settings/ColorSettings.php b/app/Settings/ColorSettings.php index 5d24b76f..0686b7b7 100644 --- a/app/Settings/ColorSettings.php +++ b/app/Settings/ColorSettings.php @@ -10,6 +10,7 @@ class ColorSettings extends Settings public string|null $favicon; public string|null $logo; public string|null $fontFamily; + public bool $darkmode; public static function group(): string { diff --git a/database/settings/2024_09_23_062400_add_darkmode.php b/database/settings/2024_09_23_062400_add_darkmode.php new file mode 100644 index 00000000..823d95da --- /dev/null +++ b/database/settings/2024_09_23_062400_add_darkmode.php @@ -0,0 +1,11 @@ +migrator->add('colors.darkmode', true); + } +}; diff --git a/resources/views/components/app.blade.php b/resources/views/components/app.blade.php index 35ee300c..3ae2f70d 100644 --- a/resources/views/components/app.blade.php +++ b/resources/views/components/app.blade.php @@ -67,7 +67,7 @@ function updateTheme() {
-