# 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**:
```typescript
interface HeaderProps {
locale: string;
siteName?: string;
logo?: string;
}
```
**Usage**:
```tsx
```
### 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**:
```typescript
interface FooterProps {
locale: string;
siteName?: string;
}
```
**Usage**:
```tsx
```
### 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**:
```typescript
interface LayoutProps {
children: ReactNode;
locale: string;
siteName?: string;
logo?: string;
showSidebar?: boolean; // Future use
breadcrumb?: Array<{ title: string; path: string }>;
}
```
**Usage**:
```tsx
{/* Your page content */}
```
### 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**:
```typescript
interface MobileMenuProps {
locale: string;
siteName: string;
onClose?: () => void;
}
```
**Usage**:
```tsx
```
### 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**:
```typescript
interface NavigationProps {
locale: string;
variant?: 'header' | 'footer';
}
```
**Usage**:
```tsx
```
## Integration with Existing Structure
### Updated Main Layout (`app/[locale]/layout.tsx`)
The main application layout has been updated to use the new Layout component:
```tsx
export default function LocaleLayout({
children,
params: { locale },
}: {
children: React.ReactNode;
params: { locale: string };
}) {
return (
<>
{children}
>
);
}
```
### 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
```tsx
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 (
My Page Content
{/* Your content here */}
);
}
```
### Page with Breadcrumb
```tsx
export default function ProductPage({ params: { locale } }: { params: { locale: string } }) {
const breadcrumb = [
{ title: 'Products', path: `/${locale}/products` },
{ title: 'Product Name', path: `/${locale}/products/123` }
];
return (
{/* Product details */}
);
}
```
## Testing the Components
A comprehensive example page has been created at `/[locale]/example` that demonstrates:
1. **Header functionality** - sticky behavior, mobile menu
2. **Footer layout** - all columns and sections
3. **Mobile menu** - slide-out drawer with all features
4. **Breadcrumb support** - navigation hierarchy
5. **UI components** - buttons, cards, badges, grids
6. **Integration patterns** - how to use in real pages
### Access the Demo
- Navigate to `/en/example` to see the full demo
- Navigate to `/en/example/subpage` to see breadcrumb functionality
- Test on mobile devices to see responsive behavior
## Benefits
1. **Consistency**: All pages use the same layout structure
2. **Maintainability**: Centralized layout logic
3. **Flexibility**: Easy to customize per page
4. **Performance**: Optimized components with proper TypeScript
5. **Accessibility**: Semantic HTML and ARIA attributes
6. **Internationalization**: Built-in locale support
7. **Responsive**: Works seamlessly across all devices
## Future Enhancements
The layout system is designed to be extensible:
1. **Sidebar Support**: The `showSidebar` prop is ready for future use
2. **Dynamic Menus**: Can be enhanced to fetch from CMS/API
3. **Theme Support**: Ready for dark mode implementation
4. **Sticky Footer**: Can be added as needed
5. **Skip Links**: For better accessibility
## Migration Guide
To migrate existing pages to use the new layout system:
1. **Replace direct imports**:
```tsx
// Old
import { Navigation } from '@/components/Navigation';
// New
import { Layout } from '@/components/layout/Layout';
```
2. **Wrap content in Layout**:
```tsx
// Old
{children}
// New
{children}
```
3. **Use Container for content**:
```tsx
{/* Your content */}
```
## 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.