Skip to content

Commit

Permalink
feat(brn) adiciona o loading
Browse files Browse the repository at this point in the history
  • Loading branch information
irineujunior committed Mar 26, 2024
1 parent fe4bdf5 commit 41b48ca
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/View/Components/Buttons/Primary.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ class Primary extends Component
{
public function __construct(
public string $label = '',
public bool $spinner = true,
) {
$this->label = $label ?: __('Save');
}

public function render(): string|View
{
return <<<'HTML'
<button {{ $attributes->merge(['type' => 'submit'])->class(['btn btn-primary']) }}>
<button {{ $attributes->merge([
'wire:loading.attr' => 'disabled',
'wire:target' => 'submit',
'type' => 'submit',
])->class(['btn btn-primary']) }}>
@if($spinner)
<span wire:loading wire:target="submit" class="spinner-border spinner-border-sm me-2"></span>
@endif
{{ ($slot->isEmpty()) ? $fallback : $slot }}
</button>
HTML;
Expand Down

0 comments on commit 41b48ca

Please sign in to comment.