umami/components/layout/Header.js
2023-01-09 23:59:26 -08:00

46 lines
1.6 KiB
JavaScript

import Logo from 'assets/logo.svg';
import HamburgerButton from 'components/common/HamburgerButton';
import Link from 'components/common/Link';
import UpdateNotice from 'components/common/UpdateNotice';
import LanguageButton from 'components/settings/LanguageButton';
import ThemeButton from 'components/settings/ThemeButton';
import UserButton from 'components/settings/UserButton';
import useConfig from 'hooks/useConfig';
import useUser from 'hooks/useUser';
import { HOMEPAGE_URL } from 'lib/constants';
import { useRouter } from 'next/router';
import { Column, Icon, Row } from 'react-basics';
import SettingsButton from '../settings/SettingsButton';
import styles from './Header.module.css';
export default function Header() {
const user = useUser();
const { pathname } = useRouter();
const { updatesDisabled, adminDisabled } = useConfig();
const isSharePage = pathname.includes('/share/');
const allowUpdate = user?.isAdmin && !updatesDisabled && !isSharePage;
return (
<>
{allowUpdate && <UpdateNotice />}
<header className={styles.header}>
<Row>
<Column className={styles.title}>
<Icon size="lg" className={styles.logo}>
<Logo />
</Icon>
<Link href={isSharePage ? HOMEPAGE_URL : '/'}>umami</Link>
</Column>
<HamburgerButton />
<Column className={styles.buttons}>
<ThemeButton />
<LanguageButton menuAlign="right" />
<SettingsButton />
{user && !adminDisabled && <UserButton />}
</Column>
</Row>
</header>
</>
);
}