Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/components/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { useLocation, NavLink } from "react-router-dom";
import { devLogo, wishlist, cart, burger, User } from "../../assets";
import { useAuth } from "../../Context/auth/auth-context";

import Tooltip from "../Tooltip/Tooltip";

import SidebarNav from "./SidebarNav";

const Navbar = () => {
Expand Down Expand Up @@ -49,9 +51,11 @@ const Navbar = () => {
{!pathArray.some((item) => currentPath.pathname === item) && (
<div className='auth-link flex jc-between flex-gap'>
{token ? (
<NavLink to='/profile' className='btn btn-icon'>
<img src={User} alt='userImage' />
</NavLink>
<Tooltip info='Profile'>
<NavLink to='/profile' className='btn btn-icon'>
<img src={User} alt='userImage' />
</NavLink>
</Tooltip>
) : (
<>
<NavLink to='/login' className='btn auth-login'>
Expand All @@ -67,14 +71,18 @@ const Navbar = () => {

<div className='nav-btn flex jc-between flex-gap'>
<a href='./screens/wishlist.html'>
<button className='btn btn-icon'>
<img src={wishlist} alt='wishlist_logo' />
</button>
<Tooltip info='wishlist'>
<button className='btn btn-icon'>
<img src={wishlist} alt='wishlist_logo' />
</button>
</Tooltip>
</a>
<a href='./screens/mycart.html'>
<button className='btn btn-icon'>
<img src={cart} alt='cart_icon' />
</button>
<Tooltip info='cart'>
<button className='btn btn-icon'>
<img src={cart} alt='cart_icon' />
</button>
</Tooltip>
</a>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions src/components/Tooltip/Shape.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const Shape = (props) => {
return (
<div className='shape flex flex-col ai-center'>
<div className='triangle'></div>
<div className='tooltip-text'>{props.children}</div>
</div>
);
};
export default Shape;
21 changes: 21 additions & 0 deletions src/components/Tooltip/Tooltip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useState } from "react";

import "./tooltip.css";
import Shape from "./Shape";
const Tooltip = (props) => {
const [show, setShow] = useState(false);
const onMouseHover = () => setShow(true);
const onMouseLeave = () => setShow(false);

return (
<div
className='tooltip-content'
onMouseOver={onMouseHover}
onMouseLeave={onMouseLeave}>
{props.children}
{show && <Shape>{props.info}</Shape>}
</div>
);
};

export default Tooltip;
14 changes: 14 additions & 0 deletions src/components/Tooltip/tooltip.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.shape {
position: absolute;
width: 100%;
}
.tooltip-text {
background-color: #575757;
padding: 8px 10px;
border-radius: 4px;
color: white;
font-size: 12px;
}
.tooltip-content {
position: relative;
}