separating out the navbar
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
import React from 'react';
|
import React, { useRef, useCallback } from 'react';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Avatar,
|
Avatar,
|
||||||
|
CircularProgress,
|
||||||
Divider,
|
Divider,
|
||||||
IconButton,
|
IconButton,
|
||||||
|
Input,
|
||||||
ListItemIcon,
|
ListItemIcon,
|
||||||
Menu,
|
Menu,
|
||||||
Stack,
|
Stack,
|
||||||
@@ -11,127 +13,85 @@ import {
|
|||||||
Typography,
|
Typography,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import NirvanaLogo from './NirvanaLogo';
|
import NirvanaLogo from './NirvanaLogo';
|
||||||
import { FiHeadphones, FiLogOut, FiMonitor, FiWind } from 'react-icons/fi';
|
import { FiHeadphones, FiLogOut, FiMonitor, FiSearch, FiUsers, FiWind } from 'react-icons/fi';
|
||||||
|
|
||||||
import MenuItem from '@mui/material/MenuItem';
|
import MenuItem from '@mui/material/MenuItem';
|
||||||
import useAuth from '../providers/AuthProvider';
|
import useAuth from '../providers/AuthProvider';
|
||||||
|
import { blueGrey } from '@mui/material/colors';
|
||||||
|
import KeyboardShortcutLabel from './KeyboardShortcutLabel';
|
||||||
|
import { useSnackbar } from 'notistack';
|
||||||
|
import { useKeyPressEvent } from 'react-use';
|
||||||
|
|
||||||
const Navbar = () => {
|
const Navbar = ({
|
||||||
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
handleChangeSearchInput,
|
||||||
const open = Boolean(anchorEl);
|
searchVal,
|
||||||
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
|
isSearching,
|
||||||
setAnchorEl(event.currentTarget);
|
}: {
|
||||||
};
|
handleChangeSearchInput: React.ChangeEventHandler;
|
||||||
const handleClose = () => {
|
searchVal: string;
|
||||||
setAnchorEl(null);
|
isSearching: boolean;
|
||||||
};
|
}) => {
|
||||||
|
|
||||||
const { logout, user } = useAuth();
|
const { logout, user } = useAuth();
|
||||||
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
|
const searchRef = useRef<HTMLInputElement>(null);
|
||||||
|
const onSearchFocus = useCallback(() => {
|
||||||
|
enqueueSnackbar('search focused');
|
||||||
|
if (searchRef?.current) searchRef.current.focus();
|
||||||
|
}, [enqueueSnackbar, searchRef]);
|
||||||
|
|
||||||
|
useKeyPressEvent('Shift', onSearchFocus);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Stack
|
||||||
<Stack
|
direction="row"
|
||||||
direction="row"
|
justifyContent={'flex-start'}
|
||||||
justifyContent={'flex-start'}
|
alignItems={'center'}
|
||||||
alignItems={'center'}
|
spacing={2}
|
||||||
sx={{
|
sx={{
|
||||||
WebkitAppRegion: 'drag',
|
WebkitAppRegion: 'drag',
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
pb: 1,
|
pb: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<NirvanaLogo />
|
<NirvanaLogo />
|
||||||
|
|
||||||
<Stack
|
<Stack
|
||||||
spacing={1}
|
direction={'row'}
|
||||||
direction={'row'}
|
sx={{
|
||||||
alignItems={'center'}
|
position: 'relative',
|
||||||
sx={{
|
display: 'flex',
|
||||||
ml: 'auto',
|
flexDirection: 'row',
|
||||||
mr: 1,
|
bgcolor: blueGrey[100],
|
||||||
color: 'GrayText',
|
opacity: '50%',
|
||||||
}}
|
borderRadius: 1,
|
||||||
>
|
px: 1,
|
||||||
<Tooltip title="Sound configuration">
|
py: 0.5,
|
||||||
<IconButton color="inherit" size="small">
|
flex: 1,
|
||||||
<FiHeadphones />
|
}}
|
||||||
</IconButton>
|
alignItems={'center'}
|
||||||
</Tooltip>
|
spacing={1}
|
||||||
<Tooltip title="Desktop modes">
|
>
|
||||||
<IconButton color="inherit" size="small">
|
<FiSearch style={{ color: blueGrey[500] }} />
|
||||||
<FiMonitor />
|
|
||||||
</IconButton>
|
<Input
|
||||||
</Tooltip>
|
onChange={handleChangeSearchInput}
|
||||||
<Tooltip title="Flow state">
|
value={searchVal}
|
||||||
<IconButton color="inherit" size="small">
|
placeholder={'Find or start a conversation'}
|
||||||
<FiWind />
|
inputRef={searchRef}
|
||||||
</IconButton>
|
/>
|
||||||
</Tooltip>
|
|
||||||
</Stack>
|
{isSearching && <CircularProgress size={20} />}
|
||||||
<IconButton
|
|
||||||
onClick={handleClick}
|
<KeyboardShortcutLabel label="Shift" />
|
||||||
size="small"
|
|
||||||
sx={{ ml: 1, borderRadius: 1 }}
|
|
||||||
aria-controls={open ? 'account-menu' : undefined}
|
|
||||||
aria-haspopup="true"
|
|
||||||
aria-expanded={open ? 'true' : undefined}
|
|
||||||
>
|
|
||||||
<Avatar alt={user.displayName} src={user.photoURL} />
|
|
||||||
</IconButton>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Menu
|
<Tooltip title={'Group conversation'}>
|
||||||
anchorEl={anchorEl}
|
<IconButton color="default" size={'small'}>
|
||||||
id="account-menu"
|
<FiUsers />
|
||||||
open={open}
|
</IconButton>
|
||||||
onClose={handleClose}
|
</Tooltip>
|
||||||
onClick={handleClose}
|
</Stack>
|
||||||
PaperProps={{
|
|
||||||
elevation: 0,
|
|
||||||
sx: {
|
|
||||||
overflow: 'visible',
|
|
||||||
filter: 'drop-shadow(0px 2px 8px rgba(0,0,0,0.32))',
|
|
||||||
mt: 1.5,
|
|
||||||
'& .MuiAvatar-root': {
|
|
||||||
width: 32,
|
|
||||||
height: 32,
|
|
||||||
ml: -0.5,
|
|
||||||
mr: 1,
|
|
||||||
},
|
|
||||||
'&:before': {
|
|
||||||
content: '""',
|
|
||||||
display: 'block',
|
|
||||||
position: 'absolute',
|
|
||||||
top: 0,
|
|
||||||
right: 14,
|
|
||||||
width: 10,
|
|
||||||
height: 10,
|
|
||||||
bgcolor: 'background.paper',
|
|
||||||
transform: 'translateY(-50%) rotate(45deg)',
|
|
||||||
zIndex: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
|
|
||||||
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
|
|
||||||
>
|
|
||||||
<MenuItem>
|
|
||||||
<Avatar /> Profile
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem>
|
|
||||||
<Avatar /> My account
|
|
||||||
</MenuItem>
|
|
||||||
|
|
||||||
<Divider />
|
|
||||||
|
|
||||||
<MenuItem onClick={logout}>
|
|
||||||
<ListItemIcon>
|
|
||||||
<FiLogOut />
|
|
||||||
</ListItemIcon>
|
|
||||||
<Typography color="warning">Logout</Typography>
|
|
||||||
</MenuItem>
|
|
||||||
</Menu>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ import KeyboardShortcutLabel from './KeyboardShortcutLabel';
|
|||||||
import Channels from '../electron/constants';
|
import Channels from '../electron/constants';
|
||||||
import { uploadAudioClip } from '../firebase/firebaseStorage';
|
import { uploadAudioClip } from '../firebase/firebaseStorage';
|
||||||
import { ContentBlock, ContentType } from '@nirvana/core/src/models/content.model';
|
import { ContentBlock, ContentType } from '@nirvana/core/src/models/content.model';
|
||||||
|
import Navbar from './Navbar';
|
||||||
type ConversationMap = {
|
type ConversationMap = {
|
||||||
[conversationId: string]: Conversation;
|
[conversationId: string]: Conversation;
|
||||||
};
|
};
|
||||||
@@ -351,22 +352,10 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
[userMap, updateUserMap],
|
[userMap, updateUserMap],
|
||||||
);
|
);
|
||||||
|
|
||||||
const searchRef = useRef<HTMLInputElement>(null);
|
|
||||||
const [searchVal, setSearchVal] = useState<string>('');
|
|
||||||
|
|
||||||
const onSearchFocus = useCallback(() => {
|
|
||||||
enqueueSnackbar('search focused');
|
|
||||||
if (searchRef?.current) searchRef.current.focus();
|
|
||||||
}, [enqueueSnackbar, searchRef]);
|
|
||||||
|
|
||||||
const [searchUsersResults, setSearchUsersResults] = useState<User[]>([]);
|
|
||||||
const [searching, setSearching] = useState<boolean>(false);
|
|
||||||
|
|
||||||
const handleEscape = useCallback(() => {
|
const handleEscape = useCallback(() => {
|
||||||
setSelectedConversationId(undefined);
|
setSelectedConversationId(undefined);
|
||||||
}, [setSelectedConversationId]);
|
}, [setSelectedConversationId]);
|
||||||
|
|
||||||
useKeyPressEvent('Shift', onSearchFocus);
|
|
||||||
useKeyPressEvent('Escape', handleEscape);
|
useKeyPressEvent('Escape', handleEscape);
|
||||||
|
|
||||||
const [isUserSpeaking, setIsUserSpeaking] = useState<boolean>(false);
|
const [isUserSpeaking, setIsUserSpeaking] = useState<boolean>(false);
|
||||||
@@ -487,6 +476,10 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
|
|
||||||
useKeyPressEvent('`', handleBroadcast, handleStopBroadcast);
|
useKeyPressEvent('`', handleBroadcast, handleStopBroadcast);
|
||||||
|
|
||||||
|
const [searchVal, setSearchVal] = useState<string>('');
|
||||||
|
const [searchUsersResults, setSearchUsersResults] = useState<User[]>([]);
|
||||||
|
const [searching, setSearching] = useState<boolean>(false);
|
||||||
|
|
||||||
const [, cancel] = useDebounce(
|
const [, cancel] = useDebounce(
|
||||||
async () => {
|
async () => {
|
||||||
if (searchVal) {
|
if (searchVal) {
|
||||||
@@ -560,56 +553,11 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
height: 'inherit',
|
height: 'inherit',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/* navbar */}
|
<Navbar
|
||||||
<Stack
|
searchVal={searchVal}
|
||||||
direction="row"
|
isSearching={searching}
|
||||||
justifyContent={'flex-start'}
|
handleChangeSearchInput={handleChangeSearchInput}
|
||||||
alignItems={'center'}
|
/>
|
||||||
spacing={2}
|
|
||||||
sx={{
|
|
||||||
WebkitAppRegion: 'drag',
|
|
||||||
cursor: 'pointer',
|
|
||||||
pb: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<NirvanaLogo />
|
|
||||||
|
|
||||||
<Stack
|
|
||||||
direction={'row'}
|
|
||||||
sx={{
|
|
||||||
position: 'relative',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'row',
|
|
||||||
bgcolor: blueGrey[100],
|
|
||||||
opacity: '50%',
|
|
||||||
borderRadius: 1,
|
|
||||||
px: 1,
|
|
||||||
py: 0.5,
|
|
||||||
flex: 1,
|
|
||||||
}}
|
|
||||||
alignItems={'center'}
|
|
||||||
spacing={1}
|
|
||||||
>
|
|
||||||
<FiSearch style={{ color: blueGrey[500] }} />
|
|
||||||
|
|
||||||
<Input
|
|
||||||
onChange={handleChangeSearchInput}
|
|
||||||
value={searchVal}
|
|
||||||
placeholder={'Find or start a conversation'}
|
|
||||||
inputRef={searchRef}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{searching && <CircularProgress size={20} />}
|
|
||||||
|
|
||||||
<KeyboardShortcutLabel label="Shift" />
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<Tooltip title={'Group conversation'}>
|
|
||||||
<IconButton color="default" size={'small'}>
|
|
||||||
<FiUsers />
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
{searchVal ? (
|
{searchVal ? (
|
||||||
<ListPeople people={searchUsersResults} />
|
<ListPeople people={searchUsersResults} />
|
||||||
|
|||||||
Reference in New Issue
Block a user