Skip to content

Commit

Permalink
Migrate Styling Configs (#2127)
Browse files Browse the repository at this point in the history
* Migrate Styling Configs

* Fix styling

---------

Co-authored-by: lrljoe <[email protected]>
  • Loading branch information
lrljoe and lrljoe authored Dec 11, 2024
1 parent d97455e commit f74fe75
Show file tree
Hide file tree
Showing 36 changed files with 383 additions and 214 deletions.
7 changes: 0 additions & 7 deletions src/Traits/Configuration/ActionsConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@

trait ActionsConfiguration
{
public function setActionWrapperAttributes(array $actionWrapperAttributes): self
{
$this->actionWrapperAttributes = [...$this->actionWrapperAttributes, ...$actionWrapperAttributes];

return $this;
}

public function setActionsInToolbar(bool $status): self
{
$this->displayActionsInToolbar = $status;
Expand Down
24 changes: 0 additions & 24 deletions src/Traits/Configuration/CollapsingColumnConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,4 @@ public function setCollapsingColumnsDisabled(): self

return $this;
}

/**
* Used to set attributes for the Collapsed Column Collapse Button
*
* @param array<mixed> $collapsingColumnButtonCollapseAttributes
*/
public function setCollapsingColumnButtonCollapseAttributes(array $collapsingColumnButtonCollapseAttributes): self
{
$this->collapsingColumnButtonCollapseAttributes = [...['default-colors' => false, 'default-styling' => false], ...$collapsingColumnButtonCollapseAttributes];

return $this;
}

/**
* Used to set attributes for the Collapsed Column Expand Button
*
* @param array<mixed> $collapsingColumnButtonExpandAttributes
*/
public function setCollapsingColumnButtonExpandAttributes(array $collapsingColumnButtonExpandAttributes): self
{
$this->collapsingColumnButtonExpandAttributes = [...['default-colors' => false, 'default-styling' => false], ...$collapsingColumnButtonExpandAttributes];

return $this;
}
}
14 changes: 0 additions & 14 deletions src/Traits/Configuration/FooterConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,4 @@ public function setUseHeaderAsFooterDisabled(): self

return $this;
}

public function setFooterTrAttributes(Closure $callback): self
{
$this->footerTrAttributesCallback = $callback;

return $this;
}

public function setFooterTdAttributes(Closure $callback): self
{
$this->footerTdAttributesCallback = $callback;

return $this;
}
}
14 changes: 0 additions & 14 deletions src/Traits/Configuration/PaginationConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,6 @@ public function setDefaultPerPage(int $defaultPerPage): self
return $this;
}

public function setPerPageFieldAttributes(array $attributes = []): self
{
$this->perPageFieldAttributes = [...$this->perPageFieldAttributes, ...$attributes];

return $this;
}

public function setShouldRetrieveTotalItemCountStatus(bool $status): self
{
$this->shouldRetrieveTotalItemCount = $status;
Expand All @@ -182,11 +175,4 @@ public function setShouldRetrieveTotalItemCountDisabled(): self

return $this;
}

public function setPaginationWrapperAttributes(array $paginationWrapperAttributes): self
{
$this->paginationWrapperAttributes = array_merge(['class' => ''], $paginationWrapperAttributes);

return $this;
}
}
10 changes: 0 additions & 10 deletions src/Traits/Configuration/ReorderingConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,4 @@ public function setDefaultReorderSort(string $field, string $direction = 'asc'):

return $this;
}

/**
* Used to set attributes for the <th> for Reorder Column
*/
public function setReorderThAttributes(array $reorderThAttributes): self
{
$this->reorderThAttributes = [...$this->reorderThAttributes, ...$reorderThAttributes];

return $this;
}
}
16 changes: 0 additions & 16 deletions src/Traits/Configuration/SecondaryHeaderConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Rappasoft\LaravelLivewireTables\Traits\Configuration;

use Closure;

trait SecondaryHeaderConfiguration
{
public function setSecondaryHeaderStatus(bool $status): self
Expand All @@ -26,18 +24,4 @@ public function setSecondaryHeaderDisabled(): self

return $this;
}

public function setSecondaryHeaderTrAttributes(Closure $callback): self
{
$this->secondaryHeaderTrAttributesCallback = $callback;

return $this;
}

public function setSecondaryHeaderTdAttributes(Closure $callback): self
{
$this->secondaryHeaderTdAttributesCallback = $callback;

return $this;
}
}
6 changes: 0 additions & 6 deletions src/Traits/Helpers/ActionsHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ public function getActionsPosition(): string
return $this->actionsPosition ?? 'right';
}

#[Computed]
public function getActionWrapperAttributes(): array
{
return [...['class' => '', 'default-styling' => true, 'default-colors' => true], ...$this->actionWrapperAttributes];
}

#[Computed]
public function hasActions(): bool
{
Expand Down
22 changes: 0 additions & 22 deletions src/Traits/Helpers/CollapsingColumnHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,6 @@ public function collapsingColumnsAreDisabled(): bool
return $this->getCollapsingColumnsStatus() === false;
}

/**
* Retrieves attributes for the Collapsed Column Collapse Button
*
* @return array<mixed>
*/
#[Computed]
public function getCollapsingColumnButtonCollapseAttributes(): array
{
return [...['default-styling' => true, 'default-colors' => true], ...$this->collapsingColumnButtonCollapseAttributes];
}

/**
* Retrieves attributes for the Collapsed Column Expand Button
*
* @return array<mixed>
*/
#[Computed]
public function getCollapsingColumnButtonExpandAttributes(): array
{
return [...['default-styling' => true, 'default-colors' => true], ...$this->collapsingColumnButtonExpandAttributes];
}

#[Computed]
public function showCollapsingColumnSections(): bool
{
Expand Down
18 changes: 0 additions & 18 deletions src/Traits/Helpers/FooterHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,4 @@ public function useHeaderAsFooterIsDisabled(): bool
{
return $this->getUseHeaderAsFooterStatus() === false;
}

/**
* @param mixed $rows
* @return array<mixed>
*/
public function getFooterTrAttributes($rows): array
{
return isset($this->footerTrAttributesCallback) ? call_user_func($this->footerTrAttributesCallback, $rows) : ['default' => true];
}

/**
* @param mixed $rows
* @return array<mixed>
*/
public function getFooterTdAttributes(Column $column, $rows, int $index): array
{
return isset($this->footerTdAttributesCallback) ? call_user_func($this->footerTdAttributesCallback, $column, $rows, $index) : ['default' => true];
}
}
17 changes: 0 additions & 17 deletions src/Traits/Helpers/PaginationHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,26 +152,9 @@ private function getPerPagePaginationSessionKey(): string
return $this->tableName.'-perPage';
}

#[Computed]
public function getPerPageFieldAttributes(): array
{
return $this->perPageFieldAttributes;
}

#[Computed]
public function getShouldRetrieveTotalItemCount(): bool
{
return $this->shouldRetrieveTotalItemCount;
}

public function getPaginationWrapperAttributes(): array
{
return $this->paginationWrapperAttributes ?? ['class' => ''];
}

#[Computed]
public function getPaginationWrapperAttributesBag(): ComponentAttributeBag
{
return new ComponentAttributeBag($this->getPaginationWrapperAttributes());
}
}
17 changes: 0 additions & 17 deletions src/Traits/Helpers/ReorderingHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,6 @@ public function getReorderingBackupSessionKey(): string
return $this->getTableName().'-reordering-backup';
}

/**
* Used to get attributes for the <th> for Bulk Actions
*
* @return array<mixed>
*/
#[Computed]
public function getReorderThAttributes(): array
{
return $this->reorderThAttributes ?? ['default' => true];
}

#[Computed]
public function hasReorderThAttributes(): bool
{
return $this->getReorderThAttributes() != ['default' => true];
}

public function getReorderColumn(): Column
{
return Column::make('reorder')->label(fn () => null);
Expand Down
20 changes: 0 additions & 20 deletions src/Traits/Helpers/SecondaryHeaderHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Rappasoft\LaravelLivewireTables\Traits\Helpers;

use Rappasoft\LaravelLivewireTables\Views\Column;

trait SecondaryHeaderHelpers
{
public function hasColumnsWithSecondaryHeader(): bool
Expand All @@ -25,22 +23,4 @@ public function secondaryHeaderIsDisabled(): bool
{
return $this->getSecondaryHeaderStatus() === false;
}

/**
* @param mixed $rows
* @return array<mixed>
*/
public function getSecondaryHeaderTrAttributes($rows): array
{
return isset($this->secondaryHeaderTrAttributesCallback) ? call_user_func($this->secondaryHeaderTrAttributesCallback, $rows) : ['default' => true];
}

/**
* @param mixed $rows
* @return array<mixed>
*/
public function getSecondaryHeaderTdAttributes(Column $column, $rows, int $index): array
{
return isset($this->secondaryHeaderTdAttributesCallback) ? call_user_func($this->secondaryHeaderTdAttributesCallback, $column, $rows, $index) : ['default' => true];
}
}
13 changes: 13 additions & 0 deletions src/Traits/Styling/Configuration/ActionsStylingConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration;

trait ActionsStylingConfiguration
{
public function setActionWrapperAttributes(array $actionWrapperAttributes): self
{
$this->actionWrapperAttributes = [...$this->actionWrapperAttributes, ...$actionWrapperAttributes];

return $this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration;

trait CollapsingColumnsStylingConfiguration
{
/**
* Used to set attributes for the Collapsed Column Collapse Button
*
* @param array<mixed> $collapsingColumnButtonCollapseAttributes
*/
public function setCollapsingColumnButtonCollapseAttributes(array $collapsingColumnButtonCollapseAttributes): self
{
$this->collapsingColumnButtonCollapseAttributes = [...['default-colors' => false, 'default-styling' => false], ...$collapsingColumnButtonCollapseAttributes];

return $this;
}

/**
* Used to set attributes for the Collapsed Column Expand Button
*
* @param array<mixed> $collapsingColumnButtonExpandAttributes
*/
public function setCollapsingColumnButtonExpandAttributes(array $collapsingColumnButtonExpandAttributes): self
{
$this->collapsingColumnButtonExpandAttributes = [...['default-colors' => false, 'default-styling' => false], ...$collapsingColumnButtonExpandAttributes];

return $this;
}
}
22 changes: 22 additions & 0 deletions src/Traits/Styling/Configuration/FooterStylingConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration;

use Closure;

trait FooterStylingConfiguration
{
public function setFooterTrAttributes(Closure $callback): self
{
$this->footerTrAttributesCallback = $callback;

return $this;
}

public function setFooterTdAttributes(Closure $callback): self
{
$this->footerTdAttributesCallback = $callback;

return $this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration;

trait PaginationStylingConfiguration
{
public function setPerPageFieldAttributes(array $attributes = []): self
{
$this->perPageFieldAttributes = [...$this->perPageFieldAttributes, ...$attributes];

return $this;
}

public function setPaginationWrapperAttributes(array $paginationWrapperAttributes): self
{
$this->paginationWrapperAttributes = array_merge(['class' => ''], $paginationWrapperAttributes);

return $this;
}
}
16 changes: 16 additions & 0 deletions src/Traits/Styling/Configuration/ReorderStylingConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration;

trait ReorderStylingConfiguration
{
/**
* Used to set attributes for the <th> for Reorder Column
*/
public function setReorderThAttributes(array $reorderThAttributes): self
{
$this->reorderThAttributes = [...$this->reorderThAttributes, ...$reorderThAttributes];

return $this;
}
}
Loading

0 comments on commit f74fe75

Please sign in to comment.