Skip to content

Commit 2e5b51c

Browse files
authored
Initial Commit
1 parent a7b1579 commit 2e5b51c

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

src/Traits/Configuration/ToolsConfiguration.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,19 @@ public function setToolBarDisabled(): self
3737
{
3838
return $this->setToolBarStatus(false);
3939
}
40+
41+
public function setToolsAttributes(array $toolsAttributes = []): self
42+
{
43+
$this->setCustomAttributes(propertyName: 'toolsAttributes', customAttributes: $toolsAttributes);
44+
45+
return $this;
46+
}
47+
48+
public function setToolBarAttributes(array $toolBarAttributes = []): self
49+
{
50+
$this->setCustomAttributes(propertyName: 'toolBarAttributes', customAttributes: $toolBarAttributes);
51+
52+
return $this;
53+
}
54+
4055
}

src/Traits/Core/HasCustomAttributes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public function getCustomAttributesBag(string $propertyName): ComponentAttribute
4040
return new ComponentAttributeBag($this->getCustomAttributes($propertyName));
4141
}
4242

43+
public function getCustomAttributesBagFromArray(array $attributesArray): ComponentAttributeBag
44+
{
45+
return new ComponentAttributeBag($attributesArray);
46+
}
47+
4348
public function setCustomAttributes(string $propertyName, array $customAttributes): self
4449
{
4550
$this->{$propertyName} = $customAttributes;

src/Traits/Helpers/ToolsHelpers.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Rappasoft\LaravelLivewireTables\Traits\Helpers;
44

55
use Livewire\Attributes\Computed;
6+
use Illuminate\View\ComponentAttributeBag;
67

78
trait ToolsHelpers
89
{
@@ -105,4 +106,27 @@ protected function hasToolbarActions(): bool
105106
{
106107
return $this->hasActions() && $this->showActionsInToolbar();
107108
}
109+
110+
public function getToolsAttributes(): array
111+
{
112+
return $this->getCustomAttributes(propertyName: 'toolsAttributes', default: false, classicMode: false);
113+
}
114+
115+
public function getToolsAttributesBag(string $propertyName): ComponentAttributeBag
116+
{
117+
return $this->getCustomAttributesBagFromArray($this->getToolsAttributes());
118+
}
119+
120+
public function getToolBarAttributes(): array
121+
{
122+
return $this->getCustomAttributes(propertyName: 'toolBarAttributes', default: false, classicMode: false);
123+
}
124+
125+
public function getToolBarAttributesBag(string $propertyName): ComponentAttributeBag
126+
{
127+
return $this->getCustomAttributesBagFromArray($this->getToolBarAttributes());
128+
129+
}
130+
131+
108132
}

src/Traits/WithTools.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@ trait WithTools
1313
protected bool $toolsStatus = true;
1414

1515
protected bool $toolBarStatus = true;
16+
17+
protected array $toolsAttributes = ['default-styling' => true, 'default-colors' => true, 'class' => ''];
18+
19+
protected array $toolBarAttributes = ['default-styling' => true, 'default-colors' => true, 'class' => ''];
20+
1621
}

0 commit comments

Comments
 (0)