-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from Tizzz-555/navbar-tooltip
Navbar Tooltip
- Loading branch information
Showing
10 changed files
with
147 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
.tooltipContainer { | ||
position: relative; | ||
display: inline-block; | ||
height: 100%; | ||
} | ||
|
||
.parent { | ||
position: absolute; | ||
z-index: 1000; | ||
top: calc(100% - 0.6rem); | ||
left: calc( | ||
-1 * (1.9rem + (1.4rem / 2)) | ||
); /* calc(-1 * (profile image width + (horizontal padding of content below / 2))) */ | ||
white-space: nowrap; | ||
opacity: 0; | ||
padding-top: 0.7rem; | ||
visibility: hidden; | ||
} | ||
|
||
.tooltipContent { | ||
padding: 1.2rem 1.4rem; | ||
background-color: hsla(var(--background-navbar-tooltip-hsl)); | ||
color: hsla(var(--foreground-inactive-hsl)); | ||
border-radius: 0.85rem; | ||
box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.1); | ||
font-size: 1.1rem; | ||
display: flex; | ||
font-weight: 400; | ||
flex-direction: column; | ||
gap: 0.8rem; | ||
} | ||
|
||
.tooltipContainer:hover > .parent { | ||
opacity: 1; | ||
top: calc(100% - 0.15rem); | ||
visibility: visible; | ||
transition: all 0.2s ease-out; | ||
} | ||
|
||
.tooltipContent > div { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.tooltipContent > div { | ||
cursor: pointer; | ||
transition: color 0.2s ease; | ||
border-radius: 4px; | ||
color: hsla(var(--foreground-inactive-hsl)); | ||
} | ||
|
||
.tooltipContent > div:hover { | ||
color: hsla(var(--foreground-active-hsl)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { AnimatePresence, motion } from 'framer-motion'; | ||
import React, { useEffect, useRef, useState } from 'react'; | ||
import styles from './Tooltip.module.css'; | ||
|
||
export default function Tooltip({ children, content }) { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const tooltipRef = useRef(null); | ||
const timeoutRef = useRef(null); | ||
|
||
const handleMouseEnter = () => { | ||
clearTimeout(timeoutRef.current); | ||
setIsOpen(true); | ||
}; | ||
|
||
const handleMouseLeave = () => { | ||
timeoutRef.current = setTimeout(() => { | ||
setIsOpen(false); | ||
}, 500); | ||
}; | ||
|
||
useEffect(() => { | ||
return () => { | ||
if (timeoutRef.current) { | ||
clearTimeout(timeoutRef.current); | ||
} | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div className={styles.tooltipContainer}> | ||
{children} | ||
<div className={styles.parent}> | ||
<div className={styles.tooltipContent}>{content}</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters