Added attachment support

This commit is contained in:
2026-04-09 13:41:04 +02:00
parent 9baab3d3bc
commit 97f7712d55
13 changed files with 270 additions and 18 deletions

View File

@@ -0,0 +1 @@
<ng-content></ng-content>

View File

@@ -0,0 +1,12 @@
:host {
display: grid;
gap: 4px;
height: 100%;
img {
display: block;
height: 100%;
width: 100%;
object-fit: cover;
}
}

View File

@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Masonry } from './masonry';
describe('Masonry', () => {
let component: Masonry;
let fixture: ComponentFixture<Masonry>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Masonry],
}).compileComponents();
fixture = TestBed.createComponent(Masonry);
component = fixture.componentInstance;
await fixture.whenStable();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,28 @@
import {AfterViewChecked, AfterViewInit, Component, ElementRef, inject, input, ViewChild} from '@angular/core';
@Component({
selector: 'masonry',
imports: [],
templateUrl: './masonry.html',
styleUrl: './masonry.scss',
})
export class Masonry implements AfterViewInit {
host = inject(ElementRef)
maxColSize = input<number>(4)
ngAfterViewInit() {
const elements = this.host.nativeElement.children.length
switch (elements) {
case 1:
this.host.nativeElement.style.gridTemplateColumns = "1fr";
break
case 3:
this.host.nativeElement.style.gridTemplateColumns = "repeat(2, 1fr)";
this.host.nativeElement.children[2].style.gridColumn = "1 / -1";
break
default:
this.host.nativeElement.style.gridTemplateColumns = `repeat(${this.maxColSize()}, 1fr)`;
}
}
}