Skip to content

Commit 274c4ab

Browse files
authored
feat: add larger hover display for rune thumbnails in stepper (#105)
Hovering over rune thumbnails in the stepper now shows a bigger preview of the rune Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com
1 parent 229d826 commit 274c4ab

2 files changed

Lines changed: 45 additions & 6 deletions

File tree

src/web/stepper/src/SubstVisualizer.tsx

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,23 @@ function ProfileHoverTextPopover({ text }: { text: string }) {
397397
);
398398
}
399399

400+
/** Popover body for an `image` part: the inline opaque-value thumbnail, enlarged to be legible. */
401+
function EnlargedThumbnailPopover({ src, alt }: { src: string; alt?: string }) {
402+
return (
403+
<div className={classNames("stepper-popover", Classes.DARK)}>
404+
<div className="stepper-display">
405+
{alt ? (
406+
<>
407+
<Icon icon="media" />
408+
<span>{` ${alt}`}</span>
409+
</>
410+
) : null}
411+
<img className="stepper-opaque-thumbnail-large" src={src} alt={alt ?? ""} />
412+
</div>
413+
</div>
414+
);
415+
}
416+
400417
/**
401418
* renderNode renders a serialized Stepper AST node to a React ReactNode.
402419
*/
@@ -860,14 +877,23 @@ function renderNode(
860877
const src = readNodeProp(node, part.image);
861878
if (typeof src !== "string" || !src.startsWith("data:")) return null;
862879
const alt = part.altProp === undefined ? undefined : readNodeProp(node, part.altProp);
880+
const altText = alt == null ? "" : String(alt);
863881
return (
864-
<img
882+
<Popover
865883
key={key}
866-
className={classNames("stepper-opaque-thumbnail", cls(part.cls))}
867-
src={src}
868-
alt={alt == null ? "" : String(alt)}
869-
title={alt == null ? undefined : String(alt)}
870-
/>
884+
interactionKind="hover"
885+
placement="bottom"
886+
usePortal={popoverDepth === 0}
887+
lazy
888+
popoverClassName="stepper-popover"
889+
content={<EnlargedThumbnailPopover src={src} alt={altText} />}
890+
>
891+
<img
892+
className={classNames("stepper-opaque-thumbnail", cls(part.cls))}
893+
src={src}
894+
alt={altText}
895+
/>
896+
</Popover>
871897
);
872898
}
873899
return null;

src/web/stepper/src/styles.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ const STEPPER_CSS = `
6262
border-radius: 3px;
6363
}
6464
65+
/* The same thumbnail enlarged, shown in the hover popover so an opaque value (e.g. a rune) is
66+
* actually legible while the inline copy stays at text height. A fixed width (not max-width) forces
67+
* a low-resolution thumbnail to scale up rather than render at its small intrinsic size. */
68+
.sa-substituter .stepper-opaque-thumbnail-large,
69+
.stepper-popover .stepper-opaque-thumbnail-large {
70+
display: block;
71+
width: min(200px, 50vw);
72+
height: auto;
73+
margin-top: 6px;
74+
border-radius: 3px;
75+
image-rendering: auto;
76+
}
77+
6578
.sa-substituter .stepper-mu-term,
6679
.stepper-popover .stepper-mu-term {
6780
font-weight: bold;

0 commit comments

Comments
 (0)