Skip to content

Commit 0519034

Browse files
committed
frame for explanation
1 parent e91a34c commit 0519034

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

src/style.css

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,19 @@ h1 {
276276
font-size: 1rem;
277277
line-height: 1.6;
278278
color: var(--text-secondary);
279-
text-align: center;
279+
text-align: left; /* Left aligned */
280280
font-family: var(--font-ui);
281-
margin-top: 1rem;
281+
margin: 1rem auto 0 auto;
282+
283+
/* Frame style */
284+
border: 1px solid var(--accent-color); /* Relevant color */
285+
background-color: #fff;
286+
padding: 1rem;
287+
border-radius: 4px;
288+
289+
/* Full width of text column */
290+
width: 100%;
291+
max-width: 700px; /* Match static-description max-width */
282292
}
283293

284294
.hover-explanation.visible {

src/ui/hover-effects.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)