MCPcopy Create free account
hub / github.com/SamuelZ12/longcut / LoadingTips

Function LoadingTips

components/loading-tips.tsx:40–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38];
39
40export function LoadingTips() {
41 const [currentTipIndex, setCurrentTipIndex] = useState(0);
42 const [isVisible, setIsVisible] = useState(true);
43 const [shuffledTips, setShuffledTips] = useState(TIPS);
44 const [isPaused, setIsPaused] = useState(false);
45
46 // Shuffle tips on mount
47 useEffect(() => {
48 const shuffled = [...TIPS].sort(() => Math.random() - 0.5);
49 setShuffledTips(shuffled);
50 }, []);
51
52 // Rotate tips
53 useEffect(() => {
54 if (isPaused) return;
55
56 const interval = setInterval(() => {
57 setIsVisible(false);
58
59 setTimeout(() => {
60 setCurrentTipIndex((prev) => (prev + 1) % shuffledTips.length);
61 setIsVisible(true);
62 }, 300);
63 }, 4000);
64
65 return () => clearInterval(interval);
66 }, [shuffledTips.length, isPaused]);
67
68 const handleDotClick = (index: number) => {
69 if (index === currentTipIndex) return;
70
71 setIsVisible(false);
72
73 setTimeout(() => {
74 setCurrentTipIndex(index);
75 setIsVisible(true);
76 }, 300);
77 };
78
79 const currentTip = shuffledTips[currentTipIndex];
80 const Icon = currentTip.icon;
81
82 return (
83 <Card
84 className="p-6 max-w-2xl mx-auto mt-6 relative"
85 onMouseEnter={() => setIsPaused(true)}
86 onMouseLeave={() => setIsPaused(false)}
87 >
88 <div
89 className={`transition-all duration-300 ${
90 isVisible ? "opacity-100 transform translate-y-0" : "opacity-0 transform -translate-y-2"
91 }`}
92 >
93 <div className="flex items-start gap-4">
94 <div className="flex-shrink-0">
95 <div className="w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center">
96 <Icon className="w-5 h-5 text-primary" />
97 </div>

Callers

nothing calls this directly

Calls 1

handleDotClickFunction · 0.85

Tested by

no test coverage detected