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 24, 2024
1 parent d168297 commit 1372c46
Show file tree
Hide file tree
Showing 46 changed files with 129 additions and 142 deletions.
18 changes: 9 additions & 9 deletions src/Views/Filters/BooleanFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ public function isEmpty(bool|int|string|null $value): bool
protected function getCoreInputAttributes(): array
{
$attributes = array_merge(parent::getCoreInputAttributes(),
[
"@click" => "toggleStatusWithUpdate",
'activeColor' => 'bg-blue-600',
'blobColor' => 'bg-white',
'inactiveColor' => 'bg-neutral-200',
"type" => "button",
"x-ref" => "switchButton",
]);
[
'@click' => 'toggleStatusWithUpdate',
'activeColor' => 'bg-blue-600',
'blobColor' => 'bg-white',
'inactiveColor' => 'bg-neutral-200',
'type' => 'button',
'x-ref' => 'switchButton',
]);
ksort($attributes);

return $attributes;
}

Expand All @@ -77,5 +78,4 @@ public function getFilterDefaultValue(): ?bool
{
return $this->filterDefaultValue ?? null;
}

}
15 changes: 8 additions & 7 deletions src/Views/Filters/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ public function getFilterPillValue($value): ?string
protected function getCoreInputAttributes(): array
{
$attributes = array_merge(parent::getCoreInputAttributes(),
[
'min' => $this->hasConfig('min') ? $this->getConfig('min') : null,
'max' => $this->hasConfig('max') ? $this->getConfig('max') : null,
'placeholder' => $this->hasConfig('placeholder') ? $this->getConfig('placeholder') : null,
'type' => 'date',
'wire:key' => $this->generateWireKey($this->getGenericDisplayData()['tableName'], 'date'),
]);
[
'min' => $this->hasConfig('min') ? $this->getConfig('min') : null,
'max' => $this->hasConfig('max') ? $this->getConfig('max') : null,
'placeholder' => $this->hasConfig('placeholder') ? $this->getConfig('placeholder') : null,
'type' => 'date',
'wire:key' => $this->generateWireKey($this->getGenericDisplayData()['tableName'], 'date'),
]);
ksort($attributes);

return $attributes;
}
}
15 changes: 8 additions & 7 deletions src/Views/Filters/DateTimeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ public function getFilterPillValue($value): ?string
protected function getCoreInputAttributes(): array
{
$attributes = array_merge(parent::getCoreInputAttributes(),
[
'min' => $this->hasConfig('min') ? $this->getConfig('min') : null,
'max' => $this->hasConfig('max') ? $this->getConfig('max') : null,
'placeholder' => $this->hasConfig('placeholder') ? $this->getConfig('placeholder') : null,
'type' => 'datetime-local',
'wire:key' => $this->generateWireKey($this->getGenericDisplayData()['tableName'], 'datetime'),
]);
[
'min' => $this->hasConfig('min') ? $this->getConfig('min') : null,
'max' => $this->hasConfig('max') ? $this->getConfig('max') : null,
'placeholder' => $this->hasConfig('placeholder') ? $this->getConfig('placeholder') : null,
'type' => 'datetime-local',
'wire:key' => $this->generateWireKey($this->getGenericDisplayData()['tableName'], 'datetime'),
]);
ksort($attributes);

return $attributes;
}
}
17 changes: 9 additions & 8 deletions src/Views/Filters/NumberFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ public function validate(float|int|string|array $value): float|int|string|false
protected function getCoreInputAttributes(): array
{
$attributes = array_merge(parent::getCoreInputAttributes(),
[
'min' => $this->hasConfig('min') ? $this->getConfig('min') : null,
'max' => $this->hasConfig('max') ? $this->getConfig('max') : null,
'placeholder' => $this->hasConfig('placeholder') ? $this->getConfig('placeholder') : null,
'type' => 'number',
'wire:key' => $this->generateWireKey($this->getGenericDisplayData()['tableName'], 'number'),

]);
[
'min' => $this->hasConfig('min') ? $this->getConfig('min') : null,
'max' => $this->hasConfig('max') ? $this->getConfig('max') : null,
'placeholder' => $this->hasConfig('placeholder') ? $this->getConfig('placeholder') : null,
'type' => 'number',
'wire:key' => $this->generateWireKey($this->getGenericDisplayData()['tableName'], 'number'),

]);
ksort($attributes);

return $attributes;
}
}
15 changes: 7 additions & 8 deletions src/Views/Filters/TextFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,18 @@ public function validate(string $value): string|bool
return strlen($value) ? $value : false;
}


protected function getCoreInputAttributes(): array
{
$attributes = array_merge(parent::getCoreInputAttributes(),
[
'type' => 'text',
'placeholder' => $this->hasConfig('placeholder') ? $this->getConfig('placeholder') : null,
'maxlength' => $this->hasConfig('maxlength') ? $this->getConfig('maxlength') : null,
'wire:key' => $this->generateWireKey($this->getGenericDisplayData()['tableName'], 'text'),
[
'type' => 'text',
'placeholder' => $this->hasConfig('placeholder') ? $this->getConfig('placeholder') : null,
'maxlength' => $this->hasConfig('maxlength') ? $this->getConfig('maxlength') : null,
'wire:key' => $this->generateWireKey($this->getGenericDisplayData()['tableName'], 'text'),

]);
]);
ksort($attributes);

return $attributes;
}

}
1 change: 0 additions & 1 deletion src/Views/Traits/Configuration/FilterConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public function setFilterDefaultValue($value): self
return $this;
}


public function setGenericDisplayData(array $genericDisplayData = []): self
{
$this->genericDisplayData = [
Expand Down
5 changes: 2 additions & 3 deletions src/Views/Traits/Helpers/FilterHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ public function hasFilterDefaultValue(): bool
return ! is_null($this->filterDefaultValue);
}


public function generateWireKey(string $tableName, string $filterType, string $extraData = ''): string
{
return $tableName.'-filter-'.$filterType.'-'.$this->getKey().($extraData != '' ? '-'.$extraData : '').($this->hasCustomPosition() ? '-'.$this->getCustomPosition() : '');
Expand All @@ -152,7 +151,7 @@ public function getFilterDisplayData(): array
public function render(): string|\Illuminate\Contracts\Foundation\Application|\Illuminate\View\View|\Illuminate\View\Factory
{
return view($this->getViewPath())
->with($this->getFilterDisplayData())
->with(['filterInputAttributes' => $this->getInputAttributesBag()]);
->with($this->getFilterDisplayData())
->with(['filterInputAttributes' => $this->getInputAttributesBag()]);
}
}
7 changes: 3 additions & 4 deletions src/Views/Traits/Styling/HandlesFilterInputAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function getInputAttributesBag(): ComponentAttributeBag
{
$attributes = array_merge($this->getCoreInputAttributes(), $this->getInputAttributes());
ksort($attributes);

return new ComponentAttributeBag($attributes);
}

Expand All @@ -23,7 +24,7 @@ protected function getInputAttributes(): array
protected function getCoreInputAttributes(): array
{
return [
'id' => $this->getGenericDisplayData()['tableName']."-filter-".$this->getKey().($this->hasCustomPosition() ? "-".$this->getCustomPosition() : ''),
'id' => $this->getGenericDisplayData()['tableName'].'-filter-'.$this->getKey().($this->hasCustomPosition() ? '-'.$this->getCustomPosition() : ''),
'default-styling' => true,
'default-colors' => true,
];
Expand All @@ -38,6 +39,4 @@ public function setInputAttributes(array $filterInputAttributes): self

return $this;
}


}
}
4 changes: 2 additions & 2 deletions src/Views/Traits/Styling/HandlesFilterLabelAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public function hasFilterLabelAttributes(): bool
{
return $this->getFilterLabelAttributes() != ['default' => true] && $this->getFilterLabelAttributes() != ['default' => false];
}

public function setFilterLabelAttributes(array $filterLabelAttributes): self
{
$this->filterLabelAttributes = [...['default' => false], ...$filterLabelAttributes];

return $this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Configuration;

use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use PHPUnit\Framework\Attributes\Group;

#[Group('Filters')]
final class FilterConfigurationTest extends TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use PHPUnit\Framework\Attributes\Group;

#[Group('Filters')]
final class QueryStringForFiltersTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Traits/Helpers/FilterHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Helpers;

use Illuminate\Support\Facades\Event;
use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Events\FilterApplied;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
Expand All @@ -12,7 +13,6 @@
use Rappasoft\LaravelLivewireTables\Views\Filters\NumberFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\SelectFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter;
use PHPUnit\Framework\Attributes\Group;

#[Group('Filters')]
final class FilterHelpersTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Traits/Styling/FilterPopoverStylingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Styling;

use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;

#[Group('Filters')]
final class FilterPopoverStylingTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Traits/Styling/FilterSlidedownStylingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Styling;

use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;

#[Group('Filters')]
final class FilterSlidedownStylingTest extends TestCase
Expand Down
5 changes: 1 addition & 4 deletions tests/Unit/Views/Filters/BooleanFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Filters;

use Rappasoft\LaravelLivewireTables\Views\Filters\BooleanFilter;
use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Views\Filters\BooleanFilter;

#[Group('Filters')]
final class BooleanFilterTest extends FilterTestCase
Expand Down Expand Up @@ -183,8 +183,5 @@ public function test_can_set_custom_input_attributes_boolean(): void
'x-ref' => 'switchButton',
], $currentAttributeBag);



}

}
2 changes: 1 addition & 1 deletion tests/Unit/Views/Filters/DateFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Filters;

use DateTime;
use Rappasoft\LaravelLivewireTables\Views\Filters\DateFilter;
use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Views\Filters\DateFilter;

#[Group('Filters')]
final class DateFilterTest extends FilterTestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Views/Filters/DateRangeFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Filters;

use Illuminate\Database\Eloquent\Builder;
use Rappasoft\LaravelLivewireTables\Views\Filters\DateRangeFilter;
use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Views\Filters\DateRangeFilter;

#[Group('Filters')]
final class DateRangeFilterTest extends FilterTestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Views/Filters/DateTimeFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use DateTime;
use Illuminate\Database\Eloquent\Builder;
use Rappasoft\LaravelLivewireTables\Views\Filters\DateTimeFilter;
use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Views\Filters\DateTimeFilter;

#[Group('Filters')]
final class DateTimeFilterTest extends FilterTestCase
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Views/Filters/FilterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Filters;

use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;

#[Group('Filters')]
abstract class FilterTestCase extends TestCase
{
protected static $filterInstance;

protected static $testGenericData;

protected static $extraFilterInputAttributes;

protected function setUp(): void
Expand Down Expand Up @@ -146,14 +148,12 @@ public function test_can_set_custom_input_attributes(): void
'default-styling' => true,
'id' => $baseAttributes['id'],
];
if(isset(self::$extraFilterInputAttributes))
{
$standardAttributes = array_merge($standardAttributes,self::$extraFilterInputAttributes);
if (isset(self::$extraFilterInputAttributes)) {
$standardAttributes = array_merge($standardAttributes, self::$extraFilterInputAttributes);
ksort($standardAttributes);
}

$this->assertSame($standardAttributes, $currentAttributeBag);

}

}
2 changes: 1 addition & 1 deletion tests/Unit/Views/Filters/LivewireComponentFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Filters;

use Illuminate\Database\Eloquent\Builder;
use Rappasoft\LaravelLivewireTables\Views\Filters\LivewireComponentFilter;
use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Views\Filters\LivewireComponentFilter;

#[Group('Filters')]
final class LivewireComponentFilterTest extends FilterTestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Views/Filters/MultiSelectDropdownFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Illuminate\Database\Eloquent\Builder;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectDropdownFilter;
use PHPUnit\Framework\Attributes\Group;

#[Group('Filters')]
final class MultiSelectDropdownFilterTest extends FilterTestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Views/Filters/MultiSelectFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Illuminate\Database\Eloquent\Builder;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectFilter;
use PHPUnit\Framework\Attributes\Group;

#[Group('Filters')]
final class MultiSelectFilterTest extends FilterTestCase
Expand Down
3 changes: 1 addition & 2 deletions tests/Unit/Views/Filters/NumberFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Filters;

use Illuminate\Database\Eloquent\Builder;
use PHPUnit\Framework\Attributes\Group;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Filters\NumberFilter;
use PHPUnit\Framework\Attributes\Group;

#[Group('Filters')]
final class NumberFilterTest extends FilterTestCase
{

protected function setUp(): void
{
parent::setUp();
Expand Down
Loading

0 comments on commit 1372c46

Please sign in to comment.