2023-07-13 07:22:08 -04:00
|
|
|
import { Toolbar } from '../Toolbar'
|
2024-05-07 14:33:11 -04:00
|
|
|
import UserSidebarMenu from 'components/UserSidebarMenu'
|
2024-02-11 12:59:00 +11:00
|
|
|
import { type IndexLoaderData } from 'lib/types'
|
2023-08-18 10:27:01 -04:00
|
|
|
import ProjectSidebarMenu from './ProjectSidebarMenu'
|
2024-03-11 20:26:13 -04:00
|
|
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
2023-08-31 09:47:59 -04:00
|
|
|
import styles from './AppHeader.module.css'
|
2024-05-07 14:33:11 -04:00
|
|
|
import { RefreshButton } from 'components/RefreshButton'
|
2024-05-08 09:57:16 -04:00
|
|
|
import { CommandBarOpenButton } from './CommandBarOpenButton'
|
2023-07-13 07:22:08 -04:00
|
|
|
|
|
|
|
interface AppHeaderProps extends React.PropsWithChildren {
|
|
|
|
showToolbar?: boolean
|
2023-10-16 13:28:41 -04:00
|
|
|
project?: Omit<IndexLoaderData, 'code'>
|
2023-08-06 21:29:26 -04:00
|
|
|
className?: string
|
2023-08-18 10:27:01 -04:00
|
|
|
enableMenu?: boolean
|
2023-07-13 07:22:08 -04:00
|
|
|
}
|
|
|
|
|
2023-08-06 21:29:26 -04:00
|
|
|
export const AppHeader = ({
|
|
|
|
showToolbar = true,
|
2023-08-18 10:27:01 -04:00
|
|
|
project,
|
2023-08-06 21:29:26 -04:00
|
|
|
children,
|
|
|
|
className = '',
|
2023-08-18 10:27:01 -04:00
|
|
|
enableMenu = false,
|
2023-08-06 21:29:26 -04:00
|
|
|
}: AppHeaderProps) => {
|
2024-03-11 20:26:13 -04:00
|
|
|
const { auth } = useSettingsAuthContext()
|
2023-10-11 13:36:54 +11:00
|
|
|
const user = auth?.context?.user
|
2023-07-27 18:59:40 -04:00
|
|
|
|
2023-07-13 07:22:08 -04:00
|
|
|
return (
|
2023-08-06 21:29:26 -04:00
|
|
|
<header
|
2024-07-01 15:31:42 -04:00
|
|
|
id="app-header"
|
2023-08-06 21:29:26 -04:00
|
|
|
className={
|
2023-12-06 14:44:13 -05:00
|
|
|
'w-full grid ' +
|
2023-08-31 09:47:59 -04:00
|
|
|
styles.header +
|
2024-07-24 23:33:31 -04:00
|
|
|
' overlaid-panes sticky top-0 z-20 px-2 items-start ' +
|
2023-08-06 21:29:26 -04:00
|
|
|
className
|
|
|
|
}
|
|
|
|
>
|
2023-10-17 12:31:14 -04:00
|
|
|
<ProjectSidebarMenu
|
2024-05-20 14:59:59 -04:00
|
|
|
enableMenu={enableMenu}
|
2023-10-17 12:31:14 -04:00
|
|
|
project={project?.project}
|
|
|
|
file={project?.file}
|
|
|
|
/>
|
2023-07-13 07:22:08 -04:00
|
|
|
{/* Toolbar if the context deems it */}
|
2023-12-06 14:44:13 -05:00
|
|
|
<div className="flex-grow flex justify-center max-w-lg md:max-w-xl lg:max-w-2xl xl:max-w-4xl 2xl:max-w-5xl">
|
2024-05-08 09:57:16 -04:00
|
|
|
{showToolbar && <Toolbar />}
|
2023-12-06 14:44:13 -05:00
|
|
|
</div>
|
2024-04-05 00:59:02 -04:00
|
|
|
<div className="flex items-center gap-1 py-1 ml-auto">
|
2023-12-06 14:44:13 -05:00
|
|
|
{/* If there are children, show them, otherwise show User menu */}
|
2024-05-07 14:33:11 -04:00
|
|
|
{children || (
|
|
|
|
<>
|
2024-05-08 09:57:16 -04:00
|
|
|
<CommandBarOpenButton />
|
2024-05-07 14:33:11 -04:00
|
|
|
<RefreshButton />
|
|
|
|
</>
|
|
|
|
)}
|
2024-07-18 14:29:15 -04:00
|
|
|
<UserSidebarMenu user={user} />
|
2023-12-06 14:44:13 -05:00
|
|
|
</div>
|
2023-07-13 07:22:08 -04:00
|
|
|
</header>
|
|
|
|
)
|
|
|
|
}
|