element-call-Github/src/Header.jsx

69 lines
1.6 KiB
React
Raw Normal View History

2021-08-20 08:49:45 +08:00
import classNames from "classnames";
2021-12-08 03:59:57 +08:00
import React, { useRef } from "react";
2021-12-03 09:21:37 +08:00
import { Link } from "react-router-dom";
2021-08-20 08:49:45 +08:00
import styles from "./Header.module.css";
2021-12-08 04:20:05 +08:00
import { ReactComponent as Logo } from "./icons/Logo.svg";
2021-11-30 08:19:48 +08:00
import { ReactComponent as VideoIcon } from "./icons/Video.svg";
import { ReactComponent as ArrowLeftIcon } from "./icons/ArrowLeft.svg";
2021-12-08 03:59:57 +08:00
import { useButton } from "@react-aria/button";
2021-08-20 08:49:45 +08:00
2021-11-30 08:19:48 +08:00
export function Header({ children, className, ...rest }) {
2021-08-20 08:49:45 +08:00
return (
2021-11-30 08:19:48 +08:00
<header className={classNames(styles.header, className)} {...rest}>
2021-08-20 08:49:45 +08:00
{children}
2021-11-30 08:19:48 +08:00
</header>
2021-08-20 08:49:45 +08:00
);
}
2021-11-30 08:19:48 +08:00
export function LeftNav({ children, className, ...rest }) {
2021-08-20 08:49:45 +08:00
return (
2021-11-30 08:19:48 +08:00
<div
className={classNames(styles.nav, styles.leftNav, className)}
{...rest}
>
2021-08-20 08:49:45 +08:00
{children}
</div>
);
}
2021-08-21 07:23:12 +08:00
2021-11-30 08:19:48 +08:00
export function RightNav({ children, className, ...rest }) {
2021-08-21 07:23:12 +08:00
return (
2021-11-30 08:19:48 +08:00
<div
className={classNames(styles.nav, styles.rightNav, className)}
{...rest}
>
{children}
</div>
2021-08-21 07:23:12 +08:00
);
}
2021-12-03 09:21:37 +08:00
export function HeaderLogo() {
return (
<Link className={styles.logo} to="/">
2021-12-08 04:20:05 +08:00
<Logo />
2021-12-03 09:21:37 +08:00
</Link>
);
}
export function RoomHeaderInfo({ roomName }) {
return (
<>
<div className={styles.roomAvatar}>
<VideoIcon width={16} height={16} />
</div>
<h3>{roomName}</h3>
</>
);
}
2021-12-08 03:59:57 +08:00
export function RoomSetupHeaderInfo({ roomName, ...rest }) {
const ref = useRef();
const { buttonProps } = useButton(rest, ref);
2021-12-03 09:21:37 +08:00
return (
2021-12-08 03:59:57 +08:00
<button className={styles.backButton} ref={ref} {...buttonProps}>
2021-12-03 09:21:37 +08:00
<ArrowLeftIcon width={16} height={16} />
<RoomHeaderInfo roomName={roomName} />
</button>
);
}