Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | 'use client';
import { forwardRef } from 'react';
import { cn } from '@/lib/core';
import { SectionProps, InlineContainerProps, PageHeaderProps } from '@/types/layout';
const paddingMap = {
none: '',
sm: 'py-8',
md: 'py-12',
lg: 'py-16',
xl: 'py-24'};
const variantMap = {
default: 'bg-white',
gray: 'bg-gray-50',
dark: 'bg-dark text-white',
blue: 'bg-blue-50'};
/**
* Section - Page section wrapper with consistent spacing
*
* Features:
* - Consistent vertical padding
* - Background color variants
* - Optional container wrapper
* - Semantic HTML elements
*
* @example
* ```tsx
* // Basic section with medium padding
* <Section padding="md">
* <h2>Section Title</h2>
* <p>Content</p>
* </Section>
*
* // Gray background with large padding
* <Section variant="gray" padding="lg">
* <Features />
* </Section>
*
* // Full width section
* <Section fullWidth>
* <Hero />
* </Section>
* ```
*/
export const Section = forwardRef<HTMLElement, SectionProps>(
(
{
padding = 'md',
variant = 'default',
fullWidth = false,
as: Component = 'section',
className,
children,
...props
},
ref
) => {
return (
<Component
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ref={ref as any}
className={cn(
paddingMap[padding],
variantMap[variant],
className
)}
{...props}
>
{fullWidth ? children : <Container>{children}</Container>}
</Component>
);
}
);
Section.displayName = 'Section';
const sizeMap = {
sm: 'max-w-3xl',
md: 'max-w-5xl',
lg: 'max-w-7xl',
xl: 'max-w-[1400px]',
full: 'max-w-full'};
/**
* Container - Responsive content container
*
* Features:
* - Responsive max-width
* - Centered by default
* - Horizontal padding
* - Multiple size variants
*
* @example
* ```tsx
* // Default container (centered, lg)
* <Container>
* <Content />
* </Container>
*
* // Small container
* <Container size="sm">
* <Article />
* </Container>
*
* // Full width container
* <Container size="full">
* <FullWidthContent />
* </Container>
* ```
*/
export const Container = forwardRef<HTMLDivElement, InlineContainerProps>(
(
{
size = 'lg',
center = true,
padding = true,
className,
children,
...props
},
ref
) => {
return (
<div
ref={ref}
className={cn(
'w-full',
sizeMap[size],
center && 'mx-auto',
padding && 'px-4 sm:px-6 lg:px-8',
className
)}
{...props}
>
{children}
</div>
);
}
);
Container.displayName = 'Container';
/**
* PageHeader - Consistent page header section
*/
export const PageHeader = forwardRef<HTMLElement, PageHeaderProps>(
({ title, description, center = false, className, children, ...props }, ref) => {
return (
<header
ref={ref}
className={cn(
'mb-8',
center && 'text-center',
className
)}
{...props}
>
<h1 className="text-3xl md:text-4xl font-bold text-dark mb-2">
{title}
</h1>
{description && (
<p className="text-lg text-gray-600 max-w-2xl">
{description}
</p>
)}
{children}
</header>
);
}
);
PageHeader.displayName = 'PageHeader';
|