Skip to content

Commit 21337bc

Browse files
committed
feat(highlighter): improved label position
1 parent ef5efac commit 21337bc

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

packages/app-backend-core/src/highlighter.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ function createOverlay () {
2424
overlayContent.style.borderRadius = '3px'
2525
overlayContent.style.color = '#333'
2626
overlayContent.style.textAlign = 'center'
27-
overlayContent.style.border = '#42B983 1px solid'
27+
overlayContent.style.border = 'rgba(65, 184, 131, 0.5) 1px solid'
28+
overlayContent.style.backgroundClip = 'padding-box'
2829
}
2930

3031
// Use a job queue to preserve highlight/unhighlight calls order
@@ -91,13 +92,16 @@ function showOverlay ({ width = 0, height = 0, top = 0, left = 0 }, children: No
9192
// Content position (prevents overflow)
9293
const contentWidth = overlayContent.offsetWidth
9394
const contentHeight = overlayContent.offsetHeight
94-
let contentLeft = left + (width - contentWidth) / 2
95+
let contentLeft = left
9596
if (contentLeft < 0) {
9697
contentLeft = 0
9798
} else if (contentLeft + contentWidth > window.innerWidth) {
9899
contentLeft = window.innerWidth - contentWidth
99100
}
100-
let contentTop = top + (height - contentHeight) / 2
101+
let contentTop = top - contentHeight - 2
102+
if (contentTop < 0) {
103+
contentTop = top + height + 2
104+
}
101105
if (contentTop < 0) {
102106
contentTop = 0
103107
} else if (contentTop + contentHeight > window.innerHeight) {

0 commit comments

Comments
 (0)