From 6045c6133e707d0168e30197634953f90b4080de Mon Sep 17 00:00:00 2001 From: vincanger <70215737+vincanger@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:38:52 +0200 Subject: [PATCH 1/7] fix Links and Nav Bar --- template/app/src/client/App.tsx | 14 +- .../{AppNavBar.tsx => NavBar/NavBar.tsx} | 112 ++++++++------- .../components/NavBar/contentSections.ts | 10 ++ .../app/src/client/hooks/useIsLandingPage.tsx | 9 ++ template/app/src/landing-page/LandingPage.tsx | 12 +- .../src/landing-page/components/Header.tsx | 127 ------------------ .../app/src/landing-page/contentSections.ts | 4 +- 7 files changed, 95 insertions(+), 193 deletions(-) rename template/app/src/client/components/{AppNavBar.tsx => NavBar/NavBar.tsx} (55%) create mode 100644 template/app/src/client/components/NavBar/contentSections.ts create mode 100644 template/app/src/client/hooks/useIsLandingPage.tsx delete mode 100644 template/app/src/landing-page/components/Header.tsx diff --git a/template/app/src/client/App.tsx b/template/app/src/client/App.tsx index 933decd42..4202d25bd 100644 --- a/template/app/src/client/App.tsx +++ b/template/app/src/client/App.tsx @@ -1,10 +1,13 @@ import { useAuth } from 'wasp/client/auth'; import { updateCurrentUser } from 'wasp/client/operations'; import './Main.css'; -import AppNavBar from './components/AppNavBar'; +import NavBar from './components/NavBar/NavBar'; +import { appNavigationItems } from './components/NavBar/contentSections'; +import { landingPageNavigationItems } from '../landing-page/contentSections'; import CookieConsentBanner from './components/cookie-consent/Banner'; -import { useMemo, useEffect, ReactNode } from 'react'; +import { useMemo, useEffect } from 'react'; import { Outlet, useLocation } from 'react-router-dom'; +import { useIsLandingPage } from './hooks/useIsLandingPage'; /** * use this component to wrap all child components @@ -13,9 +16,10 @@ import { Outlet, useLocation } from 'react-router-dom'; export default function App() { const location = useLocation(); const { data: user } = useAuth(); + const isLandingPage = useIsLandingPage(); const shouldDisplayAppNavBar = useMemo(() => { - return location.pathname !== '/' && location.pathname !== '/login' && location.pathname !== '/signup'; + return location.pathname !== '/login' && location.pathname !== '/signup'; }, [location]); const isAdminDashboard = useMemo(() => { @@ -49,7 +53,9 @@ export default function App() { ) : ( <> - {shouldDisplayAppNavBar && } + {shouldDisplayAppNavBar && ( + + )}
diff --git a/template/app/src/client/components/AppNavBar.tsx b/template/app/src/client/components/NavBar/NavBar.tsx similarity index 55% rename from template/app/src/client/components/AppNavBar.tsx rename to template/app/src/client/components/NavBar/NavBar.tsx index cdf5d35d8..7b13630d1 100644 --- a/template/app/src/client/components/AppNavBar.tsx +++ b/template/app/src/client/components/NavBar/NavBar.tsx @@ -1,37 +1,46 @@ -import { Link, routes } from 'wasp/client/router'; +import { Link } from 'wasp/client/router'; import { useAuth } from 'wasp/client/auth'; -import { useState } from 'react'; +import { useState, Dispatch, SetStateAction } from 'react'; import { Dialog } from '@headlessui/react'; import { BiLogIn } from 'react-icons/bi'; import { AiFillCloseCircle } from 'react-icons/ai'; import { HiBars3 } from 'react-icons/hi2'; -import logo from '../static/logo.png'; -import DropdownUser from '../../user/DropdownUser'; -import { UserMenuItems } from '../../user/UserMenuItems'; -import { DocsUrl, BlogUrl } from '../../shared/common'; -import DarkModeSwitcher from './DarkModeSwitcher'; +import logo from '../../static/logo.png'; +import DropdownUser from '../../../user/DropdownUser'; +import { UserMenuItems } from '../../../user/UserMenuItems'; +import DarkModeSwitcher from '../DarkModeSwitcher'; +import { useIsLandingPage } from '../../hooks/useIsLandingPage'; +import { cn } from '../../cn'; -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 }, -]; +interface NavigationItem { + name: string; + // to?: Routes['to']; // TODO: fix this + to?: any; // TODO: fix this + href?: string; +} const NavLogo = () => Your SaaS App; -export default function AppNavBar() { +export default function AppNavBar({ navigation }: { navigation: NavigationItem[] }) { const [mobileMenuOpen, setMobileMenuOpen] = useState(false); + const isLandingPage = useIsLandingPage(); const { data: user, isLoading: isUserLoading } = useAuth(); return ( -
+
); } + +function renderNavigationItems( + navigation: NavigationItem[], + setMobileMenuOpen?: Dispatch> +) { + const mobileMenuStyles = + '-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 dark:hover:bg-boxdark-2'; + const desktopStyles = + 'text-sm font-semibold leading-6 text-gray-900 duration-300 ease-in-out hover:text-yellow-500 dark:text-white'; + const menuStyles = !!setMobileMenuOpen ? mobileMenuStyles : desktopStyles; + + return navigation.map((item) => { + if (item.to) { + return ( + setMobileMenuOpen?.(false)}> + {item.name} + + ); + } else if (item.href) { + return ( + setMobileMenuOpen?.(false)}> + {item.name} + + ); + } + }); +} diff --git a/template/app/src/client/components/NavBar/contentSections.ts b/template/app/src/client/components/NavBar/contentSections.ts new file mode 100644 index 000000000..517fed73b --- /dev/null +++ b/template/app/src/client/components/NavBar/contentSections.ts @@ -0,0 +1,10 @@ +import { routes } from 'wasp/client/router'; +import { BlogUrl, DocsUrl } from '../../../shared/common'; + +export const appNavigationItems = [ + { name: 'AI Scheduler (Demo App)', to: routes.DemoAppRoute.to }, + { name: 'File Upload (AWS S3)', to: routes.FileUploadRoute.to }, + { name: 'Pricing', to: routes.PricingPageRoute.to }, + { name: 'Documentation', href: DocsUrl }, + { name: 'Blog', href: BlogUrl }, +]; diff --git a/template/app/src/client/hooks/useIsLandingPage.tsx b/template/app/src/client/hooks/useIsLandingPage.tsx new file mode 100644 index 000000000..66d7475f5 --- /dev/null +++ b/template/app/src/client/hooks/useIsLandingPage.tsx @@ -0,0 +1,9 @@ +import { useMemo } from 'react'; +import { useLocation } from 'react-router-dom'; + +export const useIsLandingPage = () => { + const location = useLocation(); + return useMemo(() => { + return location.pathname === '/'; + }, [location]); +}; diff --git a/template/app/src/landing-page/LandingPage.tsx b/template/app/src/landing-page/LandingPage.tsx index a5d3d8325..ac865a8d2 100644 --- a/template/app/src/landing-page/LandingPage.tsx +++ b/template/app/src/landing-page/LandingPage.tsx @@ -1,11 +1,4 @@ -import { - features, - navigation, - faqs, - footerNavigation, - testimonials -} from './contentSections'; -import Header from './components/Header'; +import { features, faqs, footerNavigation, testimonials } from './contentSections'; import Hero from './components/Hero'; import Clients from './components/Clients'; import Features from './components/Features'; @@ -16,8 +9,6 @@ import Footer from './components/Footer'; export default function LandingPage() { return (
-
-
@@ -25,7 +16,6 @@ export default function LandingPage() {
-
); diff --git a/template/app/src/landing-page/components/Header.tsx b/template/app/src/landing-page/components/Header.tsx deleted file mode 100644 index b4d1e74c9..000000000 --- a/template/app/src/landing-page/components/Header.tsx +++ /dev/null @@ -1,127 +0,0 @@ -import { useState } from 'react'; -import { HiBars3 } from 'react-icons/hi2'; -import { BiLogIn } from 'react-icons/bi'; -import { AiFillCloseCircle } from 'react-icons/ai'; -import { Dialog } from '@headlessui/react'; -import { Link } from 'wasp/client/router'; -import { useAuth } from 'wasp/client/auth'; -import logo from '../../client/static/logo.png'; -import DarkModeSwitcher from '../../client/components/DarkModeSwitcher'; -import DropdownUser from '../../user/DropdownUser'; -import { UserMenuItems } from '../../user/UserMenuItems'; - -interface NavigationItem { - name: string; - href: string; -}; - -export default function Header({ navigation }: { navigation: NavigationItem[] }) { - const [mobileMenuOpen, setMobileMenuOpen] = useState(false); - - const { data: user, isLoading: isUserLoading } = useAuth(); - - const NavLogo = () => Your SaaS App; - - return ( -
- - -
- -
- - Your SaaS - - - -
- -
-
-
- ) -} diff --git a/template/app/src/landing-page/contentSections.ts b/template/app/src/landing-page/contentSections.ts index 992c189b0..508f31093 100644 --- a/template/app/src/landing-page/contentSections.ts +++ b/template/app/src/landing-page/contentSections.ts @@ -3,9 +3,9 @@ import daBoiAvatar from '../client/static/da-boi.png'; import avatarPlaceholder from '../client/static/avatar-placeholder.png'; import { routes } from 'wasp/client/router'; -export const navigation = [ +export const landingPageNavigationItems = [ { name: 'Features', href: '#features' }, - { name: 'Pricing', href: routes.PricingPageRoute.build() }, + { name: 'Pricing', to: routes.PricingPageRoute.to }, { name: 'Documentation', href: DocsUrl }, { name: 'Blog', href: BlogUrl }, ]; From 4def59124166fd6ef6ee9f6407d988f74bdbde41 Mon Sep 17 00:00:00 2001 From: vincanger <70215737+vincanger@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:55:59 +0200 Subject: [PATCH 2/7] update app_diff --- .../client/components/NavBar/NavBar.tsx.diff | 70 +++++++++++++++ .../landing-page/components/Header.tsx.diff | 88 ------------------- .../src/landing-page/contentSections.ts.diff | 4 +- 3 files changed, 72 insertions(+), 90 deletions(-) create mode 100644 opensaas-sh/app_diff/src/client/components/NavBar/NavBar.tsx.diff delete mode 100644 opensaas-sh/app_diff/src/landing-page/components/Header.tsx.diff diff --git a/opensaas-sh/app_diff/src/client/components/NavBar/NavBar.tsx.diff b/opensaas-sh/app_diff/src/client/components/NavBar/NavBar.tsx.diff new file mode 100644 index 000000000..889a6012f --- /dev/null +++ b/opensaas-sh/app_diff/src/client/components/NavBar/NavBar.tsx.diff @@ -0,0 +1,70 @@ +--- template/app/src/client/components/NavBar/NavBar.tsx ++++ opensaas-sh/app/src/client/components/NavBar/NavBar.tsx +@@ -32,6 +32,7 @@ + 'shadow sticky bg-white bg-opacity-50 backdrop-blur-lg backdrop-filter dark:border dark:border-gray-100/10': !isLandingPage, + })} + > ++ {isLandingPage && } +