Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
zango-frontend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit e0d5deb1
authored
2024-07-01 19:22:15 +0530
by
Ravindra Kanojiya
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
header onclick issue resolved
1 parent
9bfe74c0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
7 deletions
components/layout/Header.js
styles/globals.css
components/layout/Header.js
View file @
e0d5deb
import
{
getSession
,
signOut
}
from
"next-auth/react"
;
import
Image
from
"next/image"
;
import
Link
from
"next/link"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
React
,
{
useEffect
,
use
Ref
,
use
State
}
from
"react"
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
cleanImage
}
from
"../../services/imageHandling"
;
import
{
Button
,
Container
,
Form
,
Nav
,
Navbar
}
from
"react-bootstrap"
;
...
...
@@ -24,9 +24,9 @@ const Header = () => {
// console.log("user", loadedUser);
const
[
isSticky
,
setIsSticky
]
=
useState
(
false
);
const
router
=
useRouter
();
const
toggleGridViewDropdown
=
()
=>
{
setIsGridViewOpen
(
!
isGridViewOpen
);
};
//
const toggleGridViewDropdown = () => {
//
setIsGridViewOpen(!isGridViewOpen);
//
};
useEffect
(()
=>
{
const
handleScroll
=
()
=>
{
// Check if the scroll position is greater than a certain threshold
...
...
@@ -49,6 +49,38 @@ const Header = () => {
useEffect
(()
=>
{
if
(
endUser
)
dispatch
(
getWishlists
({
endUser
:
endUser
.
id
}));
},
[
endUser
]);
////
// const [isGridViewOpen, setIsGridViewOpen] = useState(false);
const
innerBoxRef
=
useRef
(
null
);
// Ref to hold reference to inner-box div
const
logoutBkRef
=
useRef
(
null
);
// Function to toggle the dropdown visibility
const
toggleGridViewDropdown
=
()
=>
{
setIsGridViewOpen
(
!
isGridViewOpen
);
// Toggle the state
};
// Function to handle click outside
const
handleClickOutside
=
(
event
)
=>
{
if
(
logoutBkRef
.
current
&&
!
logoutBkRef
.
current
.
contains
(
event
.
target
)
&&
innerBoxRef
.
current
&&
!
innerBoxRef
.
current
.
contains
(
event
.
target
)
)
{
setIsGridViewOpen
(
false
);
// Close if clicked outside
}
};
// Effect to add click event listener when component mounts
useEffect
(()
=>
{
document
.
addEventListener
(
'mousedown'
,
handleClickOutside
);
return
()
=>
{
document
.
removeEventListener
(
'mousedown'
,
handleClickOutside
);
};
},
[]);
return
(
<
header
className
=
{
`header_wrap
${
isSticky
?
"stick"
:
""
}
`
}
>
{
isSticky
&&
<
div
style
=
{{
height
:
76
}}
className
=
"bg-transparent"
><
/div>
}
...
...
@@ -61,7 +93,7 @@ const Header = () => {
<
/Navbar.Brand
>
{
loadedUser
&&
loadedUser
.
id
?
(
<
div
className
=
"top-btn hide-on-desktop"
>
<
div
className
=
"logout-bk"
>
<
div
className
=
"logout-bk"
>
<
a
onClick
=
{
toggleGridViewDropdown
}
className
=
"user-icon"
>
<
span
className
=
"image-container user-pic"
>
<
Image
layout
=
"fill"
priority
alt
=
""
className
=
"image img-fluid"
src
=
"/images/icons/user.svg"
/>
...
...
@@ -71,7 +103,7 @@ const Header = () => {
<
/span
>
<
/a
>
{
/* <p>{loadedUser.phone}</p> */
}
<
div
className
=
{
`inner-box
${
isGridViewOpen
?
"open"
:
""
}
`
}
>
<
div
ref
=
{
logoutBkRef
}
className
=
{
`inner-box
${
isGridViewOpen
?
"open"
:
""
}
`
}
>
<
div
className
=
"user-info"
>
<
div
className
=
"pic"
>
<
span
className
=
"image-container"
>
...
...
@@ -267,7 +299,7 @@ const Header = () => {
<
/span
>
<
/a
>
{
/* <p>{loadedUser.phone}</p> */
}
<
div
className
=
{
`inner-box
${
isGridViewOpen
?
"open"
:
""
}
`
}
>
<
div
ref
=
{
innerBoxRef
}
className
=
{
`inner-box
${
isGridViewOpen
?
"open"
:
""
}
`
}
>
<
div
className
=
"user-info"
>
<
div
className
=
"pic"
>
<
span
className
=
"image-container"
>
...
...
styles/globals.css
View file @
e0d5deb
...
...
@@ -1920,6 +1920,7 @@ span.form-error,
.vendorDetails
p
.pview
{
color
:
#0070bd
;
text-decoration
:
underline
;
word-wrap
:
break-word
;
}
.vendorDetails
.borderLeft
{
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment