Skip to content

Commit 0b138d3

Browse files
authored
Merge pull request #78 from ht3aa/feature/adding-tooltip-to-the-button
Adding tooltip with fixing translation path
2 parents 3d0ba32 + 9aaf223 commit 0b138d3

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

resources/views/components/create-menu.blade.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929
'size-8' => ! $label,
3030
'py-1 ps-3 pe-4 gap-1' => $label,
3131
])
32-
aria-label="{{ __('filament-quick-create::quick-create.button_label') }}"
32+
@if($tooltip)
33+
x-tooltip="{
34+
content: '{{ $tooltip }}'
35+
}"
36+
@endif
37+
aria-label="{{ __('quick-create::quick-create.button_label') }}"
3338
>
3439
<x-filament::icon
3540
alias="filament-quick-create::add"

src/Components/QuickCreateMenu.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class QuickCreateMenu extends Component implements HasActions, HasForms
3939

4040
public ?array $keyBindings = null;
4141

42+
public ?string $tooltip = null;
43+
4244
/**
4345
* @throws Exception
4446
*/
@@ -49,6 +51,7 @@ public function mount(): void
4951
$this->hiddenIcons = QuickCreatePlugin::get()->shouldHideIcons();
5052
$this->label = QuickCreatePlugin::get()->getLabel();
5153
$this->keyBindings = QuickCreatePlugin::get()->getKeyBindings();
54+
$this->tooltip = QuickCreatePlugin::get()->getTooltip();
5255
}
5356

5457
/**

src/QuickCreatePlugin.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class QuickCreatePlugin implements Plugin
5454

5555
protected array|Closure|null $modalExtraAttributes = null;
5656

57+
protected string|Closure|null $tooltip = null;
58+
5759
public static function get(): static
5860
{
5961
return filament(app(static::class)->getId());
@@ -355,4 +357,16 @@ public function getModalExtraAttributes(): ?array
355357
{
356358
return $this->evaluate($this->modalExtraAttributes);
357359
}
360+
361+
public function tooltip(string|Closure|null $tooltip = null): static
362+
{
363+
$this->tooltip = $tooltip ?? __('quick-create::quick-create.button_label');
364+
365+
return $this;
366+
}
367+
368+
public function getTooltip(): ?string
369+
{
370+
return $this->evaluate($this->tooltip);
371+
}
358372
}

0 commit comments

Comments
 (0)