Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinosswald authored and github-actions[bot] committed Jan 26, 2024
1 parent adf5c06 commit 9bda47f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/FilamentInputSelectAffixServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class FilamentInputSelectAffixServiceProvider extends PackageServiceProvider
public function configurePackage(Package $package): void
{
$package->name(static::$name)
->hasViews();
->hasViews();
}
}
24 changes: 14 additions & 10 deletions src/TextInputSelectAffix.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,31 @@
class TextInputSelectAffix extends TextInput
{
use HasComponents;

protected string $view = 'filament-input-select-affix::text-input-select-affix';

protected ?\Closure $selectComponentClosure = null;

protected ?Select $selectComponent = null;

protected string $position = 'suffix';

public function select(\Closure | Select $closure): TextInputSelectAffix
public function select(\Closure|Select $closure): TextInputSelectAffix
{
if ($closure instanceof Select) {
$this->selectComponentClosure = fn() => $closure;
$this->selectComponentClosure = fn () => $closure;

return $this;
}
$this->selectComponentClosure = $closure;

return $this;
}

public function position(string $position = 'suffix'): TextInputSelectAffix
{
$this->position = $position;

return $this;
}

Expand Down Expand Up @@ -59,7 +64,7 @@ public function dehydrateValidationRules(array &$rules): void
}
}

public function getPosition():string
public function getPosition(): string
{
return $this->position;
}
Expand All @@ -68,20 +73,19 @@ public function getSelectComponent(): ComponentContainer
{
$evaluated = $this->evaluate($this->selectComponentClosure);

if (!$evaluated instanceof Select) {
throw new \RuntimeException("Passed component must be of type Select");
if (! $evaluated instanceof Select) {
throw new \RuntimeException('Passed component must be of type Select');
}

$this->selectComponent = $evaluated->hiddenLabel()
->extraAttributes(array_merge($evaluated->getExtraAttributes(),[
'style' => "border: none !important; background: transparent;--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);",
->extraAttributes(array_merge($evaluated->getExtraAttributes(), [
'style' => 'border: none !important; background: transparent;--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);',
]));
$path = explode(".", $this->getStatePath());
$path = explode('.', $this->getStatePath());
unset($path[count($path) - 1]);

return ComponentContainer::make($this->getLivewire())
->statePath( implode(".", $path))
->statePath(implode('.', $path))
->components([$this->selectComponent]);
}

}
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Filament\FilamentServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use Livewire\LivewireServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;
use Marvinosswald\FilamentInputSelectAffix\FilamentInputSelectAffixServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;

class TestCase extends Orchestra
{
Expand All @@ -15,7 +15,7 @@ protected function setUp(): void
parent::setUp();

Factory::guessFactoryNamesUsing(
fn (string $modelName) => 'Marvinosswald\\FilamentInputSelectAffix\\Database\\Factories\\' . class_basename($modelName) . 'Factory'
fn (string $modelName) => 'Marvinosswald\\FilamentInputSelectAffix\\Database\\Factories\\'.class_basename($modelName).'Factory'
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TextInputSelectAffix.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$field = (new TextInputSelectAffix($name = Str::random()))
->container(ComponentContainer::make(Livewire::make()));

$field->select(Select::make("select"));
$field->select(Select::make('select'));

expect($field)
->hasSelect()->toBeTrue();
Expand Down

0 comments on commit 9bda47f

Please sign in to comment.