From 29a20a930e198c993c0219b0bcfc4e25c9202720 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Tue, 12 Sep 2023 09:35:32 -0500 Subject: [PATCH] feat(media): [closes #157] Improve media button styling (#164) --- src/components/Room/MediaButton.tsx | 49 +++++++++++++++++++ src/components/Room/RoomAudioControls.tsx | 10 ++-- .../Room/RoomFileUploadControls.tsx | 14 +++--- .../Room/RoomScreenShareControls.tsx | 10 ++-- .../Room/RoomShowMessagesControls.tsx | 11 +++-- src/components/Room/RoomVideoControls.tsx | 10 ++-- 6 files changed, 77 insertions(+), 27 deletions(-) create mode 100644 src/components/Room/MediaButton.tsx diff --git a/src/components/Room/MediaButton.tsx b/src/components/Room/MediaButton.tsx new file mode 100644 index 0000000..84fef5c --- /dev/null +++ b/src/components/Room/MediaButton.tsx @@ -0,0 +1,49 @@ +import Fab, { FabProps } from '@mui/material/Fab' +import { forwardRef } from 'react' + +interface MediaButtonProps extends Partial { + isActive: boolean +} + +export const MediaButton = forwardRef( + ({ isActive, ...props }: MediaButtonProps, ref) => { + return ( + + theme.palette.mode === 'dark' + ? isActive + ? { + color: theme.palette.common.white, + background: theme.palette.success.main, + '&:hover': { + background: theme.palette.success.dark, + }, + } + : { + background: theme.palette.grey[500], + '&:hover': { + background: theme.palette.grey[600], + }, + } + : isActive + ? { + color: theme.palette.common.white, + background: theme.palette.success.main, + '&:hover': { + background: theme.palette.success.dark, + }, + } + : { + color: theme.palette.common.black, + background: theme.palette.grey[400], + '&:hover': { + background: theme.palette.grey[500], + }, + } + } + /> + ) + } +) diff --git a/src/components/Room/RoomAudioControls.tsx b/src/components/Room/RoomAudioControls.tsx index 1805291..0bac291 100644 --- a/src/components/Room/RoomAudioControls.tsx +++ b/src/components/Room/RoomAudioControls.tsx @@ -7,12 +7,12 @@ import ListItem from '@mui/material/ListItem' import ListItemText from '@mui/material/ListItemText' import Menu from '@mui/material/Menu' import MenuItem from '@mui/material/MenuItem' -import Fab from '@mui/material/Fab' import Tooltip from '@mui/material/Tooltip' import { PeerRoom } from 'services/PeerRoom/PeerRoom' import { useRoomAudio } from './useRoomAudio' +import { MediaButton } from './MediaButton' export interface RoomAudioControlsProps { peerRoom: PeerRoom @@ -70,13 +70,13 @@ export function RoomAudioControls({ peerRoom }: RoomAudioControlsProps) { : 'Turn on microphone and speak to room' } > - - {isSpeakingToRoom ? : } - + {isSpeakingToRoom ? : } + {audioDevices.length > 0 && ( diff --git a/src/components/Room/RoomFileUploadControls.tsx b/src/components/Room/RoomFileUploadControls.tsx index b66ad27..e2d38be 100644 --- a/src/components/Room/RoomFileUploadControls.tsx +++ b/src/components/Room/RoomFileUploadControls.tsx @@ -1,8 +1,7 @@ import { ChangeEventHandler, useContext, useRef } from 'react' import Box from '@mui/material/Box' -import UploadFile from '@mui/icons-material/UploadFile' -import Cancel from '@mui/icons-material/Cancel' -import Fab from '@mui/material/Fab' +import Folder from '@mui/icons-material/Folder' +import FolderOff from '@mui/icons-material/FolderOff' import Tooltip from '@mui/material/Tooltip' import CircularProgress from '@mui/material/CircularProgress' @@ -10,6 +9,7 @@ import { RoomContext } from 'contexts/RoomContext' import { PeerRoom } from 'services/PeerRoom/PeerRoom' import { useRoomFileShare } from './useRoomFileShare' +import { MediaButton } from './MediaButton' export interface RoomFileUploadControlsProps { onInlineMediaUpload: (files: File[]) => void @@ -61,7 +61,7 @@ export function RoomFileUploadControls({ const disableFileUpload = !isFileSharingEnabled || isMessageSending - const buttonIcon = isSharingFile ? : + const buttonIcon = isSharingFile ? : return ( - )} - + ) diff --git a/src/components/Room/RoomScreenShareControls.tsx b/src/components/Room/RoomScreenShareControls.tsx index 8cc4c9a..c3068ab 100644 --- a/src/components/Room/RoomScreenShareControls.tsx +++ b/src/components/Room/RoomScreenShareControls.tsx @@ -1,12 +1,12 @@ import Box from '@mui/material/Box' import ScreenShare from '@mui/icons-material/ScreenShare' import StopScreenShare from '@mui/icons-material/StopScreenShare' -import Fab from '@mui/material/Fab' import Tooltip from '@mui/material/Tooltip' import { PeerRoom } from 'services/PeerRoom/PeerRoom' import { useRoomScreenShare } from './useRoomScreenShare' +import { MediaButton } from './MediaButton' export interface RoomFileUploadControlsProps { peerRoom: PeerRoom @@ -47,13 +47,13 @@ export function RoomScreenShareControls({ isSharingScreen ? 'Stop sharing screen' : 'Share screen with room' } > - - {isSharingScreen ? : } - + {isSharingScreen ? : } + ) diff --git a/src/components/Room/RoomShowMessagesControls.tsx b/src/components/Room/RoomShowMessagesControls.tsx index 965f0b1..125513a 100644 --- a/src/components/Room/RoomShowMessagesControls.tsx +++ b/src/components/Room/RoomShowMessagesControls.tsx @@ -1,12 +1,13 @@ import { useContext } from 'react' -import Fab from '@mui/material/Fab' import Tooltip from '@mui/material/Tooltip' import { Comment, CommentsDisabled } from '@mui/icons-material' import { Badge, Box } from '@mui/material' import { RoomContext } from 'contexts/RoomContext' +import { MediaButton } from './MediaButton' + export function RoomShowMessagesControls() { const { isShowingMessages, setIsShowingMessages, unreadMessages } = useContext(RoomContext) @@ -22,15 +23,15 @@ export function RoomShowMessagesControls() { }} > - setIsShowingMessages(!isShowingMessages)} > - {isShowingMessages ? : } + {isShowingMessages ? : } - + ) diff --git a/src/components/Room/RoomVideoControls.tsx b/src/components/Room/RoomVideoControls.tsx index 2ad612e..114614a 100644 --- a/src/components/Room/RoomVideoControls.tsx +++ b/src/components/Room/RoomVideoControls.tsx @@ -7,12 +7,12 @@ import ListItem from '@mui/material/ListItem' import ListItemText from '@mui/material/ListItemText' import Menu from '@mui/material/Menu' import MenuItem from '@mui/material/MenuItem' -import Fab from '@mui/material/Fab' import Tooltip from '@mui/material/Tooltip' import { PeerRoom } from 'services/PeerRoom/PeerRoom' import { useRoomVideo } from './useRoomVideo' +import { MediaButton } from './MediaButton' export interface RoomVideoControlsProps { peerRoom: PeerRoom @@ -64,13 +64,13 @@ export function RoomVideoControls({ peerRoom }: RoomVideoControlsProps) { }} > - - {isCameraEnabled ? : } - + {isCameraEnabled ? : } + {videoDevices.length > 0 && (