2025-08-20 04:12:49 -06:00

92 lines
2.1 KiB
TypeScript

'use client';
import * as React from 'react';
import { motion, type Variants } from 'motion/react';
import {
getVariants,
useAnimateIconContext,
IconWrapper,
type IconProps,
} from '@/registry/icons/icon';
type StarProps = IconProps<keyof typeof animations>;
const animations = {
default: {
group: {
initial: {
scale: 1,
},
animate: {
scale: [1, 0.9, 1.2, 1],
transition: { duration: 0.6, ease: 'easeInOut' },
},
},
path: {},
} satisfies Record<string, Variants>,
fill: {
group: {
initial: {
scale: 1,
},
animate: {
scale: [1, 0.9, 1.2, 1],
transition: { duration: 0.6, ease: 'easeInOut' },
},
},
path: {
initial: {
fill: 'currentColor',
fillOpacity: 0,
},
animate: {
fillOpacity: 1,
transition: { delay: 0.2 },
},
},
} satisfies Record<string, Variants>,
} as const;
function IconComponent({ size, ...props }: StarProps) {
const { controls } = useAnimateIconContext();
const variants = getVariants(animations);
return (
<motion.svg
xmlns="http://www.w3.org/2000/svg"
width={size}
height={size}
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth={2}
strokeLinecap="round"
strokeLinejoin="round"
variants={variants.group}
initial="initial"
animate={controls}
{...props}
>
<motion.path
d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"
variants={variants.path}
initial="initial"
animate={controls}
/>
</motion.svg>
);
}
function Star(props: StarProps) {
return <IconWrapper icon={IconComponent} {...props} />;
}
export {
animations,
Star,
Star as StarIcon,
type StarProps,
type StarProps as StarIconProps,
};