atom
lucide-animated-pqoqubbw/atomFreeComponent
lucide-animated publishes no description for this item.
Install it
npx shadcn@latest add https://lucide-animated.com/r/atom.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 AtomIconHandle {11 startAnimation: () => void;12 stopAnimation: () => void;13}1415interface AtomIconProps extends HTMLAttributes<HTMLDivElement> {16 size?: number;17}1819const PATH_VARIANTS: Variants = {20 normal: (custom: number) => ({21 opacity: 1,22 pathLength: 1,23 pathOffset: 0,24 transition: {25 duration: 0.4,26 ease: "easeInOut",27 delay: custom,28 },29 }),30 animate: (custom: number) => ({31 opacity: [0, 1],32 pathLength: [0, 1],33 pathOffset: [1, 0],34 transition: {35 duration: 0.4,36 ease: "easeInOut",37 delay: custom,38 },39 }),40};4142const AtomIcon = forwardRef<AtomIconHandle, AtomIconProps>(43 ({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {44 const controls = useAnimation();45 const isControlledRef = useRef(false);4647 useImperativeHandle(ref, () => {48 isControlledRef.current = true;4950 return {51 startAnimation: () => controls.start("animate"),52 stopAnimation: () => controls.start("normal"),53 };54 });5556 const handleMouseEnter = useCallback(57 (e: React.MouseEvent<HTMLDivElement>) => {58 if (isControlledRef.current) {59 onMouseEnter?.(e);60 } else {61 controls.start("animate");62 }63 },64 [controls, onMouseEnter]65 );6667 const handleMouseLeave = useCallback(68 (e: React.MouseEvent<HTMLDivElement>) => {69 if (isControlledRef.current) {70 onMouseLeave?.(e);71 } else {72 controls.start("normal");73 }74 },75 [controls, onMouseLeave]76 );7778 return (79 <div80 className={cn(className)}81 onMouseEnter={handleMouseEnter}82 onMouseLeave={handleMouseLeave}83 {...props}84 >85 <svg86 fill="none"87 height={size}88 stroke="currentColor"89 strokeLinecap="round"90 strokeLinejoin="round"91 strokeWidth="2"92 viewBox="0 0 24 24"93 width={size}94 xmlns="http://www.w3.org/2000/svg"95 >96 <motion.circle97 animate={controls}98 custom={0}99 cx="12"100 cy="12"101 r="1"102 variants={PATH_VARIANTS}103 />104// … truncated
What it pulls in
npm packages
Files it writes
More from lucide-animated
All 466 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 | |
| activityactivity | 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 |
