2023-04-24 20:58:57 +03:00
|
|
|
import { Tooltip, Avatar } from 'antd';
|
2023-05-23 04:56:44 +03:00
|
|
|
import { FC, useEffect, useState } from 'react';
|
2022-11-05 06:04:13 +03:00
|
|
|
import cn from 'classnames';
|
2023-01-10 03:09:13 +03:00
|
|
|
import dynamic from 'next/dynamic';
|
2023-01-22 10:19:17 +03:00
|
|
|
import Link from 'next/link';
|
2022-09-07 10:00:28 +03:00
|
|
|
import styles from './Header.module.scss';
|
2022-04-28 19:54:33 +03:00
|
|
|
|
2023-01-10 03:09:13 +03:00
|
|
|
// Lazy loaded components
|
|
|
|
|
2023-01-11 03:39:12 +03:00
|
|
|
const UserDropdown = dynamic(
|
|
|
|
() => import('../../common/UserDropdown/UserDropdown').then(mod => mod.UserDropdown),
|
|
|
|
{
|
|
|
|
ssr: false,
|
|
|
|
},
|
2023-01-10 03:09:13 +03:00
|
|
|
);
|
|
|
|
|
2022-09-07 10:00:28 +03:00
|
|
|
export type HeaderComponentProps = {
|
2022-05-08 10:41:47 +03:00
|
|
|
name: string;
|
2022-05-26 21:08:37 +03:00
|
|
|
chatAvailable: boolean;
|
2022-09-11 06:03:58 +03:00
|
|
|
chatDisabled: boolean;
|
2023-01-22 10:19:17 +03:00
|
|
|
online: boolean;
|
2022-09-07 10:00:28 +03:00
|
|
|
};
|
2022-04-28 19:54:33 +03:00
|
|
|
|
2023-05-23 04:56:44 +03: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-22 10:19:17 +03:00
|
|
|
</Link>
|
2023-05-23 04:56:44 +03:00
|
|
|
<Link href="#footer" className={styles.skipLink}>
|
|
|
|
Skip to footer
|
2023-01-30 03:31:52 +03:00
|
|
|
</Link>
|
2023-05-23 04:56:44 +03: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-09 01:16:05 +03:00
|
|
|
</div>
|
2023-05-23 04:56:44 +03: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 10:00:28 +03:00
|
|
|
export default Header;
|