-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored main menu collapse behavior
- Loading branch information
Showing
7 changed files
with
104 additions
and
68 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
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,24 @@ | ||
"use client"; | ||
|
||
import {usePathname} from "next/navigation"; | ||
import {useEffect} from "react"; | ||
|
||
const DrupalWindowSync = () => { | ||
const pathname = usePathname(); | ||
|
||
useEffect(() => { | ||
if (!pathname) return; | ||
|
||
if ( | ||
pathname && | ||
!pathname?.startsWith('/gallery/') && | ||
window && | ||
window.top !== window.self | ||
) { | ||
window.parent.postMessage({type: "NEXT_DRUPAL_ROUTE_SYNC", path: pathname}, process.env.NEXT_PUBLIC_DRUPAL_BASE_URL as string) | ||
} | ||
}, [pathname]); | ||
return null; | ||
} | ||
|
||
export default DrupalWindowSync |
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 |
---|---|---|
@@ -1,32 +1,27 @@ | ||
'use client'; | ||
|
||
import {usePathname} from 'next/navigation'; | ||
import {useEffect, useState} from "react"; | ||
import {useEffect} from "react"; | ||
|
||
/** | ||
* When the user navigates to another page, get the url. | ||
*/ | ||
const useNavigationEvent = () => { | ||
const [url, setUrl] = useState<string>(); | ||
const pathname = usePathname(); | ||
|
||
useEffect(() => { | ||
if (!pathname) return; | ||
|
||
if (pathname !== url && !(pathname?.startsWith('/gallery-image/'))) { | ||
setUrl(pathname); | ||
|
||
if (pathname && window && window.top !== window.self) { | ||
// console.log('pathname', pathname); | ||
window.parent.postMessage( | ||
{type: "NEXT_DRUPAL_ROUTE_SYNC", path: pathname}, | ||
process.env.NEXT_PUBLIC_DRUPAL_BASE_URL as string | ||
) | ||
} | ||
if (pathname && !pathname?.startsWith('/gallery/') && window && window.top !== window.self) { | ||
// console.log('pathname', pathname); | ||
window.parent.postMessage( | ||
{type: "NEXT_DRUPAL_ROUTE_SYNC", path: pathname}, | ||
process.env.NEXT_PUBLIC_DRUPAL_BASE_URL as string | ||
) | ||
} | ||
}, [url, pathname]); | ||
}, [pathname]); | ||
|
||
return url; | ||
return pathname; | ||
} | ||
|
||
export default useNavigationEvent; |
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