Featured assets and asset groups

This commit is contained in:
softsimon
2022-02-06 01:20:26 +04:00
parent 8e2943a6a0
commit d2bb3356da
19 changed files with 421 additions and 110 deletions

View File

@@ -0,0 +1,26 @@
<div *ngIf="group$ | async as group">
<div class="main-title">
<h2>{{ group.group.name }}</h2>
<div class="sub-title">Group of {{ group.group.assets.length | number }} assets</div>
</div>
<div class="clearfix"></div>
<br>
<div class="featuredBox">
<div *ngFor="let asset of group.assets">
<div class="card">
<img class="assetIcon" [src]="'https://liquid.network/api/v1/asset/' + asset.asset_id + '/icon'">
<div class="title">
<a [routerLink]="['/assets/asset/', group.asset_id]">{{ asset.name }}</a>
</div>
<div class="ticker">{{ asset.ticker }}</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,57 @@
.image {
width: 150px;
float: left;
}
.main-title {
float: left
}
.sub-title {
color: grey;
}
.featuredBox {
display: flex;
flex-flow: row wrap;
justify-content: center;
gap: 27px;
}
.card {
background-color: #1d1f31;
width: 200px;
height: 200px;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
.title {
font-size: 14px;
font-weight: bold;
margin-top: 10px;
}
.sub-title {
color: grey;
}
.assetIcon {
width: 100px;
height: 100px;
}
.image {
width: 100px;
height: 100px;
align-self: center;
}
.view-link {
margin-top: 30px;
}
.ticker {
color: grey;
}

View File

@@ -0,0 +1,45 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { combineLatest, Observable } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiService } from 'src/app/services/api.service';
import { AssetsService } from 'src/app/services/assets.service';
@Component({
selector: 'app-asset-group',
templateUrl: './asset-group.component.html',
styleUrls: ['./asset-group.component.scss']
})
export class AssetGroupComponent implements OnInit {
group$: Observable<any>;
constructor(
private route: ActivatedRoute,
private apiService: ApiService,
private assetsService: AssetsService,
) { }
ngOnInit(): void {
this.group$ = this.route.paramMap
.pipe(
switchMap((params: ParamMap) => {
return combineLatest([
this.assetsService.getAssetsJson$,
this.apiService.getAssetGroup$(params.get('id')),
]);
}),
map(([assets, group]) => {
const items = [];
// @ts-ignore
for (const item of group.assets) {
items.push(assets[item]);
}
console.log(group);
return {
group: group,
assets: items
};
})
);
}
}