feat: add some listing components

This commit is contained in:
2026-01-25 16:02:33 -03:00
parent 68866f4725
commit 3774750a56
10 changed files with 101 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
export class IconActionListItem {
constructor(public iconSrc: string, public label = '', public value: string){}
}

View File

@@ -0,0 +1,8 @@
<mat-action-list>
@for (item of items(); track item.value) {
<button mat-list-item (click)="action.emit(item.value)">
<img matListItemAvatar src="{{item.iconSrc}}" alt=""/>
<span matListItemTitle>{{item.label|translate|titlecase}}</span>
</button>
}
</mat-action-list>

View File

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

View File

@@ -0,0 +1,16 @@
import { Component, input, output } from '@angular/core';
import { MatListModule } from '@angular/material/list';
import { IconActionListItem } from './IconActionListItem';
import { TranslatePipe } from '@ngx-translate/core';
import { TitleCasePipe } from '@angular/common';
@Component({
selector: 'app-icon-action-list',
imports: [MatListModule, TranslatePipe, TitleCasePipe],
templateUrl: './icon-action-list.html',
styleUrl: './icon-action-list.scss',
})
export class IconActionList {
readonly items = input<IconActionListItem[]>([]);
readonly action = output<string>();
}

View File

@@ -0,0 +1,3 @@
export class IconNavListItem {
constructor(public icon = 'thumb_up' , public label = '', public routerLink: string|string[] = ['/']){}
}

View File

@@ -0,0 +1,8 @@
<mat-nav-list>
@for (item of items(); track item.label) {
<a mat-list-item [routerLink]="item.routerLink">
<mat-icon matListItemIcon>{{item.icon}}</mat-icon>
<span matListItemTitle>{{item.label|translate|titlecase }}</span>
</a>
}
</mat-nav-list>

View File

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

View File

@@ -0,0 +1,17 @@
import { Component, input } from '@angular/core';
import { MatIcon } from '@angular/material/icon';
import { MatListModule } from '@angular/material/list';
import { RouterLink } from '@angular/router';
import { IconNavListItem } from './IconNavListItem';
import { TranslatePipe } from '@ngx-translate/core';
import { TitleCasePipe } from '@angular/common';
@Component({
selector: 'app-icon-nav-list',
imports: [MatListModule, MatIcon, RouterLink, TranslatePipe, TitleCasePipe],
templateUrl: './icon-nav-list.html',
styleUrl: './icon-nav-list.scss',
})
export class IconNavList {
readonly items = input<IconNavListItem[]>([]);
}