forked from ShelterTechSF/askdarcel-web
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds component markup for logo and dropdown menus using Strapi data for desktop #65
Merged
rosschapman
merged 19 commits into
OUR415-87-header-nav-base
from
OUR415-87-header-nav-logo-dropdown
Jul 2, 2024
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
7bda4b1
Checkpoint
rosschapman aa15d41
Decouples SiteSearch from Navigation
rosschapman 3a2b9eb
Removes unused param
rosschapman 5c9291e
Merge branch 'OUR415-87-header-nav-decouple-search' into OUR415-87-he…
rosschapman 80337a9
Adds types
rosschapman 707e6ea
Checkpoint
rosschapman b6eea79
Checkpoint
rosschapman 1c93660
Checkpoint
rosschapman 998d9ed
Updates types
rosschapman 9864db0
Fixes types
rosschapman f3ac3a2
Moves comment
rosschapman 72cf424
Checkpoint
rosschapman ca92571
Checkpoint
rosschapman 8c064f4
Merge branch 'OUR415-87-header-nav-base' into OUR415-87-header-nav-lo…
rosschapman f0ed582
Updates markup scope
rosschapman f12a317
Merge branch 'OUR415-87-header-nav-base' into OUR415-87-header-nav-lo…
rosschapman 27f8c44
Merge branch 'OUR415-87-header-nav-base' into OUR415-87-header-nav-lo…
rosschapman 9739156
Removes empty
rosschapman f57e29c
Reverts minor changes
rosschapman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,20 +1,71 @@ | ||
import React from "react"; | ||
import React, { useState } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import Translate from "./Translate"; | ||
import Translate from "components/ui/Translate"; | ||
import { useNavigationData } from "../../hooks/StrapiAPI"; | ||
import { | ||
StrapiModel, | ||
extractLogoFromNavigationResponse, | ||
extractNavigationMenusFromNavigationResponse, | ||
} from "../../models/Strapi"; | ||
import styles from "./Navigation.module.scss"; | ||
|
||
export const Navigation = ({ | ||
toggleHamburgerMenu, | ||
}: { | ||
toggleHamburgerMenu: () => void; | ||
}) => { | ||
const { data: navigationResponse, error, isLoading } = useNavigationData(); | ||
const [dropdown, setDropdown] = useState(false); | ||
const logoData = extractLogoFromNavigationResponse(navigationResponse); | ||
const menus = | ||
extractNavigationMenusFromNavigationResponse(navigationResponse); | ||
|
||
// TODO | ||
if (error) { | ||
return <span>ERROR</span>; | ||
} | ||
|
||
// TODO | ||
if (isLoading) { | ||
return <span>is loading...</span>; | ||
} | ||
|
||
return ( | ||
<nav className={styles.siteNav}> | ||
<div className={styles.primaryRow}> | ||
<div className={styles.navLeft}> | ||
<SiteLogo /> | ||
<Link className={`${styles.navLogo}`} to="/"> | ||
<img src={logoData?.url} alt={logoData?.alternativeText} /> | ||
</Link> | ||
</div> | ||
<SiteLinks /> | ||
|
||
<ul className={styles.navRight}> | ||
{menus?.map((menu) => ( | ||
<div className={styles.menuContainer} key={menu.id.toString()}> | ||
<button | ||
type="button" | ||
aria-haspopup="menu" | ||
aria-expanded={dropdown ? "true" : "false"} | ||
onClick={() => setDropdown((prev) => !prev)} | ||
> | ||
{menu.title} | ||
</button> | ||
|
||
<ul | ||
className={`${styles.dropdown} ${ | ||
dropdown ? styles.showDropdown : "" | ||
}`} | ||
> | ||
{menu.link.map((linkItem: StrapiModel.Link) => ( | ||
<li key={linkItem.id} className="menu-item"> | ||
<Link to={linkItem.url}>{linkItem.text}</Link> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
))} | ||
<Translate /> | ||
</ul> | ||
<div className={styles.mobileNavigation}> | ||
<button | ||
type="button" | ||
|
@@ -28,19 +79,4 @@ export const Navigation = ({ | |
); | ||
}; | ||
|
||
const SiteLogo = () => ( | ||
<Link className={`${styles.navLogo}`} to="/"> | ||
{/* TODO */} | ||
[SITE LOGO HERE] | ||
</Link> | ||
); | ||
|
||
const SiteLinks = () => { | ||
return ( | ||
<div className={styles.navRight}> | ||
<Translate /> | ||
</div> | ||
); | ||
}; | ||
|
||
Comment on lines
-31
to
-45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be worth separating these out later but I didn't see much use for this abstraction at the moment while I was rewriting things. |
||
export default Navigation; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allows clever removal of properties from an object with destructuring. I'm open to debate on it, although to me it feels restricted when the intent of this type of code is quite clear. See example below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach works for me!