Add text truncation component

This commit is contained in:
Mononaut
2023-01-05 11:00:08 -06:00
parent 05a8154db0
commit 44147f5976
4 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import { Component, Input, Inject, LOCALE_ID } from '@angular/core';
@Component({
selector: 'app-truncate',
templateUrl: './truncate.component.html',
styleUrls: ['./truncate.component.scss']
})
export class TruncateComponent {
@Input() text: string;
@Input() lastChars: number = 4;
@Input() maxWidth: number = null;
rtl: boolean;
constructor(
@Inject(LOCALE_ID) private locale: string,
) {
if (this.locale.startsWith('ar') || this.locale.startsWith('fa') || this.locale.startsWith('he')) {
this.rtl = true;
}
}
}