export bitcoinsatoshis pipe module, allow custom class for first part

This commit is contained in:
nymkappa 2024-09-27 17:26:27 +02:00
parent 676abf58fd
commit 2d7316942f
No known key found for this signature in database
GPG key ID: 92358FC85D9645DE
2 changed files with 3 additions and 2 deletions

View file

@ -8,7 +8,7 @@ export class BitcoinsatoshisPipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer) { }
transform(value: string): SafeHtml {
transform(value: string, firstPartClass?: string): SafeHtml {
const newValue = this.insertSpaces(parseFloat(value || '0').toFixed(8));
const position = (newValue || '0').search(/[1-9]/);
@ -16,7 +16,7 @@ export class BitcoinsatoshisPipe implements PipeTransform {
const secondPart = newValue.slice(position);
return this.sanitizer.bypassSecurityTrustHtml(
`<span class="text-secondary">${firstPart}</span>${secondPart}`
`<span class="${firstPartClass ? firstPartClass : 'text-secondary'}">${firstPart}</span>${secondPart}`
);
}

View file

@ -365,6 +365,7 @@ import { OnlyVsizeDirective, OnlyWeightDirective } from './components/weight-dir
TwitterWidgetComponent,
TwitterLogin,
BitcoinInvoiceComponent,
BitcoinsatoshisPipe,
MempoolBlockOverviewComponent,
ClockchainComponent,