Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web-ui: added color effect on newest blocks (fixes #20) #25

Merged
merged 4 commits into from
Jun 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.latest-block {
AlexITC marked this conversation as resolved.
Show resolved Hide resolved
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;
}
}