Skip to content

Commit

Permalink
web-ui: added a color effect on new blocks (fixes #20)
Browse files Browse the repository at this point in the history
  • Loading branch information
mario128mex authored and AlexITC committed Jun 17, 2018
1 parent c3632db commit 590fa9f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.latest-block {
animation: blinker 1s linear;
}

@keyframes blinker {
50% {
background-color: #D4FFD4;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h4>{{'message.loadingLatestBlocks' | translate}}</h4>
</thead>

<tbody>
<tr *ngFor="let item of blocks">
<tr *ngFor="let item of blocks" [ngClass]="{ 'latest-block': isBlockRecent(item) }">
<td>
<a routerLink="/blocks/{{item.hash}}">{{item.height}}</a>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import { ErrorService } from '../../services/error.service';
})
export class LatestBlocksComponent implements OnInit, OnDestroy {

blocks: Block[];
blocks: Block[] = [];
private latestBlockHeight = 0;
private subscription$: Subscription;

constructor(
Expand Down Expand Up @@ -70,6 +71,7 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
}

private onBlockRetrieved(response: Block[]) {
this.latestBlockHeight = this.blocks.reduce((max, block) => Math.max(block.height, max), 0);
this.blocks = response;
}

Expand All @@ -92,4 +94,8 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
age(block: Block): string {
return '';
}

isBlockRecent(item: Block): boolean {
return item.height > this.latestBlockHeight;
}
}

0 comments on commit 590fa9f

Please sign in to comment.