Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…tables into devsrv-develop
  • Loading branch information
rappasoft committed Jul 10, 2021
2 parents a75b15b + d33e4dc commit f280c14
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 7 deletions.
18 changes: 16 additions & 2 deletions resources/views/bootstrap-4/components/table/heading.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,28 @@
'text' => null,
])

@php
$headerAttributesList = [];
$headerAttributesList[] = ['class' => $attributes->get('class')];
$headerAttributesList[] = $attributes->get('extraAttributes') ?? [];
$headerAttributes = '';
collect($headerAttributesList)->each(function($item) use(&$headerAttributes) {
if(count($item)) {
$headerAttributes .= collect($item)->map(fn($value, $key) => $key . '="' . $value . '"')->implode(' ');
}
});
@endphp

@unless ($sortingEnabled && $sortable)
<th {{ $attributes->only('class') }}>
<th {!! $headerAttributes !!}>
{{ $text ?? $slot }}
</th>
@else
<th
wire:click="sortBy('{{ $column }}', '{{ $text ?? $column }}')"
{{ $attributes->only('class') }}
{!! $headerAttributes !!}
style="cursor:pointer;"
>
<div class="d-flex align-items-center">
Expand Down
1 change: 1 addition & 0 deletions resources/views/bootstrap-4/includes/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
:direction="$column->column() ? $sorts[$column->column()] ?? null : null"
:text="$column->text() ?? ''"
:class="$column->class() ?? ''"
:extraAttributes="$column->attributes()"
/>
@endif
@endif
Expand Down
18 changes: 16 additions & 2 deletions resources/views/bootstrap-5/components/table/heading.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,28 @@
'text' => null,
])

@php
$headerAttributesList = [];
$headerAttributesList[] = ['class' => $attributes->get('class')];
$headerAttributesList[] = $attributes->get('extraAttributes') ?? [];
$headerAttributes = '';
collect($headerAttributesList)->each(function($item) use(&$headerAttributes) {
if(count($item)) {
$headerAttributes .= collect($item)->map(fn($value, $key) => $key . '="' . $value . '"')->implode(' ');
}
});
@endphp

@unless ($sortingEnabled && $sortable)
<th {{ $attributes->only('class') }}>
<th {!! $headerAttributes !!}>
{{ $text ?? $slot }}
</th>
@else
<th
wire:click="sortBy('{{ $column }}', '{{ $text ?? $column }}')"
{{ $attributes->only('class') }}
{!! $headerAttributes !!}
style="cursor:pointer;"
>
<div class="d-flex align-items-center">
Expand Down
1 change: 1 addition & 0 deletions resources/views/bootstrap-5/includes/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class="form-check-input"
:direction="$column->column() ? $sorts[$column->column()] ?? null : null"
:text="$column->text() ?? ''"
:class="$column->class() ?? ''"
:extraAttributes="$column->attributes()"
/>
@endif
@endif
Expand Down
18 changes: 15 additions & 3 deletions resources/views/tailwind/components/table/heading.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,21 @@
'text' => null,
])

<th
{{ $attributes->merge(['class' => 'px-3 py-2 md:px-6 md:py-3 bg-gray-50'])->only('class') }}
>
@php
$headerAttributesList = [];
$headerAttributesList[] = ['class' => 'px-3 py-2 md:px-6 md:py-3 bg-gray-50 ' . $attributes->get('class')];
$headerAttributesList[] = $attributes->get('extraAttributes') ?? [];
$headerAttributes = '';
collect($headerAttributesList)->each(function($item) use(&$headerAttributes) {
if(count($item)) {
$headerAttributes .= collect($item)->map(fn($value, $key) => $key . '="' . $value . '"')->implode(' ');
}
});
@endphp

<th {!! $headerAttributes !!}>
@unless ($sortingEnabled && $sortable)
<span class="block text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider">
{{ $text ?? $slot }}
Expand Down
1 change: 1 addition & 0 deletions resources/views/tailwind/includes/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class="rounded-md shadow-sm border-gray-300 block transition duration-150 ease-i
:direction="$column->column() ? $sorts[$column->column()] ?? null : null"
:text="$column->text() ?? ''"
:class="$column->class() ?? ''"
:extraAttributes="$column->attributes()"
/>
@endif
@endif
Expand Down
25 changes: 25 additions & 0 deletions src/Views/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class Column
*/
public ?string $text = null;

/**
* @var array
*/
public array $attributes = [];

/**
* @var bool
*/
Expand Down Expand Up @@ -170,6 +175,18 @@ public function addClass(string $class): self
return $this;
}

/**
* @param array $attributes
*
* @return $this
*/
public function addAttributes(array $attributes): self
{
$this->attributes = $attributes;

return $this;
}

/**
* @return Column
*/
Expand Down Expand Up @@ -204,6 +221,14 @@ public function text(): ?string
return $this->text;
}

/**
* @return array
*/
public function attributes(): array
{
return $this->attributes;
}

/**
* @param callable $callable
*
Expand Down

0 comments on commit f280c14

Please sign in to comment.