Skip to content

Commit 8d3a24e

Browse files
committed
add icon animation
1 parent e0ccc67 commit 8d3a24e

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

resources/views/infolists/components/activity-icon.blade.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1+
@php
2+
use JaOcero\ActivityTimeline\Enums\IconAnimation;
3+
@endphp
14
@if ($icon = $getIcon($getState()))
25
@php
36
$color = $getColor($getState()) ?? 'gray';
7+
$animation = $getAnimation($getState());
48
@endphp
59

6-
<div class="relative flex items-center justify-center w-8 h-8">
10+
<div @class([
11+
'relative flex items-center justify-center w-8 h-8',
12+
match ($animation) {
13+
IconAnimation::Spin, 'spin' => 'animate-spin',
14+
IconAnimation::Ping, 'ping' => 'animate-ping',
15+
IconAnimation::Pulse, 'pulse' => 'animate-pulse',
16+
IconAnimation::Bounce, 'bounce' => 'animate-bounce',
17+
default => $animation,
18+
},
19+
])>
720
<span @class([
821
'flex flex-shrink-0 p-[5px] w-8 h-8 justify-center items-center dark:border rounded-full dark:bg-gray-800 dark:border-gray-700',
922
match ($color) {

src/Components/ActivityIcon.php

+18
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,32 @@
22

33
namespace JaOcero\ActivityTimeline\Components;
44

5+
use Closure;
56
use Filament\Infolists\Components\IconEntry;
7+
use JaOcero\ActivityTimeline\Enums\IconAnimation;
68

79
class ActivityIcon extends IconEntry
810
{
911
protected string $viewIdentifier = 'activityIcon';
1012

13+
protected IconAnimation|string|Closure|null $animation = null;
14+
1115
protected string $view = 'activity-timeline::infolists.components.activity-icon';
1216

17+
public function animation(IconAnimation|string|Closure|null $animation): static
18+
{
19+
$this->animation = $animation;
20+
21+
return $this;
22+
}
23+
24+
public function getAnimation(mixed $state): IconAnimation|string|null
25+
{
26+
return $this->evaluate($this->animation, [
27+
'state' => $state,
28+
]);
29+
}
30+
1331
public function getViewIdentifier(): string
1432
{
1533
return $this->viewIdentifier;

src/Enums/IconAnimation.php

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace JaOcero\ActivityTimeline\Enums;
4+
5+
enum IconAnimation: string
6+
{
7+
case Spin = 'spin';
8+
9+
case Ping = 'ping';
10+
11+
case Pulse = 'pulse';
12+
13+
case Bounce = 'bounce';
14+
}

0 commit comments

Comments
 (0)