-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2756df
commit f648383
Showing
4 changed files
with
21 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
<span class="chip"> | ||
<a *ngIf="linkUrl !== ''" [routerLink]="linkUrl"> | ||
{{ label }} | ||
</a> | ||
<span *ngIf="linkUrl === ''"> | ||
{{ label }} | ||
</span> | ||
|
||
|
||
Check failure on line 2 in projects/ngx-cream-lib/src/lib/chip/chip.component.html GitHub Actions / Run linters
|
||
@if(linkUrl !== ''){ | ||
<a *ngIf="" [routerLink]="linkUrl"> | ||
{{ label }} | ||
</a> | ||
} @else { | ||
<span> | ||
{{ label }} | ||
</span> | ||
} | ||
|
||
<button *ngIf="deletable" type="button" [disabled]="disabled" (click)="deleteChip()" [attr.aria-label]="'Delete chip ' + label"> | ||
<svg role="img" width="25" height="25" aria-hidden="true"> | ||
<use href="./assets/img/sprite.svg#bt-close"></use> | ||
</svg> | ||
<ng-container i18n>Delete</ng-container> | ||
{{ label }} | ||
</button> | ||
</span> | ||
</span> | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,22 @@ | ||
import { Component, OnInit, Input, ElementRef, Renderer2 } from '@angular/core'; | ||
import { Component, Input, ElementRef, Renderer2, inject } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'c3m-chip', | ||
templateUrl: './chip.component.html', | ||
styleUrls: ['./chip.component.css'], | ||
}) | ||
export class ChipComponent implements OnInit { | ||
constructor(private elementRef: ElementRef, private renderer: Renderer2) { | ||
this.chipIdNum = this.randomID(); | ||
} | ||
export class ChipComponent { | ||
|
||
elementRef = inject(ElementRef); | ||
renderer = inject(Renderer2) | ||
|
||
@Input() label: string = ''; | ||
@Input() deletable: boolean = true; | ||
@Input() disabled: boolean = false; | ||
@Input() linkUrl: string = ''; | ||
|
||
chipIdNum!: number; | ||
chipId!: string; | ||
|
||
ngOnInit() { | ||
this.chipId = 'chip' + this.chipIdNum; | ||
} | ||
|
||
deleteChip(): void { | ||
this.renderer.removeChild(this.elementRef.nativeElement.parentNode, this.elementRef.nativeElement); | ||
} | ||
|
||
randomID() { | ||
const idRandom = Math.round(Math.random() * (20000 - 1) + 1); | ||
return idRandom; | ||
} | ||
} |
13 changes: 3 additions & 10 deletions
13
projects/ngx-cream-lib/src/lib/collapsible/collapsible.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters