199ocero / activity-timeline

Add timelines to custom pages or infolist entries effortlessly. Plus, it teams up smoothly with Spatie Activitylog for easy tracking.
https://filamentphp.com/plugins/jaocero-activity-timeline
MIT License
65 stars 18 forks source link

Add possibility to animate icon #32

Open agencetwogether opened 1 month ago

agencetwogether commented 1 month ago

Hello,

I made a little contribution, a possibility to animate icon in activity timeline according to tailwind presets animation (animate-spin, animate-pin, animate-pulse, animate-bounce)

So for example, if you want animate an icon you can use

ActivityIcon::make('status')
 //with Enum
 //->animation(IconAnimation::Pulse)
 //or with a closure
  ->animation(fn (?string $state) => match ($state) {
      'current' => IconAnimation::Pulse,
      default => null,
  })
  //or with a string
  ->animation('animate-ping')
  ->icon(fn (?string $state): ?string => match ($state) {
      'current' => 'heroicon-m-light-bulb',
      default => 'heroicon-o-light-bulb',
  })

Closure, Enum, or string are possibilities.