Skip to content

Commit

Permalink
style(#47): 💄 add background to the labels
Browse files Browse the repository at this point in the history
add background to make the labels visible even while displaying black or white datasets
  • Loading branch information
franmagn committed Nov 4, 2025
1 parent df109d3 commit 39ac3f2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
17 changes: 17 additions & 0 deletions src/MeasurementControl/measurementsPanel.css
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,21 @@
pointer-events: none;
}

/* On-canvas measurement label styling for improved contrast */
.measurement-canvas-label {
position: absolute;
transform: translate(-50%, -100%);
pointer-events: none;
color: #000;
background: rgba(255,255,255,0.95);
padding: 2px 6px;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0,0,0,0.35);
border: 1px solid rgba(0,0,0,0.08);
font-weight: 600;
font-size: 12px;
white-space: nowrap;
z-index: 2100;
}


12 changes: 3 additions & 9 deletions src/MeasurementControl/measurementsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export function initMeasurementsPanel(viewer) {
}
})
targetContainer = panel.querySelector('#measurements_list')
}
}
}
if (!targetContainer) {
console.warn(
'Measurements list container not found and dynamic injection failed'
Expand Down Expand Up @@ -186,13 +186,6 @@ export function initMeasurementsPanel(viewer) {
if (!lbl) {
lbl = document.createElement('div')
lbl.className = 'measurement-canvas-label'
lbl.style.position = 'absolute'
lbl.style.transform = 'translate(-50%, -100%)'
lbl.style.pointerEvents = 'none'
lbl.style.color = 'white'
lbl.style.fontWeight = 'bold'
lbl.style.textShadow = '0 0 4px rgba(0,0,0,0.9)'
lbl.style.fontSize = '12px'
overlay.appendChild(lbl)
overlayMap.set(measurement.uuid, lbl)
}
Expand All @@ -218,7 +211,8 @@ export function initMeasurementsPanel(viewer) {
el.style.display = 'none'
} else {
el.style.display = ''
el.style.transform = `translate(${Math.round(pos.x)}px, ${Math.round(pos.y)}px)`
el.style.left = Math.round(pos.x) + 'px'
el.style.top = Math.round(pos.y) + 'px'
}
} catch (e) {
// ignore
Expand Down

0 comments on commit 39ac3f2

Please sign in to comment.