mirror of
https://github.com/mempool/mempool.git
synced 2025-03-03 17:47:01 +01:00
Add fee rate display component
This commit is contained in:
parent
a45f1fde1c
commit
c29558db20
6 changed files with 39 additions and 2 deletions
|
@ -0,0 +1,4 @@
|
||||||
|
<ng-container *ngIf="rateUnits$ | async as units">
|
||||||
|
<ng-container *ngIf="units !== 'wu'">{{ fee / (weight / 4) | feeRounding:rounding }} <span *ngIf="showUnit" [class]="unitClass">sat/vB</span></ng-container>
|
||||||
|
<ng-container *ngIf="units === 'wu'">{{ fee / weight | feeRounding:rounding }} <span *ngIf="showUnit" [class]="unitClass">sat/WU</span></ng-container>
|
||||||
|
</ng-container>
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { StateService } from '../../../services/state.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-fee-rate',
|
||||||
|
templateUrl: './fee-rate.component.html',
|
||||||
|
styleUrls: ['./fee-rate.component.scss']
|
||||||
|
})
|
||||||
|
export class FeeRateComponent implements OnInit {
|
||||||
|
@Input() fee: number;
|
||||||
|
@Input() weight: number = 4;
|
||||||
|
@Input() rounding: string = null;
|
||||||
|
@Input() showUnit: boolean = true;
|
||||||
|
@Input() unitClass: string = 'symbol';
|
||||||
|
|
||||||
|
rateUnits$: Observable<string>;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private stateService: StateService,
|
||||||
|
) { }
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.rateUnits$ = this.stateService.rateUnits$;
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,7 +9,11 @@ export class FeeRoundingPipe implements PipeTransform {
|
||||||
@Inject(LOCALE_ID) private locale: string,
|
@Inject(LOCALE_ID) private locale: string,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
transform(fee: number): string {
|
transform(fee: number, rounding = null): string {
|
||||||
|
if (rounding) {
|
||||||
|
return formatNumber(fee, this.locale, rounding);
|
||||||
|
}
|
||||||
|
|
||||||
if (fee >= 100) {
|
if (fee >= 100) {
|
||||||
return formatNumber(fee, this.locale, '1.0-0')
|
return formatNumber(fee, this.locale, '1.0-0')
|
||||||
} else if (fee < 10) {
|
} else if (fee < 10) {
|
||||||
|
|
|
@ -83,6 +83,7 @@ import { IndexingProgressComponent } from '../components/indexing-progress/index
|
||||||
import { SvgImagesComponent } from '../components/svg-images/svg-images.component';
|
import { SvgImagesComponent } from '../components/svg-images/svg-images.component';
|
||||||
import { ChangeComponent } from '../components/change/change.component';
|
import { ChangeComponent } from '../components/change/change.component';
|
||||||
import { SatsComponent } from './components/sats/sats.component';
|
import { SatsComponent } from './components/sats/sats.component';
|
||||||
|
import { FeeRateComponent } from './components/fee-rate/fee-rate.component';
|
||||||
import { TruncateComponent } from './components/truncate/truncate.component';
|
import { TruncateComponent } from './components/truncate/truncate.component';
|
||||||
import { SearchResultsComponent } from '../components/search-form/search-results/search-results.component';
|
import { SearchResultsComponent } from '../components/search-form/search-results/search-results.component';
|
||||||
import { TimestampComponent } from './components/timestamp/timestamp.component';
|
import { TimestampComponent } from './components/timestamp/timestamp.component';
|
||||||
|
@ -173,6 +174,7 @@ import { ClockComponent } from '../components/clock/clock.component';
|
||||||
SvgImagesComponent,
|
SvgImagesComponent,
|
||||||
ChangeComponent,
|
ChangeComponent,
|
||||||
SatsComponent,
|
SatsComponent,
|
||||||
|
FeeRateComponent,
|
||||||
TruncateComponent,
|
TruncateComponent,
|
||||||
SearchResultsComponent,
|
SearchResultsComponent,
|
||||||
TimestampComponent,
|
TimestampComponent,
|
||||||
|
@ -287,6 +289,7 @@ import { ClockComponent } from '../components/clock/clock.component';
|
||||||
SvgImagesComponent,
|
SvgImagesComponent,
|
||||||
ChangeComponent,
|
ChangeComponent,
|
||||||
SatsComponent,
|
SatsComponent,
|
||||||
|
FeeRateComponent,
|
||||||
TruncateComponent,
|
TruncateComponent,
|
||||||
SearchResultsComponent,
|
SearchResultsComponent,
|
||||||
TimestampComponent,
|
TimestampComponent,
|
||||||
|
|
|
@ -221,7 +221,7 @@ main {
|
||||||
}
|
}
|
||||||
|
|
||||||
.block-size, .blocks-container {
|
.block-size, .blocks-container {
|
||||||
span {
|
.symbol {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: #fff !important;
|
color: #fff !important;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue