|
| 1 | +# HeaderBlock Usage Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +HeaderBlock is a versatile layout block that serves as the main header section of a page. It has been significantly enhanced with new content structure options, improved accessibility, and better responsive design integration. |
| 6 | + |
| 7 | +## Enhanced Properties |
| 8 | + |
| 9 | +### Content Structure |
| 10 | + |
| 11 | +#### `overtitle` |
| 12 | + |
| 13 | +- **Type**: `string | JSX.Element` |
| 14 | +- **Description**: Text or JSX element displayed above the main title |
| 15 | +- **Usage**: For category labels, breadcrumb-like navigation, or contextual information |
| 16 | + |
| 17 | +```json |
| 18 | +{ |
| 19 | + "type": "header-block", |
| 20 | + "overtitle": "Product Category", |
| 21 | + "title": "Main Product Title" |
| 22 | +} |
| 23 | +``` |
| 24 | + |
| 25 | +#### `additionalInfo` |
| 26 | + |
| 27 | +- **Type**: `string` |
| 28 | +- **Description**: Additional information displayed after the description |
| 29 | +- **Content Type**: YFM (Yandex Flavored Markdown) |
| 30 | +- **Usage**: For supplementary details, disclaimers, or extended descriptions |
| 31 | + |
| 32 | +```json |
| 33 | +{ |
| 34 | + "type": "header-block", |
| 35 | + "title": "Product Title", |
| 36 | + "description": "Main product description", |
| 37 | + "additionalInfo": "**Note**: Additional details about the product" |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +#### `status` |
| 42 | + |
| 43 | +- **Type**: `JSX.Element` |
| 44 | +- **Description**: Status element displayed next to the title |
| 45 | +- **Usage**: For badges, labels, or status indicators |
| 46 | + |
| 47 | +### Custom Rendering |
| 48 | + |
| 49 | +#### `renderTitle` |
| 50 | + |
| 51 | +- **Type**: `(title: string) => React.ReactNode` |
| 52 | +- **Description**: Function for custom title rendering |
| 53 | +- **Usage**: When you need custom title formatting or additional elements within the title |
| 54 | + |
| 55 | +### Media Enhancements |
| 56 | + |
| 57 | +#### `mediaView` |
| 58 | + |
| 59 | +- **Type**: `'full' | 'fit'` |
| 60 | +- **Default**: `'full'` |
| 61 | +- **Description**: Controls how media content is displayed |
| 62 | +- **Usage**: |
| 63 | + - `'full'`: Media fills the available space |
| 64 | + - `'fit'`: Media maintains aspect ratio within bounds |
| 65 | + |
| 66 | +#### `mediaClassName` |
| 67 | + |
| 68 | +- **Type**: `string` |
| 69 | +- **Description**: Additional CSS class for media elements |
| 70 | +- **Usage**: For custom styling of media content |
| 71 | + |
| 72 | +### Background Enhancements |
| 73 | + |
| 74 | +#### `fullWidthMedia` |
| 75 | + |
| 76 | +- **Type**: `boolean` |
| 77 | +- **Description**: Allows media backgrounds to extend to full viewport width |
| 78 | +- **Usage**: For immersive background experiences |
| 79 | + |
| 80 | +```json |
| 81 | +{ |
| 82 | + "type": "header-block", |
| 83 | + "title": "Immersive Header", |
| 84 | + "background": { |
| 85 | + "image": "background.jpg", |
| 86 | + "fullWidthMedia": true |
| 87 | + } |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +## Technical Implementation |
| 92 | + |
| 93 | +### Component Architecture |
| 94 | + |
| 95 | +The HeaderBlock now uses a component composition pattern: |
| 96 | + |
| 97 | +``` |
| 98 | +HeaderBlock |
| 99 | +├── Background (for media backgrounds) |
| 100 | +├── FullWidthBackground (for full-width backgrounds) |
| 101 | +└── Content Structure |
| 102 | + ├── overtitle |
| 103 | + ├── title (with custom rendering support) |
| 104 | + ├── description |
| 105 | + ├── additionalInfo |
| 106 | + └── buttons |
| 107 | +``` |
| 108 | + |
| 109 | +### Responsive Design |
| 110 | + |
| 111 | +- **WindowWidth Integration**: Uses `useWindowWidth` hook for responsive behavior |
| 112 | +- **Breakpoint Constants**: Leverages `BREAKPOINTS` constants for consistent responsive design |
| 113 | +- **Mobile Adaptation**: Enhanced mobile experience with conditional media rendering |
| 114 | + |
| 115 | +### Accessibility Features |
| 116 | + |
| 117 | +- **Unique IDs**: Uses `useUniqId()` hook for proper ARIA labeling |
| 118 | +- **ARIA Relationships**: Buttons are properly associated with titles using `aria-describedby` |
| 119 | +- **Screen Reader Support**: Improved content structure for better screen reader navigation |
| 120 | + |
| 121 | +### Background Components |
| 122 | + |
| 123 | +#### Background Component |
| 124 | + |
| 125 | +- Handles media backgrounds with video and image support |
| 126 | +- Mobile-responsive media rendering |
| 127 | +- Parallax support (disabled by default) |
| 128 | + |
| 129 | +#### FullWidthBackground Component |
| 130 | + |
| 131 | +- Renders full-width background colors |
| 132 | +- Used when `fullWidth` or `fullWidthMedia` is enabled |
| 133 | + |
| 134 | +## Usage Examples |
| 135 | + |
| 136 | +### Basic Enhanced Header |
| 137 | + |
| 138 | +```json |
| 139 | +{ |
| 140 | + "type": "header-block", |
| 141 | + "overtitle": "New Release", |
| 142 | + "title": "Product Launch 2024", |
| 143 | + "description": "Introducing our latest innovation", |
| 144 | + "additionalInfo": "Available in **limited quantities**", |
| 145 | + "buttons": [ |
| 146 | + { |
| 147 | + "text": "Learn More", |
| 148 | + "url": "/product", |
| 149 | + "theme": "action" |
| 150 | + } |
| 151 | + ] |
| 152 | +} |
| 153 | +``` |
| 154 | + |
| 155 | +### Header with Full-Width Media Background |
| 156 | + |
| 157 | +```json |
| 158 | +{ |
| 159 | + "type": "header-block", |
| 160 | + "title": "Immersive Experience", |
| 161 | + "description": "Full-width background showcase", |
| 162 | + "background": { |
| 163 | + "image": { |
| 164 | + "src": "hero-background.jpg", |
| 165 | + "alt": "Hero background" |
| 166 | + }, |
| 167 | + "fullWidthMedia": true, |
| 168 | + "color": "#1a1a1a" |
| 169 | + }, |
| 170 | + "theme": "dark" |
| 171 | +} |
| 172 | +``` |
| 173 | + |
| 174 | +### Header with Custom Media View |
| 175 | + |
| 176 | +```json |
| 177 | +{ |
| 178 | + "type": "header-block", |
| 179 | + "title": "Product Showcase", |
| 180 | + "description": "Featured product display", |
| 181 | + "image": { |
| 182 | + "src": "product-image.jpg", |
| 183 | + "alt": "Product showcase" |
| 184 | + }, |
| 185 | + "mediaView": "fit", |
| 186 | + "mediaClassName": "custom-media-style" |
| 187 | +} |
| 188 | +``` |
| 189 | + |
| 190 | +## Migration Notes |
| 191 | + |
| 192 | +### New Properties |
| 193 | + |
| 194 | +- All new properties are optional and backward compatible |
| 195 | +- Existing HeaderBlock configurations will continue to work unchanged |
| 196 | + |
| 197 | +### Enhanced Features |
| 198 | + |
| 199 | +- Improved accessibility is automatically applied |
| 200 | +- Responsive design enhancements are enabled by default |
| 201 | +- Background rendering improvements are transparent to existing usage |
| 202 | + |
| 203 | +### Deprecated Properties |
| 204 | + |
| 205 | +- Some legacy properties may be deprecated in future versions |
| 206 | +- Check the schema for current property status |
| 207 | + |
| 208 | +## Best Practices |
| 209 | + |
| 210 | +1. **Content Hierarchy**: Use `overtitle` for contextual information, `title` for main heading, `description` for primary details, and `additionalInfo` for supplementary content |
| 211 | + |
| 212 | +2. **Accessibility**: Always provide meaningful `alt` text for images and ensure proper content structure |
| 213 | + |
| 214 | +3. **Responsive Design**: Test headers across different screen sizes, especially when using custom media configurations |
| 215 | + |
| 216 | +4. **Performance**: Use appropriate image sizes and formats for background media |
| 217 | + |
| 218 | +5. **Theme Consistency**: Ensure theme settings work well with background colors and media content |
| 219 | + |
| 220 | +## Schema Reference |
| 221 | + |
| 222 | +The HeaderBlock schema includes all enhanced properties with proper validation: |
| 223 | + |
| 224 | +- `overtitle`: String or JSX content type |
| 225 | +- `additionalInfo`: YFM content with textarea input |
| 226 | +- `mediaView`: Enum with 'full' and 'fit' options |
| 227 | +- `fullWidthMedia`: Boolean for background configuration |
| 228 | +- `renderTitle`: Function prop (not in schema, runtime only) |
| 229 | +- `status`: JSX element (not in schema, runtime only) |
| 230 | +- `mediaClassName`: String for custom styling |
0 commit comments