Skip to content

Commit 9790e68

Browse files
authored
fix: adjust positioning logic for mean label in RangeWithValue component (#307)
Co-authored-by: Simon Bigelmayr <simon.bigelmayr@mll.com>
1 parent 3d58b2e commit 9790e68

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/RangeWithValue/index.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,16 @@ export function RangeWithValue({
7272
});
7373

7474
const meanValue = (expectedMin + expectedMax) / 2;
75-
const meanLabelWidth = 28;
75+
const meanLabelWidth = 18;
7676

7777
return (
7878
<Container>
7979
<Scale>
8080
<RangeLine left={`${percentage(expectedMin)}%`} />
8181
<RangeLine left={`${percentage(expectedMax)}%`} />
8282
{showMean && (
83-
<Label
84-
left={`calc(${percentage(meanValue)}% - ${meanLabelWidth / 2}px)`}
85-
>
86-
{meanValue.toFixed(2)}
87-
</Label>
83+
<RangeLine left={`calc(${percentage(meanValue)}% - 0.5px)`} />
8884
)}
89-
9085
<Tooltip
9186
title={(() => {
9287
if (isOutOfRange) {
@@ -129,6 +124,13 @@ export function RangeWithValue({
129124
<Label left={`calc(${percentage(expectedMax)}% - 14px)`}>
130125
{expectedMax}
131126
</Label>
127+
{showMean && (
128+
<Label
129+
left={`calc(${percentage(meanValue)}% - ${meanLabelWidth / 2}px)`}
130+
>
131+
{meanValue.toFixed(2)}
132+
</Label>
133+
)}
132134
</LabelWrapper>
133135
</Container>
134136
);

0 commit comments

Comments
 (0)