fix: position floating catalog post preview relative to thumbnail dimensions

This commit is contained in:
Tom (plebeius.eth)
2024-06-08 12:07:36 +02:00
parent a8e3ce8429
commit 2a5ecf90ee
+6 -5
View File
@@ -112,7 +112,7 @@ const CatalogPost = ({ post }: { post: Comment }) => {
placement: placementRef.current, placement: placementRef.current,
middleware: [ middleware: [
shift({ padding: 10 }), shift({ padding: 10 }),
offset({ mainAxis: -7 }), offset({ mainAxis: 5 }),
size({ size({
apply({ availableWidth, elements }) { apply({ availableWidth, elements }) {
availableWidthRef.current = availableWidth; availableWidthRef.current = availableWidth;
@@ -157,11 +157,13 @@ const CatalogPost = ({ post }: { post: Comment }) => {
return ( return (
<> <>
<div className={styles.post} ref={refs.setReference}> <div className={styles.post}>
<div onMouseOver={() => setHoveredCid(cid)} onMouseLeave={() => setHoveredCid(null)}> <div onMouseOver={() => setHoveredCid(cid)} onMouseLeave={() => setHoveredCid(null)}>
{hasThumbnail ? ( {hasThumbnail ? (
<Link <Link to={postLink}>
to={postLink} <div
className={styles.mediaPaddingWrapper}
ref={refs.setReference}
onMouseOver={() => (timeoutRef.current = setTimeout(() => setShowPortal(true), 250))} onMouseOver={() => (timeoutRef.current = setTimeout(() => setShowPortal(true), 250))}
onMouseLeave={() => { onMouseLeave={() => {
setShowPortal(false); setShowPortal(false);
@@ -171,7 +173,6 @@ const CatalogPost = ({ post }: { post: Comment }) => {
} }
}} }}
> >
<div className={styles.mediaPaddingWrapper}>
{threadIcons} {threadIcons}
<CatalogPostMedia commentMediaInfo={commentMediaInfo} isOutOfFeed={isDescription || isRules} linkWidth={linkWidth} linkHeight={linkHeight} /> <CatalogPostMedia commentMediaInfo={commentMediaInfo} isOutOfFeed={isDescription || isRules} linkWidth={linkWidth} linkHeight={linkHeight} />
</div> </div>