Skip to content

Commit

Permalink
Table Caption - Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe authored Oct 5, 2024
1 parent 2fe4db1 commit 783a91b
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/views/components/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
->except(['default','default-styling','default-colors']) }}

>
@if($this->hasTableCaptionMessage()) <caption>{{ $this->getTableCaptionMessage() }}</caption> @endif
<thead wire:key="{{ $tableName }}-thead"
{{ $attributes->merge($customAttributes['thead'])
->class(['bg-gray-50 dark:bg-gray-800' => $customAttributes['thead']['default'] ?? true])
Expand Down
14 changes: 14 additions & 0 deletions src/Traits/Features/Configuration/TableCaptionConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Features\Configuration;

trait TableCaptionConfiguration
{
public function setTableCaptionMessage(string $tableCaptionMessage): self
{
$this->tableCaptionMessage = $tableCaptionMessage;

return $this;
}

}
14 changes: 14 additions & 0 deletions src/Traits/Features/HasTableCaption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Features;

use Rappasoft\LaravelLivewireTables\Traits\Features\Configuration\TableCaptionConfiguration;
use Rappasoft\LaravelLivewireTables\Traits\Features\Helpers\TableCaptionHelpers;

trait HasTableCaption
{
use TableCaptionConfiguration,
TableCaptionHelpers;

protected ?string $tableCaptionMessage;
}
19 changes: 19 additions & 0 deletions src/Traits/Features/Helpers/TableCaptionHelpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Features\Helpers;

use Livewire\Attributes\Computed;

trait TableCaptionHelpers
{
public function hasTableCaptionMessage(): bool
{
return isset($this->tableCaptionMessage);
}

#[Computed]
public function getTableCaptionMessage(): string
{
return $this->hasTableCaptionMessage() ? $this->tableCaptionMessage : '';
}
}
3 changes: 3 additions & 0 deletions src/Traits/HasAllTraits.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Rappasoft\LaravelLivewireTables\Traits\Core\HasCustomAttributes;
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasTheme;
use Rappasoft\LaravelLivewireTables\Traits\Features\{HasTableCaption};

trait HasAllTraits
{
Expand Down Expand Up @@ -35,4 +36,6 @@ trait HasAllTraits
WithSessionStorage,
WithTableAttributes,
WithTools;

use HasTableCaption;
}

0 comments on commit 783a91b

Please sign in to comment.