Skip to content

Commit

Permalink
Add has methods
Browse files Browse the repository at this point in the history
  • Loading branch information
francoism90 committed May 29, 2024
1 parent f1c806e commit 9054746
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 5 deletions.
11 changes: 7 additions & 4 deletions resources/views/actions/button.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'layer' => 'flex shrink-0 cursor-pointer items-center justify-center',
'label' => 'text-sm',
'primary' => 'py-1.5 px-3 bg-primary-500 rounded border border-primary-500',
'icon' => 'size-6 text-secondary-400',
])
->mergeAttributes($action->getComponentAttributes())
->classMerge([
Expand All @@ -17,12 +18,14 @@
@if ($slot->isEmpty())
<x-wireuse::actions-icon
:$action
class:icon="size-6 text-secondary-400"
class:icon="{{ $attributes->classFor('icon') }}"
/>

<span class="{{ $attributes->classFor('label') }}">
{{ $label() }}
</span>
@if ($action->hasLabel())
<span class="{{ $attributes->classFor('label') }}">
{{ $label() }}
</span>
@endif
@else
{{ $slot }}
@endif
Expand Down
2 changes: 1 addition & 1 deletion resources/views/actions/icon.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'layer',
])
}}>
@if ($iconName() && filled($action->getState()))
@if ($iconName() && $action->hasState())
<x-icon
x-cloak
x-show="! {{ $action->getState() }}"
Expand Down
5 changes: 5 additions & 0 deletions src/Support/Components/Concerns/HasComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public function getComponent(): ?string
return $this->value('component');
}

public function hasComponent(): bool
{
return $this->offsetExists('component');
}

public function getComponentAttributes(): array
{
return $this->value('componentAttributes', []);
Expand Down
10 changes: 10 additions & 0 deletions src/Support/Components/Concerns/HasIcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,18 @@ public function getIcon(): ?string
return $this->value('icon');
}

public function hasIcon(): bool
{
return $this->offsetExists('icon');
}

public function getActiveIcon(): ?string
{
return $this->value('iconActive', $this->getIcon());
}

public function hasActiveIcon(): bool
{
return $this->offsetExists('iconActive');
}
}
5 changes: 5 additions & 0 deletions src/Support/Components/Concerns/HasLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ public function getLabel(): ?string
{
return $this->value('label');
}

public function hasLabel(): bool
{
return $this->offsetExists('label');
}
}
5 changes: 5 additions & 0 deletions src/Support/Components/Concerns/HasLivewire.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public function getWireModel(): ?string
return $this->value('wireModel');
}

public function hasWireModel(): bool
{
return $this->offsetExists('wireModel');
}

public function getWireModifier(): ?string
{
return $this->value('wireModifier');
Expand Down
5 changes: 5 additions & 0 deletions src/Support/Components/Concerns/HasName.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ public function getName(): ?string
{
return $this->value('name');
}

public function hasName(): bool
{
return $this->offsetExists('name');
}
}
5 changes: 5 additions & 0 deletions src/Support/Components/Concerns/HasRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public function getUrl(): ?string
return $this->value('url');
}

public function hasUrl(): bool
{
return $this->offsetExists('url');
}

public function isAppUrl(): bool
{
$url = str($this->value('url', ''))->trim();
Expand Down
5 changes: 5 additions & 0 deletions src/Support/Components/Concerns/HasRouting.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public function getRoute(): ?string
);
}

public function hasRoute(): bool
{
return $this->offsetExists('route');
}

public function getRouteName(): ?string
{
return $this->value('route');
Expand Down
5 changes: 5 additions & 0 deletions src/Support/Components/Concerns/HasState.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public function getState(): mixed
return $this->value('state');
}

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

public function getDefault(): mixed
{
return $this->value('default');
Expand Down
5 changes: 5 additions & 0 deletions src/Support/Components/Concerns/HasVisibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public function getVisible(): ?bool
return $this->value('visible');
}

public function hasVisible(): bool
{
return $this->offsetExists('visible');
}

public function getHidden(): ?bool
{
return $this->value('hidden');
Expand Down

0 comments on commit 9054746

Please sign in to comment.