Header.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { Tag, Tooltip } from 'antd';
  2. import { FC } from 'react';
  3. import cn from 'classnames';
  4. import dynamic from 'next/dynamic';
  5. import Link from 'next/link';
  6. import { OwncastLogo } from '../../common/OwncastLogo/OwncastLogo';
  7. import styles from './Header.module.scss';
  8. // Lazy loaded components
  9. const UserDropdown = dynamic(
  10. () => import('../../common/UserDropdown/UserDropdown').then(mod => mod.UserDropdown),
  11. {
  12. ssr: false,
  13. },
  14. );
  15. export type HeaderComponentProps = {
  16. name: string;
  17. chatAvailable: boolean;
  18. chatDisabled: boolean;
  19. online: boolean;
  20. };
  21. export const Header: FC<HeaderComponentProps> = ({ name, chatAvailable, chatDisabled, online }) => (
  22. <header className={cn([`${styles.header}`], 'global-header')}>
  23. {online ? (
  24. <Link href="#player" className={styles.skipLink}>
  25. Skip to player
  26. </Link>
  27. ) : (
  28. <Link href="#offline-message" className={styles.skipLink}>
  29. Skip to offline message
  30. </Link>
  31. )}
  32. <Link href="#skip-to-content" className={styles.skipLink}>
  33. Skip to page content
  34. </Link>
  35. <Link href="#footer" className={styles.skipLink}>
  36. Skip to footer
  37. </Link>
  38. <div className={styles.logo}>
  39. <div id="header-logo" className={styles.logoImage}>
  40. <OwncastLogo variant="contrast" />
  41. </div>
  42. <h1 className={styles.title} id="global-header-text">
  43. {name}
  44. </h1>
  45. </div>
  46. {chatAvailable && !chatDisabled && <UserDropdown />}
  47. {!chatAvailable && !chatDisabled && (
  48. <Tooltip title="Chat is available when the stream is live." placement="left">
  49. <Tag className={styles.offlineTag}>Chat offline</Tag>
  50. </Tooltip>
  51. )}
  52. </header>
  53. );
  54. export default Header;