# HLCRF Deep Dive This guide provides an in-depth look at the HLCRF (Header-Left-Content-Right-Footer) layout system, covering all layout combinations, the ID system, responsive patterns, and complex real-world examples. ## Layout Combinations HLCRF supports any combination of its five regions. The variant name describes which regions are present. ### All Possible Combinations | Variant | Regions | Use Case | |---------|---------|----------| | `C` | Content only | Simple content pages | | `HC` | Header + Content | Landing pages | | `CF` | Content + Footer | Article pages | | `HCF` | Header + Content + Footer | Standard pages | | `LC` | Left + Content | App with navigation | | `CR` | Content + Right | Content with sidebar | | `LCR` | Left + Content + Right | Three-column layout | | `HLC` | Header + Left + Content | Admin dashboard | | `HCR` | Header + Content + Right | Blog with widgets | | `LCF` | Left + Content + Footer | App with footer | | `CRF` | Content + Right + Footer | Blog layout | | `HLCF` | Header + Left + Content + Footer | Standard admin | | `HCRF` | Header + Content + Right + Footer | Blog layout | | `HLCR` | Header + Left + Content + Right | Full admin | | `LCRF` | Left + Content + Right + Footer | Complex app | | `HLCRF` | All five regions | Complete layout | ### Content-Only (C) Minimal layout for simple content: ```php use Core\Front\Components\Layout; $layout = Layout::make('C') ->c('
Simple content without chrome
'); echo $layout->render(); ``` **Output:** ```html
Simple content without chrome
``` ### Header + Content + Footer (HCF) Standard page layout: ```php $layout = Layout::make('HCF') ->h('') ->c('
Page Content
') ->f(''); ``` ### Left + Content (LC) Application with navigation sidebar: ```php $layout = Layout::make('LC') ->l('') ->c('
App Content
'); ``` ### Three-Column (LCR) Full three-column layout: ```php $layout = Layout::make('LCR') ->l('') ->c('
Content
') ->r(''); ``` ### Full Admin (HLCRF) Complete admin panel: ```php $layout = Layout::make('HLCRF') ->h('
Admin Header
') ->l('') ->c('
Dashboard
') ->r('') ->f(''); ``` ## The ID System Every HLCRF element receives a unique, hierarchical ID that describes its position in the layout tree. ### ID Format ``` {Region}-{Index}[-{NestedRegion}-{NestedIndex}]... ``` **Components:** - **Region Letter** - `H`, `L`, `C`, `R`, or `F` - **Index** - Zero-based position within that slot (0, 1, 2, ...) - **Nesting** - Dash-separated chain for nested layouts ### Region Letters | Letter | Region | Semantic Role | |--------|--------|---------------| | `H` | Header | Top navigation, branding | | `L` | Left | Primary sidebar, navigation | | `C` | Content | Main content area | | `R` | Right | Secondary sidebar, widgets | | `F` | Footer | Bottom links, copyright | ### ID Examples **Simple layout:** ```html
First header element
Second header element
First content element
``` **Nested layout:** ```html
Nested content
``` ### ID Interpretation | ID | Meaning | |----|---------| | `H-0` | First element in Header | | `L-2` | Third element in Left sidebar | | `C-0` | First element in Content | | `C-L-0` | Content > Left > First element | | `C-R-2` | Content > Right > Third element | | `C-L-0-R-1` | Content > Left > First > Right > Second | | `H-0-C-0-L-0` | Header > Content > Left (deeply nested) | ### Using IDs for CSS The ID system enables precise CSS targeting: ```css /* Target first header element */ [data-block="H-0"] { background: #1a1a2e; } /* Target all elements in left sidebar */ [data-slot="L"] > [data-block] { padding: 1rem; } /* Target nested content areas */ [data-block*="-C-"] { margin: 2rem; } /* Target second element in any right sidebar */ [data-block$="-R-1"] { border-top: 1px solid #e5e7eb; } /* Target deeply nested layouts */ [data-layout*="-"][data-layout*="-"] { background: #f9fafb; } ``` ### Using IDs for Testing ```php // PHPUnit/Pest $this->assertSee('[data-block="H-0"]'); $this->assertSeeInOrder(['[data-slot="L"]', '[data-slot="C"]']); // Playwright/Cypress await page.locator('[data-block="C-0"]').click(); await expect(page.locator('[data-slot="R"]')).toBeVisible(); ``` ### Using IDs for JavaScript ```javascript // Target specific elements const header = document.querySelector('[data-block="H-0"]'); const sidebar = document.querySelector('[data-slot="L"]'); // Dynamic targeting function getContentBlock(index) { return document.querySelector(`[data-block="C-${index}"]`); } // Nested targeting const nestedLeft = document.querySelector('[data-block="C-L-0"]'); ``` ## Responsive Design Patterns ### Mobile-First Stacking On mobile, stack regions vertically: ```blade Navigation Content Widgets ``` **Behavior:** - **Mobile (< 768px):** Left -> Content -> Right (vertical) - **Tablet (768px-1024px):** Left | Content (two columns) - **Desktop (> 1024px):** Left | Content | Right (three columns) ### Collapsible Sidebars ```blade ``` ### Hidden Regions on Mobile ```blade ``` ### Flexible Width Distribution ```blade Fixed-width sidebar Flexible content Percentage-width sidebar ``` ### Responsive Grid Inside Content ```blade
``` ## Complex Real-World Examples ### Admin Dashboard A complete admin dashboard with nested layouts: ```php use Core\Front\Components\Layout; // Main admin layout $admin = Layout::make('HLCF') ->h( '' ) ->l( '' ) ->c( // Nested layout inside content Layout::make('HCR') ->h('

Dashboard

') ->c('
Stat 1
Stat 2
Stat 3

Recent Activity

...
') ->r('') ) ->f( '' ); echo $admin->render(); ``` **Generated IDs:** - `H-0` - Admin header/navigation - `L-0` - Sidebar navigation - `C-0` - Nested layout container - `C-0-H-0` - Content header (page title/actions) - `C-0-C-0` - Content main area (stats/table) - `C-0-R-0` - Content right sidebar (quick actions) - `F-0` - Admin footer ### E-Commerce Product Page Product page with nested sections: ```php $productPage = Layout::make('HCF') ->h('
Search | Cart | Account
') ->c( Layout::make('LCR') ->l('
Product
') ->c( // Empty - using left/right only ) ->r('

Product Name

$99.99

Product description...

Shipping Info

Free delivery over $50

'), // Reviews section Layout::make('CR') ->c('

Customer Reviews

Review 1...
Review 2...
') ->r('') ) ->f(''); ``` ### Multi-Panel Settings Page Settings page with multiple nested panels: ```php $settings = Layout::make('HLC') ->h('

Account Settings

') ->l('') ->c( // Profile section Layout::make('HCF') ->h('

Profile Information

Update your account details

') ->c('
') ->f('
') ); ``` ### Documentation Site Documentation layout with table of contents: ```php $docs = Layout::make('HLCRF') ->h('
') ->l('') ->c('

Introduction

Welcome to the documentation...

Key Features

Next Steps

Continue to the installation guide...

') ->r('') ->f(''); ``` ### Email Client Interface Complex email client with multiple nested panels: ```php $email = Layout::make('HLCR') ->h('
JD
') ->l('') ->c( Layout::make('LC') ->l('
John Smith 10:30 AM
Meeting Tomorrow
Hi, just wanted to confirm...
Jane Doe Yesterday
Project Update
Here is the latest update...
') ->c('

Meeting Tomorrow

JS
John Smith <john@example.com>
to me
Jan 15, 2026, 10:30 AM

Hi,

Just wanted to confirm our meeting tomorrow at 2pm.

Best regards,
John

') ) ->r(''); ``` ## Performance Considerations ### Lazy Content Loading For large layouts, defer non-critical content: ```php $layout = Layout::make('LCR') ->l('') ->c('
Loading...
@livewire("content-panel")
') ->r(fn () => view('widgets.sidebar')); // Closure defers evaluation ``` ### Conditional Region Rendering Only render regions when needed: ```php $layout = Layout::make('LCR'); $layout->l(''); $layout->c('
Content
'); // Conditionally add right sidebar if ($user->hasFeature('widgets')) { $layout->r(''); } ``` ### Efficient CSS Targeting Use data attributes instead of deep selectors: ```css /* Efficient - uses data attribute */ [data-block="C-0"] { padding: 1rem; } /* Less efficient - deep selector */ .hlcrf-layout > .hlcrf-body > .hlcrf-content > div:first-child { padding: 1rem; } ``` ## Testing HLCRF Layouts ### Unit Testing ```php use Core\Front\Components\Layout; use PHPUnit\Framework\TestCase; class LayoutTest extends TestCase { public function test_generates_correct_ids(): void { $layout = Layout::make('LC') ->l('Left') ->c('Content'); $html = $layout->render(); $this->assertStringContainsString('data-slot="L"', $html); $this->assertStringContainsString('data-slot="C"', $html); $this->assertStringContainsString('data-block="L-0"', $html); $this->assertStringContainsString('data-block="C-0"', $html); } public function test_nested_layout_ids(): void { $nested = Layout::make('LR') ->l('Nested Left') ->r('Nested Right'); $outer = Layout::make('C') ->c($nested); $html = $outer->render(); $this->assertStringContainsString('data-block="C-0-L-0"', $html); $this->assertStringContainsString('data-block="C-0-R-0"', $html); } } ``` ### Browser Testing ```php // Pest with Playwright it('renders admin layout correctly', function () { $this->browse(function ($browser) { $browser->visit('/admin') ->assertPresent('[data-layout="root"]') ->assertPresent('[data-slot="H"]') ->assertPresent('[data-slot="L"]') ->assertPresent('[data-slot="C"]'); }); }); ``` ## Best Practices ### 1. Use Semantic Region Names ```php // Good - semantic use ->h('') ->l('') ->c('
Page content
') ->r('') ->f('') // Bad - misuse of regions ->h('') // Header for sidebar? ``` ### 2. Leverage the ID System ```css /* Target specific elements precisely */ [data-block="H-0"] { /* Header first element */ } [data-block="C-L-0"] { /* Content > Left > First */ } /* Don't fight the system with complex selectors */ ``` ### 3. Keep Nesting Shallow ```php // Good - 2-3 levels max Layout::make('HCF') ->c(Layout::make('LCR')->...); // Avoid - too deep Layout::make('C') ->c(Layout::make('C') ->c(Layout::make('C') ->c(Layout::make('C')...)))); ``` ### 4. Use Consistent Widths ```php // Good - consistent sidebar widths across app ->l('