umami/components/layout/Header.js

39 lines
1.4 KiB
JavaScript
Raw Normal View History

import HamburgerButton from 'components/common/HamburgerButton';
import UpdateNotice from 'components/common/UpdateNotice';
import LanguageButton from 'components/buttons/LanguageButton';
import ThemeButton from 'components/buttons/ThemeButton';
import UserButton from 'components/buttons/UserButton';
2022-08-29 05:20:54 +02:00
import useConfig from 'hooks/useConfig';
2022-08-09 23:58:27 +02:00
import useUser from 'hooks/useUser';
import { useRouter } from 'next/router';
import { Column, Row } from 'react-basics';
import SettingsButton from '../buttons/SettingsButton';
import styles from './Header.module.css';
import classNames from 'classnames';
2020-07-24 04:56:55 +02:00
export default function Header({ className }) {
const user = useUser();
const { pathname } = useRouter();
2022-10-28 01:42:57 +02:00
const { updatesDisabled, adminDisabled } = useConfig();
2022-08-09 23:58:27 +02:00
const isSharePage = pathname.includes('/share/');
const allowUpdate = user?.isAdmin && !updatesDisabled && !isSharePage;
2020-08-05 07:45:05 +02:00
2020-07-24 04:56:55 +02:00
return (
2022-03-01 03:39:37 +01:00
<>
2022-08-09 23:58:27 +02:00
{allowUpdate && <UpdateNotice />}
<header className={classNames(styles.header, className)}>
2022-12-10 23:26:52 +01:00
<Row>
<Column className={styles.title}></Column>
2022-12-10 23:26:52 +01:00
<HamburgerButton />
<Column className={styles.buttons}>
<ThemeButton />
<LanguageButton menuAlign="right" />
<SettingsButton />
{user && !adminDisabled && <UserButton />}
</Column>
</Row>
2022-03-01 03:39:37 +01:00
</header>
</>
2020-07-24 04:56:55 +02:00
);
}