Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsam726 authored and github-actions[bot] committed Aug 8, 2022
1 parent 18065f4 commit afa72f7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion config/filament-flatpickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
];
28 changes: 21 additions & 7 deletions src/Flatpickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -59,7 +67,7 @@ public function isAltInput(): bool
}

/**
* @param bool $enableTime
* @param bool $enableTime
* @return Flatpickr
*/
public function enableTime(bool $enableTime = true): Flatpickr
Expand All @@ -70,6 +78,7 @@ public function enableTime(bool $enableTime = true): Flatpickr
$this->altInput(false);
$this->altFormat('Z');
}

return $this;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down
14 changes: 7 additions & 7 deletions src/FlatpickrServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,6 +33,7 @@ public function configurePackage(Package $package): void
->hasConfigFile()
->hasViews();
}

protected function getScriptData(): array
{
return [];
Expand Down

0 comments on commit afa72f7

Please sign in to comment.