import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { GridContainerComponent } from 'ui-essentials'; @Component({ selector: 'ui-grid-container-demo', standalone: true, imports: [CommonModule, FormsModule, GridContainerComponent], template: `

GridContainer Demo

Advanced CSS Grid wrapper with template areas support, responsive column/row definitions, and auto-placement algorithms.

Basic Grid Layouts

Auto-fit Grid (Responsive)

@for (item of basicItems; track item.id) {
{{ item.label }}
}

Fixed 3-Column Grid

@for (item of basicItems; track item.id) {
{{ item.label }}
}

Gap Sizes

@for (gap of gaps; track gap) {

{{ gap }} Gap

@for (item of shortItems; track item.id) {
{{ item.label }}
}
}

Column Layouts

@for (colCount of columnCounts; track colCount) {

{{ colCount }} Columns

@for (item of getItemsForColumns(colCount); track item.id) {
{{ item.label }}
}
}

Auto Grid Types

Auto-fit (Items stretch to fill space)

@for (item of autoItems; track item.id) {
{{ item.label }}
}

Auto-fill (Empty columns maintained)

@for (item of autoItems; track item.id) {
{{ item.label }}
}

Advanced Features

Dense Grid (Auto-placement fills gaps)

Wide Item (2 cols)
Item 1
Tall Item
Item 2
Item 3
Extra Wide (3 cols)
Item 4
Item 5

Grid with Template Areas

Header
Sidebar
Main Content
Aside
Footer

Alignment Options

Justify Content: Center

Item 1
Item 2

Align Items: Center

Centered
Items
Vertically

Row Modes

@for (rowMode of rowModes; track rowMode) {

{{ rowMode }} Rows

@if (rowMode === 'min-content') { Short } @else if (rowMode === 'max-content') { This is longer content to demonstrate max-content behavior } @else { Content for {{ rowMode }} }
Item 2
Item 3
}

Interactive Grid Builder

@for (item of interactiveItems; track item.id) {
{{ item.label }} @if (item.span > 1) { ({{ item.span }} cols) } @if (item.rowSpan > 1) { ({{ item.rowSpan }} rows) }
}
`, styleUrl: './grid-container-demo.component.scss' }) export class GridContainerDemoComponent { gaps = ['sm', 'md', 'lg'] as const; columnCounts = [1, 2, 3, 4, 5, 6] as const; allColumns = [1, 2, 3, 4, 5, 6, 'auto-fit', 'auto-fill'] as const; rowModes = ['auto', 'equal', 'min-content', 'max-content'] as const; basicItems = [ { id: 1, label: 'Item 1' }, { id: 2, label: 'Item 2' }, { id: 3, label: 'Item 3' }, { id: 4, label: 'Item 4' }, { id: 5, label: 'Item 5' }, { id: 6, label: 'Item 6' }, { id: 7, label: 'Item 7' }, { id: 8, label: 'Item 8' } ]; shortItems = [ { id: 1, label: 'A' }, { id: 2, label: 'B' }, { id: 3, label: 'C' } ]; autoItems = [ { id: 1, label: 'Auto Item 1' }, { id: 2, label: 'Auto Item 2' }, { id: 3, label: 'Auto Item 3' }, { id: 4, label: 'Auto Item 4' } ]; interactiveConfig = { columns: 'auto-fit' as const, gap: 'md' as const, dense: false }; interactiveItems = [ { id: 1, label: 'Regular', variant: 'primary', span: 1, rowSpan: 1 }, { id: 2, label: 'Wide', variant: 'secondary', span: 2, rowSpan: 1 }, { id: 3, label: 'Tall', variant: 'success', span: 1, rowSpan: 2 }, { id: 4, label: 'Extra Wide', variant: 'info', span: 3, rowSpan: 1 }, { id: 5, label: 'Normal', variant: 'warning', span: 1, rowSpan: 1 }, { id: 6, label: 'Regular', variant: 'danger', span: 1, rowSpan: 1 }, { id: 7, label: 'Wide', variant: 'primary', span: 2, rowSpan: 1 }, { id: 8, label: 'Normal', variant: 'secondary', span: 1, rowSpan: 1 } ]; getItemsForColumns(colCount: number) { const count = Math.min(colCount * 2, this.basicItems.length); return this.basicItems.slice(0, count); } }