From afa72f77ec58b9fda926cff9cef21fa13e122114 Mon Sep 17 00:00:00 2001 From: coolsam726 Date: Mon, 8 Aug 2022 20:38:10 +0000 Subject: [PATCH] Fix styling --- config/filament-flatpickr.php | 2 +- src/Flatpickr.php | 28 +++++++++++++++++++++------- src/FlatpickrServiceProvider.php | 14 +++++++------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/config/filament-flatpickr.php b/config/filament-flatpickr.php index 83627c3..6ebe8ba 100644 --- a/config/filament-flatpickr.php +++ b/config/filament-flatpickr.php @@ -2,5 +2,5 @@ // config for Savannabits/Flatpickr return [ - 'default_theme' => 'airbnb' // 'default','dark','material_blue','material_green','material_red','material_orange','airbnb','confetti' + 'default_theme' => 'airbnb', // 'default','dark','material_blue','material_green','material_red','material_orange','airbnb','confetti' ]; diff --git a/src/Flatpickr.php b/src/Flatpickr.php index 0eed817..74bdce7 100755 --- a/src/Flatpickr.php +++ b/src/Flatpickr.php @@ -7,28 +7,35 @@ class Flatpickr extends Field { protected string $view = 'filament-flatpickr::flatpickr'; + protected bool $monthPicker = false; + protected bool $altInput = true; + protected ?string $altFormat = 'F j, Y'; + protected bool $enableTime = false; + protected ?string $dateFormat = 'Y-m-d'; + protected ?string $theme; protected function setUp(): void { parent::setUp(); - $theme = config('filament-flatpickr.default_theme','default'); + $theme = config('filament-flatpickr.default_theme', 'default'); $this->theme($theme); $this->reactive(); } /** - * @param bool $monthPicker + * @param bool $monthPicker * @return Flatpickr */ public function monthPicker(?bool $monthPicker = true): Flatpickr { $this->monthPicker = $monthPicker; + return $this; } @@ -41,12 +48,13 @@ public function isMonthPicker(): bool } /** - * @param bool $altInput + * @param bool $altInput * @return Flatpickr */ public function altInput(bool $altInput = true): Flatpickr { $this->altInput = $altInput; + return $this; } @@ -59,7 +67,7 @@ public function isAltInput(): bool } /** - * @param bool $enableTime + * @param bool $enableTime * @return Flatpickr */ public function enableTime(bool $enableTime = true): Flatpickr @@ -70,6 +78,7 @@ public function enableTime(bool $enableTime = true): Flatpickr $this->altInput(false); $this->altFormat('Z'); } + return $this; } @@ -82,12 +91,13 @@ public function isEnableTime(): bool } /** - * @param string $dateFormat + * @param string $dateFormat * @return Flatpickr */ public function dateFormat(string $dateFormat): Flatpickr { $this->dateFormat = $dateFormat; + return $this; } @@ -100,12 +110,13 @@ public function getDateFormat(): ?string } /** - * @param string $altFormat + * @param string $altFormat * @return Flatpickr */ public function altFormat(string $altFormat): Flatpickr { $this->altFormat = $altFormat; + return $this; } @@ -118,14 +129,17 @@ public function getAltFormat(): ?string } /** - * @param string $theme + * @param string $theme * @description Possible values: 'default','dark','material_blue','material_green','material_red','material_orange','airbnb','confetti' + * * @see https://flatpickr.js.org/themes/ + * * @return Flatpickr */ public function theme(string $theme): Flatpickr { $this->theme = $theme; + return $this; } diff --git a/src/FlatpickrServiceProvider.php b/src/FlatpickrServiceProvider.php index 0958572..337c001 100644 --- a/src/FlatpickrServiceProvider.php +++ b/src/FlatpickrServiceProvider.php @@ -2,24 +2,23 @@ namespace Savannabits\Flatpickr; -use Filament\FilamentServiceProvider; use Filament\PluginServiceProvider; -use Illuminate\Foundation\Vite; use Spatie\LaravelPackageTools\Package; -use Savannabits\Flatpickr\Commands\FlatpickrCommand; class FlatpickrServiceProvider extends PluginServiceProvider { protected array $styles = [ - 'flatpickr-css' => __DIR__.'/../public/dist/flatpickr.min.css', - 'monthselect-style' =>__DIR__.'/../public/dist/plugins/monthSelect/style.css', + 'flatpickr-css' => __DIR__.'/../public/dist/flatpickr.min.css', + 'monthselect-style' => __DIR__.'/../public/dist/plugins/monthSelect/style.css', ]; + protected array $beforeCoreScripts = [ - 'flatpickr-js' => __DIR__.'/../public/dist/flatpickr.min.js', + 'flatpickr-js' => __DIR__.'/../public/dist/flatpickr.min.js', ]; + protected array $scripts = [ 'range-plugin' => __DIR__.'/../public/dist/plugins/rangePlugin.js', - 'month-select' => __DIR__.'/../public/dist/plugins/monthSelect/index.js' + 'month-select' => __DIR__.'/../public/dist/plugins/monthSelect/index.js', ]; public function configurePackage(Package $package): void @@ -34,6 +33,7 @@ public function configurePackage(Package $package): void ->hasConfigFile() ->hasViews(); } + protected function getScriptData(): array { return [];