File tree Expand file tree Collapse file tree 3 files changed +64
-0
lines changed
app/(docs)/components/button/rotating-complete-button Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 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" />
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import MagneticButton from '../components/button/MagneticButton'
1212import StarWarsButton from '../components/button/StarWarsButton'
1313import TextRevealButton from '../components/button/TextRevealButton'
1414import Card from './Card'
15+ import RotatingCompleteButton from '@/showcase/components/button/3DButton'
1516
1617const 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' ,
You can’t perform that action at this time.
0 commit comments