fixing header more with search bar or not
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
|
import { $desktopMode, $selectedOutputMode } from "../../controller/recoil";
|
||||||
import { Avatar, Menu } from "antd";
|
import { Avatar, Menu } from "antd";
|
||||||
import { GlobalHotKeys, KeyMap } from "react-hotkeys";
|
import { GlobalHotKeys, KeyMap } from "react-hotkeys";
|
||||||
import { HeadsetMicSharp, VideocamSharp } from "@mui/icons-material";
|
import { HeadsetMicSharp, VideocamSharp } from "@mui/icons-material";
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
|
import { useRecoilState, useRecoilValue } from "recoil";
|
||||||
|
|
||||||
import { $selectedOutputMode } from "../../controller/recoil";
|
|
||||||
import { FaSearch } from "react-icons/fa";
|
import { FaSearch } from "react-icons/fa";
|
||||||
import Logo from "../Logo";
|
import Logo from "../Logo";
|
||||||
import { useGetUserDetails } from "../../controller/index";
|
import { useGetUserDetails } from "../../controller/index";
|
||||||
import { useRecoilState } from "recoil";
|
|
||||||
|
|
||||||
export default function NirvanaHeader({
|
export default function NirvanaHeader({
|
||||||
onHeaderFocus,
|
onHeaderFocus,
|
||||||
@@ -22,6 +22,8 @@ export default function NirvanaHeader({
|
|||||||
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
||||||
const [outputMode, setOutputMode] = useRecoilState($selectedOutputMode);
|
const [outputMode, setOutputMode] = useRecoilState($selectedOutputMode);
|
||||||
|
|
||||||
|
const desktopMode = useRecoilValue($desktopMode);
|
||||||
|
|
||||||
const [userVideoStream, setUserVideoStream] =
|
const [userVideoStream, setUserVideoStream] =
|
||||||
useState<MediaStream>(undefined);
|
useState<MediaStream>(undefined);
|
||||||
|
|
||||||
@@ -40,16 +42,18 @@ export default function NirvanaHeader({
|
|||||||
videoElem.srcObject = userVideoStream;
|
videoElem.srcObject = userVideoStream;
|
||||||
}, [userVideoStream, outputMode]);
|
}, [userVideoStream, outputMode]);
|
||||||
|
|
||||||
const menuOpen = useMemo(() => Boolean(anchorEl), [anchorEl]);
|
/** hide the search bar in the header so that it's cleaner for these two modes */
|
||||||
|
const shouldHideSearch = useMemo(() => {
|
||||||
|
if (desktopMode === "flowState" || desktopMode === "overlayOnly")
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}, [desktopMode]);
|
||||||
|
|
||||||
const handleOpenMenu = useCallback((event: React.MouseEvent<HTMLElement>) => {
|
const handleOpenMenu = useCallback((event: React.MouseEvent<HTMLElement>) => {
|
||||||
setAnchorEl(event.currentTarget);
|
setAnchorEl(event.currentTarget);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleCloseMenu = useCallback(() => {
|
|
||||||
setAnchorEl(null);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const selectSearch = () => {
|
const selectSearch = () => {
|
||||||
inputRef.current?.focus();
|
inputRef.current?.focus();
|
||||||
};
|
};
|
||||||
@@ -76,32 +80,34 @@ export default function NirvanaHeader({
|
|||||||
<GlobalHotKeys handlers={handlers} keyMap={keyMap} />
|
<GlobalHotKeys handlers={handlers} keyMap={keyMap} />
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className="flex flex-row items-center bg-gray-100 pl-7 border-b border-b-gray-200"
|
className="flex flex-row items-center bg-gray-100 pl-7 h-16 border-b border-b-gray-200"
|
||||||
id="titlebar"
|
id="titlebar"
|
||||||
>
|
>
|
||||||
<div onClick={onHeaderFocus}>
|
<div onClick={onHeaderFocus}>
|
||||||
<Logo type="small" />
|
<Logo type="small" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mx-auto flex flex-row items-center space-x-2">
|
{!shouldHideSearch && (
|
||||||
<FaSearch className="text-xs text-gray-300" />
|
<div className="mx-auto flex flex-row items-center space-x-2">
|
||||||
<input
|
<FaSearch className="text-xs text-gray-300" />
|
||||||
placeholder="Type / to search"
|
<input
|
||||||
className="bg-transparent placeholder-gray-300 placeholder:text-xs focus:outline-none"
|
placeholder="Type / to search"
|
||||||
ref={inputRef}
|
className="bg-transparent placeholder-gray-300 placeholder:text-xs focus:outline-none"
|
||||||
onChange={onSearchChange}
|
ref={inputRef}
|
||||||
value={searchInput}
|
onChange={onSearchChange}
|
||||||
/>
|
value={searchInput}
|
||||||
</div>
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* todo: move this ghost button to components */}
|
{/* todo: move this ghost button to components */}
|
||||||
<button className="text-gray-300 text-xs px-2 py-1 transition-all hover:bg-gray-200">
|
<button className="text-gray-300 ml-auto text-xs px-2 py-1 transition-all hover:bg-gray-200">
|
||||||
flow state
|
flow state
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div onClick={handleOpenMenu} className={"cursor-pointer ml-2"}>
|
<div onClick={handleOpenMenu} className={"cursor-pointer ml-2"}>
|
||||||
{outputMode === "video" && (
|
{outputMode === "video" && (
|
||||||
<video height={"75px"} width={"90"} muted autoPlay />
|
<video height={"64px"} width={"90"} muted autoPlay />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{userDetailsRes?.user?.picture && outputMode === "audio" && (
|
{userDetailsRes?.user?.picture && outputMode === "audio" && (
|
||||||
|
|||||||
@@ -24,6 +24,15 @@ function Video({ peer }: { peer: Peer }) {
|
|||||||
console.log("stream coming in, adding video src object");
|
console.log("stream coming in, adding video src object");
|
||||||
|
|
||||||
if (videoRef?.current) videoRef.current.srcObject = remoteStream;
|
if (videoRef?.current) videoRef.current.srcObject = remoteStream;
|
||||||
|
|
||||||
|
// check if other user muted
|
||||||
|
setInterval(() => {
|
||||||
|
const videoAvailabe = remoteStream
|
||||||
|
.getVideoTracks()
|
||||||
|
.find((track) => track.enabled);
|
||||||
|
|
||||||
|
if (!videoAvailabe) console.log("someone muted!!! ooo");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
peer.on("close", () => {
|
peer.on("close", () => {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ button {
|
|||||||
#titlebar {
|
#titlebar {
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
-webkit-app-region: drag;
|
-webkit-app-region: drag;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.titlebar-button {
|
.titlebar-button {
|
||||||
|
|||||||
Reference in New Issue
Block a user