Skip to content

Commit

Permalink
Added Theme Table container and base for Tailwind Custom Themes (#1583)
Browse files Browse the repository at this point in the history
* Added Theme Table container and base for Tailwind Custom Themes

* Added data_get default values
  • Loading branch information
marcheffels committed Jun 13, 2024
1 parent 2d624af commit 989407a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ class="flex flex-col"
>
<div
id="power-grid-table-container"
class="-my-2 overflow-x-auto sm:-mx-3 lg:-mx-8"
class="{{ data_get($theme, 'table.containerClass', '-my-2 overflow-x-auto sm:-mx-3 lg:-mx-8') }}"
style="{{ data_get($theme, 'table.containerStyle') }}"
>
<div
id="power-grid-table-base"
class="p-3 align-middle inline-block min-w-full w-full sm:px-6 lg:px-8"
class="{{ data_get($theme, 'table.baseClass', 'p-3 align-middle inline-block min-w-full w-full sm:px-6 lg:px-8') }}"
style="{{ data_get($theme, 'table.baseStyle') }}"
>

@include(data_get($theme, 'layout.header'), [
Expand Down
24 changes: 24 additions & 0 deletions src/Themes/Components/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

class Table
{
public string $containerClass = '';

public string $containerStyle = '';

public string $baseClass = '';

public string $baseStyle = '';

public string $divClass = '';

public string $divStyle = '';
Expand Down Expand Up @@ -75,6 +83,22 @@ public function __construct(string $tableClass, string $tableStyle = '')
$this->tableStyle = $tableStyle;
}

public function container(string $attrClass, string $attrStyle = ''): Table
{
$this->containerClass = $attrClass;
$this->containerStyle = $attrStyle;

return $this;
}

public function base(string $attrClass, string $attrStyle = ''): Table
{
$this->baseClass = $attrClass;
$this->baseStyle = $attrStyle;

return $this;
}

public function div(string $attrClass, string $attrStyle = ''): Table
{
$this->divClass = $attrClass;
Expand Down
2 changes: 2 additions & 0 deletions src/Themes/Tailwind.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Tailwind extends ThemeBase
public function table(): Table
{
return Theme::table('min-w-full dark:!bg-primary-800')
->container('-my-2 overflow-x-auto sm:-mx-3 lg:-mx-8')
->base('p-3 align-middle inline-block min-w-full w-full sm:px-6 lg:px-8')
->div('rounded-t-lg relative border-x border-t border-pg-primary-200 dark:bg-pg-primary-700 dark:border-pg-primary-600')
->thead('shadow-sm rounded-t-lg bg-pg-primary-100 dark:bg-pg-primary-900')
->thAction('!font-bold')
Expand Down

0 comments on commit 989407a

Please sign in to comment.