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 2, 2023
1 parent 0ba4588 commit efd84af
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 41 deletions.
2 changes: 1 addition & 1 deletion config/coolsam-flatpickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
use Coolsam\FilamentFlatpickr\Enums\FlatpickrTheme;

return [
'default_theme' => FlatpickrTheme::DEFAULT
'default_theme' => FlatpickrTheme::DEFAULT,
];
13 changes: 8 additions & 5 deletions src/Enums/FlatpickrMode.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php

namespace Coolsam\FilamentFlatpickr\Enums;
enum FlatpickrMode: string {
case RANGE = 'range';
case SINGLE = 'single';
case MULTIPLE = 'multiple';
case TIME = 'time';

enum FlatpickrMode: string
{
case RANGE = 'range';
case SINGLE = 'single';
case MULTIPLE = 'multiple';
case TIME = 'time';
}
5 changes: 4 additions & 1 deletion src/Enums/FlatpickrMonthSelectorType.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace Coolsam\FilamentFlatpickr\Enums;
enum FlatpickrMonthSelectorType: string {

enum FlatpickrMonthSelectorType: string
{
case DROPDOWN = 'dropdown';
case STATIK = 'static';
}
26 changes: 14 additions & 12 deletions src/Enums/FlatpickrPosition.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php

namespace Coolsam\FilamentFlatpickr\Enums;

enum FlatpickrPosition: string
{
case AUTO = "auto";
case ABOVE = "above";
case BELOW = "below";
case AUTO_LEFT = "auto left";
case AUTO_CENTER = "auto center";
case AUTO_RIGHT = "auto right";
case ABOVE_LEFT = "above left";
case ABOVE_CENTER = "above center";
case ABOVE_RIGHT = "above right";
case BELOW_LEFT = "below left";
case BELOW_CENTER = "below center";
case BELOW_RIGHT = "below right";
case AUTO = 'auto';
case ABOVE = 'above';
case BELOW = 'below';
case AUTO_LEFT = 'auto left';
case AUTO_CENTER = 'auto center';
case AUTO_RIGHT = 'auto right';
case ABOVE_LEFT = 'above left';
case ABOVE_CENTER = 'above center';
case ABOVE_RIGHT = 'above right';
case BELOW_LEFT = 'below left';
case BELOW_CENTER = 'below center';
case BELOW_RIGHT = 'below right';
}
5 changes: 4 additions & 1 deletion src/Enums/FlatpickrTheme.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace Coolsam\FilamentFlatpickr\Enums;
enum FlatpickrTheme: string {

enum FlatpickrTheme: string
{
case DEFAULT = 'default';
case DARK = 'dark';
case LIGHT = 'light';
Expand Down
34 changes: 17 additions & 17 deletions src/FilamentFlatpickrServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ public function configurePackage(Package $package): void
public function packageBooted()
{
FilamentAsset::register([
Js::make('flatpickr-range-plugin', __DIR__ . '/../resources/assets/flatpickr/dist/plugins/rangePlugin.js'),
Js::make('flatpickr-confirm-date', __DIR__ . '/../resources/assets/flatpickr/dist/plugins/confirmDate/confirmDate.js'),
Js::make('flatpickr-month-select-plugin', __DIR__ . '/../resources/assets/flatpickr/dist/plugins/monthSelect/index.js')->loadedOnRequest(),
Js::make('flatpickr-week-select-plugin', __DIR__ . '/../resources/assets/flatpickr/dist/plugins/weekSelect/weekSelect.js')->loadedOnRequest(),
Css::make('flatpickr-css', __DIR__ . '/../resources/assets/flatpickr/dist/flatpickr.css')->loadedOnRequest(),
Css::make('month-select-style', __DIR__ . '/../resources/assets/flatpickr/dist/plugins/monthSelect/style.css')->loadedOnRequest(),
Css::make('flatpickr-confirm-date-style', __DIR__ . '/../resources/assets/flatpickr/dist/plugins/confirmDate/confirmDate.css')->loadedOnRequest(),
Css::make('flatpickr-airbnb-theme', __DIR__ . '/../resources/assets/flatpickr/dist/themes/airbnb.css')->loadedOnRequest(),
Css::make('flatpickr-confetti-theme', __DIR__ . '/../resources/assets/flatpickr/dist/themes/confetti.css')->loadedOnRequest(),
Css::make('flatpickr-dark-theme', __DIR__ . '/../resources/assets/flatpickr/dist/themes/dark.css')->loadedOnRequest(),
Css::make('flatpickr-light-theme', __DIR__ . '/../resources/assets/flatpickr/dist/themes/light.css')->loadedOnRequest(),
Css::make('flatpickr-default-theme', __DIR__ . '/../resources/assets/flatpickr/dist/themes/light.css')->loadedOnRequest(),
Css::make('flatpickr-material_blue-theme', __DIR__ . '/../resources/assets/flatpickr/dist/themes/material_blue.css')->loadedOnRequest(),
Css::make('flatpickr-material_green-theme', __DIR__ . '/../resources/assets/flatpickr/dist/themes/material_green.css')->loadedOnRequest(),
Css::make('flatpickr-material_red-theme', __DIR__ . '/../resources/assets/flatpickr/dist/themes/material_red.css')->loadedOnRequest(),
Css::make('flatpickr-material_orange-theme', __DIR__ . '/../resources/assets/flatpickr/dist/themes/material_orange.css')->loadedOnRequest(),
AlpineComponent::make('flatpickr-component', __DIR__ . '/../resources/js/dist/components/flatpickr-component.js')->loadedOnRequest(),
Js::make('flatpickr-range-plugin', __DIR__.'/../resources/assets/flatpickr/dist/plugins/rangePlugin.js'),
Js::make('flatpickr-confirm-date', __DIR__.'/../resources/assets/flatpickr/dist/plugins/confirmDate/confirmDate.js'),
Js::make('flatpickr-month-select-plugin', __DIR__.'/../resources/assets/flatpickr/dist/plugins/monthSelect/index.js')->loadedOnRequest(),
Js::make('flatpickr-week-select-plugin', __DIR__.'/../resources/assets/flatpickr/dist/plugins/weekSelect/weekSelect.js')->loadedOnRequest(),
Css::make('flatpickr-css', __DIR__.'/../resources/assets/flatpickr/dist/flatpickr.css')->loadedOnRequest(),
Css::make('month-select-style', __DIR__.'/../resources/assets/flatpickr/dist/plugins/monthSelect/style.css')->loadedOnRequest(),
Css::make('flatpickr-confirm-date-style', __DIR__.'/../resources/assets/flatpickr/dist/plugins/confirmDate/confirmDate.css')->loadedOnRequest(),
Css::make('flatpickr-airbnb-theme', __DIR__.'/../resources/assets/flatpickr/dist/themes/airbnb.css')->loadedOnRequest(),
Css::make('flatpickr-confetti-theme', __DIR__.'/../resources/assets/flatpickr/dist/themes/confetti.css')->loadedOnRequest(),
Css::make('flatpickr-dark-theme', __DIR__.'/../resources/assets/flatpickr/dist/themes/dark.css')->loadedOnRequest(),
Css::make('flatpickr-light-theme', __DIR__.'/../resources/assets/flatpickr/dist/themes/light.css')->loadedOnRequest(),
Css::make('flatpickr-default-theme', __DIR__.'/../resources/assets/flatpickr/dist/themes/light.css')->loadedOnRequest(),
Css::make('flatpickr-material_blue-theme', __DIR__.'/../resources/assets/flatpickr/dist/themes/material_blue.css')->loadedOnRequest(),
Css::make('flatpickr-material_green-theme', __DIR__.'/../resources/assets/flatpickr/dist/themes/material_green.css')->loadedOnRequest(),
Css::make('flatpickr-material_red-theme', __DIR__.'/../resources/assets/flatpickr/dist/themes/material_red.css')->loadedOnRequest(),
Css::make('flatpickr-material_orange-theme', __DIR__.'/../resources/assets/flatpickr/dist/themes/material_orange.css')->loadedOnRequest(),
AlpineComponent::make('flatpickr-component', __DIR__.'/../resources/js/dist/components/flatpickr-component.js')->loadedOnRequest(),
], package: FilamentFlatpickr::getPackageName());
}
}
10 changes: 6 additions & 4 deletions src/Forms/Components/Flatpickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
use Coolsam\FilamentFlatpickr\Enums\FlatpickrMonthSelectorType;
use Coolsam\FilamentFlatpickr\Enums\FlatpickrPosition;
use Coolsam\FilamentFlatpickr\Enums\FlatpickrTheme;
use Filament\Forms\Components\Field;
use Filament\Support\Concerns\HasExtraAlpineAttributes;
use Filament\Forms\Components\Concerns;
use Filament\Forms\Components\Contracts;
use Filament\Support\Facades\FilamentAsset;
use Filament\Forms\Components\Field;
use Filament\Support\Concerns\HasExtraAlpineAttributes;

class Flatpickr extends Field implements Contracts\CanBeLengthConstrained, Contracts\HasAffixActions
{
Expand All @@ -25,7 +24,9 @@ class Flatpickr extends Field implements Contracts\CanBeLengthConstrained, Contr
use Concerns\HasInputMode;
use Concerns\HasPlaceholder;
use HasExtraAlpineAttributes;

const PACKAGE_NAME = 'coolsam/flatpickr';

protected string $view = 'coolsam-flatpickr::forms.components.flatpickr';

protected bool $monthSelect = false;
Expand Down Expand Up @@ -236,7 +237,7 @@ protected function setUp(): void
</svg>
'
);
$this->theme(config('coolsam-flatpickr.default_theme',FlatpickrTheme::DEFAULT));
$this->theme(config('coolsam-flatpickr.default_theme', FlatpickrTheme::DEFAULT));
$this->dehydrateStateUsing(static function (Flatpickr $component, $state) {
return self::dehydratePickerState($component, $state);
});
Expand Down Expand Up @@ -800,6 +801,7 @@ public function getThemeAsset(): string
if ($this->getTheme() === FlatpickrTheme::DEFAULT->value) {
$this->theme(FlatpickrTheme::LIGHT);
}

return asset('css/'.static::PACKAGE_NAME.'/flatpickr-'.$this->getTheme().'-theme.css');
}

Expand Down

0 comments on commit efd84af

Please sign in to comment.