Skip to content

Commit 9733dd2

Browse files
committed
chore: add nowrap to whitespaces, lower avalanche background image quality, rename some stuff
1 parent ef52ac5 commit 9733dd2

File tree

15 files changed

+48
-37
lines changed

15 files changed

+48
-37
lines changed

src/assets/css/custom.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@
8484

8585
/* DELEGATION LIST */
8686

87-
8887
.delegation-updates {
8988
display: grid;
9089
grid-template-columns: auto auto auto auto auto;
90+
white-space: nowrap;
9191
overflow-x: auto;
9292
}
9393

src/assets/css/specs.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
.specs-table-container {
99
overflow-x: auto;
10+
white-space: nowrap;
1011
width: auto;
1112
}
1213

@@ -32,8 +33,8 @@
3233

3334
.specs-table-data-right {
3435
text-align: right;
35-
color: white;
3636
font-weight: bold;
37+
color: white;
3738
}
3839

3940
.specs-table-data-left {
-830 KB
Binary file not shown.
146 KB
Loading

src/components/pages/fsp-stats.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const FspStatsComponent = ({ stats, chain }: { stats: FspStatisticsDto, chain: C
5454
<div className="row">
5555
<div className="col-lg-6">
5656
<MeterBar name='Primary Success' ranges={[20, 50]} value={last.primary} text={primary} />
57-
<MeterBar name='Secondary Success' ranges={[80, 95]} value={last.secondary} text={secondary} />
57+
<MeterBar name='Secondary Success' ranges={[75, 90]} value={last.secondary} text={secondary} />
5858
</div>
5959
<div className="col-lg-6">
6060
<MeterBar name='Uptime' ranges={[95, 98]} value={last.uptime} text={uptime} />

src/components/sections/hero.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { PageDataService } from '~/backendApi'
55
import profile from "../../assets/images/about/profile.svg"
66
import SlideUp from '../../utils/animations/slideUp'
77
import ServerError from '../ui/serverError'
8-
import DelegatedStats from '../ui/baseMetrics'
9-
import DelegationList from '../ui/delegationList'
8+
import DelegationSummary from '../ui/delegationSummary'
9+
import DelegationUpdates from '../ui/delegationUpdates'
1010
import { REFRESH_QUERY_SLOW_MS } from '~/constants'
1111

1212

@@ -26,12 +26,12 @@ const Hero = () => {
2626
component = <>
2727
<SlideUp>
2828
<div className="about-content-part">
29-
<DelegatedStats data={data} isLoading={isLoading} error={error} />
29+
<DelegationSummary data={data} isLoading={isLoading} error={error} />
3030
</div>
3131
</SlideUp>
3232
<SlideUp>
3333
<div className="about-content-part-bottom">
34-
<DelegationList data={data} isLoading={isLoading} error={error} />
34+
<DelegationUpdates data={data} isLoading={isLoading} error={error} />
3535
</div>
3636
</SlideUp>
3737
</>
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { PAGE_COLOR_CODE } from "~/constants"
77
const DOWN_ARROW = "M6 9L12 15L18 9"
88
const UP_ARROW = "M18 15L12 9L6 15"
99

10-
const DelegatedStats = ({ data, isLoading, error }: {
10+
const DelegationSummary = ({ data, isLoading, error }: {
1111
data: ApiResponseDto_PageStatsDto, isLoading: boolean, error: string
1212
}) => {
1313
let delegated = null
@@ -21,8 +21,8 @@ const DelegatedStats = ({ data, isLoading, error }: {
2121
const _delegators1 = data.data.delegated.reduce((x, y) => x + y.delegators, 0)
2222
delegated = Formatter.number(_delegated1)
2323
delegators = Formatter.number(_delegators1)
24-
delegatedDiff = Formatter.percent(_delegated0 > 0 ? _delegated1 / _delegated0 - 1 : 0, 0)
25-
delegatorDiff = Formatter.percent(_delegators0 > 0 ? _delegators1 / _delegators0 - 1 : 0, 0)
24+
delegatedDiff = Formatter.percent(_delegated0 > 0 ? _delegated1 / _delegated0 - 1 : 0)
25+
delegatorDiff = Formatter.percent(_delegators0 > 0 ? _delegators1 / _delegators0 - 1 : 0)
2626
} else if (isLoading) {
2727
return <div style={{ textAlign: 'center' }}>
2828
<SpinnerCircular color={PAGE_COLOR_CODE} size={40} />
@@ -82,4 +82,4 @@ const DelegatedStats = ({ data, isLoading, error }: {
8282
</div>
8383
}
8484

85-
export default DelegatedStats
85+
export default DelegationSummary
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const NumberDiff = ({ text, value }: { text: string, value: bigint }) => {
5757
}
5858
}
5959

60-
const DelegationList = ({ data, isLoading, error }: {
60+
const DelegationUpdates = ({ data, isLoading, error }: {
6161
data: ApiResponseDto_PageStatsDto, isLoading: boolean, error: string
6262
}) => {
6363

@@ -97,4 +97,4 @@ const DelegationList = ({ data, isLoading, error }: {
9797
}
9898

9999

100-
export default DelegationList
100+
export default DelegationUpdates

src/components/ui/meterBar.tsx

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { Formatter } from "~/utils/misc/formatter"
22

33
const MAX_PERC = 100
4-
const LED_TOTAL = 70
4+
5+
const LEDS_PER_PIXEL = 0.035
6+
const MIN_LEDS = 10
7+
const MAX_LEDS = 70
58

69
const OPACITY_BEFORE = 0.25
710
const OPACITY_AFTER = 1
@@ -20,40 +23,45 @@ type args = {
2023
reverse?: boolean
2124
}
2225

23-
const MeterBar = ({ name, value, text, ranges, height = 40, reverse = false }: args) => {
26+
const MeterBar = ({ name, value, text, ranges, height = 40 }: args) => {
27+
const leds = Math.min(Math.max(LEDS_PER_PIXEL * window.innerWidth, MIN_LEDS), MAX_LEDS)
28+
2429
value = value * MAX_PERC
30+
let valueidx = 0
2531

2632
function getRatio(index: number) {
27-
return Math.floor(MAX_PERC * index / LED_TOTAL)
33+
return Math.floor(MAX_PERC * index / leds)
2834
}
2935

3036
function getLedOpacity(ratio: number) {
3137
return value < ratio ? OPACITY_BEFORE : OPACITY_AFTER
3238
}
3339

34-
function getLedColor(ratio: number) {
40+
function getColorIdx(ratio: number): number {
41+
if (ratio < value) {
42+
return valueidx
43+
}
3544
let coloridx = null
3645
for (let i = 0; i < ranges.length; i++) {
37-
if (ratio < ranges[i]) {
46+
if (ranges[i] >= ratio) {
3847
coloridx = i
3948
break
4049
}
4150
}
42-
if (coloridx == null) coloridx = ranges.length
43-
return reverse ? COLORS[ranges.length-coloridx] : COLORS[coloridx]
51+
if (coloridx == null) {
52+
coloridx = ranges.length
53+
}
54+
return coloridx
4455
}
4556

46-
const valuecolor = getLedColor(value)
47-
if (text == null) {
48-
text = Formatter.percent(value / 100, 0)
49-
}
57+
valueidx = getColorIdx(value)
5058

5159
let data: { color: string[], opacity: number }[] = []
52-
for (let i = 0; i < LED_TOTAL; i++) {
60+
for (let i = 0; i < leds; i++) {
5361
const ratio = getRatio(i)
54-
const color = getLedColor(ratio)
62+
const color = getColorIdx(ratio)
5563
const opacity = getLedOpacity(ratio)
56-
data.push({ color, opacity })
64+
data.push({ color: COLORS[color], opacity })
5765
}
5866

5967
return (
@@ -66,7 +74,9 @@ const MeterBar = ({ name, value, text, ranges, height = 40, reverse = false }: a
6674
key={i} style={{ background: d.color[1], opacity: d.opacity }}></span>
6775
})
6876
}
69-
<span className='meter-bar-desc' style={{ color: valuecolor[0] }}>{ text }</span>
77+
<span className='meter-bar-desc' style={{ color: COLORS[valueidx][0] }}>
78+
{ text ?? Formatter.percent(value / MAX_PERC) }
79+
</span>
7080
</div>
7181
</div>
7282
);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { unixnow } from "~/utils/misc/time"
55
import { REFRESH_QUERY_FAST_MS } from "~/constants"
66

77

8-
const DelegatorList = ({ delegators }: { delegators: AvalancheDelegationDto[] }) => {
8+
const UserDelegations = ({ delegators }: { delegators: AvalancheDelegationDto[] }) => {
99
let { data: now } = useSWR('delegator-list-refresh', (_) => null, { refreshInterval: REFRESH_QUERY_FAST_MS })
1010
now = unixnow()
1111

@@ -37,4 +37,4 @@ const DelegatorList = ({ delegators }: { delegators: AvalancheDelegationDto[] })
3737

3838
}
3939

40-
export default DelegatorList
40+
export default UserDelegations

0 commit comments

Comments
 (0)