Skip to content

Commit

Permalink
add missing new app dir
Browse files Browse the repository at this point in the history
  • Loading branch information
viet nguyen committed Oct 23, 2023
1 parent 944f698 commit d573ac5
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/app/components/DesktopHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
'use client'
import { signIn } from 'next-auth/react'

import { Logo } from 'app/header'
import { XSearchMinimal } from '@/components/search/XSearch'
import { NavMenuItem, NavMenuItemProps } from '@/components/ui/NavMenuButton'
import GitHubStars from '@/components/GitHubStars'

export const DesktopHeader: React.FC = () => {
const navListDefault: NavMenuItemProps[] = [
{
to: 'https://discord.gg/ptpnWWNkJx',
label: 'Discord'
},
{
to: '/about',
label: 'About'
},
{
to: 'https://opencollective.com/openbeta/contribute/t-shirt-31745',
label: 'T-shirts'
},
{
to: 'https://docs.openbeta.io',
label: 'Docs'
},
{
onClick: () => { void signIn('auth0', { callbackUrl: '/api/user/me' }) },
label: 'Login',
type: 'rounded-btn border bg-accent'
}
]

const menu = navListDefault.map(
({ onClick, label, to, type }: NavMenuItemProps, index) => (
<NavMenuItem
key={index}
onClick={onClick}
type={type}
label={label}
to={to}
/>)
)

menu.unshift(
<GitHubStars key='gh-button' />
)

return (
<header className='hidden lg:flex items-center justify-between'>
<div className='flex items-center gap-6'><Logo />
<XSearchMinimal />
</div>
<div className='menu menu-vertical lg:menu-horizontal rounded-box gap-2'>{menu}</div>
</header>
)
}
18 changes: 18 additions & 0 deletions src/app/components/MobileHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use client'
import { useSession } from 'next-auth/react'
import { Logo } from 'app/header'
import { XSearchMinimal } from '@/components/search/XSearch'
import { AuthenticatedNav13, LoginButton, More } from '@/components/MobileAppBar'

export const MobileHeader: React.FC = () => {
const { status } = useSession()
const nav = status === 'authenticated' ? <AuthenticatedNav13 /> : <LoginButton />
return (
<header className='flex lg:hidden items-center justify-between gap-6'>
<Logo />
<XSearchMinimal />
{nav}
<More />
</header>
)
}
10 changes: 10 additions & 0 deletions src/app/components/NextAuthProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use client'
import { SessionProvider } from 'next-auth/react'

interface Props {
children?: React.ReactNode
}

export const NextAuthProvider: React.FC<Props> = ({ children }) => {
return <SessionProvider>{children}</SessionProvider>
}
3 changes: 3 additions & 0 deletions src/app/footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Footer (): any {
return (<div>footer</div>)
}
8 changes: 8 additions & 0 deletions src/app/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@import '../styles/algolia.css';
@tailwind base;
@tailwind components;
@tailwind utilities;

.aa-hidden-mobile-trigger-btn {
@apply hidden !important;
}
21 changes: 21 additions & 0 deletions src/app/header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Link from 'next/link'
import OpenBetaLogo from '@/assets/brand/openbeta-logo'
import { DesktopHeader } from './components/DesktopHeader'
import { MobileHeader } from './components/MobileHeader'

export default async function Header (): Promise<any> {
return (
<div className='max-w-5xl mx-auto px-4 xl:px-0'>
<MobileHeader />
<DesktopHeader />
</div>
)
}

export const Logo: React.FC = () => {
return (
<Link href='/' className=''>
<OpenBetaLogo />
</Link>
)
}
29 changes: 29 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import './global.css'
import Header from './header'
import Footer from './footer'
import { NextAuthProvider } from './components/NextAuthProvider'

export const metadata = {
title: 'Next.js',
description: 'Generated by Next.js'
}

export default function RootLayout ({
children
}: {
children: React.ReactNode
}): any {
return (
<html lang='en'>
<body className='mx-auto'>
<NextAuthProvider>
<Header />
</NextAuthProvider>
<div>
{children}
</div>
<Footer />
</body>
</html>
)
}
3 changes: 3 additions & 0 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default async function Home (): Promise<any> {
return (<div>home page</div>)
}

0 comments on commit d573ac5

Please sign in to comment.