Skip to content

Commit 96995f5

Browse files
committed
fixed highlight for mobile
1 parent 9422482 commit 96995f5

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/pages/community/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,22 @@ export default function CommunityPage(): JSX.Element {
159159
const scrollToSection = (sectionId: string) => {
160160
const element = document.getElementById(sectionId);
161161
if (element) {
162-
const offset = 80;
162+
const offset = 80;
163163
const top = element.offsetTop - offset;
164164
window.scrollTo({ top, behavior: "smooth" });
165165
setSelectedSection(sectionId);
166166
}
167167
};
168168

169+
const [isMobile, setIsMobile] = useState(false);
170+
171+
useEffect(() => {
172+
const checkMobile = () => setIsMobile(window.innerWidth < 768);
173+
checkMobile();
174+
window.addEventListener('resize', checkMobile);
175+
return () => window.removeEventListener('resize', checkMobile);
176+
}, []);
177+
169178

170179
return (
171180
<Layout
@@ -236,7 +245,10 @@ export default function CommunityPage(): JSX.Element {
236245
<motion.div
237246
key={section.id}
238247
id={section.id}
239-
className={`contribution-section ${selectedSection === section.id ? 'selected' : ''}`}
248+
className={`contribution-section ${(isMobile ? activeSections.includes(section.id) : selectedSection === section.id)
249+
? 'selected'
250+
: ''
251+
}`}
240252
initial={{ opacity: 0, y: 30 }}
241253
animate={{ opacity: 1, y: 0 }}
242254
transition={{ duration: 0.6, delay: 0.1 * index }}

0 commit comments

Comments
 (0)