lu-atom
animateicons/lu-atomFreeComponent
animateicons publishes no description for this item.
Install it
npx shadcn@latest add https://animateicons.in/r/lu-atom.jsonSource
1"use client";23import { cn } from "@/lib/utils";4import type { Variants } from "motion/react";5import {6 LazyMotion,7 domMin,8 m,9 useAnimation,10 useReducedMotion,11} from "motion/react";12import {13 forwardRef,14 useCallback,15 useImperativeHandle,16 useRef,17 type HTMLAttributes,18} from "react";19export interface AtomIconHandle {20 startAnimation: () => void;21 stopAnimation: () => void;22}2324interface AtomIconProps extends Omit<25 HTMLAttributes<HTMLDivElement>,26 | "color"27 | "onDrag"28 | "onDragStart"29 | "onDragEnd"30 | "onAnimationStart"31 | "onAnimationEnd"32 | "onAnimationIteration"33> {34 size?: number;35 duration?: number;36 isAnimated?: boolean;37 color?: string;38}3940const AtomIcon = forwardRef<AtomIconHandle, AtomIconProps>(41 (42 {43 onMouseEnter,44 onMouseLeave,45 className,46 size = 24,47 duration = 1,48 isAnimated = true,49 color,50 ...props51 },52 ref,53 ) => {54 const controls = useAnimation();55 const reduced = useReducedMotion();56 const isControlled = useRef(false);5758 useImperativeHandle(ref, () => {59 isControlled.current = true;60 return {61 startAnimation: () =>62 reduced ? controls.start("normal") : controls.start("animate"),63 stopAnimation: () => controls.start("normal"),64 };65 });6667 const handleEnter = useCallback(68 (e?: React.MouseEvent<HTMLDivElement>) => {69 if (!isAnimated || reduced) return;70 if (!isControlled.current) controls.start("animate");71 else onMouseEnter?.(e as any);72 },73 [controls, reduced, isAnimated, onMouseEnter],74 );7576 const handleLeave = useCallback(77 (e: React.MouseEvent<HTMLDivElement>) => {78 if (!isControlled.current) {79 controls.start("normal");80 } else {81 onMouseLeave?.(e as any);82 }83 },84 [controls, onMouseLeave],85 );86 const pathVariants: Variants = {87 normal: {88 rotate: 0,89 scale: 1,90 transition: { duration: 0.3 * duration },91 },92 animate: {93 rotate: 360,94 scale: [1, 1.1, 1],95 transition: {96 duration: 2 * duration,97 ease: "linear",98 repeat: Infinity,99 },100 },101 };102 return (103 <LazyMotion features={domMin} strict>104 <m.div105 className={cn("inline-flex items-center justify-center", className)}106 onMouseEnter={handleEnter}107 onMouseLeave={handleLeave}108 {...props}109 style={{ color, ...props.style }}110 >111 <m.svg112 xmlns="http://www.w3.org/2000/svg"113 width={size}114 height={size}115 viewBox="0 0 24 24"116 fill="none"117 stroke="currentColor"118 strokeWidth="2"119// … truncated
What it pulls in
npm packages
Files it writes
More from animateicons
All 326 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| hu-activityhu-activity | animateicons | Components | Free | 1 dep | |
| hu-bookmarkhu-bookmark | animateicons | Components | Free | 1 dep | |
| hu-bookmark-checkhu-bookmark-check | animateicons | Components | Free | 1 dep | |
| hu-bookmark-minushu-bookmark-minus | animateicons | Components | Free | 1 dep | |
| hu-bookmark-removehu-bookmark-remove | animateicons | Components | Free | 1 dep | |
| hu-checkhu-check | animateicons | Components | Free | 1 dep | |
| hu-check-checkhu-check-check | animateicons | Components | Free | 1 dep | |
| hu-chevron-righthu-chevron-right | animateicons | Components | Free | 1 dep |
