첫 커밋
This commit is contained in:
26
src/shared/ui/reset-button/index.tsx
Normal file
26
src/shared/ui/reset-button/index.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import clsx from 'clsx';
|
||||
import { motion, useAnimation } from 'framer-motion';
|
||||
|
||||
interface RefreshButtonProps {
|
||||
onClick: () => void;
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
export const RefreshButton = ({ onClick, children }: RefreshButtonProps) => {
|
||||
const controls = useAnimation();
|
||||
const handleReset = async () => {
|
||||
controls.start({
|
||||
rotate: 360,
|
||||
transition: { duration: 0.4 },
|
||||
});
|
||||
controls.set({ rotate: 0 });
|
||||
onClick?.();
|
||||
};
|
||||
return (
|
||||
<button type="button" onClick={handleReset} className="flex flex-row">
|
||||
{children}
|
||||
<motion.div className={clsx('btn reset-btn')} animate={controls}>
|
||||
<span>reset</span>
|
||||
</motion.div>
|
||||
</button>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user