@@ -41,9 +41,14 @@ export function setupHoverEffects(parsedContent: ParsedContent) {
4141 }
4242 } ;
4343
44- const showDefinition = ( definition : string ) => {
44+ const showDefinition = ( definition : string , color : string = '' ) => {
4545 hoverDiv . innerHTML = renderLatexInText ( definition ) ;
4646 hoverDiv . classList . add ( "visible" ) ;
47+ if ( color ) {
48+ hoverDiv . style . borderColor = color ;
49+ } else {
50+ hoverDiv . style . borderColor = 'var(--border-color)' ; // Fallback
51+ }
4752 } ;
4853
4954 document . querySelectorAll ( '[class*="term-"]' ) . forEach ( ( element ) => {
@@ -55,7 +60,10 @@ export function setupHoverEffects(parsedContent: ParsedContent) {
5560 const definition = parsedContent . definitions . get (
5661 termClass . replace ( "term-" , "" )
5762 ) ;
58- // if (!definition) return; // Description might not have definition map if logic differs, but usually it matches
63+
64+ // Pre-calculate color
65+ const computedStyle = window . getComputedStyle ( element ) ;
66+ const termColor = computedStyle . color ;
5967
6068 ( element as HTMLElement ) . style . cursor = "pointer" ;
6169
@@ -68,7 +76,7 @@ export function setupHoverEffects(parsedContent: ParsedContent) {
6876 // If clicked from description, we need to find a definition if possible or just highlight
6977 if ( definition ) {
7078 clicked = { element : element as HTMLElement , termClass, definition } ;
71- showDefinition ( definition ) ;
79+ showDefinition ( definition , termColor ) ;
7280 } else {
7381 // Just highlight for visual feedback if no definition?
7482 // Assuming definitions exist for all valid term classes
@@ -92,7 +100,7 @@ export function setupHoverEffects(parsedContent: ParsedContent) {
92100 . querySelectorAll ( `.static-description .${ termClass } ` )
93101 . forEach ( ( el ) => el . classList . add ( "active" ) ) ;
94102
95- if ( definition ) showDefinition ( definition ) ;
103+ if ( definition ) showDefinition ( definition , termColor ) ;
96104 } ) ;
97105
98106 element . addEventListener ( "mouseleave" , ( ) => {
@@ -102,9 +110,14 @@ export function setupHoverEffects(parsedContent: ParsedContent) {
102110 . forEach ( ( el ) => el . classList . remove ( "active" ) ) ;
103111
104112 updateOverlay ( ) ; // Restore clicked state or clear
105- clicked
106- ? showDefinition ( clicked . definition )
107- : hoverDiv . classList . remove ( "visible" ) ;
113+ if ( clicked ) {
114+ // Re-apply color for clicked element
115+ const clickedEl = document . querySelector ( `.${ clicked . termClass } ` ) ;
116+ const clickedColor = clickedEl ? window . getComputedStyle ( clickedEl ) . color : '' ;
117+ showDefinition ( clicked . definition , clickedColor ) ;
118+ } else {
119+ hoverDiv . classList . remove ( "visible" ) ;
120+ }
108121 } ) ;
109122 } ) ;
110123}
0 commit comments