import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AspectRatioComponent } from '../../../../../ui-essentials/src/lib/components/layout/aspect-ratio';
@Component({
selector: 'ui-aspect-ratio-demo',
standalone: true,
imports: [CommonModule, AspectRatioComponent],
template: `
Aspect Ratio Demo
Components for maintaining consistent aspect ratios across responsive content.
Aspect Ratio Presets
@for (preset of presets; track preset.ratio) {
{{ preset.label }}
{{ preset.ratio }} ({{ preset.description }})
}
Custom Aspect Ratios
@for (custom of customRatios; track custom.ratio) {
{{ custom.label }}
{{ custom.ratio }}
}
Size Variants
@for (size of sizes; track size) {
Size: {{ size }}
{{ size }} size
}
Style Variants
@for (variant of variants; track variant) {
{{ variant | titlecase }}
{{ variant }} variant
@if (variant === 'interactive') {
Click me!
}
}
Image Examples
Square Image
Video Aspect
Portrait Image
Loading State
Loading
Dynamic Loading
Content Centering
Fill Container
Fills entire container
Centered Content
I'm centered!
Interactive Examples
Click Counter
{{ clickCount }}
Click to increment
`,
styleUrl: './aspect-ratio-demo.component.scss'
})
export class AspectRatioDemoComponent {
presets = [
{ ratio: 'square' as const, label: 'Square', description: '1:1' },
{ ratio: 'video' as const, label: 'Video', description: '16:9' },
{ ratio: 'cinema' as const, label: 'Cinema', description: '21:9' },
{ ratio: 'photo' as const, label: 'Photo', description: '3:2' },
{ ratio: 'portrait' as const, label: 'Portrait', description: '3:4' },
{ ratio: 'golden' as const, label: 'Golden', description: '1.618:1' }
];
customRatios = [
{ ratio: '4/3', label: 'Custom 4:3' },
{ ratio: '75%', label: 'Custom 75%' },
{ ratio: '1.33', label: 'Custom 1.33' },
{ ratio: '125%', label: 'Custom 125%' }
];
sizes = ['sm', 'md', 'lg'] as const;
variants = ['default', 'elevated', 'bordered', 'interactive'] as const;
clickCount = 0;
isLoading = false;
private colors = [
'linear-gradient(45deg, #667eea, #764ba2)',
'linear-gradient(135deg, #f093fb, #f5576c)',
'linear-gradient(45deg, #4facfe, #00f2fe)',
'linear-gradient(135deg, #43e97b, #38f9d7)',
'linear-gradient(45deg, #fa709a, #fee140)',
'linear-gradient(135deg, #a8edea, #fed6e3)',
'linear-gradient(45deg, #ffecd2, #fcb69f)',
'linear-gradient(135deg, #ff9a9e, #fecfef)'
];
getRandomColor(): string {
return this.colors[Math.floor(Math.random() * this.colors.length)];
}
handleInteractiveClick(event: MouseEvent): void {
console.log('Interactive aspect ratio clicked', event);
}
incrementCounter(): void {
this.clickCount++;
}
toggleLoading(): void {
this.isLoading = !this.isLoading;
}
}