Skip to content

Commit ede1c78

Browse files
kuco23claude
andcommitted
claude:design: co-locate meterBar styles + delete dead progressBar.css
Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 11cfbfb commit ede1c78

5 files changed

Lines changed: 49 additions & 75 deletions

File tree

src/assets/css/index.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
@import 'responsive.css';
1414
@import 'custom.css';
1515
@import 'wallet.css';
16-
@import 'meterBar.css';
17-
@import 'progressBar.css';
1816
@import 'specs.css';
1917

2018
// --- Error display (used by ServerError + 404 page) ---

src/assets/css/meterBar.css

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/assets/css/progressBar.css

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/components/ui/meterBar.scss

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@use '../../assets/css/tokens' as t;
2+
3+
// LED-row meter used on the protocol stats pages (FSP success rates,
4+
// validator uptime, etc.). The LEDs and the status colours are bespoke
5+
// data-viz, not theme tokens — they live alongside the component so the
6+
// status palette stays scoped here.
7+
8+
.meter-bar-container {
9+
margin-top: t.$space-3;
10+
}
11+
12+
.meter-bar-title {
13+
font-size: t.$text-base;
14+
color: var(--heading-color);
15+
}
16+
17+
.meter-bar {
18+
display: flex;
19+
padding: 1.5px;
20+
}
21+
22+
.meter-bar-desc {
23+
text-align: center;
24+
width: 100px;
25+
font-size: t.$text-lg;
26+
margin: auto;
27+
margin-left: t.$space-2;
28+
}
29+
30+
.meter-bar-led {
31+
min-height: 100%;
32+
margin: 1px;
33+
flex-grow: 1;
34+
border-radius: 2px;
35+
}

src/components/ui/meterBar.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useMemo } from "react"
22
import { Formatter } from "~/utils/misc/formatter"
3+
import './meterBar.scss'
34

45
const MAX_PERC = 100
56

@@ -10,10 +11,14 @@ const MAX_LEDS = 70
1011
const OPACITY_BEFORE = 0.25
1112
const OPACITY_AFTER = 1
1213

13-
const COLOR_BAD = ["#d94357", "radial-gradient(#d94357 25%, #a82234)"]
14-
const COLOR_MED = ["#e58630", "radial-gradient(#a05714 25%, #dd781c)"]
15-
const COLOR_GUD = ["#76B768", "radial-gradient(#487e3c 25%, #64ae55)"]
16-
const COLORS = [COLOR_BAD, COLOR_MED, COLOR_GUD]
14+
// Bespoke status palette for the meter LEDs. Each tier carries the flat
15+
// label colour + the radial gradient used to render the LED itself.
16+
type StatusPalette = { label: string, gradient: string }
17+
18+
const STATUS_BAD: StatusPalette = { label: '#d94357', gradient: 'radial-gradient(#d94357 25%, #a82234)' }
19+
const STATUS_MEDIUM: StatusPalette = { label: '#e58630', gradient: 'radial-gradient(#a05714 25%, #dd781c)' }
20+
const STATUS_GOOD: StatusPalette = { label: '#76B768', gradient: 'radial-gradient(#487e3c 25%, #64ae55)' }
21+
const STATUS_PALETTE = [STATUS_BAD, STATUS_MEDIUM, STATUS_GOOD]
1722

1823
type args = {
1924
name: string
@@ -50,12 +55,12 @@ const MeterBar = ({ name, value, text, ranges, height = 40 }: args) => {
5055

5156
valueidx = getColorIdx(scaledValue, -1)
5257

53-
const data: { color: string[], opacity: number }[] = []
58+
const data: { palette: StatusPalette, opacity: number }[] = []
5459
for (let i = 0; i < leds; i++) {
5560
const ratio = getRatio(i)
56-
const color = getColorIdx(ratio, scaledValue)
61+
const idx = getColorIdx(ratio, scaledValue)
5762
const opacity = scaledValue < ratio ? OPACITY_BEFORE : OPACITY_AFTER
58-
data.push({ color: COLORS[color], opacity })
63+
data.push({ palette: STATUS_PALETTE[idx], opacity })
5964
}
6065

6166
return { data, valueidx }
@@ -68,10 +73,10 @@ const MeterBar = ({ name, value, text, ranges, height = 40 }: args) => {
6873
{
6974
data.map((d, i) => {
7075
return <span className='meter-bar-led'
71-
key={i} style={{ background: d.color[1], opacity: d.opacity }}></span>
76+
key={i} style={{ background: d.palette.gradient, opacity: d.opacity }}></span>
7277
})
7378
}
74-
<span className='meter-bar-desc' style={{ color: COLORS[valueidx][0] }}>
79+
<span className='meter-bar-desc' style={{ color: STATUS_PALETTE[valueidx].label }}>
7580
{ text ?? Formatter.percent(scaledValue / MAX_PERC) }
7681
</span>
7782
</div>

0 commit comments

Comments
 (0)