@@ -10,7 +10,7 @@ const Handler_Gap = 20;
1010const Handler_Width = 14 ;
1111
1212const store = useSequenceDiagramStore ();
13- const { handlers, endpointCentrePoints } = storeToRefs (store );
13+ const { handlers, endpointCentrePoints, highlightId } = storeToRefs (store );
1414
1515const messageTypeRefs = ref <SVGTextElement []>([]);
1616
@@ -27,6 +27,7 @@ const handlerItems = computed(() => {
2727 const fill = (() => {
2828 if (handler .id === " First" ) return " black" ;
2929 if (handler .state === HandlerState .Fail ) return " var(--error)" ;
30+ if (handler .route ?.name === highlightId .value ) return " var(--highlight-background)" ;
3031 return " var(--gray60)" ;
3132 })();
3233 const icon = (() => {
@@ -41,7 +42,8 @@ const handlerItems = computed(() => {
4142 })();
4243
4344 return {
44- key: handler .id ,
45+ id: handler .id ,
46+ incomingId: handler .route ?.name ,
4547 left: (endpoint ?.centre ?? 0 ) - Handler_Width / 2 ,
4648 right: (endpoint ?.centre ?? 0 ) + Handler_Width / 2 ,
4749 y ,
@@ -51,11 +53,12 @@ const handlerItems = computed(() => {
5153 iconSize ,
5254 messageType: handler .name ,
5355 messageTypeOffset: handler .direction === Direction .Right ? ((messageTypeElement ?.getBBox ().width ?? 0 ) + 24 ) * - 1 : 20 ,
56+ messageTypeHighlight: handler .route ?.name === highlightId .value ,
5457 };
5558 });
5659
5760 store .setMaxHeight (nextY );
58- store .setHandlerLocations (result .map ((handler ) => ({ id: handler .key , left: handler .left , right: handler .right , y: handler .y , height: handler .height })));
61+ store .setHandlerLocations (result .map ((handler ) => ({ id: handler .id , left: handler .left , right: handler .right , y: handler .y , height: handler .height })));
5962
6063 return result ;
6164});
@@ -67,15 +70,28 @@ function setMessageTypeRef(el: SVGTextElement, index: number) {
6770
6871<template >
6972 <g >
70- <g v-for =" (handler, i) in handlerItems" :key =" handler.key " :transform =" `translate(${handler.left}, ${handler.y})`" >
73+ <g v-for =" (handler, i) in handlerItems" :key =" handler.id " :transform =" `translate(${handler.left}, ${handler.y})`" >
7174 <!-- Handler Activation Box-->
72- <rect :width =" Handler_Width" :height =" handler.height" :fill =" handler.fill" />
75+ <rect :width =" Handler_Width" :height =" handler.height" :class = " handler.incomingId && 'clickable' " : fill =" handler.fill" @mouseover = " () => store.setHighlightId(handler.incomingId) " @mouseleave = " () => store.setHighlightId() " />
7376 <path v-if =" handler.icon" :d =" handler.icon" fill =" white" :transform =" `translate(${Handler_Width / 2 - handler.iconSize / 2}, ${handler.height / 2 - handler.iconSize / 2})`" />
7477 <!-- Message Type and Icon-->
75- <g v-if =" handler.messageType" :transform =" `translate(${handler.messageTypeOffset}, 4)`" fill =" var(--gray40)" >
78+ <g
79+ v-if =" handler.messageType"
80+ :transform =" `translate(${handler.messageTypeOffset}, 4)`"
81+ class =" clickable"
82+ :fill =" handler.messageTypeHighlight ? 'var(--highlight)' : 'var(--gray40)'"
83+ @mouseover =" () => store.setHighlightId(handler.incomingId)"
84+ @mouseleave =" () => store.setHighlightId()"
85+ >
7686 <path d =" M9,3L9,3 9,0 0,0 0,3 4,3 4,6 0,6 0,9 4,9 4,12 0,12 0,15 9,15 9,12 5,12 5,9 9,9 9,6 5,6 5,3z" />
7787 <text x =" 14" y =" 10" alignment-baseline =" middle" :ref =" (el) => setMessageTypeRef(el as SVGTextElement, i)" >{{ handler.messageType }}</text >
7888 </g >
7989 </g >
8090 </g >
8191</template >
92+
93+ <style scoped>
94+ .clickable {
95+ cursor : pointer ;
96+ }
97+ </style >
0 commit comments