Skip to content

Commit

Permalink
Update docs - add Action setLabelAttributes method (#1952)
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe authored Sep 18, 2024
1 parent 530b0bf commit a76ae7b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
17 changes: 17 additions & 0 deletions docs/filters/available-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ Example label blade:
```

### setFilterLabelAttributes

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

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.
Expand All @@ -401,6 +403,21 @@ TextFilter::make('Name')
),
```

#### New Method (Recommended)
Set custom attributes for a Filter Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts.

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.

```php
TextFilter::make('Name')
->setLabelAttributes(
[
'class' => 'text-xl',
'default' => true,
]
),
```

### setCustomView
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:
- setCustomFilterLabel
Expand Down
16 changes: 16 additions & 0 deletions docs/misc/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ public function actions(): array

## Button Available Methods

### setLabelAttributes
Set custom attributes for an Action Label. At present it is recommended to only use this for "class" and "style" attributes to avoid conflicts.

By default, this replaces the default classes on the Action Label, if you would like to keep them, set the default flag to true.

```php
Action::make('Dashboard')
->setRoute('dashboard')
->wireNavigate()
->setLabelAttributes([
'class' => 'text-xl',
'default' => true,
]),
```

### setActionAttributes

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.
Expand Down Expand Up @@ -252,6 +267,7 @@ public function actions(): array
}
```


## Extending

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).
Expand Down
6 changes: 3 additions & 3 deletions resources/views/includes/actions/button.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
>

@if($action->hasIcon() && $action->getIconRight())
<span>{{ $action->getLabel() }}</span>
<span {{ $action->getLabelAttributesBag() }}>{{ $action->getLabel() }}</span>
<i {{ $action->getIconAttributes()
->class(["ms-1 ". $action->getIcon() => $isBootstrap])
->class(["ml-1 ". $action->getIcon() => $isTailwind])
Expand All @@ -28,8 +28,8 @@
->except(['default','default-styling','default-colors'])
}}
></i>
<span>{{ $action->getLabel() }}</span>
<span {{ $action->getLabelAttributesBag() }}>{{ $action->getLabel() }}</span>
@else
<span>{{ $action->getLabel() }}</span>
<span {{ $action->getLabelAttributesBag() }}>{{ $action->getLabel() }}</span>
@endif
</a>
3 changes: 2 additions & 1 deletion src/Views/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
use Illuminate\View\ComponentAttributeBag;
use Rappasoft\LaravelLivewireTables\Views\Traits\Actions\{HasActionAttributes, HasRoute};
use Rappasoft\LaravelLivewireTables\Views\Traits\Columns\HasVisibility;
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasIcon, HasLabel, HasTheme, HasView, HasWireActions};
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasIcon, HasLabel, HasLabelAttributes, HasTheme, HasView, HasWireActions};

class Action extends Component
{
use HasActionAttributes;
use HasIcon;
use HasLabel;
use HasLabelAttributes;
use HasRoute;
use HasTheme;
use HasView;
Expand Down

0 comments on commit a76ae7b

Please sign in to comment.