From e91cf1e7409621526cfcdbc8d947e71128010f99 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Fri, 23 Apr 2021 23:35:27 +0100 Subject: [PATCH] wip --- .../resources/views/components/checkbox.blade.php | 8 ++++---- .../resources/views/components/toggle.blade.php | 8 ++++---- packages/forms/src/Components/Checkbox.php | 6 ++++-- ...nAlternateLayoutDirection.php => CanBeInline.php} | 12 ++++++------ packages/forms/src/Components/Toggle.php | 6 ++++-- .../Forms/Components/Concerns/CanBeInline.php | 8 ++++++++ 6 files changed, 30 insertions(+), 18 deletions(-) rename packages/forms/src/Components/Concerns/{CanAlternateLayoutDirection.php => CanBeInline.php} (55%) create mode 100644 src/Resources/Forms/Components/Concerns/CanBeInline.php diff --git a/packages/forms/resources/views/components/checkbox.blade.php b/packages/forms/resources/views/components/checkbox.blade.php index 8d1cae2409..1a27e06dd4 100644 --- a/packages/forms/resources/views/components/checkbox.blade.php +++ b/packages/forms/resources/views/components/checkbox.blade.php @@ -7,8 +7,8 @@ :label="$formComponent->getLabel()" :required="$formComponent->isRequired()" > - @if($formComponent->isInlineLayout()) - + @if ($formComponent->isInline()) + @endif isAutofocused() ? 'autofocus' : null !!} @@ -20,7 +20,7 @@ class="rounded text-primary-600 shadow-sm focus:border-primary-700 focus:ring focus:ring-blue-200 focus:ring-opacity-50 {{ $errors->has($formComponent->getName()) ? 'border-danger-600 ' : 'border-gray-300' }}" {!! Filament\format_attributes($formComponent->getExtraAttributes()) !!} /> - @if($formComponent->isInlineLayout()) - + @if ($formComponent->isInline()) + @endif diff --git a/packages/forms/resources/views/components/toggle.blade.php b/packages/forms/resources/views/components/toggle.blade.php index 91d96e92ef..5eedbe0042 100644 --- a/packages/forms/resources/views/components/toggle.blade.php +++ b/packages/forms/resources/views/components/toggle.blade.php @@ -7,8 +7,8 @@ :label="$formComponent->getLabel()" :required="$formComponent->isRequired()" > - @if($formComponent->isInlineLayout()) - + @if ($formComponent->isInline()) + @endif - @if($formComponent->isInlineLayout()) - + @if ($formComponent->isInline()) + @endif diff --git a/packages/forms/src/Components/Checkbox.php b/packages/forms/src/Components/Checkbox.php index e53bc562ca..8b30ad1484 100644 --- a/packages/forms/src/Components/Checkbox.php +++ b/packages/forms/src/Components/Checkbox.php @@ -5,10 +5,12 @@ namespace Filament\Forms\Components; class Checkbox extends Field { use Concerns\CanBeAutofocused; - use Concerns\CanAlternateLayoutDirection; + use Concerns\CanBeInline; protected function setUp() { - $this->default(false)->inline(); + $this->default(false); + + $this->inline(); } } diff --git a/packages/forms/src/Components/Concerns/CanAlternateLayoutDirection.php b/packages/forms/src/Components/Concerns/CanBeInline.php similarity index 55% rename from packages/forms/src/Components/Concerns/CanAlternateLayoutDirection.php rename to packages/forms/src/Components/Concerns/CanBeInline.php index a6dfe74655..d8bddd91df 100644 --- a/packages/forms/src/Components/Concerns/CanAlternateLayoutDirection.php +++ b/packages/forms/src/Components/Concerns/CanBeInline.php @@ -2,14 +2,14 @@ namespace Filament\Forms\Components\Concerns; -trait CanAlternateLayoutDirection +trait CanBeInline { - protected $isInlineLayout = false; + protected $isInline = false; public function inline() { $this->configure(function () { - $this->isInlineLayout = true; + $this->isInline = true; }); return $this; @@ -18,14 +18,14 @@ trait CanAlternateLayoutDirection public function stacked() { $this->configure(function () { - $this->isInlineLayout = false; + $this->isInline = false; }); return $this; } - public function isInlineLayout(): bool + public function isInline() { - return $this->isInlineLayout; + return $this->isInline; } } diff --git a/packages/forms/src/Components/Toggle.php b/packages/forms/src/Components/Toggle.php index d488800248..9c33a3b197 100644 --- a/packages/forms/src/Components/Toggle.php +++ b/packages/forms/src/Components/Toggle.php @@ -8,7 +8,7 @@ use Filament\Forms\Components\Field; class Toggle extends Field { use Concerns\CanBeAutofocused; - use Concerns\CanAlternateLayoutDirection; + use Concerns\CanBeInline; protected $onIcon; @@ -16,7 +16,9 @@ class Toggle extends Field protected function setUp() { - $this->default(false)->inline(); + $this->default(false); + + $this->inline(); } public function onIcon($icon) diff --git a/src/Resources/Forms/Components/Concerns/CanBeInline.php b/src/Resources/Forms/Components/Concerns/CanBeInline.php new file mode 100644 index 0000000000..bdf6860ad8 --- /dev/null +++ b/src/Resources/Forms/Components/Concerns/CanBeInline.php @@ -0,0 +1,8 @@ +