Update room and room setup headers

This commit is contained in:
Robert Long 2021-11-29 16:19:48 -08:00
parent 3cccb86902
commit dbaf467a20
5 changed files with 134 additions and 71 deletions

View file

@ -1,8 +1,67 @@
import classNames from "classnames"; import classNames from "classnames";
import React from "react"; import React from "react";
import { Link } from "react-router-dom"; import { Link, useHistory } from "react-router-dom";
import styles from "./Header.module.css"; import styles from "./Header.module.css";
import { ReactComponent as Logo } from "./Logo.svg"; import { ReactComponent as LogoIcon } from "./Logo.svg";
import { ReactComponent as VideoIcon } from "./icons/Video.svg";
import { ReactComponent as ArrowLeftIcon } from "./icons/ArrowLeft.svg";
export function RoomHeader({ roomName, children }) {
return (
<Header>
<LeftNav>
<div className={styles.roomAvatar}>
<VideoIcon width={16} height={16} />
</div>
<h3>{roomName}</h3>
</LeftNav>
<RightNav>{children}</RightNav>
</Header>
);
}
export function RoomSetupHeader({ roomName, children }) {
const history = useHistory();
return (
<Header>
<LeftNav>
<button className={styles.backButton} onClick={() => history.goBack()}>
<ArrowLeftIcon width={16} height={16} />
<div className={styles.roomAvatar}>
<VideoIcon width={16} height={16} />
</div>
<h3>{roomName}</h3>
</button>
</LeftNav>
<RightNav>{children}</RightNav>
</Header>
);
}
export function HomeHeader({ userName, signedIn, onLogout }) {
return (
<Header>
<LeftNav>
<Link className={styles.logo} to="/">
<LogoIcon width={32} height={32} />
</Link>
</LeftNav>
{signedIn && (
<RightNav>
<span className={styles.userName}>{userName}</span>
<button
className={styles.signOutButton}
type="button"
onClick={onLogout}
>
Sign Out
</button>
</RightNav>
)}
</Header>
);
}
export function Header({ children, className, ...rest }) { export function Header({ children, className, ...rest }) {
return ( return (
@ -14,18 +73,10 @@ export function Header({ children, className, ...rest }) {
export function LeftNav({ children, className, ...rest }) { export function LeftNav({ children, className, ...rest }) {
return ( return (
<div className={classNames(styles.leftNav, className)} {...rest}> <div
<Link className={styles.logo} to="/"> className={classNames(styles.nav, styles.leftNav, className)}
<Logo width={32} height={32} /> {...rest}
</Link> >
{children}
</div>
);
}
export function CenterNav({ children, className, ...rest }) {
return (
<div className={classNames(styles.centerNav, className)} {...rest}>
{children} {children}
</div> </div>
); );
@ -33,23 +84,11 @@ export function CenterNav({ children, className, ...rest }) {
export function RightNav({ children, className, ...rest }) { export function RightNav({ children, className, ...rest }) {
return ( return (
<div className={classNames(styles.rightNav, className)} {...rest}> <div
className={classNames(styles.nav, styles.rightNav, className)}
{...rest}
>
{children} {children}
</div> </div>
); );
} }
export function UserNav({ signedIn, userName, onLogout }) {
if (!signedIn) {
return null;
}
return (
<RightNav>
<span className={styles.userName}>{userName}</span>
<button className={styles.signOutButton} type="button" onClick={onLogout}>
Sign Out
</button>
</RightNav>
);
}

View file

@ -1,16 +1,18 @@
.header { .header {
position: relative; position: relative;
display: flex; display: flex;
justify-content: center; justify-content: space-between;
align-items: center; align-items: center;
height: 64px; height: 64px;
user-select: none; user-select: none;
flex-shrink: 0; flex-shrink: 0;
} }
.leftNav { .nav {
position: absolute; display: flex;
left: 20px; align-items: center;
white-space: nowrap;
margin: 0 20px;
} }
.logo { .logo {
@ -19,19 +21,52 @@
text-decoration: none; text-decoration: none;
} }
.rightNav { .leftNav > * {
position: absolute; margin-right: 12px;
right: 20px;
max-width: 40%;
white-space: nowrap;
display: flex;
} }
.rightNav > * { .rightNav > * {
margin-right: 24px; margin-right: 24px;
} }
.rightNav > :last-child { .nav > :last-child {
margin-right: 0;
}
.roomAvatar {
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: 36px;
height: 36px;
border-radius: 36px;
background-color: #5c56f5;
}
.roomAvatar > * {
fill: white;
stroke: white;
}
.backButton {
background: transparent;
border: none;
display: flex;
color: var(--textColor1);
cursor: pointer;
align-items: center;
}
.backButton h3 {
margin: 0;
}
.backButton > * {
margin-right: 12px;
}
.backButton > :last-child {
margin-right: 0; margin-right: 0;
} }

View file

@ -20,7 +20,7 @@ import {
useGroupCallRooms, useGroupCallRooms,
usePublicRooms, usePublicRooms,
} from "./ConferenceCallManagerHooks"; } from "./ConferenceCallManagerHooks";
import { Header, LeftNav, UserNav } from "./Header"; import { HomeHeader } from "./Header";
import ColorHash from "color-hash"; import ColorHash from "color-hash";
import styles from "./Home.module.css"; import styles from "./Home.module.css";
import { FieldRow, InputField, Button, ErrorMessage } from "./Input"; import { FieldRow, InputField, Button, ErrorMessage } from "./Input";
@ -121,10 +121,7 @@ export function Home({ client, onLogout }) {
return ( return (
<> <>
<Header> <HomeHeader signedIn userName={client.getUserId()} onLogout={onLogout} />
<LeftNav />
<UserNav signedIn userName={client.getUserId()} onLogout={onLogout} />
</Header>
<Content> <Content>
<Center> <Center>
<Modal> <Modal>

View file

@ -26,7 +26,7 @@ import {
DropdownButton, DropdownButton,
SettingsButton, SettingsButton,
} from "./RoomButton"; } from "./RoomButton";
import { Header, LeftNav, RightNav, CenterNav } from "./Header"; import { Header, LeftNav, RoomHeader, RoomSetupHeader } from "./Header";
import { Button } from "./Input"; import { Button } from "./Input";
import { GroupCallState } from "matrix-js-sdk/src/webrtc/groupCall"; import { GroupCallState } from "matrix-js-sdk/src/webrtc/groupCall";
import VideoGrid, { import VideoGrid, {
@ -249,12 +249,7 @@ function RoomSetupView({
return ( return (
<> <>
<Header> <RoomSetupHeader roomName={roomName} />
<LeftNav />
<CenterNav>
<h3>{roomName}</h3>
</CenterNav>
</Header>
<div className={styles.joinRoom}> <div className={styles.joinRoom}>
{hasLocalParticipant && ( {hasLocalParticipant && (
<p>Warning, you are signed into this call on another device.</p> <p>Warning, you are signed into this call on another device.</p>
@ -470,12 +465,7 @@ function InRoomView({
return ( return (
<> <>
<Header> <RoomHeader roomName={roomName}>
<LeftNav />
<CenterNav>
<h3>{roomName}</h3>
</CenterNav>
<RightNav>
<SettingsButton <SettingsButton
title={showInspector ? "Hide Inspector" : "Show Inspector"} title={showInspector ? "Hide Inspector" : "Show Inspector"}
on={showInspector} on={showInspector}
@ -486,8 +476,7 @@ function InRoomView({
layout={layout} layout={layout}
onClick={toggleLayout} onClick={toggleLayout}
/> />
</RightNav> </RoomHeader>
</Header>
{items.length === 0 ? ( {items.length === 0 ? (
<div className={styles.centerMessage}> <div className={styles.centerMessage}>
<p>Waiting for other participants...</p> <p>Waiting for other participants...</p>

3
src/icons/ArrowLeft.svg Normal file
View file

@ -0,0 +1,3 @@
<svg width="20" height="16" viewBox="0 0 20 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18.6663 8H1.33301M1.33301 8L7.83301 14.5M1.33301 8L7.83301 1.5" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 258 B