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 Dec 8, 2024
1 parent 7b0d75c commit a1ee4e9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public function setFilterSlidedownWrapperAttributes(array $filterSlidedownWrappe
return $this;
}


/**
* Set a list of attributes to override on the th sort button elements
*/
Expand Down
1 change: 0 additions & 1 deletion src/Traits/Styling/HasFilterMenuStyling.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ trait HasFilterMenuStyling
protected array $filterSlidedownWrapperAttributes = ['class' => '', 'default-colors' => true, 'default-styling' => true];

protected ?\Closure $filterSlidedownRowCallback;

}
6 changes: 2 additions & 4 deletions src/Traits/Styling/Helpers/FilterMenuStylingHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ public function getFilterSlidedownRowAttributes(string $rowIndex): array
{

if (isset($this->filterSlidedownRowCallback)) {
return array_merge( ['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => (int) $rowIndex], call_user_func($this->filterSlidedownRowCallback, (int) $rowIndex));
return array_merge(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => (int) $rowIndex], call_user_func($this->filterSlidedownRowCallback, (int) $rowIndex));
}

return ['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => (int) $rowIndex];
return ['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => (int) $rowIndex];
}



public function getFilterSlideDownDefaultStatus(): bool
{
return $this->filterSlideDownDefaultVisible;
Expand Down
46 changes: 22 additions & 24 deletions tests/Unit/Traits/Styling/FilterSlidedownStylingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

final class FilterSlidedownStylingTest extends TestCase
{

public function test_filter_slidedown_wrapper_attributes_returns_default_if_not_set(): void
{
$this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true], $this->basicTable->getFilterSlidedownWrapperAttributes());
Expand All @@ -18,10 +17,10 @@ public function test_filter_slidedown_wrapper_attributes_can_be_changed(): void
$this->basicTable->setFilterSlidedownWrapperAttributes([
'class' => 'text-blue-500',
'default-colors' => true,
'default-styling' => true,
'default-styling' => true,
'x-transition:enter' => 'transition ease-out duration-1000',
]);

$this->assertSame(['class' => 'text-blue-500', 'default-colors' => true, 'default-styling' => true, 'x-transition:enter' => 'transition ease-out duration-1000'], $this->basicTable->getFilterSlidedownWrapperAttributes());

$this->basicTable->setFilterSlidedownWrapperAttributes([
Expand All @@ -32,38 +31,37 @@ public function test_filter_slidedown_wrapper_attributes_can_be_changed(): void

}


public function test_filter_slidedown_row_attributes_returns_default_if_not_set(): void
{
$this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1));
$this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes(2));
$this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes("1"));
$this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes("2"));
$this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes('1'));
$this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes('2'));
}

public function test_filter_slidedown_row_attributes_can_be_changed(): void
{
$this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1));

$this->basicTable->setFilterSlidedownRowAttributes(fn($rowIndex) => $rowIndex % 2 === 0 ?
$this->basicTable->setFilterSlidedownRowAttributes(fn ($rowIndex) => $rowIndex % 2 === 0 ?
[
'class' => 'bg-red-500',
'default-colors' => true,
'default-styling' => true,
] : [
'default-styling' => true,
] : [
'class' => 'bg-blue-500',
'default-colors' => true,
'default-styling' => true,
]
'default-styling' => true,
]
);
$this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes(0));
$this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1));
$this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes(2));
$this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes(3));
$this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes("0"));
$this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes("1"));
$this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes("2"));
$this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes("3"));
$this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes('0'));
$this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes('1'));
$this->assertSame(['class' => 'bg-red-500', 'default-colors' => true, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes('2'));
$this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => true, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes('3'));

}

Expand All @@ -72,23 +70,23 @@ public function test_filter_slidedown_row_attributes_can_be_changed_and_sets_def
$this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes(0));
$this->assertSame(['class' => '', 'default-colors' => true, 'default-styling' => true, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1));

$this->basicTable->setFilterSlidedownRowAttributes(fn($rowIndex) => $rowIndex % 2 === 0 ?
$this->basicTable->setFilterSlidedownRowAttributes(fn ($rowIndex) => $rowIndex % 2 === 0 ?
[
'class' => 'bg-red-500',
'default-colors' => false,
] : [
] : [
'class' => 'bg-blue-500',
'default-styling' => false,
]
'default-styling' => false,
]
);
$this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes(0));
$this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes(1));
$this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes(2));
$this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes(3));
$this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes("0"));
$this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes("1"));
$this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes("2"));
$this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes("3"));
$this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 0], $this->basicTable->getFilterSlidedownRowAttributes('0'));
$this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 1], $this->basicTable->getFilterSlidedownRowAttributes('1'));
$this->assertSame(['class' => 'bg-red-500', 'default-colors' => false, 'default-styling' => true, 'row' => 2], $this->basicTable->getFilterSlidedownRowAttributes('2'));
$this->assertSame(['class' => 'bg-blue-500', 'default-colors' => true, 'default-styling' => false, 'row' => 3], $this->basicTable->getFilterSlidedownRowAttributes('3'));

}
}
}

0 comments on commit a1ee4e9

Please sign in to comment.