Skip to content

Commit 58c2972

Browse files
committed
move variable to units
1 parent dbd9603 commit 58c2972

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

src/components/ui/Colorbar.tsx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,15 @@ const Colorbar = ({units, valueScales} : {units: string, valueScales: {maxVal: n
136136
</p>
137137
))}
138138
<canvas ref={canvasRef} width={512} height={24} onMouseDown={handleMouseDown}/>
139-
<p style={{
140-
position:'absolute',
141-
top:'-24px',
142-
left:'50%',
143-
transform:'translateX(-50%)',
144-
}}>
145-
{units}
146-
</p>
139+
<p className="colorbar-title"
140+
style={{
141+
position:'absolute',
142+
top:'-24px',
143+
left:'50%',
144+
transform:'translateX(-50%)',
145+
}}>
146+
{`${variable} [ ${units} ]`}
147+
</p>
147148
{(cScale != 1 || cOffset != 0) && <RxReset size={25} style={{position:'absolute', top:'-25px', cursor:'pointer'}} onClick={()=>{setCScale(1); setCOffset(0)}}/>}
148149
<div
149150
style={{
@@ -158,13 +159,6 @@ const Colorbar = ({units, valueScales} : {units: string, valueScales: {maxVal: n
158159
<FaMinus className='cursor-pointer' onClick={()=>setTickCount(Math.max(tickCount-1, 2))}/>
159160
<FaPlus className='cursor-pointer' onClick={()=>setTickCount(Math.min(tickCount+1, 10))}/>
160161
</div>
161-
<p style={{
162-
position:'absolute',
163-
top:'-24px',
164-
left:'0%',
165-
}}>
166-
{variable}
167-
</p>
168162
</div>
169163

170164
</>

src/components/ui/css/Colorbar.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
padding: 0 4px;
2525
}
2626

27+
.colorbar-title {
28+
white-space: nowrap;
29+
max-width: 90%;
30+
overflow: hidden;
31+
text-overflow: ellipsis;
32+
}
33+
34+
2735
@media (max-width: 768px) {
2836
.colorbar {
2937
width: 75%;

0 commit comments

Comments
 (0)