Skip to content
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

Replacing a tags with link tags in AppNavBar #264

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
41 changes: 26 additions & 15 deletions template/app/src/client/components/AppNavBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Link, routes } from 'wasp/client/router';
import { routes } from 'wasp/client/router';
import { useAuth } from 'wasp/client/auth';
import { Link } from 'react-router-dom';
import { useState } from 'react';
import { Dialog } from '@headlessui/react';
import { BiLogIn } from 'react-icons/bi';
Expand All @@ -15,8 +16,6 @@ const navigation = [
{ name: 'AI Scheduler (Demo App)', href: routes.DemoAppRoute.build() },
{ name: 'File Upload (AWS S3)', href: routes.FileUploadRoute.build() },
{ name: 'Pricing', href: routes.PricingPageRoute.build() },
{ name: 'Documentation', href: DocsUrl },
{ name: 'Blog', href: BlogUrl },
];

const NavLogo = () => <img className='h-8 w-8' src={logo} alt='Your SaaS App' />;
Expand All @@ -29,9 +28,9 @@ export default function AppNavBar() {
<header className='absolute inset-x-0 top-0 z-50 shadow sticky bg-white bg-opacity-50 backdrop-blur-lg backdrop-filter dark:border dark:border-gray-100/10 dark:bg-boxdark-2'>
<nav className='flex items-center justify-between p-6 lg:px-8' aria-label='Global'>
<div className='flex lg:flex-1'>
<a href='/' className='-m-1.5 p-1.5'>
<Link to='/' className='-m-1.5 p-1.5'>
<img className='h-8 w-8' src={logo} alt='My SaaS App' />
</a>
</Link>
</div>
<div className='flex lg:hidden'>
<button
Expand All @@ -45,26 +44,28 @@ export default function AppNavBar() {
</div>
<div className='hidden lg:flex lg:gap-x-12'>
{navigation.map((item) => (
<a
<Link
key={item.name}
href={item.href}
to={item.href}
className='text-sm font-semibold leading-6 text-gray-900 duration-300 ease-in-out hover:text-yellow-500 dark:text-white'
>
{item.name}
</a>
</Link>
))}
<a href={DocsUrl}>Documentation</a>
<a href={BlogUrl}>Blog</a>
</div>
<div className='hidden lg:flex lg:flex-1 gap-3 justify-end items-center'>
<ul className='flex justify-center items-center gap-2 sm:gap-4'>
<DarkModeSwitcher />
</ul>

{isUserLoading ? null : !user ? (
<a href={!user ? routes.LoginRoute.build() : routes.AccountRoute.build()} className='text-sm font-semibold leading-6 ml-4'>
<Link to={!user ? routes.LoginRoute.build() : routes.AccountRoute.build()} className='text-sm font-semibold leading-6 ml-4'>
<div className='flex items-center duration-300 ease-in-out text-gray-900 hover:text-yellow-500 dark:text-white'>
Log in <BiLogIn size='1.1rem' className='ml-1 mt-[0.1rem]' />
</div>
</a>
</Link>
) : (
<div className='ml-4'>
<DropdownUser user={user} />
Expand All @@ -76,10 +77,10 @@ export default function AppNavBar() {
<div className='fixed inset-0 z-50' />
<Dialog.Panel className='fixed inset-y-0 right-0 z-50 w-full overflow-y-auto bg-white dark:text-white dark:bg-boxdark px-6 py-6 sm:max-w-sm sm:ring-1 sm:ring-gray-900/10'>
<div className='flex items-center justify-between'>
<a href='/' className='-m-1.5 p-1.5'>
<Link to='/' className='-m-1.5 p-1.5'>
<span className='sr-only'>Your SaaS</span>
<NavLogo />
</a>
</Link>
<button
type='button'
className='-m-2.5 rounded-md p-2.5 text-gray-700 dark:text-gray-50'
Expand All @@ -93,15 +94,25 @@ export default function AppNavBar() {
<div className='-my-6 divide-y divide-gray-500/10'>
<div className='space-y-2 py-6'>
{navigation.map((item) => (
<a
<Link
key={item.name}
href={item.href}
to={item.href}
onClick={() => setMobileMenuOpen(false)}
className='-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7 text-gray-900 hover:bg-gray-50 dark:text-white hover:dark:bg-boxdark-2'
>
{item.name}
</a>
</Link>
))}
<a
href={DocsUrl}
className='-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7 text-gray-900 hover:bg-gray-50 dark:text-white hover:dark:bg-boxdark-2'>
Documentation
</a>
<a
href={BlogUrl}
className='-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7 text-gray-900 hover:bg-gray-50 dark:text-white hover:dark:bg-boxdark-2'>
Blog
</a>
</div>
<div className='py-6'>
{isUserLoading ? null : !user ? (
Expand Down