activity
lucide-animated-pqoqubbw/activityFreeComponent
lucide-animated publishes no description for this item.
Install it
npx shadcn@latest add https://lucide-animated.com/r/activity.jsonSource
1"use client";23import type { Variants } from "motion/react";4import { motion, useAnimation } from "motion/react";5import type { HTMLAttributes } from "react";6import { forwardRef, useCallback, useImperativeHandle, useRef } from "react";78import { cn } from "@/lib/utils";910export interface ActivityIconHandle {11 startAnimation: () => void;12 stopAnimation: () => void;13}1415interface ActivityIconProps extends HTMLAttributes<HTMLDivElement> {16 size?: number;17}1819const VARIANTS: Variants = {20 normal: {21 opacity: 1,22 pathLength: 1,23 pathOffset: 0,24 transition: {25 duration: 0.4,26 opacity: { duration: 0.1 },27 },28 },29 animate: {30 opacity: [0, 1],31 pathLength: [0, 1],32 pathOffset: [1, 0],33 transition: {34 duration: 0.6,35 ease: "linear",36 opacity: { duration: 0.1 },37 },38 },39};4041const ActivityIcon = forwardRef<ActivityIconHandle, ActivityIconProps>(42 ({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {43 const controls = useAnimation();44 const isControlledRef = useRef(false);4546 useImperativeHandle(ref, () => {47 isControlledRef.current = true;4849 return {50 startAnimation: () => controls.start("animate"),51 stopAnimation: () => controls.start("normal"),52 };53 });5455 const handleMouseEnter = useCallback(56 (e: React.MouseEvent<HTMLDivElement>) => {57 if (isControlledRef.current) {58 onMouseEnter?.(e);59 } else {60 controls.start("animate");61 }62 },63 [controls, onMouseEnter]64 );6566 const handleMouseLeave = useCallback(67 (e: React.MouseEvent<HTMLDivElement>) => {68 if (isControlledRef.current) {69 onMouseLeave?.(e);70 } else {71 controls.start("normal");72 }73 },74 [controls, onMouseLeave]75 );7677 return (78 <div79 className={cn(className)}80 onMouseEnter={handleMouseEnter}81 onMouseLeave={handleMouseLeave}82 {...props}83 >84 <svg85 fill="none"86 height={size}87 stroke="currentColor"88 strokeLinecap="round"89 strokeLinejoin="round"90 strokeWidth="2"91 viewBox="0 0 24 24"92 width={size}93 xmlns="http://www.w3.org/2000/svg"94 >95 <motion.path96 animate={controls}97 d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"98// … truncated
What it pulls in
npm packages
Files it writes
More from lucide-animated
All 464 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| a-arrow-downa-arrow-down | lucide-animated | Components | Free | 1 dep | |
| a-arrow-upa-arrow-up | lucide-animated | Components | Free | 1 dep | |
| accessibilityaccessibility | lucide-animated | Components | Free | 1 dep | |
| air-ventair-vent | lucide-animated | Components | Free | 1 dep | |
| airplaneairplane | lucide-animated | Components | Free | 1 dep | |
| airplayairplay | lucide-animated | Components | Free | 1 dep | |
| alarm-clockalarm-clock | lucide-animated | Components | Free | 1 dep | |
| alarm-clock-checkalarm-clock-check | lucide-animated | Components | Free | 1 dep |
