Skip to content

Commit bda96bd

Browse files
sloweyyyslowey-katalonclaude
authored
fix(leetcode): instant CSS tooltip on compact badges (was 1-2s native delay) (#7)
Native HTML title="" has a browser-imposed hover delay (~1-2 seconds on most platforms, longer on touch). For a tight icon strip like the compact badges row, that's unusable. Replaced with a data-tip attribute + CSS-only tooltip on .lc-badge-tip: - 80ms transition delay (instant-feeling, no flicker on quick passes) - Carbon canvas styling: surface-hi background, border-hi border, mono text, soft shadow, downward-pointing caret - Positioned above the icon, opacity 0→1 on :hover and :focus-visible Tile variant on /m/:login already showed name + date inline below the icon, so its now-redundant title= attribute was removed entirely. Co-authored-by: Truong Le Vinh Phuc <phuc.truong@katalon.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 460355a commit bda96bd

2 files changed

Lines changed: 53 additions & 2 deletions

File tree

app/globals.css

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,53 @@ footer {
14411441
border-radius: var(--r-button);
14421442
background: var(--surface-hi);
14431443
border: 1px solid var(--border);
1444+
position: relative;
1445+
}
1446+
1447+
/* CSS-only tooltip for compact badge icons. Native HTML title="" has a
1448+
browser-imposed ~1-2s hover delay; this fires within ~80ms and matches
1449+
the rest of the carbon canvas. */
1450+
.lc-badge-tip::after,
1451+
.lc-badge-tip::before {
1452+
position: absolute;
1453+
bottom: calc(100% + 8px);
1454+
left: 50%;
1455+
transform: translateX(-50%);
1456+
pointer-events: none;
1457+
opacity: 0;
1458+
transition: opacity 80ms ease-out 80ms;
1459+
z-index: 10;
1460+
}
1461+
1462+
.lc-badge-tip::after {
1463+
content: attr(data-tip);
1464+
white-space: nowrap;
1465+
background: var(--surface-hi);
1466+
color: var(--text-bright);
1467+
border: 1px solid var(--border-hi);
1468+
border-radius: var(--r-button);
1469+
padding: 6px 10px;
1470+
font-family: var(--font-mono);
1471+
font-size: 0.75rem;
1472+
letter-spacing: -0.1px;
1473+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
1474+
}
1475+
1476+
.lc-badge-tip::before {
1477+
content: "";
1478+
bottom: calc(100% + 2px);
1479+
width: 0;
1480+
height: 0;
1481+
border-left: 5px solid transparent;
1482+
border-right: 5px solid transparent;
1483+
border-top: 6px solid var(--border-hi);
1484+
}
1485+
1486+
.lc-badge-tip:hover::after,
1487+
.lc-badge-tip:hover::before,
1488+
.lc-badge-tip:focus-visible::after,
1489+
.lc-badge-tip:focus-visible::before {
1490+
opacity: 1;
14441491
}
14451492

14461493
.lc-badge img {

components/LeetcodeBadges.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ export default function LeetcodeBadges({ badges, variant = "compact", limit }: P
3434
</h4>
3535
<div className="lc-badges" aria-label={`${sorted.length} badges`}>
3636
{list.map((b) => (
37-
<span key={b.id} className="lc-badge" title={`${b.name} · ${b.creationDate}`}>
37+
<span
38+
key={b.id}
39+
className="lc-badge lc-badge-tip"
40+
data-tip={`${b.name} · ${b.creationDate}`}
41+
>
3842
<img src={b.icon} alt={b.name} loading="lazy" />
3943
</span>
4044
))}
@@ -68,7 +72,7 @@ export default function LeetcodeBadges({ badges, variant = "compact", limit }: P
6872
</h4>
6973
<div className="lc-badges">
7074
{groups.get(cat)!.map((b) => (
71-
<span key={b.id} className="lc-badge lc-badge-tile" title={`${b.name} · ${b.creationDate}`}>
75+
<span key={b.id} className="lc-badge lc-badge-tile">
7276
<img src={b.icon} alt={b.name} loading="lazy" />
7377
<span className="lc-badge-name">{b.name}</span>
7478
<span className="lc-badge-date">{b.creationDate}</span>

0 commit comments

Comments
 (0)