Files
klz-cables.com/LAYOUT_COMPONENTS_SUMMARY.md
2025-12-29 18:18:48 +01:00

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" />

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:

  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:

    // Old
    import { Navigation } from '@/components/Navigation';
    
    // New
    import { Layout } from '@/components/layout/Layout';
    
  2. Wrap content in Layout:

    // Old
    <Navigation siteName="KLZ Cables" locale={locale} />
    <main>{children}</main>
    
    // New
    <Layout locale={locale} siteName="KLZ Cables">
      {children}
    </Layout>
    
  3. 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.