feat: add some listing components
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
export class IconActionListItem {
|
||||||
|
constructor(public iconSrc: string, public label = '', public value: string){}
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
23
src/app/components/icon-action-list/icon-action-list.spec.ts
Normal file
23
src/app/components/icon-action-list/icon-action-list.spec.ts
Normal 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
16
src/app/components/icon-action-list/icon-action-list.ts
Normal file
16
src/app/components/icon-action-list/icon-action-list.ts
Normal 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>();
|
||||||
|
}
|
||||||
3
src/app/components/icon-nav-list/IconNavListItem.ts
Normal file
3
src/app/components/icon-nav-list/IconNavListItem.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export class IconNavListItem {
|
||||||
|
constructor(public icon = 'thumb_up' , public label = '', public routerLink: string|string[] = ['/']){}
|
||||||
|
}
|
||||||
8
src/app/components/icon-nav-list/icon-nav-list.html
Normal file
8
src/app/components/icon-nav-list/icon-nav-list.html
Normal 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>
|
||||||
0
src/app/components/icon-nav-list/icon-nav-list.scss
Normal file
0
src/app/components/icon-nav-list/icon-nav-list.scss
Normal file
23
src/app/components/icon-nav-list/icon-nav-list.spec.ts
Normal file
23
src/app/components/icon-nav-list/icon-nav-list.spec.ts
Normal 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
17
src/app/components/icon-nav-list/icon-nav-list.ts
Normal file
17
src/app/components/icon-nav-list/icon-nav-list.ts
Normal 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[]>([]);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user