From e5f0544cc27c1b78bd3f4986c7c5ad84b68c2d83 Mon Sep 17 00:00:00 2001 From: natsoni Date: Thu, 8 Feb 2024 18:32:07 +0100 Subject: [PATCH] Fix Liquid dashboard layout for mobile view --- .../lbtc-pegs-graph.component.ts | 2 +- .../app/dashboard/dashboard.component.html | 4 +-- .../app/dashboard/dashboard.component.scss | 2 +- .../src/app/dashboard/dashboard.component.ts | 31 +++++++++++++++---- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/components/lbtc-pegs-graph/lbtc-pegs-graph.component.ts b/frontend/src/app/components/lbtc-pegs-graph/lbtc-pegs-graph.component.ts index e2231e7ce..9931fb78a 100644 --- a/frontend/src/app/components/lbtc-pegs-graph/lbtc-pegs-graph.component.ts +++ b/frontend/src/app/components/lbtc-pegs-graph/lbtc-pegs-graph.component.ts @@ -18,9 +18,9 @@ import { EChartsOption } from '../../graphs/echarts'; }) export class LbtcPegsGraphComponent implements OnInit, OnChanges { @Input() data: any; + @Input() height: number | string = '320'; pegsChartOptions: EChartsOption; - height: number | string = '320'; right: number | string = '10'; top: number | string = '20'; left: number | string = '50'; diff --git a/frontend/src/app/dashboard/dashboard.component.html b/frontend/src/app/dashboard/dashboard.component.html index 9ebc22dd4..a2c46a198 100644 --- a/frontend/src/app/dashboard/dashboard.component.html +++ b/frontend/src/app/dashboard/dashboard.component.html @@ -44,7 +44,7 @@
- + @@ -187,7 +187,7 @@ - + diff --git a/frontend/src/app/dashboard/dashboard.component.scss b/frontend/src/app/dashboard/dashboard.component.scss index 9bd44ea29..70972ae8e 100644 --- a/frontend/src/app/dashboard/dashboard.component.scss +++ b/frontend/src/app/dashboard/dashboard.component.scss @@ -69,7 +69,7 @@ @media (min-width: 485px) { margin: 0px auto 10px; } - @media (min-width: 785px) { + @media (min-width: 768px) { margin: 0px auto 0px; } &:last-child { diff --git a/frontend/src/app/dashboard/dashboard.component.ts b/frontend/src/app/dashboard/dashboard.component.ts index cd393e89f..5dfd68419 100644 --- a/frontend/src/app/dashboard/dashboard.component.ts +++ b/frontend/src/app/dashboard/dashboard.component.ts @@ -1,6 +1,6 @@ import { AfterViewInit, ChangeDetectionStrategy, Component, HostListener, OnDestroy, OnInit } from '@angular/core'; -import { combineLatest, EMPTY, merge, Observable, of, Subject, Subscription, timer } from 'rxjs'; -import { catchError, delayWhen, filter, map, scan, share, shareReplay, startWith, switchMap, takeUntil, tap, throttleTime } from 'rxjs/operators'; +import { combineLatest, EMPTY, fromEvent, merge, Observable, of, Subject, Subscription, timer } from 'rxjs'; +import { catchError, delayWhen, distinctUntilChanged, filter, map, scan, share, shareReplay, startWith, switchMap, takeUntil, tap, throttleTime } from 'rxjs/operators'; import { AuditStatus, BlockExtended, CurrentPegs, OptimizedMempoolStats } from '../interfaces/node-api.interface'; import { MempoolInfo, TransactionStripped, ReplacementInfo } from '../interfaces/websocket.interface'; import { ApiService } from '../services/api.service'; @@ -33,6 +33,7 @@ interface MempoolStatsData { }) export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit { featuredAssets$: Observable; + nbFeaturedAssets = 6; network$: Observable; mempoolBlocksData$: Observable; mempoolInfoData$: Observable; @@ -58,6 +59,7 @@ export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit { currencySubscription: Subscription; currency: string; incomingGraphHeight: number = 300; + lbtcPegGraphHeight: number = 320; private lastPegBlockUpdate: number = 0; private lastPegAmount: string = ''; private lastReservesBlockUpdate: number = 0; @@ -153,16 +155,23 @@ export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit { }) ); - this.featuredAssets$ = this.apiService.listFeaturedAssets$() - .pipe( - map((featured) => { + const windowResize$ = fromEvent(window, 'resize').pipe( + distinctUntilChanged(), + startWith(null) + ); + + this.featuredAssets$ = combineLatest([ + this.apiService.listFeaturedAssets$(), + windowResize$ + ]).pipe( + map(([featured, _]) => { const newArray = []; for (const feature of featured) { if (feature.ticker !== 'L-BTC' && feature.asset) { newArray.push(feature); } } - return newArray.slice(0, 6); + return newArray.slice(0, this.nbFeaturedAssets); }), ); @@ -362,17 +371,27 @@ export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit { return block.height; } + getArrayFromNumber(num: number): number[] { + return Array.from({ length: num }, (_, i) => i + 1); + } + @HostListener('window:resize', ['$event']) onResize(): void { if (window.innerWidth >= 992) { this.incomingGraphHeight = 300; this.goggleResolution = 82; + this.lbtcPegGraphHeight = 320; + this.nbFeaturedAssets = 6; } else if (window.innerWidth >= 768) { this.incomingGraphHeight = 215; this.goggleResolution = 80; + this.lbtcPegGraphHeight = 230; + this.nbFeaturedAssets = 4; } else { this.incomingGraphHeight = 180; this.goggleResolution = 86; + this.lbtcPegGraphHeight = 220; + this.nbFeaturedAssets = 4; } } }