Skip to content

Commit 559387f

Browse files
committed
✨ added Rotating Complete Button
1 parent 5854159 commit 559387f

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const metadata = {
2+
title: 'Rotating Complete Button',
3+
description:
4+
'A button that rotates when clicked and shows a checkmark when completed.',
5+
}
6+
7+
<BackButton href="/components/button" />
8+
9+
<ComponentPreview path="components/button/RotatingCompleteButton" />
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'use client'
2+
3+
import { motion } from 'framer-motion'
4+
import { Check, ChevronRight, Zap } from 'lucide-react'
5+
import React, { useEffect } from 'react'
6+
7+
const RotatingCompleteButton = () => {
8+
const [isOpen, setIsOpen] = React.useState(false)
9+
10+
useEffect(() => {
11+
if (isOpen) {
12+
setTimeout(() => {
13+
setIsOpen(false)
14+
}, 2000)
15+
}
16+
}, [isOpen])
17+
18+
return (
19+
<motion.button
20+
className={`rounded-full ${
21+
isOpen ? 'bg-green-500' : 'bg-red-500'
22+
} px-4 py-2 font-semibold text-white`}
23+
animate={{
24+
rotate: isOpen ? 180 : 0,
25+
}}
26+
whileHover={{ scale: 1.05 }}
27+
whileTap={{ scale: 0.95 }}
28+
onClick={() => setIsOpen(!isOpen)}
29+
>
30+
<motion.span
31+
initial={{ opacity: 0 }}
32+
animate={{ opacity: 1 }}
33+
exit={{ opacity: 0 }}
34+
>
35+
{isOpen ? (
36+
<span className="flex rotate-180 items-center gap-1 text-sm font-medium">
37+
Marked as complete <Check size={16} />
38+
</span>
39+
) : (
40+
<span className="flex items-center gap-1 text-sm font-medium">
41+
Mark as complete <ChevronRight size={16} />
42+
</span>
43+
)}
44+
</motion.span>
45+
</motion.button>
46+
)
47+
}
48+
49+
export default RotatingCompleteButton

src/showcase/ui-group/ButtonCards.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import MagneticButton from '../components/button/MagneticButton'
1212
import StarWarsButton from '../components/button/StarWarsButton'
1313
import TextRevealButton from '../components/button/TextRevealButton'
1414
import Card from './Card'
15+
import RotatingCompleteButton from '@/showcase/components/button/3DButton'
1516

1617
const data = [
1718
{
@@ -55,6 +56,11 @@ const data = [
5556
link: '/components/button/text-reveal-button',
5657
component: <TextRevealButton />,
5758
},
59+
{
60+
title: 'Rotating Complete',
61+
link: '/components/button/rotating-complete-button',
62+
component: <RotatingCompleteButton />,
63+
},
5864
{
5965
title: 'Bounce',
6066
link: '/components/button/bounce-button',

0 commit comments

Comments
 (0)