-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from lara-zeus/support-hover
add support for hover trigger
- Loading branch information
Showing
5 changed files
with
70 additions
and
54 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
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
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,40 +1,48 @@ | ||
<div x-data class="fi-popover"> | ||
@php | ||
$getState = $getState(); | ||
$getTrigger = $getTrigger(); | ||
$getPlacement = $getPlacement(); | ||
$getOffset = $getOffset(); | ||
$getPopOverMaxWidth = $getPopOverMaxWidth(); | ||
$getIcon = $getIcon($getState); | ||
@endphp | ||
<template x-ref="template"> | ||
<div class="fi-popover-content"> | ||
{{ $getContent() }} | ||
</div> | ||
</template> | ||
@php | ||
$getState = $getState(); | ||
$getTrigger = $getTrigger(); | ||
$getPlacement = $getPlacement(); | ||
$getOffset = $getOffset(); | ||
$getPopOverMaxWidth = $getPopOverMaxWidth(); | ||
$getIcon = $getIcon($getState); | ||
$getContent = $getContent(); | ||
@endphp | ||
<div | ||
wire:key="{{ $this->getId() }}.entry.record.{{ $getName() }}" | ||
x-data="{ open: false }" | ||
|
||
<button | ||
class="w-full fi-popover-trigger cursor-pointer flex items-center gap-2" | ||
x-tooltip="{ | ||
trigger: '{{ $getTrigger }}', | ||
placement: '{{ $getPlacement }}', | ||
offset: @js($getOffset), | ||
maxWidth: '{{ $getPopOverMaxWidth }}', | ||
content: () => $refs.template.innerHTML, | ||
appendTo: $root, | ||
allowHTML: true, | ||
interactive: true, | ||
theme: $store.theme, | ||
}"> | ||
@if($getTrigger === 'hover') | ||
@pointerleave="clearTimeout($time); open = false" | ||
@else | ||
@click.away="open = false" | ||
@endif | ||
|
||
class="fi-popover grid w-full gap-y-1 px-3 py-4" | ||
> | ||
<div | ||
class="relative w-full fi-popover-trigger cursor-pointer flex items-center gap-2" | ||
x-ref="button" | ||
@if($getTrigger === 'hover') | ||
@pointerenter="$time = setTimeout(() => { open = true }, 200)" | ||
@else | ||
@click="open = ! open" | ||
@endif | ||
> | ||
{{ $getState }} | ||
|
||
@if($getIcon) | ||
<x-filament::icon | ||
:icon="$getIcon" | ||
class="h-5 w-5 text-gray-500 dark:text-gray-400" | ||
:icon="$getIcon" | ||
class="h-5 w-5 text-gray-500 dark:text-gray-400" | ||
/> | ||
@endif | ||
</button> | ||
</div> | ||
|
||
<div class="z-50 fi-popover-content w-[{{ $getPopOverMaxWidth }}px] border border-gray-500 shadow-lg bg-white dark:bg-gray-800" | ||
x-cloak x-trap="open" | ||
x-show="open" | ||
x-anchor.{{ $getPlacement }}.offset.{{ $getOffset }}="$refs.button" | ||
> | ||
{{ $getContent }} | ||
</div> | ||
</div> |