Skip to content

Commit 92d3844

Browse files
committed
feat: highlight axes when hovering/focusing related facet inputs
1 parent bc140c5 commit 92d3844

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

app/components/Compare/FacetScatterChart.vue

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const { colors } = useCssVariables(
2929
'--border',
3030
'--border-subtle',
3131
'--border-hover',
32+
'--accent',
3233
],
3334
{
3435
element: rootEl,
@@ -269,6 +270,13 @@ const config = computed<VueUiScatterConfig>(() => {
269270
})
270271
271272
const step = shallowRef(0)
273+
274+
type AxisHighlight = 'x' | 'y' | null
275+
const highlightedAxis = shallowRef<AxisHighlight>(null)
276+
277+
function toggleAxisHighlight(state: AxisHighlight) {
278+
highlightedAxis.value = state
279+
}
272280
</script>
273281

274282
<template>
@@ -300,6 +308,9 @@ const step = shallowRef(0)
300308
size="sm"
301309
block
302310
@change="step += 1"
311+
@mouseenter="toggleAxisHighlight('x')"
312+
@mouseleave="toggleAxisHighlight(null)"
313+
@blur="toggleAxisHighlight(null)"
303314
/>
304315
<SelectField
305316
class="w-full"
@@ -310,6 +321,9 @@ const step = shallowRef(0)
310321
size="sm"
311322
block
312323
@change="step += 1"
324+
@mouseenter="toggleAxisHighlight('y')"
325+
@mouseleave="toggleAxisHighlight(null)"
326+
@blur="toggleAxisHighlight(null)"
313327
/>
314328
</div>
315329

@@ -374,6 +388,32 @@ const step = shallowRef(0)
374388
})
375389
"
376390
/>
391+
392+
<!-- Highlighted axes when hovering facet inputs -->
393+
<template v-if="highlightedAxis">
394+
<line
395+
v-if="highlightedAxis === 'x'"
396+
:x1="svg.drawingArea.left"
397+
:x2="svg.drawingArea.right"
398+
:y1="svg.drawingArea.bottom"
399+
:y2="svg.drawingArea.bottom"
400+
:stroke="colors.accent"
401+
stroke-dasharray="5"
402+
stroke-linecap="round"
403+
stroke-width="2"
404+
/>
405+
<line
406+
v-if="highlightedAxis === 'y'"
407+
:x1="svg.drawingArea.left"
408+
:x2="svg.drawingArea.left"
409+
:y1="svg.drawingArea.top"
410+
:y2="svg.drawingArea.bottom"
411+
:stroke="colors.accent"
412+
stroke-dasharray="5"
413+
stroke-linecap="round"
414+
stroke-width="2"
415+
/>
416+
</template>
377417
</template>
378418

379419
<template #menuIcon="{ isOpen }">

0 commit comments

Comments
 (0)