Also use CallFooter for lobby

This commit is contained in:
Timo K
2026-04-14 13:25:33 +02:00
parent be74ebbb6c
commit 400259207e
12 changed files with 370 additions and 230 deletions

View File

@@ -0,0 +1,31 @@
{/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/}
{/*
This is a custom doc page overwriting the default autodocs tag.
This can be done by using the same filename as the component
With the help of Primary, Controls,Stories the overhead is minimal
*/}
import { Meta,Primary,Controls,Stories,Title,Subtitle } from '@storybook/addon-docs/blocks';
import * as CallFooterStories from './CallFooter.stories';
<Meta of={CallFooterStories} />
<Title> Call Footer </Title>
The footer compoentn contains all main interactions needed for a call.
<Subtitle> Mobile layouts </Subtitle>
This component is reactive. To properly check the mobile layout, you will need to click on the stories in the left sidebar to see the
component on a mobile screen.
The story summary here does not render the mobile layouts correctly.
<Primary />
<Controls of={CallFooterStories.Primary} />
<Stories/>

View File

@@ -51,6 +51,7 @@ Please see LICENSE in the repository root for full details.
.settingsLogoContainer {
display: flex;
align-items: center;
gap: var(--cpd-space-4x);
flex-direction: row;
}

View File

@@ -0,0 +1,232 @@
/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import { fn } from "storybook/test";
import { BehaviorSubject } from "rxjs";
import { type ReactNode } from "react";
import { Link } from "@vector-im/compound-web";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { CallFooter, type FooterProps } from "./CallFooter";
import inCallViewStyles from "../room/InCallView.module.css";
import { ReactionsSenderContext } from "../reactions/useReactionsSender";
import { type ReactionOption } from "../reactions";
function CallFooterWrapper(props: FooterProps): ReactNode {
return (
<div className={inCallViewStyles.inRoom}>
<ReactionsSenderContext
value={{
supportsReactions: false,
toggleRaisedHand: async () => Promise.resolve(),
sendReaction: async (reaction: ReactionOption) => Promise.resolve(),
}}
>
<CallFooter {...props} />
</ReactionsSenderContext>
</div>
);
}
const meta = {
component: CallFooterWrapper,
} satisfies Meta<typeof CallFooterWrapper>;
export default meta;
type Story = StoryObj<typeof meta>;
const reactionIdentifier = "@user:example.com:DEVICE";
const reactionData = {
handsRaised$: new BehaviorSubject({}),
reactions$: new BehaviorSubject({}),
};
const fnArgType = {
control: { type: "select" as const },
options: ["MockedCallback", "undefined"],
mapping: { MockedCallback: fn(), undefined: undefined },
};
export const Default: Story = {
args: {
hideLogo: true,
layoutMode: "grid",
setLayoutMode: fn(),
openSettings: fn(),
toggleAudio: fn(),
toggleVideo: fn(),
toggleScreenSharing: fn(),
hangup: fn(),
},
parameters: {
layout: "fullscreen",
},
argTypes: {
layoutMode: { control: "radio", options: ["grid", "spotlight"] },
audioOutputSwitcher: {
control: "select",
options: ["NoOutputCallback", "speaker", "earpiece"],
table: { defaultValue: { summary: "NoOutputCallback" } },
mapping: {
NoOutputCallback: undefined,
// This is inverersed (speaker<->earpice) because the switcher object stores the target output, not the current one.
speaker: { targetOutput: "speaker", switch: fn() },
earpiece: { targetOutput: "earpiece", switch: fn() },
},
},
toggleScreenSharing: fnArgType,
setLayoutMode: fnArgType,
openSettings: fnArgType,
toggleAudio: fnArgType,
toggleVideo: fnArgType,
hangup: fnArgType,
},
};
export const WithLogo: Story = {
...Default,
args: {
...Default.args,
hideLogo: false,
},
};
export const AudioVideoEnabled: Story = {
...Default,
args: {
...Default.args,
audioEnabled: true,
videoEnabled: true,
},
};
export const WithAudioOutput: Story = {
...Default,
args: {
...Default.args,
audioOutputSwitcher: { targetOutput: "speaker", switch: fn() },
},
};
export const WithReactions: Story = {
...Default,
args: {
...Default.args,
reactionIdentifier,
reactionData,
},
};
export const Pip: Story = {
...Default,
args: {
...Default.args,
asPip: true,
},
};
export const NoControlsWithLogo: Story = {
...Default,
args: {
...Default.args,
hideControls: true,
hideLogo: false,
},
};
export const DebugData: Story = {
...Default,
args: {
...Default.args,
debugTileLayout: true,
tileStoreGeneration: 74,
},
};
export const UnavailableMediaDevices: Story = {
...Default,
args: {
...Default.args,
toggleAudio: undefined,
toggleVideo: undefined,
audioOutputSwitcher: undefined,
},
};
export const MobileLayout: Story = {
...Default,
args: {
...Default.args,
hideLogo: true,
audioOutputSwitcher: { targetOutput: "speaker", switch: fn() },
},
globals: {
viewport: { value: "mobile2", isRotated: false },
},
parameters: {
...Default.parameters,
},
};
export const Lobby: Story = {
...Default,
args: {
...Default.args,
hideLogo: true,
openSettings: undefined,
setLayoutMode: undefined,
toggleScreenSharing: undefined,
},
parameters: {
...Default.parameters,
},
};
export const LobbyMobile: Story = {
...Default,
args: {
...Default.args,
hideLogo: true,
setLayoutMode: undefined,
toggleScreenSharing: undefined,
},
globals: {
viewport: { value: "mobile2", isRotated: false },
},
parameters: {
...Default.parameters,
},
};
export const LobbyRecentButton: Story = {
...Default,
args: {
...Default.args,
children: <Link>Back To Recents</Link>,
hideLogo: true,
setLayoutMode: undefined,
toggleScreenSharing: undefined,
},
parameters: {
...Default.parameters,
},
};
export const LobbyRecentButtonMobile: Story = {
...Default,
args: {
...Default.args,
children: <Link>Back To Recents</Link>,
hideLogo: true,
setLayoutMode: undefined,
toggleScreenSharing: undefined,
},
globals: {
viewport: { value: "mobile2", isRotated: false },
},
parameters: {
...Default.parameters,
},
};

View File

@@ -7,6 +7,7 @@ Please see LICENSE in the repository root for full details.
import { type FC, type JSX, type Ref, useMemo } from "react";
import classNames from "classnames";
import { BehaviorSubject } from "rxjs";
import LogoMark from "../icons/LogoMark.svg?react";
import LogoType from "../icons/LogoType.svg?react";
@@ -19,7 +20,7 @@ import {
ReactionToggleButton,
LoudspeakerButton,
} from "../button";
import styles from "./InCallFooter.module.css";
import styles from "./CallFooter.module.css";
import { LayoutToggle } from "../room/LayoutToggle";
import {
type CallViewModel,
@@ -32,44 +33,60 @@ export interface AudioOutputSwitcher {
switch: () => void;
}
export interface InCallFooterProps {
export interface FooterProps {
ref?: Ref<HTMLDivElement>;
/** Children will only be visible if the component is wider than 5*/
children?: JSX.Element | JSX.Element[] | false;
/* This is needed for WindowMode = "flat" */
asOverlay: boolean;
showFooter: boolean;
showControls: boolean;
hideSettingsButton: boolean;
hideLogo: boolean;
hideControls?: boolean;
/** hide the entire footer*/
hidden?: boolean;
/** Pip controls buttonSize and hides: settings button, layout switcher and logo */
asPip: boolean;
gridMode: GridMode;
setGridMode: (mode: GridMode) => void;
openSettings: () => void;
audioEnabled: boolean;
videoEnabled: boolean;
asPip?: boolean;
/** The footer should be used as an overlay.
* (Over the Call Grid) This saves spaces on small screens.*/
asOverlay?: boolean;
layoutMode?: GridMode;
/** Also controls if the layout button is visible */
setLayoutMode?: (mode: GridMode) => void;
audioEnabled?: boolean;
/** Also controls if the audioMute button is disabled */
toggleAudio?: () => void;
videoEnabled?: boolean;
/** Also controls if the videoMute button is disabled */
toggleVideo?: () => void;
sharingScreen: boolean;
sharingScreen?: boolean;
toggleScreenSharing?: () => void;
supportsReactions: boolean;
reactionIdentifier: string;
reactionData: Pick<CallViewModel, "handsRaised$" | "reactions$">;
audioOutputSwitcher: AudioOutputSwitcher | null;
hangup: () => void;
debugTileLayout: boolean;
tileStoreGeneration: number;
/** Also controls if the audio button is visible */
audioOutputSwitcher?: AudioOutputSwitcher;
/** Also controls if the settings button is visible */
openSettings?: () => void;
/** Also controls if the hangup button is visible */
hangup?: () => void;
reactionIdentifier?: string;
reactionData?: Pick<CallViewModel, "handsRaised$" | "reactions$">;
hideLogo?: boolean;
// debug stuff
debugTileLayout?: boolean;
tileStoreGeneration?: number;
}
export const InCallFooter: FC<InCallFooterProps> = ({
export const CallFooter: FC<FooterProps> = ({
ref,
children,
asOverlay,
showFooter,
showControls,
hideSettingsButton,
hidden,
hideControls,
hideLogo,
asPip,
gridMode,
setGridMode,
layoutMode,
setLayoutMode,
openSettings,
audioEnabled,
videoEnabled,
@@ -77,7 +94,6 @@ export const InCallFooter: FC<InCallFooterProps> = ({
toggleVideo,
sharingScreen,
toggleScreenSharing,
supportsReactions,
reactionIdentifier,
reactionData,
audioOutputSwitcher,
@@ -87,8 +103,9 @@ export const InCallFooter: FC<InCallFooterProps> = ({
}) => {
const buttons: JSX.Element[] = [];
const buttonSize = asPip ? "sm" : "lg";
const showSettingsButton = !hideSettingsButton && !asPip && showControls;
const showLayoutSwitcher = !asPip && showControls;
const showSettingsButton =
openSettings !== undefined && !asPip && !hideControls;
const showLayoutSwitcher = !asPip && !hideControls;
const showLogoDebugContainer = !asPip || (!hideLogo && !debugTileLayout);
const showLogo = !hideLogo && !asPip;
if (showSettingsButton) {
@@ -108,39 +125,45 @@ export const InCallFooter: FC<InCallFooterProps> = ({
<MicButton
size={buttonSize}
key="audio"
enabled={audioEnabled}
onClick={toggleAudio ?? undefined}
enabled={audioEnabled ?? false}
onClick={toggleAudio}
disabled={toggleAudio === undefined}
data-testid="incall_mute"
/>,
<VideoButton
size={buttonSize}
key="video"
enabled={videoEnabled}
onClick={toggleVideo ?? undefined}
enabled={videoEnabled ?? false}
onClick={toggleVideo}
disabled={toggleVideo === undefined}
data-testid="incall_videomute"
/>,
);
if (toggleScreenSharing !== null) {
if (toggleScreenSharing !== undefined) {
buttons.push(
<ShareScreenButton
size={buttonSize}
key="share_screen"
className={styles.shareScreen}
enabled={sharingScreen}
enabled={sharingScreen ?? false}
onClick={toggleScreenSharing}
data-testid="incall_screenshare"
/>,
);
}
if (supportsReactions) {
if (reactionIdentifier) {
buttons.push(
<ReactionToggleButton
size={buttonSize}
reactionData={reactionData}
reactionData={
reactionData ??
({
handsRaised$: new BehaviorSubject({}),
reactions$: new BehaviorSubject({}),
} as Pick<CallViewModel, "handsRaised$" | "reactions$">)
}
key="raise_hand"
className={styles.raiseHand}
identifier={reactionIdentifier}
@@ -150,7 +173,7 @@ export const InCallFooter: FC<InCallFooterProps> = ({
// In this PR we just move the button to the bottom bar. We do not yet update its appearance
const audioOutputButton = useMemo(() => {
if (audioOutputSwitcher === null) return null;
if (audioOutputSwitcher === undefined) return null;
return (
<LoudspeakerButton
size={buttonSize}
@@ -166,14 +189,15 @@ export const InCallFooter: FC<InCallFooterProps> = ({
<SettingsButton key="settings" onClick={openSettings} />,
);
buttons.push(
<EndCallButton
size={buttonSize}
key="end_call"
onClick={hangup}
data-testid="incall_leave"
/>,
);
if (hangup)
buttons.push(
<EndCallButton
size={buttonSize}
key="end_call"
onClick={hangup}
data-testid="incall_leave"
/>,
);
const logoDebugContainer = (
<div className={styles.logo}>
@@ -196,7 +220,7 @@ export const InCallFooter: FC<InCallFooterProps> = ({
ref={ref}
className={classNames(styles.footer, {
[styles.overlay]: asOverlay,
[styles.hidden]: !showFooter,
[styles.hidden]: hidden,
})}
>
<div className={styles.settingsLogoContainer}>
@@ -207,16 +231,15 @@ export const InCallFooter: FC<InCallFooterProps> = ({
onClick={openSettings}
/>
)}
{children}
{showLogoDebugContainer && logoDebugContainer}
</div>
{showControls && <div className={styles.buttons}>{buttons}</div>}
{showLayoutSwitcher && (
{!hideControls && <div className={styles.buttons}>{buttons}</div>}
{setLayoutMode && layoutMode && showLayoutSwitcher && (
<LayoutToggle
className={styles.layout}
layout={gridMode}
setLayout={setGridMode}
layout={layoutMode}
setLayout={setLayoutMode}
/>
)}
</div>

View File

@@ -1,132 +0,0 @@
/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import { fn } from "storybook/test";
import { BehaviorSubject } from "rxjs";
import { type ReactNode } from "react";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { InCallFooter, type InCallFooterProps } from "./InCallFooter";
import inCallViewStyles from "../room/InCallView.module.css";
function InCallFooterWrapper(props: InCallFooterProps): ReactNode {
return (
<div className={inCallViewStyles.inRoom}>
<InCallFooter {...props} />
</div>
);
}
const meta = {
component: InCallFooterWrapper,
} satisfies Meta<typeof InCallFooterWrapper>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {
args: {
asOverlay: false,
showFooter: true,
showControls: true,
hideSettingsButton: false,
hideLogo: true,
asPip: false,
gridMode: "grid",
audioEnabled: true,
videoEnabled: true,
sharingScreen: false,
supportsReactions: false,
audioOutputSwitcher: null,
debugTileLayout: false,
tileStoreGeneration: 0,
reactionData: {
handsRaised$: new BehaviorSubject({}),
reactions$: new BehaviorSubject({}),
},
reactionIdentifier: "@user:example.com:DEVICE",
setGridMode: fn(),
openSettings: fn(),
toggleAudio: fn(),
toggleVideo: fn(),
toggleScreenSharing: fn(),
hangup: fn(),
},
parameters: {
layout: "fullscreen",
},
argTypes: {
gridMode: { control: "radio", options: ["grid", "spotlight"] },
audioOutputSwitcher: {
control: "radio",
options: ["noOutputSwitcher", "earpiece", "speaker"],
mapping: {
noOutputSwitcher: null,
// This is inverersed (speaker<->earpice) because the switcher object stores the target output, not the current one.
earpiece: { targetOutput: "speaker", switch: fn() },
speaker: { targetOutput: "earpiece", switch: fn() },
},
},
},
};
export const WithLogo: Story = {
...Default,
args: {
...Default.args,
hideLogo: false,
},
};
export const WithAudioOutput: Story = {
...Default,
args: {
...Default.args,
audioOutputSwitcher: { targetOutput: "speaker", switch: fn() },
},
};
export const Pip: Story = {
...Default,
args: {
...Default.args,
asPip: true,
},
};
export const NoControlsWithLogo: Story = {
...Default,
args: {
...Default.args,
showControls: false,
hideLogo: false,
},
};
export const DebugData: Story = {
...Default,
args: {
...Default.args,
debugTileLayout: true,
tileStoreGeneration: 74,
audioOutputSwitcher: null,
},
};
export const MobileLayout: Story = {
...Default,
args: {
...Default.args,
hideLogo: true,
debugTileLayout: true,
tileStoreGeneration: 74,
audioOutputSwitcher: null,
},
globals: {
viewport: { value: "mobile2", isRotated: false },
},
parameters: {
...Default.parameters,
},
};