Improve project structure.
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
This commit is contained in:
11
frontend/hooks/useCookieSettings.ts
Normal file
11
frontend/hooks/useCookieSettings.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback } from 'react';
|
||||
|
||||
export const useCookieSettings = () => {
|
||||
const openCookieSettings = useCallback(() => {
|
||||
window.dispatchEvent(new Event('show-cookie-banner'));
|
||||
}, []);
|
||||
|
||||
return { openCookieSettings };
|
||||
};
|
||||
32
frontend/hooks/useScrollNavigation.ts
Normal file
32
frontend/hooks/useScrollNavigation.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
'use client';
|
||||
|
||||
import { usePathname, useRouter } from 'next/navigation';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
export const useScrollNavigation = () => {
|
||||
const pathname = usePathname();
|
||||
const router = useRouter();
|
||||
|
||||
const handleNavClick = useCallback((id: string) => {
|
||||
if (typeof window === 'undefined') return;
|
||||
|
||||
if (pathname === '/') {
|
||||
const el = document.getElementById(id);
|
||||
if (el) {
|
||||
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}
|
||||
} else {
|
||||
localStorage.setItem('scrollToId', id);
|
||||
router.push('/');
|
||||
}
|
||||
}, [pathname, router]);
|
||||
|
||||
const scrollToSection = useCallback((id: string) => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) {
|
||||
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}
|
||||
}, []);
|
||||
|
||||
return { handleNavClick, scrollToSection };
|
||||
};
|
||||
18
frontend/hooks/useScrollToSection.ts
Normal file
18
frontend/hooks/useScrollToSection.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
'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);
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
};
|
||||
Reference in New Issue
Block a user