Refactor trait name and methods

This commit is contained in:
Dan Pock
2021-04-20 15:29:43 -04:00
parent 00f31c98bb
commit 80c67f0474
6 changed files with 37 additions and 28 deletions
@@ -7,7 +7,7 @@
:label="$formComponent->getLabel()"
:required="$formComponent->isRequired()"
>
@if(!$formComponent->isColumnLayout())
@if($formComponent->isInlineLayout())
<x-slot name="labelPrefix">
@endif
<input
@@ -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->isColumnLayout())
@if($formComponent->isInlineLayout())
</x-slot>
@endif
</x-forms::field-group>
@@ -7,7 +7,7 @@
:label="$formComponent->getLabel()"
:required="$formComponent->isRequired()"
>
@if(!$formComponent->isColumnLayout())
@if($formComponent->isInlineLayout())
<x-slot name="labelPrefix">
@endif
<button
@@ -61,7 +61,7 @@
</span>
</span>
</button>
@if(!$formComponent->isColumnLayout())
@if($formComponent->isInlineLayout())
</x-slot>
@endif
</x-forms::field-group>
+1 -1
View File
@@ -5,7 +5,7 @@ namespace Filament\Forms\Components;
class Checkbox extends Field
{
use Concerns\CanBeAutofocused;
use Concerns\CanAlternateToColumnLayout;
use Concerns\CanAlternateLayoutDirection;
protected function setUp()
{
@@ -0,0 +1,31 @@
<?php
namespace Filament\Forms\Components\Concerns;
trait CanAlternateLayoutDirection
{
protected $inlineLayout = true;
public function inlinelLayout()
{
$this->configure(function () {
$this->inlineLayout = true;
});
return $this;
}
public function stackedLayout()
{
$this->configure(function () {
$this->inlineLayout = false;
});
return $this;
}
public function isInlineLayout()
{
return $this->inlineLayout;
}
}
@@ -1,22 +0,0 @@
<?php
namespace Filament\Forms\Components\Concerns;
trait CanAlternateToColumnLayout
{
protected $columnLayout = false;
public function columnLayout()
{
$this->configure(function () {
$this->columnLayout = true;
});
return $this;
}
public function isColumnLayout()
{
return $this->columnLayout;
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ use Filament\Forms\Components\Field;
class Toggle extends Field
{
use Concerns\CanBeAutofocused;
use Concerns\CanAlternateToColumnLayout;
use Concerns\CanAlternateLayoutDirection;
protected $onIcon;