Skip to content

Commit 27b84bb

Browse files
committed
Added logScale to tank widget
1 parent 23d08f2 commit 27b84bb

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/ui/widgets/Tank/tank.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const TankComponent = (
9292
percent={percent}
9393
width={width}
9494
outline={outline}
95+
logScale={logScale}
9596
></TankWithScale>
9697
);
9798
} else {

src/ui/widgets/Tank/tankWithScale.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const TankWithScale = (props: {
1313
percent: number;
1414
width: number;
1515
outline: string;
16+
logScale: boolean;
1617
}): JSX.Element => {
1718
const {
1819
min,
@@ -24,7 +25,8 @@ export const TankWithScale = (props: {
2425
font,
2526
percent,
2627
width,
27-
outline
28+
outline,
29+
logScale
2830
} = props;
2931
return (
3032
<span
@@ -45,7 +47,7 @@ export const TankWithScale = (props: {
4547
...font?.css()
4648
}}
4749
>
48-
{Number(max).toFixed(1)}
50+
{logScale ? Number(max).toExponential(0) : Number(max).toFixed(1)}
4951
</span>
5052
<span
5153
className={classes.ScaleMarker}
@@ -58,7 +60,9 @@ export const TankWithScale = (props: {
5860
...font?.css()
5961
}}
6062
>
61-
{Number(max / 2).toFixed(1)}
63+
{logScale
64+
? Number(max / 2).toExponential(0)
65+
: Number(max / 2).toFixed(1)}
6266
</span>
6367
<span
6468
className={classes.ScaleMarker}
@@ -71,7 +75,7 @@ export const TankWithScale = (props: {
7175
...font?.css()
7276
}}
7377
>
74-
{Number(min).toFixed(1)}
78+
{logScale ? Number(min).toExponential(0) : Number(min).toFixed(1)}
7579
</span>
7680
<span
7781
className={classes.EmptyTank}

0 commit comments

Comments
 (0)