Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
francoism90 committed Apr 27, 2024
1 parent 72cb588 commit 0a17a67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
6 changes: 3 additions & 3 deletions resources/views/actions/icon.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
])

<div class="inline-flex">
@if ($action->hasIcon() && $action->hasActiveState())
@if ($action->hasIcon() && $action->hasState())
<div x-data x-cloak>
<x-icon
x-show="! {{ $action->getActive() }}"
x-show="! {{ $action->getState() }}"
:name="$action->getIcon()"
{{ $attributes->class('size-5') }}
/>

<x-icon
x-show="{{ $action->getActive() }}"
x-show="{{ $action->getState() }}"
:name="$action->getIconActive()"
{{ $attributes->class('size-5') }}
/>
Expand Down
24 changes: 17 additions & 7 deletions src/Actions/Concerns/HasState.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,37 @@

trait HasState
{
public function state(string|null $state = null): static
{
$this->state = $state;

return $this;
}

public function active(bool|string|null $active = null): static
{
$this->active = $active;

return $this;
}

public function getActive(): mixed
public function getState(): ?string
{
return $this->value('active');
return $this->value('state');
}

public function hasActive(): mixed
public function hasState(): bool
{
return $this->offsetExists('active');
return $this->offsetExists('state');
}

public function hasActiveState(): bool
public function getActive(): mixed
{
$active = $this->getActive();
return $this->value('active');
}

return is_string($active) && str($active)->startsWith('$wire');
public function hasActive(): mixed
{
return $this->offsetExists('active');
}
}

0 comments on commit 0a17a67

Please sign in to comment.