From 536fa6c917d63b14feeb8f876e6a1d62acb577fc Mon Sep 17 00:00:00 2001 From: Sam Light Date: Thu, 12 Feb 2026 00:23:02 +0000 Subject: Created new dropdown toolbar item --- src/Toolbar/Button.php | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) (limited to 'src/Toolbar/Button.php') diff --git a/src/Toolbar/Button.php b/src/Toolbar/Button.php index 92b041f..1ac686a 100644 --- a/src/Toolbar/Button.php +++ b/src/Toolbar/Button.php @@ -4,38 +4,16 @@ declare(strict_types=1); namespace Lightscale\LaralightTables\Toolbar; -use Illuminate\View\ComponentAttributeBag; use Illuminate\View\View; -use Lightscale\LaralightTables\Concerns\WithAttributes; +use Lightscale\LaralightTables\Toolbar\Concerns\WithAction; +use Lightscale\LaralightTables\Toolbar\Concerns\WithAttributes; +use Lightscale\LaralightTables\Toolbar\Concerns\WithSlot; class Button extends Item { + use WithAction; use WithAttributes; - - private ?string $action = null; - - private string $slot = ''; - - public function action(string $action): static - { - $this->action = $action; - - return $this; - } - - public function slot(string $slot): static - { - $this->slot = $slot; - - return $this; - } - - private function makeAttributes(): ComponentAttributeBag - { - return $this->getAttributes()->merge([ - 'wire:click' => $this->action, - ]); - } + use WithSlot; public function render(): View { @@ -43,7 +21,9 @@ class Button extends Item 'laralight-tables::toolbar.button', [ 'action' => $this->action, - 'attributes' => $this->makeAttributes(), + 'attributes' => $this->getAttributes([ + 'wire:click' => $this->action, + ]), 'slot' => $this->slot, ] ); -- cgit v1.2.3