From 075359d1dbd6dc53ca82048b4d2533fa59ebf98c Mon Sep 17 00:00:00 2001 From: Richard Bergsma Date: Sat, 7 Jun 2025 14:05:28 +0200 Subject: [PATCH] Refactor ContributionCalendar component by removing mobile scroll indicator - Eliminated the scroll indicator functionality for mobile users to streamline the component. - Retained calendar reference for future use while simplifying the rendering logic. - Adjusted related useEffect hooks to enhance performance and maintainability. --- src/components/ContributionCalendar.jsx | 38 ++----------------------- 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/src/components/ContributionCalendar.jsx b/src/components/ContributionCalendar.jsx index 5f63b96..74bb133 100644 --- a/src/components/ContributionCalendar.jsx +++ b/src/components/ContributionCalendar.jsx @@ -95,25 +95,6 @@ export default function ContributionCalendar({ data }) { const visibleDays = days.slice(startWeek * 7, 52 * 7); const visibleMonthLabels = monthLabels.filter(l => l.week >= startWeek); - // Scroll indicator for mobile - const [showScrollHint, setShowScrollHint] = useState(false); - const calendarRef = React.useRef(null); - useEffect(() => { - if (!isMobile) return; - const el = calendarRef.current; - if (!el) return; - const checkScroll = () => { - setShowScrollHint(el.scrollWidth > el.clientWidth && el.scrollLeft < 16); - }; - checkScroll(); - el.addEventListener('scroll', checkScroll); - window.addEventListener('resize', checkScroll); - return () => { - el.removeEventListener('scroll', checkScroll); - window.removeEventListener('resize', checkScroll); - }; - }, [isMobile, expanded]); - // When expanding to full year on mobile, scroll to the right (most recent weeks) useEffect(() => { if (!isMobile) return; @@ -130,6 +111,8 @@ export default function ContributionCalendar({ data }) { // Get max count for scaling (optional, for more dynamic color) // const max = Math.max(...Object.values(data)); + const calendarRef = React.useRef(null); + return (
- {/* Scroll indicator for mobile */} - {isMobile && showScrollHint && ( -
- ⬅️➡️ Scroll -
- )} {/* Month labels */}