Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe authored and github-actions[bot] committed Sep 29, 2024
1 parent 7d6fac7 commit 673cc58
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 101 deletions.
40 changes: 20 additions & 20 deletions src/Traits/Styling/Configuration/ToolsStylingConfiguration.php
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;
}
}
33 changes: 16 additions & 17 deletions src/Traits/Styling/HasToolsStyling.php
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' => ''];
}
65 changes: 32 additions & 33 deletions src/Traits/Styling/Helpers/ToolsStylingHelpers.php
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());

}
}
2 changes: 0 additions & 2 deletions src/Traits/WithTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ trait WithTools
protected bool $toolsStatus = true;

protected bool $toolBarStatus = true;


}
57 changes: 28 additions & 29 deletions tests/Traits/Helpers/ToolsStylingHelpersTest.php
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());
}
}

0 comments on commit 673cc58

Please sign in to comment.