-
-
Notifications
You must be signed in to change notification settings - Fork 834
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
Improve Nav Bar & use Wasp Link components #311
Conversation
@vincanger maybe best to have @infomiho take a look at this since he is the author of Wasp Link stuff? |
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.
Nice job Vinny, left some comments
import { useMemo } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
export const useIsLandingPage = () => { |
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.
Nice job on creating custom hooks :)
template/app/src/client/App.tsx
Outdated
@@ -49,7 +53,9 @@ export default function App() { | |||
<Outlet /> | |||
) : ( | |||
<> | |||
{shouldDisplayAppNavBar && <AppNavBar />} | |||
{shouldDisplayAppNavBar && ( | |||
<NavBar navigation={isLandingPage ? landingPageNavigationItems : appNavigationItems} /> |
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.
One thing you could do here is extract the ternary expresison:
const navigationItems = isLandingPage ? landingPageNavigationItems : appNavigationItems;
...
<NavBar navigation={navigationItems} />
That being said, it looks to me that the navigation
prop should be named navigationItems
since we are calling all the vars that way xNavigationItems
.
|
||
const NavLogo = () => <img className='h-8 w-8' src={logo} alt='Your SaaS App' />; | ||
|
||
export default function AppNavBar() { | ||
export default function AppNavBar({ navigation }: { navigation: NavigationItem[] }) { |
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.
I'd name the navigation
prop as navigationItems
so it matches the way we use it. navigation
feels generic as opposed to navigationItems
.
@@ -124,3 +112,28 @@ export default function AppNavBar() { | |||
</header> | |||
); | |||
} | |||
|
|||
function renderNavigationItems( | |||
navigation: NavigationItem[], |
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.
navigation: NavigationItem[], | |
navigationItems: NavigationItem[], |
|
||
return navigation.map((item) => { | ||
return ( | ||
<Link |
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.
I'd maybe import both Link
from wasp/client/router
and react-router-dom
and use them in different places.
- I'd use the
import { Link as ReactRouterLink } from 'react-router-dom';
and<ReactRouterLink>
component in places where we are having dynamicto
prop (in this fn) - I'd use the Wasp's
Link
elsewhere where we use theto
prop explicitly - we get as much out of the type safe component as possible.
template/app/src/client/App.tsx
Outdated
|
||
const shouldDisplayAppNavBar = useMemo(() => { | ||
return location.pathname !== '/' && location.pathname !== '/login' && location.pathname !== '/signup'; | ||
return location.pathname !== '/login' && location.pathname !== '/signup'; |
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.
To avoid hard-coding values, you could use routes.LoginRoute.build()
and routes.SignupRoute.build()
to get the routes :)
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.
🚢 it!
TODO
item.to
typeapp_diff
Description
Fixes #264 & #181 as well as merges the landing page's navbar and the
AppNavBar
into oneContributor Checklist