import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { GridSystemComponent } from '../../../../../ui-essentials/src/lib/components/layout';
@Component({
selector: 'ui-grid-system-demo',
standalone: true,
imports: [CommonModule, GridSystemComponent],
template: `
Grid System Demo
Column Variants
@for (cols of columnVariants; track cols) {
{{ cols }} Columns
@for (item of getItems(getItemCount(cols)); track $index) {
{{ $index + 1 }}
}
}
Gap Sizes
@for (gap of gapSizes; track gap) {
Gap: {{ gap }}
@for (item of getItems(6); track $index) {
{{ $index + 1 }}
}
}
Auto Layout
Auto-fit (items stretch to fill)
@for (item of getItems(4); track $index) {
Auto-fit {{ $index + 1 }}
}
Auto-fill (creates empty columns)
@for (item of getItems(4); track $index) {
Auto-fill {{ $index + 1 }}
}
Alignment Options
Justify Items: Center
@for (item of getItems(6); track $index) {
{{ $index + 1 }}
}
Align Items: Center
@for (item of getItems(6); track $index) {
{{ $index + 1 }}
}
Custom Grid Template
Custom Columns: 200px 1fr 100px
Fixed 200px
Flexible 1fr
Fixed 100px
Responsive Grid
Resize the window to see responsive behavior
@for (item of getItems(24); track $index) {
{{ $index + 1 }}
}
`,
styleUrl: './grid-system-demo.component.scss'
})
export class GridSystemDemoComponent {
columnVariants: (1 | 2 | 3 | 4 | 6 | 12)[] = [1, 2, 3, 4, 6, 12];
gapSizes: ('xs' | 'sm' | 'md' | 'lg' | 'xl')[] = ['xs', 'sm', 'md', 'lg', 'xl'];
getItems(count: number): number[] {
return Array.from({ length: count }, (_, i) => i + 1);
}
getItemCount(cols: number | string): number {
if (typeof cols === 'number') {
return Math.min(cols * 2, 12);
}
return 6;
}
}