Skip to content

Commit 9aaf223

Browse files
committed
making ->tooltip method
1 parent ad99604 commit 9aaf223

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
'size-8' => ! $label,
3030
'py-1 ps-3 pe-4 gap-1' => $label,
3131
])
32-
x-tooltip="{
33-
content: '{{ __('quick-create::quick-create.button_label') }}'
34-
}"
32+
@if($tooltip)
33+
x-tooltip="{
34+
content: '{{ $tooltip }}'
35+
}"
36+
@endif
3537
aria-label="{{ __('quick-create::quick-create.button_label') }}"
3638
>
3739
<x-filament::icon

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)