-
-
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
Showing
7 changed files
with
122 additions
and
15 deletions.
There are no files selected for viewing
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,8 +1,12 @@ | ||
@aware(['component','isTailwind','isBootstrap']) | ||
@php($toolsAttributes = $this->getToolsAttributesBag()) | ||
|
||
<div @class([ | ||
'flex-col' => $isTailwind, | ||
'd-flex flex-column ' => ($isBootstrap), | ||
])> | ||
<div {{ | ||
$toolsAttributes->merge() | ||
->class(['flex-col' => $isTailwind && ($toolsAttributes['default-styling'] ?? true)]) | ||
->class(['d-flex flex-column' => $isBootstrap && ($toolsAttributes['default-styling'] ?? true)]) | ||
->except(['default','default-styling','default-colors']) | ||
}} | ||
> | ||
{{ $slot }} | ||
</div> |
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
20 changes: 20 additions & 0 deletions
20
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 |
---|---|---|
@@ -0,0 +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; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?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()); | ||
|
||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?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()); | ||
} | ||
|
||
} |