Skip to content

Commit 2fd682d

Browse files
committed
tooltip
1 parent 4229c8e commit 2fd682d

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed
Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,32 @@
11
{{-- This renderIf method is implemented in every action --}}
22
@php
3-
$class = 'flex hover:text-blue-600 transition-all duration-300 ease-in-out focus:text-blue-600 active:text-blue-600"'
3+
$class = 'flex hover:text-blue-600 transition-all duration-300 ease-in-out focus:text-blue-600 active:text-blue-600"'
44
@endphp
55
@if ($action->renderIf($item))
6-
<a href="#!" title="{{$action->title}}" wire:click.prevent="executeAction('{{ $action->id }}', '{{ $item->getKey() }}', true)" class="{{ $class }}">
7-
{{ $slot }}
8-
</a>
6+
7+
<div x-data="{ tooltip: false }" class="cursor-pointer relative z-30 inline-flex"
8+
@mousemove.away="tooltip = false"
9+
>
10+
<button
11+
@mousemove="setInterval(function(){tooltip = false}, 2000); tooltip = true"
12+
@mouseleave="tooltip = false"
13+
wire:click.prevent="executeAction('{{ $action->id }}', '{{ $item->getKey() }}', true)"
14+
class="{{ $class }}">
15+
{{ $slot }}
16+
</button>
17+
<div class="relative" x-cloak x-show.transition.origin.top="tooltip"
18+
@mousemove="tooltip = false"
19+
>
20+
<div
21+
@mousemove="tooltip = false"
22+
class="flex justify-center absolute top-0 z-30 w-32 p-2 -mt-3 text-sm leading-tight text-white transform -translate-x-1/2 -translate-y-full bg-gray-400 rounded-md shadow-md">
23+
{{ $action->title }}
24+
</div>
25+
<svg class="absolute z-30 w-6 h-6 text-gray-400 transform -translate-x-8 -translate-y-5 fill-current stroke-current"
26+
width="8" height="8">
27+
<rect x="12" y="-10" width="8" height="8" transform="rotate(45)"/>
28+
</svg>
29+
</div>
30+
</div>
31+
932
@endif

src/Actions/Action.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ abstract class Action
77
/** @var String $title Title of the action */
88
public $title;
99

10+
/** @var String $tooltip Tooltip of the action */
11+
public $tooltip;
12+
1013
/** @var String $icon Feather icon name*/
1114
public $icon;
1215

0 commit comments

Comments
 (0)