Skip to content

Commit 783a91b

Browse files
authored
Table Caption - Initial Commit
1 parent 2fe4db1 commit 783a91b

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

resources/views/components/table.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
->except(['default','default-styling','default-colors']) }}
2424

2525
>
26+
@if($this->hasTableCaptionMessage()) <caption>{{ $this->getTableCaptionMessage() }}</caption> @endif
2627
<thead wire:key="{{ $tableName }}-thead"
2728
{{ $attributes->merge($customAttributes['thead'])
2829
->class(['bg-gray-50 dark:bg-gray-800' => $customAttributes['thead']['default'] ?? true])
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Traits\Features\Configuration;
4+
5+
trait TableCaptionConfiguration
6+
{
7+
public function setTableCaptionMessage(string $tableCaptionMessage): self
8+
{
9+
$this->tableCaptionMessage = $tableCaptionMessage;
10+
11+
return $this;
12+
}
13+
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Traits\Features;
4+
5+
use Rappasoft\LaravelLivewireTables\Traits\Features\Configuration\TableCaptionConfiguration;
6+
use Rappasoft\LaravelLivewireTables\Traits\Features\Helpers\TableCaptionHelpers;
7+
8+
trait HasTableCaption
9+
{
10+
use TableCaptionConfiguration,
11+
TableCaptionHelpers;
12+
13+
protected ?string $tableCaptionMessage;
14+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Traits\Features\Helpers;
4+
5+
use Livewire\Attributes\Computed;
6+
7+
trait TableCaptionHelpers
8+
{
9+
public function hasTableCaptionMessage(): bool
10+
{
11+
return isset($this->tableCaptionMessage);
12+
}
13+
14+
#[Computed]
15+
public function getTableCaptionMessage(): string
16+
{
17+
return $this->hasTableCaptionMessage() ? $this->tableCaptionMessage : '';
18+
}
19+
}

src/Traits/HasAllTraits.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Rappasoft\LaravelLivewireTables\Traits\Core\HasCustomAttributes;
66
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasTheme;
7+
use Rappasoft\LaravelLivewireTables\Traits\Features\{HasTableCaption};
78

89
trait HasAllTraits
910
{
@@ -35,4 +36,6 @@ trait HasAllTraits
3536
WithSessionStorage,
3637
WithTableAttributes,
3738
WithTools;
39+
40+
use HasTableCaption;
3841
}

0 commit comments

Comments
 (0)