Merge pull request #2738 from robintown/narrow-footer

Make the footer display more nicely on narrow screens
This commit is contained in:
Robin
2024-11-08 12:46:29 -05:00
committed by GitHub
3 changed files with 146 additions and 106 deletions

View File

@@ -211,7 +211,7 @@ export function ReactionPopupMenu({
); );
} }
interface ReactionToggleButtonProps { interface ReactionToggleButtonProps extends ComponentPropsWithoutRef<"button"> {
rtcSession: MatrixRTCSession; rtcSession: MatrixRTCSession;
client: MatrixClient; client: MatrixClient;
} }
@@ -219,6 +219,7 @@ interface ReactionToggleButtonProps {
export function ReactionToggleButton({ export function ReactionToggleButton({
client, client,
rtcSession, rtcSession,
...props
}: ReactionToggleButtonProps): ReactNode { }: ReactionToggleButtonProps): ReactNode {
const { t } = useTranslation(); const { t } = useTranslation();
const { raisedHands, lowerHand, reactions } = useReactions(); const { raisedHands, lowerHand, reactions } = useReactions();
@@ -327,6 +328,7 @@ export function ReactionToggleButton({
onClick={() => setShowReactionsMenu((show) => !show)} onClick={() => setShowReactionsMenu((show) => !show)}
raised={isHandRaised} raised={isHandRaised}
open={showReactionsMenu} open={showReactionsMenu}
{...props}
/> />
<Modal <Modal
open={showReactionsMenu} open={showReactionsMenu}

View File

@@ -36,12 +36,14 @@ Please see LICENSE in the repository root for full details.
inset-block-end: 0; inset-block-end: 0;
z-index: 1; z-index: 1;
display: grid; display: grid;
grid-template-columns: 1fr auto 1fr; grid-template-columns: minmax(0, var(--inline-content-inset)) 1fr auto 1fr minmax(
grid-template-areas: "logo buttons layout"; 0,
var(--inline-content-inset)
);
grid-template-areas: ". logo buttons layout .";
align-items: center; align-items: center;
gap: var(--cpd-space-3x); gap: var(--cpd-space-3x);
padding-block: var(--cpd-space-4x); padding-block: var(--cpd-space-10x);
padding-inline: var(--inline-content-inset);
background: linear-gradient( background: linear-gradient(
180deg, 180deg,
rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 0%,
@@ -83,6 +85,7 @@ Please see LICENSE in the repository root for full details.
.buttons { .buttons {
grid-area: buttons; grid-area: buttons;
justify-self: center;
display: flex; display: flex;
gap: var(--cpd-space-3x); gap: var(--cpd-space-3x);
} }
@@ -92,15 +95,49 @@ Please see LICENSE in the repository root for full details.
justify-self: end; justify-self: end;
} }
@media (min-height: 400px) { @media (max-width: 660px) {
.footer { .footer {
padding-block: var(--cpd-space-8x); grid-template-areas: ". buttons buttons buttons .";
}
.logo {
display: none;
}
.layout {
display: none !important;
} }
} }
@media (min-height: 800px) { @media (max-width: 370px) {
.raiseHand {
display: none;
}
}
@media (max-width: 340px) {
.invite,
.switchCamera,
.shareScreen {
display: none;
}
@media (max-height: 400px) {
.footer { .footer {
padding-block: var(--cpd-space-10x); display: none;
}
}
}
@media (max-height: 400px) {
.footer {
padding-block: var(--cpd-space-4x);
}
}
@media (max-height: 800px) {
.footer {
padding-block: var(--cpd-space-8x);
} }
} }

View File

@@ -213,7 +213,6 @@ export const InCallView: FC<InCallViewProps> = ({
const containerRef1 = useRef<HTMLDivElement | null>(null); const containerRef1 = useRef<HTMLDivElement | null>(null);
const [containerRef2, bounds] = useMeasure(); const [containerRef2, bounds] = useMeasure();
const boundsValid = bounds.height > 0;
// Merge the refs so they can attach to the same element // Merge the refs so they can attach to the same element
const containerRef = useMergedRefs(containerRef1, containerRef2); const containerRef = useMergedRefs(containerRef1, containerRef2);
@@ -241,10 +240,6 @@ export const InCallView: FC<InCallViewProps> = ({
(muted) => muteStates.audio.setEnabled?.(!muted), (muted) => muteStates.audio.setEnabled?.(!muted),
); );
const mobile = boundsValid && bounds.width <= 660;
const reducedControls = boundsValid && bounds.width <= 340;
const noControls = reducedControls && bounds.height <= 400;
const windowMode = useObservableEagerState(vm.windowMode); const windowMode = useObservableEagerState(vm.windowMode);
const layout = useObservableEagerState(vm.layout); const layout = useObservableEagerState(vm.layout);
const gridMode = useObservableEagerState(vm.gridMode); const gridMode = useObservableEagerState(vm.gridMode);
@@ -526,11 +521,6 @@ export const InCallView: FC<InCallViewProps> = ({
.catch(logger.error); .catch(logger.error);
}, [localParticipant, isScreenShareEnabled]); }, [localParticipant, isScreenShareEnabled]);
let footer: JSX.Element | null;
if (noControls) {
footer = null;
} else {
const buttons: JSX.Element[] = []; const buttons: JSX.Element[] = [];
buttons.push( buttons.push(
@@ -549,15 +539,19 @@ export const InCallView: FC<InCallViewProps> = ({
data-testid="incall_videomute" data-testid="incall_videomute"
/>, />,
); );
if (!reducedControls) {
if (switchCamera !== null) if (switchCamera !== null)
buttons.push( buttons.push(
<SwitchCameraButton key="switch_camera" onClick={switchCamera} />, <SwitchCameraButton
key="switch_camera"
className={styles.switchCamera}
onClick={switchCamera}
/>,
); );
if (canScreenshare && !hideScreensharing) { if (canScreenshare && !hideScreensharing) {
buttons.push( buttons.push(
<ShareScreenButton <ShareScreenButton
key="share_screen" key="share_screen"
className={styles.shareScreen}
enabled={isScreenShareEnabled} enabled={isScreenShareEnabled}
onClick={toggleScreensharing} onClick={toggleScreensharing}
data-testid="incall_screenshare" data-testid="incall_screenshare"
@@ -567,14 +561,15 @@ export const InCallView: FC<InCallViewProps> = ({
if (supportsReactions) { if (supportsReactions) {
buttons.push( buttons.push(
<ReactionToggleButton <ReactionToggleButton
key="raise_hand"
className={styles.raiseHand}
client={client} client={client}
rtcSession={rtcSession} rtcSession={rtcSession}
key="4"
/>, />,
); );
} }
if (layout.type !== "pip")
buttons.push(<SettingsButton key="settings" onClick={openSettings} />); buttons.push(<SettingsButton key="settings" onClick={openSettings} />);
}
buttons.push( buttons.push(
<EndCallButton <EndCallButton
@@ -585,7 +580,7 @@ export const InCallView: FC<InCallViewProps> = ({
data-testid="incall_leave" data-testid="incall_leave"
/>, />,
); );
footer = ( const footer = (
<div <div
ref={footerRef} ref={footerRef}
className={classNames(styles.footer, { className={classNames(styles.footer, {
@@ -593,7 +588,7 @@ export const InCallView: FC<InCallViewProps> = ({
[styles.hidden]: !showFooter || (!showControls && hideHeader), [styles.hidden]: !showFooter || (!showControls && hideHeader),
})} })}
> >
{!mobile && !hideHeader && ( {!hideHeader && (
<div className={styles.logo}> <div className={styles.logo}>
<LogoMark width={24} height={24} aria-hidden /> <LogoMark width={24} height={24} aria-hidden />
<LogoType <LogoType
@@ -604,7 +599,7 @@ export const InCallView: FC<InCallViewProps> = ({
</div> </div>
)} )}
{showControls && <div className={styles.buttons}>{buttons}</div>} {showControls && <div className={styles.buttons}>{buttons}</div>}
{!mobile && showControls && ( {showControls && (
<LayoutToggle <LayoutToggle
className={styles.layout} className={styles.layout}
layout={gridMode} layout={gridMode}
@@ -614,7 +609,6 @@ export const InCallView: FC<InCallViewProps> = ({
)} )}
</div> </div>
); );
}
return ( return (
<div <div
@@ -646,8 +640,11 @@ export const InCallView: FC<InCallViewProps> = ({
/> />
</LeftNav> </LeftNav>
<RightNav> <RightNav>
{!reducedControls && showControls && onShareClick !== null && ( {showControls && onShareClick !== null && (
<InviteButton onClick={onShareClick} /> <InviteButton
className={styles.invite}
onClick={onShareClick}
/>
)} )}
</RightNav> </RightNav>
</Header> </Header>
@@ -669,7 +666,9 @@ export const InCallView: FC<InCallViewProps> = ({
</span> </span>
))} ))}
{footer} {footer}
{!noControls && <RageshakeRequestModal {...rageshakeRequestModalProps} />} {layout.type !== "pip" && (
<>
<RageshakeRequestModal {...rageshakeRequestModalProps} />
<SettingsModal <SettingsModal
client={client} client={client}
roomId={rtcSession.room.roomId} roomId={rtcSession.room.roomId}
@@ -678,6 +677,8 @@ export const InCallView: FC<InCallViewProps> = ({
tab={settingsTab} tab={settingsTab}
onTabChange={setSettingsTab} onTabChange={setSettingsTab}
/> />
</>
)}
</div> </div>
); );
}; };