New Project Structure: - Created reusable UI components (ServiceCard, AnimatedSection, SectionTitle) - Split large components into smaller, focused ones - Extracted shared hooks for common functionality - Organized constants into separate files Key Improvements: - Hooks: useScrollNavigation, useScrollToSection, useCookieSettings - UI Components: Modular components for consistent styling and behavior - Constants: Centralized data management (ServicesData, NavigationData) - Component Split: Navbar, Hero, and Footer broken into logical sub-components
18 lines
514 B
TypeScript
18 lines
514 B
TypeScript
'use client';
|
|
|
|
import { useEffect } from 'react';
|
|
|
|
export const useScrollToSection = () => {
|
|
useEffect(() => {
|
|
const scrollToId = localStorage.getItem('scrollToId');
|
|
if (scrollToId) {
|
|
localStorage.removeItem('scrollToId');
|
|
const el = document.getElementById(scrollToId);
|
|
if (el) {
|
|
setTimeout(() => {
|
|
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
}, 200);
|
|
}
|
|
}
|
|
}, []);
|
|
}; |