8.0 KiB
Layout Components Summary
This document provides a comprehensive overview of the new layout components created for the KLZ Cables Next.js application.
Overview
The layout components provide a complete structure for all pages in the application, including responsive headers, footers, mobile navigation, and main layout wrappers. These components are built using the existing design system and UI components.
Components Created
1. Header Component (components/layout/Header.tsx)
Purpose: Provides the main site header with navigation, branding, and actions.
Features:
- Sticky positioning with shadow on scroll
- Logo/site branding with customizable text or image
- Desktop navigation menu
- Locale switcher integration
- Contact CTA button
- Mobile menu trigger
- Fully responsive design
Props:
interface HeaderProps {
locale: string;
siteName?: string;
logo?: string;
}
Usage:
<Header locale="en" siteName="KLZ Cables" />
2. Footer Component (components/layout/Footer.tsx)
Purpose: Comprehensive footer with company info, links, and contact details.
Features:
- 4-column responsive layout (stacks on mobile)
- Company information with description
- Quick links section
- Product categories section
- Contact information (email, phone, address)
- Social media links
- Legal links (Privacy, Terms, Imprint)
- Copyright notice with current year
Props:
interface FooterProps {
locale: string;
siteName?: string;
}
Usage:
<Footer locale="en" siteName="KLZ Cables" />
3. Layout Component (components/layout/Layout.tsx)
Purpose: Main layout wrapper that orchestrates Header, Footer, and content area.
Features:
- Wraps entire page structure
- Optional breadcrumb support
- Flexible content area
- Support for different page layouts
- Proper spacing and padding
- Semantic HTML structure
Props:
interface LayoutProps {
children: ReactNode;
locale: string;
siteName?: string;
logo?: string;
showSidebar?: boolean; // Future use
breadcrumb?: Array<{ title: string; path: string }>;
}
Usage:
<Layout
locale="en"
siteName="KLZ Cables"
breadcrumb={[
{ title: 'Products', path: '/en/products' },
{ title: 'Details', path: '/en/products/123' }
]}
>
{/* Your page content */}
</Layout>
4. MobileMenu Component (components/layout/MobileMenu.tsx)
Purpose: Slide-out drawer for mobile navigation.
Features:
- Hamburger toggle button
- Smooth slide-in animation
- Overlay backdrop
- Main navigation links
- Product categories
- Language switcher
- Contact information
- CTA button
- Auto-close on route change
- Accessibility support (ARIA labels)
Props:
interface MobileMenuProps {
locale: string;
siteName: string;
onClose?: () => void;
}
Usage:
<MobileMenu locale="en" siteName="KLZ Cables" />
5. Navigation Component (components/layout/Navigation.tsx)
Purpose: Main navigation menu for both header and footer contexts.
Features:
- Active link highlighting
- Two variants: 'header' and 'footer'
- Responsive styling
- Smooth transitions
- TypeScript support
Props:
interface NavigationProps {
locale: string;
variant?: 'header' | 'footer';
}
Usage:
<Navigation locale="en" variant="header" />
<Navigation locale="en" variant="footer" />
Integration with Existing Structure
Updated Main Layout (app/[locale]/layout.tsx)
The main application layout has been updated to use the new Layout component:
export default function LocaleLayout({
children,
params: { locale },
}: {
children: React.ReactNode;
params: { locale: string };
}) {
return (
<>
<Layout
locale={locale}
siteName="KLZ Cables"
>
{children}
</Layout>
<CookieConsent />
</>
);
}
Backward Compatibility
The original Navigation.tsx component has been updated with:
- Deprecation notice
- Enhanced functionality
- Better integration with new layout
Design System Integration
All layout components use:
- Design Tokens: CSS custom properties for colors, spacing, typography
- UI Components: Button, Container, Grid, Card, Badge
- Utility Functions:
cn()for class merging, i18n utilities - Tailwind CSS: Consistent styling approach
Responsive Behavior
Desktop (> 768px)
- Full header with navigation
- 4-column footer layout
- Desktop navigation visible
Mobile (≤ 768px)
- Hamburger menu triggers mobile drawer
- Stacked footer columns
- Touch-optimized interactions
- Simplified navigation
Example Usage
Basic Page
import { Metadata } from 'next';
import { Layout } from '@/components/layout/Layout';
import { Container } from '@/components/ui/Container';
export const metadata: Metadata = {
title: 'My Page | KLZ Cables',
description: 'Page description',
};
export default function MyPage({ params: { locale } }: { params: { locale: string } }) {
return (
<Layout locale={locale} siteName="KLZ Cables">
<Container maxWidth="6xl" padding="md">
<h1>My Page Content</h1>
{/* Your content here */}
</Container>
</Layout>
);
}
Page with Breadcrumb
export default function ProductPage({ params: { locale } }: { params: { locale: string } }) {
const breadcrumb = [
{ title: 'Products', path: `/${locale}/products` },
{ title: 'Product Name', path: `/${locale}/products/123` }
];
return (
<Layout
locale={locale}
siteName="KLZ Cables"
breadcrumb={breadcrumb}
>
<Container maxWidth="6xl" padding="md">
{/* Product details */}
</Container>
</Layout>
);
}
Testing the Components
A comprehensive example page has been created at /[locale]/example that demonstrates:
- Header functionality - sticky behavior, mobile menu
- Footer layout - all columns and sections
- Mobile menu - slide-out drawer with all features
- Breadcrumb support - navigation hierarchy
- UI components - buttons, cards, badges, grids
- Integration patterns - how to use in real pages
Access the Demo
- Navigate to
/en/exampleto see the full demo - Navigate to
/en/example/subpageto see breadcrumb functionality - Test on mobile devices to see responsive behavior
Benefits
- Consistency: All pages use the same layout structure
- Maintainability: Centralized layout logic
- Flexibility: Easy to customize per page
- Performance: Optimized components with proper TypeScript
- Accessibility: Semantic HTML and ARIA attributes
- Internationalization: Built-in locale support
- Responsive: Works seamlessly across all devices
Future Enhancements
The layout system is designed to be extensible:
- Sidebar Support: The
showSidebarprop is ready for future use - Dynamic Menus: Can be enhanced to fetch from CMS/API
- Theme Support: Ready for dark mode implementation
- Sticky Footer: Can be added as needed
- Skip Links: For better accessibility
Migration Guide
To migrate existing pages to use the new layout system:
-
Replace direct imports:
// Old import { Navigation } from '@/components/Navigation'; // New import { Layout } from '@/components/layout/Layout'; -
Wrap content in Layout:
// Old <Navigation siteName="KLZ Cables" locale={locale} /> <main>{children}</main> // New <Layout locale={locale} siteName="KLZ Cables"> {children} </Layout> -
Use Container for content:
<Container maxWidth="6xl" padding="md"> {/* Your content */} </Container>
Conclusion
The new layout components provide a solid foundation for all pages in the KLZ Cables application. They are built with modern React practices, fully typed with TypeScript, and designed to be maintainable and extensible. The system integrates seamlessly with the existing design system and provides a consistent user experience across all devices.