feat(annotations): add hover effect — increased opacity and inset border on hover
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -100,6 +100,8 @@ function handlePointerUp(event: PointerEvent) {
|
|||||||
drawRect = null;
|
drawRect = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let hoveredId = $state<string | null>(null);
|
||||||
|
|
||||||
const containerStyle = $derived(
|
const containerStyle = $derived(
|
||||||
`position: absolute; top: 0; left: 0; width: 100%; height: 100%;${canAnnotate ? ' cursor: crosshair;' : ''}`
|
`position: absolute; top: 0; left: 0; width: 100%; height: 100%;${canAnnotate ? ' cursor: crosshair;' : ''}`
|
||||||
);
|
);
|
||||||
@@ -120,14 +122,18 @@ const containerStyle = $derived(
|
|||||||
tabindex="0"
|
tabindex="0"
|
||||||
onclick={() => onAnnotationClick?.(annotation.id)}
|
onclick={() => onAnnotationClick?.(annotation.id)}
|
||||||
onkeydown={(e) => { if (e.key === 'Enter' || e.key === ' ') onAnnotationClick?.(annotation.id); }}
|
onkeydown={(e) => { if (e.key === 'Enter' || e.key === ' ') onAnnotationClick?.(annotation.id); }}
|
||||||
|
onmouseenter={() => (hoveredId = annotation.id)}
|
||||||
|
onmouseleave={() => (hoveredId = null)}
|
||||||
style="
|
style="
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: {annotation.x * 100}%;
|
left: {annotation.x * 100}%;
|
||||||
top: {annotation.y * 100}%;
|
top: {annotation.y * 100}%;
|
||||||
width: {annotation.width * 100}%;
|
width: {annotation.width * 100}%;
|
||||||
height: {annotation.height * 100}%;
|
height: {annotation.height * 100}%;
|
||||||
background-color: {hexToRgba(annotation.color, 0.3)};
|
background-color: {hexToRgba(annotation.color, hoveredId === annotation.id ? 0.5 : 0.3)};
|
||||||
|
box-shadow: {hoveredId === annotation.id ? `inset 0 0 0 2px ${hexToRgba(annotation.color, 0.8)}` : 'none'};
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
|
transition: background-color 0.15s ease, box-shadow 0.15s ease;
|
||||||
{onAnnotationClick && !canAnnotate ? 'cursor: pointer;' : ''}
|
{onAnnotationClick && !canAnnotate ? 'cursor: pointer;' : ''}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user