From 6b53ce6f7cc3180413588c5ecdbd937f308e7c89 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Tue, 5 Sep 2023 21:40:29 +0200 Subject: [PATCH] improve catalog card hover --- .../styled/views/Catalog.styled.jsx | 42 +++++++-------- src/components/views/Catalog.jsx | 51 +++++++++++-------- 2 files changed, 51 insertions(+), 42 deletions(-) diff --git a/src/components/styled/views/Catalog.styled.jsx b/src/components/styled/views/Catalog.styled.jsx index cdb422ca..6afe8d10 100644 --- a/src/components/styled/views/Catalog.styled.jsx +++ b/src/components/styled/views/Catalog.styled.jsx @@ -4,7 +4,7 @@ export const Threads = styled.div` padding: 20px 0; text-align: center; margin: 0; - overflow:hidden; + overflow: hidden; .thread { width: 180px; @@ -18,48 +18,49 @@ export const Threads = styled.div` padding: 5px 0 3px; } - .thread_popup{ + .thread_popup { display: inline-block; - height:auto; - background-color:black; - position:absolute; - margin-top:0px; - text-align:left; - z-index:10; + height: auto; + background-color: black; + position: absolute; + margin-top: 0px; + text-align: left; + z-index: 10; transform:none; - padding-left:5px;padding-right:5px; - border-radius:3px; + padding-left: 5px; + padding-right: 5px; + border-radius: 3px; + white-space: nowrap; } .thread_popup_content { + max-width: 500px; margin: 5px 3px 2px 3px !important; color: #dedede; display: inline-block; overflow: hidden; - white-space:nowrap; - font-size:13px; + font-size: 13px; } - .thread_popup_lastReply{ + .thread_popup_lastReply { margin: 0px 4px 5px 4px !important; color: #bbbfbd; display: block; - width: auto; min-width: 250px; - overflow: hidden; text-overflow: ellipsis; - font-size:90%; + font-size: 90%; } - .thread_popup_title{ + .thread_popup_title { color:#a89baa } - .thread_popup_author{ - color:#519860;font-weight:bold + .thread_popup_author { + color:#519860; + font-weight: bold } - .thread_popup_authorAdmin{ + .thread_popup_authorAdmin { color: purple; font-weight: 700; } @@ -128,7 +129,6 @@ export const Threads = styled.div` } .meta { - cursor: help; font-size: 11px; line-height: 8px; margin-top: 2px; diff --git a/src/components/views/Catalog.jsx b/src/components/views/Catalog.jsx index 02325712..2dcf81b6 100755 --- a/src/components/views/Catalog.jsx +++ b/src/components/views/Catalog.jsx @@ -134,7 +134,6 @@ const CatalogPost = ({post}) => { const handleMouseOnLeaveThread = () => { - setIsHoveringForMenu(false); if (hoverTimeoutId) { clearTimeout(hoverTimeoutId); setHoverTimeoutId(null); @@ -350,13 +349,9 @@ const CatalogPost = ({post}) => { { setIsHoveringForMenu('rules'); - if (!hoverTimeoutId) { - const timeoutId = setTimeout(() => { - setIsHoveringOnThread("rules"); - }, 250); - setHoverTimeoutId(timeoutId); - } - }}> + handleMouseOnLeaveThread(); + }} + onMouseLeave={() => setIsHoveringForMenu(false)}>
R: 0 / L: 0
{ }, 250); setHoverTimeoutId(timeoutId); } - }}> + }} + onMouseLeave={() => setIsHoveringForMenu(false)}>
Rules {": " + subplebbit.rules?.map((rule, index) => `${index + 1}. ${rule}`).join(' ')} @@ -459,6 +455,7 @@ const CatalogPost = ({post}) => { setHoverTimeoutId(timeoutId); } }} + onMouseLeave={() => setIsHoveringForMenu(false)} src={subplebbit.suggested.avatarUrl} alt="board avatar" /> ) : null} @@ -475,13 +472,9 @@ const CatalogPost = ({post}) => { { setIsHoveringForMenu('description'); - if (!hoverTimeoutId) { - const timeoutId = setTimeout(() => { - setIsHoveringOnThread("description"); - }, 250); - setHoverTimeoutId(timeoutId); - } - }}> + handleMouseOnLeaveThread(); + }} + onMouseLeave={() => setIsHoveringForMenu(false)}>
R: 0 / L: 0 {subplebbit.suggested?.avatarUrl ? null : ( @@ -579,7 +572,8 @@ const CatalogPost = ({post}) => { }, 250); setHoverTimeoutId(timeoutId); } - }}> + }} + onMouseLeave={() => setIsHoveringForMenu(false)}>
Welcome to {subplebbit.title || subplebbit.address}! {": " + subplebbit.description} @@ -637,7 +631,12 @@ const CatalogPost = ({post}) => { : null } {commentMediaInfo?.url ? ( setSelectedThread(thread.cid)} onMouseOver={() => setIsHoveringOnThread(thread.cid)}> + onClick={() => setSelectedThread(thread.cid)} + onMouseOver={() => { + setIsHoveringOnThread(thread.cid); + setIsHoveringForMenu(thread.cid); + }} + onMouseLeave={() => setIsHoveringForMenu(false)}> {commentMediaInfo?.type === "webpage" ? ( thread.thumbnailUrl ? ( @@ -697,7 +696,12 @@ const CatalogPost = ({post}) => { ) : null}
) : null} - handleMouseOnLeaveThread()} + { + setIsHoveringForMenu(thread.cid); + handleMouseOnLeaveThread(); + }} + onMouseLeave={() => setIsHoveringForMenu(false)} style={{ all: "unset"}}>
R: {thread.replyCount} @@ -723,7 +727,7 @@ const CatalogPost = ({post}) => {
)} {
(threadRefs.current[thread.cid] = el)}> - setIsHoveringOnThread(thread.cid)}> + { + setIsHoveringOnThread(thread.cid); + setIsHoveringForMenu(thread.cid); + }} + onMouseLeave={() => setIsHoveringForMenu(false)}> {thread.title ? `${thread.title}` : null} {thread.content ? `: ${thread.content}` : null}