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 daad6b5 commit abef879
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 22 deletions.
41 changes: 30 additions & 11 deletions src/Flatpickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,33 @@
class Flatpickr extends Field
{
protected string $view = 'filament-flatpickr::flatpickr';

protected bool $monthSelect = false;

protected bool $weekSelect = false;

protected bool $rangePicker = false;

protected bool $multiplePicker = 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 ?string $theme;

/**
* @param bool $weekSelect
* @param bool $weekSelect
* @return Flatpickr
*/
public function weekSelect(bool $weekSelect = true): Flatpickr
{
$this->weekSelect = $weekSelect;

return $this;
}

Expand All @@ -37,12 +46,13 @@ public function isWeekSelect(): bool
}

/**
* @param bool $rangePicker
* @param bool $rangePicker
* @return Flatpickr
*/
public function rangePicker(bool $rangePicker = true): Flatpickr
{
$this->rangePicker = $rangePicker;

return $this;
}

Expand All @@ -55,12 +65,13 @@ public function isRangePicker(): bool
}

/**
* @param bool $multiplePicker
* @param bool $multiplePicker
* @return Flatpickr
*/
public function multiplePicker(bool $multiplePicker = true): Flatpickr
{
$this->multiplePicker = $multiplePicker;

return $this;
}

Expand All @@ -75,18 +86,19 @@ public function isMultiplePicker(): bool
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 $monthSelect
* @param bool $monthSelect
* @return Flatpickr
*/
public function monthSelect(?bool $monthSelect = true): Flatpickr
{
$this->monthSelect = $monthSelect;

return $this;
}

Expand All @@ -99,12 +111,13 @@ public function isMonthSelect(): bool
}

/**
* @param bool $altInput
* @param bool $altInput
* @return Flatpickr
*/
public function altInput(bool $altInput = true): Flatpickr
{
$this->altInput = $altInput;

return $this;
}

Expand All @@ -117,7 +130,7 @@ public function isAltInput(): bool
}

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

return $this;
}

Expand All @@ -140,12 +154,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 @@ -158,12 +173,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 @@ -176,14 +192,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
21 changes: 10 additions & 11 deletions src/FlatpickrServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +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',
'month-select-style' =>__DIR__.'/../public/dist/plugins/monthSelect/style.css',
'confirm-date-style' =>__DIR__.'/../public/dist/plugins/confirmDate/confirmDate.css',
'flatpickr-css' => __DIR__.'/../public/dist/flatpickr.min.css',
'month-select-style' => __DIR__.'/../public/dist/plugins/monthSelect/style.css',
'confirm-date-style' => __DIR__.'/../public/dist/plugins/confirmDate/confirmDate.css',
];

protected array $beforeCoreScripts = [
'flatpickr-core' => __DIR__.'/../public/dist/flatpickr.min.js',
'flatpickr-range-plugin' => __DIR__.'/../public/dist/plugins/rangePlugin.js',
'flatpickr-month-select' => __DIR__.'/../public/dist/plugins/monthSelect/index.js',
'flatpickr-week-select' => __DIR__.'/../public/dist/plugins/weekSelect/weekSelect.js',
'flatpickr-confirm-date' => __DIR__.'/../public/dist/plugins/confirmDate/confirmDate.js',
'flatpickr-core' => __DIR__.'/../public/dist/flatpickr.min.js',
'flatpickr-range-plugin' => __DIR__.'/../public/dist/plugins/rangePlugin.js',
'flatpickr-month-select' => __DIR__.'/../public/dist/plugins/monthSelect/index.js',
'flatpickr-week-select' => __DIR__.'/../public/dist/plugins/weekSelect/weekSelect.js',
'flatpickr-confirm-date' => __DIR__.'/../public/dist/plugins/confirmDate/confirmDate.js',
];

protected array $scripts = [
Expand All @@ -38,6 +36,7 @@ public function configurePackage(Package $package): void
->hasConfigFile()
->hasViews();
}

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

0 comments on commit abef879

Please sign in to comment.