2023-04-24 10:58:57 -07:00
|
|
|
import { Tooltip, Avatar } from 'antd';
|
2023-05-22 18:56:44 -07:00
|
|
|
import { FC, useEffect, useState } from 'react';
|
2022-11-04 20:04:13 -07:00
|
|
|
import cn from 'classnames';
|
2023-01-09 16:09:13 -08:00
|
|
|
import dynamic from 'next/dynamic';
|
2023-01-21 23:19:17 -08:00
|
|
|
import Link from 'next/link';
|
2022-09-07 09:00:28 +02:00
|
|
|
import styles from './Header.module.scss';
|
2022-04-28 18:54:33 +02:00
|
|
|
|
2023-01-09 16:09:13 -08:00
|
|
|
// Lazy loaded components
|
|
|
|
|
2023-01-10 16:39:12 -08:00
|
|
|
const UserDropdown = dynamic(
|
|
|
|
() => import('../../common/UserDropdown/UserDropdown').then(mod => mod.UserDropdown),
|
|
|
|
{
|
|
|
|
ssr: false,
|
|
|
|
},
|
2023-01-09 16:09:13 -08:00
|
|
|
);
|
|
|
|
|
2022-09-07 09:00:28 +02:00
|
|
|
export type HeaderComponentProps = {
|
2022-05-08 09:41:47 +02:00
|
|
|
name: string;
|
2022-05-26 11:08:37 -07:00
|
|
|
chatAvailable: boolean;
|
2022-09-10 20:03:58 -07:00
|
|
|
chatDisabled: boolean;
|
2023-01-21 23:19:17 -08:00
|
|
|
online: boolean;
|
2022-09-07 09:00:28 +02:00
|
|
|
};
|
2022-04-28 18:54:33 +02:00
|
|
|
|
2023-05-22 18:56:44 -07:00
|
|
|
export const Header: FC<HeaderComponentProps> = ({ name, chatAvailable, chatDisabled, online }) => {
|
|
|
|
const [canHideChat, setCanHideChat] = useState(false);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
setCanHideChat(window.innerWidth >= 768);
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<header className={cn([`${styles.header}`], 'global-header')}>
|
|
|
|
{online ? (
|
|
|
|
<Link href="#player" className={styles.skipLink}>
|
|
|
|
Skip to player
|
|
|
|
</Link>
|
|
|
|
) : (
|
|
|
|
<Link href="#offline-message" className={styles.skipLink}>
|
|
|
|
Skip to offline message
|
|
|
|
</Link>
|
|
|
|
)}
|
|
|
|
<Link href="#skip-to-content" className={styles.skipLink}>
|
|
|
|
Skip to page content
|
2023-01-21 23:19:17 -08:00
|
|
|
</Link>
|
2023-05-22 18:56:44 -07:00
|
|
|
<Link href="#footer" className={styles.skipLink}>
|
|
|
|
Skip to footer
|
2023-01-29 16:31:52 -08:00
|
|
|
</Link>
|
2023-05-22 18:56:44 -07:00
|
|
|
<div className={styles.logo}>
|
|
|
|
<div id="header-logo" className={styles.logoImage}>
|
|
|
|
<Avatar src="/logo" size="large" shape="circle" className={styles.avatar} />
|
|
|
|
</div>
|
|
|
|
<h1 className={styles.title} id="global-header-text">
|
|
|
|
{name}
|
|
|
|
</h1>
|
2022-12-08 14:16:05 -08:00
|
|
|
</div>
|
2023-05-22 18:56:44 -07:00
|
|
|
{chatAvailable && !chatDisabled && (
|
|
|
|
<UserDropdown id="user-menu" hideTitleOnMobile showToggleChatOption={canHideChat} />
|
|
|
|
)}
|
|
|
|
{!chatAvailable && !chatDisabled && (
|
|
|
|
<Tooltip
|
|
|
|
overlayClassName={styles.toolTip}
|
|
|
|
title="Chat will be available when the stream is live."
|
|
|
|
placement="left"
|
|
|
|
>
|
|
|
|
<span className={styles.chatOfflineText}>Chat is offline</span>
|
|
|
|
</Tooltip>
|
|
|
|
)}
|
|
|
|
</header>
|
|
|
|
);
|
|
|
|
};
|
2022-09-07 09:00:28 +02:00
|
|
|
export default Header;
|