Skip to content

Commit a76ae7b

Browse files
authored
Update docs - add Action setLabelAttributes method (rappasoft#1952)
1 parent 530b0bf commit a76ae7b

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

docs/filters/available-methods.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ Example label blade:
387387
```
388388

389389
### setFilterLabelAttributes
390+
391+
#### Old Method (Still Supported)
390392
Set custom attributes for a Filter Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts.
391393

392394
By default, this replaces the default classes on the Filter Label wrapper, if you would like to keep them, set the default flag to true.
@@ -401,6 +403,21 @@ TextFilter::make('Name')
401403
),
402404
```
403405

406+
#### New Method (Recommended)
407+
Set custom attributes for a Filter Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts.
408+
409+
By default, this replaces the default classes on the Filter Label wrapper, if you would like to keep them, set the default flag to true.
410+
411+
```php
412+
TextFilter::make('Name')
413+
->setLabelAttributes(
414+
[
415+
'class' => 'text-xl',
416+
'default' => true,
417+
]
418+
),
419+
```
420+
404421
### setCustomView
405422
Use a fully custom view for a filter. This will utilise solely your view when rendering this filter. Note that the following methods will no longer apply to a filter using this:
406423
- setCustomFilterLabel

docs/misc/actions.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ public function actions(): array
9292

9393
## Button Available Methods
9494

95+
### setLabelAttributes
96+
Set custom attributes for an Action Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts.
97+
98+
By default, this replaces the default classes on the Action Label, if you would like to keep them, set the default flag to true.
99+
100+
```php
101+
Action::make('Dashboard')
102+
->setRoute('dashboard')
103+
->wireNavigate()
104+
->setLabelAttributes([
105+
'class' => 'text-xl',
106+
'default' => true,
107+
]),
108+
```
109+
95110
### setActionAttributes
96111

97112
setActionAttributes is used to pass any attributes that you wish to implement on the "button" element for the action button. By default it will merge with the default classes.
@@ -252,6 +267,7 @@ public function actions(): array
252267
}
253268
```
254269

270+
255271
## Extending
256272

257273
You can extend the Base Action class which can be a useful timesaver, when you wish to re-use the same look/feel of an Action, but wish to set a different route (for example).

resources/views/includes/actions/button.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
>
1515

1616
@if($action->hasIcon() && $action->getIconRight())
17-
<span>{{ $action->getLabel() }}</span>
17+
<span {{ $action->getLabelAttributesBag() }}>{{ $action->getLabel() }}</span>
1818
<i {{ $action->getIconAttributes()
1919
->class(["ms-1 ". $action->getIcon() => $isBootstrap])
2020
->class(["ml-1 ". $action->getIcon() => $isTailwind])
@@ -28,8 +28,8 @@
2828
->except(['default','default-styling','default-colors'])
2929
}}
3030
></i>
31-
<span>{{ $action->getLabel() }}</span>
31+
<span {{ $action->getLabelAttributesBag() }}>{{ $action->getLabel() }}</span>
3232
@else
33-
<span>{{ $action->getLabel() }}</span>
33+
<span {{ $action->getLabelAttributesBag() }}>{{ $action->getLabel() }}</span>
3434
@endif
3535
</a>

src/Views/Action.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
use Illuminate\View\ComponentAttributeBag;
77
use Rappasoft\LaravelLivewireTables\Views\Traits\Actions\{HasActionAttributes, HasRoute};
88
use Rappasoft\LaravelLivewireTables\Views\Traits\Columns\HasVisibility;
9-
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasIcon, HasLabel, HasTheme, HasView, HasWireActions};
9+
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasIcon, HasLabel, HasLabelAttributes, HasTheme, HasView, HasWireActions};
1010

1111
class Action extends Component
1212
{
1313
use HasActionAttributes;
1414
use HasIcon;
1515
use HasLabel;
16+
use HasLabelAttributes;
1617
use HasRoute;
1718
use HasTheme;
1819
use HasView;

0 commit comments

Comments
 (0)