-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d6fac7
commit 673cc58
Showing
5 changed files
with
96 additions
and
101 deletions.
There are no files selected for viewing
40 changes: 20 additions & 20 deletions
40
src/Traits/Styling/Configuration/ToolsStylingConfiguration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration; | ||
|
||
trait ToolsStylingConfiguration | ||
{ | ||
public function setToolsAttributes(array $toolsAttributes = []): self | ||
{ | ||
$this->setCustomAttributes(propertyName: 'toolsAttributes', customAttributes: $toolsAttributes); | ||
|
||
return $this; | ||
} | ||
|
||
public function setToolBarAttributes(array $toolBarAttributes = []): self | ||
{ | ||
$this->setCustomAttributes(propertyName: 'toolBarAttributes', customAttributes: $toolBarAttributes); | ||
|
||
return $this; | ||
} | ||
} | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration; | ||
|
||
trait ToolsStylingConfiguration | ||
{ | ||
public function setToolsAttributes(array $toolsAttributes = []): self | ||
{ | ||
$this->setCustomAttributes(propertyName: 'toolsAttributes', customAttributes: $toolsAttributes); | ||
|
||
return $this; | ||
} | ||
|
||
public function setToolBarAttributes(array $toolBarAttributes = []): self | ||
{ | ||
$this->setCustomAttributes(propertyName: 'toolBarAttributes', customAttributes: $toolBarAttributes); | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Styling; | ||
|
||
use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\ToolsStylingConfiguration; | ||
use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\ToolsStylingHelpers; | ||
|
||
trait HasToolsStyling | ||
{ | ||
use ToolsStylingConfiguration, | ||
ToolsStylingHelpers; | ||
|
||
protected array $toolsAttributes = ['default-styling' => true, 'default-colors' => true, 'class' => '']; | ||
|
||
protected array $toolBarAttributes = ['default-styling' => true, 'default-colors' => true, 'class' => '']; | ||
|
||
} | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Styling; | ||
|
||
use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\ToolsStylingConfiguration; | ||
use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\ToolsStylingHelpers; | ||
|
||
trait HasToolsStyling | ||
{ | ||
use ToolsStylingConfiguration, | ||
ToolsStylingHelpers; | ||
|
||
protected array $toolsAttributes = ['default-styling' => true, 'default-colors' => true, 'class' => '']; | ||
|
||
protected array $toolBarAttributes = ['default-styling' => true, 'default-colors' => true, 'class' => '']; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,32 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; | ||
|
||
use Livewire\Attributes\Computed; | ||
use Illuminate\View\ComponentAttributeBag; | ||
|
||
trait ToolsStylingHelpers | ||
{ | ||
|
||
protected function getToolsAttributes(): array | ||
{ | ||
return $this->getCustomAttributes(propertyName: 'toolsAttributes', default: false, classicMode: false); | ||
} | ||
|
||
#[Computed] | ||
public function getToolsAttributesBag(): ComponentAttributeBag | ||
{ | ||
return $this->getCustomAttributesBagFromArray($this->getToolsAttributes()); | ||
} | ||
|
||
protected function getToolBarAttributes(): array | ||
{ | ||
return $this->getCustomAttributes(propertyName: 'toolBarAttributes', default: false, classicMode: false); | ||
} | ||
|
||
#[Computed] | ||
public function getToolBarAttributesBag(): ComponentAttributeBag | ||
{ | ||
return $this->getCustomAttributesBagFromArray($this->getToolBarAttributes()); | ||
|
||
} | ||
} | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; | ||
|
||
use Illuminate\View\ComponentAttributeBag; | ||
use Livewire\Attributes\Computed; | ||
|
||
trait ToolsStylingHelpers | ||
{ | ||
protected function getToolsAttributes(): array | ||
{ | ||
return $this->getCustomAttributes(propertyName: 'toolsAttributes', default: false, classicMode: false); | ||
} | ||
|
||
#[Computed] | ||
public function getToolsAttributesBag(): ComponentAttributeBag | ||
{ | ||
return $this->getCustomAttributesBagFromArray($this->getToolsAttributes()); | ||
} | ||
|
||
protected function getToolBarAttributes(): array | ||
{ | ||
return $this->getCustomAttributes(propertyName: 'toolBarAttributes', default: false, classicMode: false); | ||
} | ||
|
||
#[Computed] | ||
public function getToolBarAttributesBag(): ComponentAttributeBag | ||
{ | ||
return $this->getCustomAttributesBagFromArray($this->getToolBarAttributes()); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,4 @@ trait WithTools | |
protected bool $toolsStatus = true; | ||
|
||
protected bool $toolBarStatus = true; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Tests\Traits\Helpers; | ||
|
||
use Rappasoft\LaravelLivewireTables\Tests\TestCase; | ||
|
||
final class ToolsStylingHelpersTest extends TestCase | ||
{ | ||
public function test_can_get_tools_attributes_initial_status(): void | ||
{ | ||
$this->assertTrue($this->basicTable->hasCustomAttributes('toolsAttributes')); | ||
} | ||
|
||
public function test_can_get_tools_attributes_initial_values(): void | ||
{ | ||
$this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => ''], $this->basicTable->getToolsAttributesBag()->getAttributes()); | ||
} | ||
|
||
public function test_can_get_toolbar_attributes_initial_status(): void | ||
{ | ||
$this->assertTrue($this->basicTable->hasCustomAttributes('toolBarAttributes')); | ||
} | ||
|
||
public function test_can_get_toolbar_attributes_initial_values(): void | ||
{ | ||
$this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => ''], $this->basicTable->getToolBarAttributesBag()->getAttributes()); | ||
} | ||
|
||
} | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Tests\Traits\Helpers; | ||
|
||
use Rappasoft\LaravelLivewireTables\Tests\TestCase; | ||
|
||
final class ToolsStylingHelpersTest extends TestCase | ||
{ | ||
public function test_can_get_tools_attributes_initial_status(): void | ||
{ | ||
$this->assertTrue($this->basicTable->hasCustomAttributes('toolsAttributes')); | ||
} | ||
|
||
public function test_can_get_tools_attributes_initial_values(): void | ||
{ | ||
$this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => ''], $this->basicTable->getToolsAttributesBag()->getAttributes()); | ||
} | ||
|
||
public function test_can_get_toolbar_attributes_initial_status(): void | ||
{ | ||
$this->assertTrue($this->basicTable->hasCustomAttributes('toolBarAttributes')); | ||
} | ||
|
||
public function test_can_get_toolbar_attributes_initial_values(): void | ||
{ | ||
$this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => ''], $this->basicTable->getToolBarAttributesBag()->getAttributes()); | ||
} | ||
} |