diff --git a/frontend/src/components/MeetingRoom/AudioControlButton/AudioControlButton.tsx b/frontend/src/components/MeetingRoom/AudioControlButton/AudioControlButton.tsx index 29b16c30..8d882954 100644 --- a/frontend/src/components/MeetingRoom/AudioControlButton/AudioControlButton.tsx +++ b/frontend/src/components/MeetingRoom/AudioControlButton/AudioControlButton.tsx @@ -34,7 +34,7 @@ const AudioControlButton = (): ReactElement => { return (
- + { const [closed, setClosed] = useState(false); + const isSmallViewPort = useIsSmallViewport(); + const sxProps: SxProps = isSmallViewPort + ? { + left: '50%', + transform: 'translate(-50%, 0%)', + // We account for the SmallViewportHeader + top: '64px', + } + : { + left: '0.25rem', + top: '0.25rem', + }; return ( !closed && ( - - { - setClosed(true); - }, - } - : {})} - > - {title} - {message} - - + { + setClosed(true); + }, + } + : {})} + sx={{ + ...sxProps, + position: 'absolute', + width: '100%', + maxWidth: '320px', + }} + > + {title} + {message} + ) ); }; diff --git a/frontend/src/components/MutedAlert/MutedAlert.tsx b/frontend/src/components/MutedAlert/MutedAlert.tsx index 7f18222d..e9cb5ec1 100644 --- a/frontend/src/components/MutedAlert/MutedAlert.tsx +++ b/frontend/src/components/MutedAlert/MutedAlert.tsx @@ -1,75 +1,48 @@ -import Paper from '@mui/material/Paper'; -import Popper from '@mui/material/Popper'; import Fade from '@mui/material/Fade'; -import IconButton from '@mui/material/IconButton'; -import CloseIcon from '@mui/icons-material/Close'; -import { useTheme } from '@mui/material/styles'; -import { useState, useEffect, RefObject, ReactElement } from 'react'; +import { useState, useEffect, ReactElement } from 'react'; +import { Alert } from '@mui/material'; import { MUTED_ALERT_MESSAGE, FORCE_MUTED_ALERT_MESSAGE } from '../../utils/constants'; import useSpeakingDetector from '../../hooks/useSpeakingDetector'; import usePublisherContext from '../../hooks/usePublisherContext'; - -export type MutedAlertProps = { - anchorRef: RefObject; -}; +import useIsSmallViewport from '../../hooks/useIsSmallViewport'; /** * MutedAlert Component * * Displays a dismissible notification when the user is speaking while muted or has been muted by another participant. - * @param {MutedAlertProps} props - The props for the component. - * @property {RefObject} anchorRef - The reference element for the MutedAlert component. * @returns {ReactElement} - The MutedAlert component. */ -const MutedAlert = ({ anchorRef }: MutedAlertProps): ReactElement => { +const MutedAlert = (): ReactElement => { const { publisher, isAudioEnabled, isForceMuted } = usePublisherContext(); const [open, setOpen] = useState(false); const isSpeakingWhileMuted = useSpeakingDetector({ isAudioEnabled, selectedMicrophoneId: publisher?.getAudioSource()?.id, }); - const theme = useTheme(); + const isSmallViewport = useIsSmallViewport(); + const messageToDisplay = isForceMuted ? FORCE_MUTED_ALERT_MESSAGE : MUTED_ALERT_MESSAGE; useEffect(() => { setOpen(isForceMuted || isSpeakingWhileMuted); }, [isForceMuted, isSpeakingWhileMuted]); return ( - - {({ TransitionProps }) => ( - - -
- {isForceMuted && {FORCE_MUTED_ALERT_MESSAGE}} - {isSpeakingWhileMuted && !isForceMuted && {MUTED_ALERT_MESSAGE}} - setOpen(false)} - sx={{ color: '#fff', padding: 0, marginLeft: 1 }} - size="small" - > - - -
-
-
- )} -
+ + setOpen(false)} + sx={{ + position: 'absolute', + bottom: isSmallViewport ? '80px' : '96px', + left: '50%', + transform: 'translate(-50%, 0%)', + width: '100%', + maxWidth: '320px', + }} + > + {messageToDisplay} + + ); };