-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prices on home page and 24 hour change difference
- Loading branch information
Showing
4 changed files
with
119 additions
and
75 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
src/Blockcore.Explorer/ClientApp/src/app/home/home.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
.chains-home { | ||
width: 100%; | ||
font-size: 1.2em; | ||
text-align: center; | ||
} | ||
|
||
.chains-home img { | ||
width: 32px; | ||
height: 32px; | ||
} | ||
|
||
.chains-home li { | ||
margin-left: 0.5em; | ||
width: 180px; | ||
} | ||
|
||
.chains-home { | ||
padding: 2rem; | ||
} | ||
|
||
.chains-home > ul { | ||
display: grid; | ||
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); | ||
grid-gap: 1em; | ||
list-style-type: none; | ||
} | ||
|
||
.chains-home > ul > li { | ||
margin: 0.5em; | ||
} | ||
|
||
.chain-home-link:hover { | ||
text-decoration: underline; | ||
} | ||
|
||
.chains-home > ul > li > a { | ||
white-space: nowrap; | ||
text-decoration: none !important; | ||
} | ||
|
||
.chain-home-item { | ||
display: grid; | ||
grid-template-columns: 32px 1fr; | ||
grid-template-rows: 1fr 1fr; | ||
margin-bottom: 1em; | ||
column-gap: 10px; | ||
row-gap: 0px; | ||
} | ||
|
||
.chain-home-ticker { | ||
clear: both; | ||
display: block; | ||
place-self: start; | ||
white-space: nowrap; | ||
color: var(--foreground-alternative); | ||
font-size: 0.8em; | ||
} | ||
|
||
.chain-home-link { | ||
height: 32px; | ||
line-height: 32px; | ||
place-self: start; | ||
} | ||
|
||
.chain-home-link img { | ||
margin-right: 0.2em; | ||
} | ||
|
||
.chain-home-link:hover { | ||
text-decoration: none; | ||
} | ||
|
||
.chain-home-ticker-change { | ||
margin-left: 0.2em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 36 additions & 3 deletions
39
src/Blockcore.Explorer/ClientApp/src/app/home/home.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,51 @@ | ||
import { Component, HostBinding } from '@angular/core'; | ||
import { Component, HostBinding, OnInit } from '@angular/core'; | ||
import { SetupService } from '../services/setup.service'; | ||
import { Router } from '@angular/router'; | ||
import { ApiService } from '../services/api.service'; | ||
|
||
@Component({ | ||
selector: 'app-home', | ||
templateUrl: './home.component.html', | ||
styleUrls: ['./home.component.css'] | ||
}) | ||
export class HomeComponent { | ||
export class HomeComponent implements OnInit { | ||
// @HostBinding('class.content-centered') hostClass = true; | ||
tickers: any; | ||
|
||
constructor(public setup: SetupService, private router: Router) { | ||
constructor( | ||
public setup: SetupService, | ||
private api: ApiService, | ||
private router: Router) { | ||
// When we are not in multichain mode, redirect to chain-home. | ||
if (!setup.multiChain) { | ||
router.navigate(['/' + setup.current.toLowerCase()]); | ||
} | ||
} | ||
|
||
async ngOnInit() { | ||
await this.updateTicker(); | ||
} | ||
|
||
getChangeClass(value: number) { | ||
if (value < 0) { | ||
return 'negative'; | ||
} else { | ||
return 'positive'; | ||
} | ||
} | ||
|
||
async updateTicker() { | ||
|
||
try { | ||
const coins = this.setup.chains.map(c => c.coin).filter((c) => c != null);; | ||
const coinList = coins.join('%2C'); | ||
const url = `https://api.coingecko.com/api/v3/simple/price?ids=${coinList}&vs_currencies=btc&include_24hr_vol=true&include_24hr_change=true&include_last_updated_at=true` | ||
|
||
const request = await this.api.download(url); | ||
this.tickers = request; | ||
} | ||
catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters