Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

fix: undefined nav home button #540

Merged
merged 3 commits into from
Aug 24, 2023
Merged
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
20 changes: 18 additions & 2 deletions components/Layouts/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Props = {
}

const AppLayout = ({ children, username }: Props) => {
const router = useRouter()
const { memo } = useRouter().query
const [openSideBar, setOpenSideBar] = React.useState<boolean>(false)
const [copied, setCopied] = React.useState<boolean>(false)
Expand All @@ -35,12 +36,27 @@ const AppLayout = ({ children, username }: Props) => {
setOpenSideBar(false)
}

const navigateHome = () => {
let pathname = "/"
if (username) pathname = `/${username}`
router.push(
{
pathname,
},
undefined,
{ shallow: true },
)
setTimeout(function () {
router.reload() // Force a reload after a short delay to allow location href to update
}, 200)
}

return (
<div className={`${openSideBar && styles.container_bg} ${styles.container}`}>
<nav className={styles.nav_bar}>
<a href={`/${username}`} style={{ cursor: "pointer" }}>
<button className={styles.nav_home} onClick={navigateHome}>
<Image src="/icons/blink-logo-icon.svg" alt="logo" width="50" height="50" />
</a>
</button>
<div onClick={() => setOpenSideBar(!openSideBar)} className={styles.hamburger}>
<span className={`${openSideBar && styles.toggle}`}></span>
<span className={`${openSideBar && styles.toggle}`}></span>
Expand Down
6 changes: 6 additions & 0 deletions components/Layouts/app-layout.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
text-transform: uppercase;
}

.nav_home {
cursor: "pointer";
border: 0;
background-color: rgba(255, 0, 0, 0);
}

.lightning_addr {
padding-left: 1rem;
}
Expand Down