-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for keybindings to open quick add dropdown
- Loading branch information
1 parent
aa0051a
commit 8c6f9e2
Showing
4 changed files
with
93 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,51 @@ | ||
<div class="quick-create-component"> | ||
@if ($resources && $this->shouldBeHidden() === false) | ||
<x-filament::dropdown placement="bottom-end" :teleport="true"> | ||
<x-slot name="trigger"> | ||
<button | ||
@class([ | ||
'flex flex-shrink-0 bg-gray-100 items-center justify-center text-primary-500 hover:text-primary-900 dark:bg-gray-800 hover:bg-primary-500 dark:hover:bg-primary-500', | ||
'rounded-full' => $rounded, | ||
'rounded-md' => ! $rounded, | ||
'w-8 h-8' => ! $label, | ||
'py-1 ps-3 pe-4 gap-1' => $label, | ||
]) | ||
aria-label="{{ __('filament-quick-create::quick-create.button_label') }}" | ||
> | ||
<x-filament::icon | ||
alias="filament-quick-create::add" | ||
icon="heroicon-o-plus" | ||
class="w-5 h-5" | ||
/> | ||
@if ($label) | ||
<span class="">{{ $label }}</span> | ||
@endif | ||
</button> | ||
</x-slot> | ||
<x-filament::dropdown.list> | ||
@foreach($resources as $resource) | ||
<x-filament::dropdown.list.item | ||
:icon="$hiddenIcons ? null : $resource['icon']" | ||
:wire:click="$resource['action']" | ||
:href="$resource['url']" | ||
:tag="$resource['url'] ? 'a' : 'button'" | ||
@php | ||
$keyBindings = collect($keyBindings ?? []) | ||
->map(fn (string $keyBinding): string => str_replace('+', '-', $keyBinding)) | ||
->implode('.'); | ||
@endphp | ||
|
||
<div class="quick-create-component" x-data="{ dropdownOpen: false }"> | ||
@if ($resources && $this->shouldBeHidden() === false) | ||
<x-filament::dropdown placement="bottom-end" :teleport="true"> | ||
<x-slot name="trigger"> | ||
<button | ||
x-ref="triggerButton" | ||
@click="dropdownOpen = !dropdownOpen" | ||
x-mousetrap.global.{{ $keyBindings }}="$refs.triggerButton.click()" | ||
@class([ | ||
'flex flex-shrink-0 bg-gray-100 items-center justify-center text-primary-500 hover:text-primary-900 dark:bg-gray-800 hover:bg-primary-500 dark:hover:bg-primary-500', | ||
'rounded-full' => $rounded, | ||
'rounded-md' => ! $rounded, | ||
'w-8 h-8' => ! $label, | ||
'py-1 ps-3 pe-4 gap-1' => $label, | ||
]) | ||
aria-label="{{ __('filament-quick-create::quick-create.button_label') }}" | ||
> | ||
{{ $resource['label'] }} | ||
</x-filament::dropdown.list.item> | ||
@endforeach | ||
</x-filament::dropdown.list> | ||
</x-filament::dropdown> | ||
<x-filament::icon | ||
alias="filament-quick-create::add" | ||
icon="heroicon-o-plus" | ||
class="w-5 h-5" | ||
/> | ||
@if ($label) | ||
<span class="">{{ $label }}</span> | ||
@endif | ||
</button> | ||
</x-slot> | ||
|
||
<x-filament::dropdown.list> | ||
@foreach($resources as $resource) | ||
<x-filament::dropdown.list.item | ||
:icon="$hiddenIcons ? null : $resource['icon']" | ||
:wire:click="$resource['action']" | ||
:href="$resource['url']" | ||
:tag="$resource['url'] ? 'a' : 'button'" | ||
> | ||
{{ $resource['label'] }} | ||
</x-filament::dropdown.list.item> | ||
@endforeach | ||
</x-filament::dropdown.list> | ||
</x-filament::dropdown> | ||
|
||
<x-filament-actions::modals /> | ||
@endif | ||
<x-filament-actions::modals/> | ||
@endif | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters