mirror of
https://github.com/vector-im/element-call.git
synced 2026-12-04 10:21:10 +08:00
Compare commits
53
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfc3711811 | ||
|
|
e5e61a0769 | ||
|
|
c128c298b3 | ||
|
|
0041a04138 | ||
|
|
1612771502 | ||
|
|
c3ba3d8e16 | ||
|
|
7ff34b9b74 | ||
|
|
6421dc7583 | ||
|
|
e5e7e8d9cf | ||
|
|
f52f60f68f | ||
|
|
975eae92b4 | ||
|
|
a0e9dec1e5 | ||
|
|
5b98e03a67 | ||
|
|
d49f4640f7 | ||
|
|
048df31f06 | ||
|
|
3020e022ea | ||
|
|
bcb2a18abb | ||
|
|
32c6d17b01 | ||
|
|
42bd2fc2d4 | ||
|
|
f73339199c | ||
|
|
9ba6a31996 | ||
|
|
0691a09dc5 | ||
|
|
090ff55b4a | ||
|
|
e4f816b1fc | ||
|
|
068d968aab | ||
|
|
9f67069451 | ||
|
|
90b48be6b4 | ||
|
|
54299d7043 | ||
|
|
8e8886b250 | ||
|
|
965e77be36 | ||
|
|
3818c34c3b | ||
|
|
b7374c4906 | ||
|
|
2100b93f5b | ||
|
|
a62d3f4dd9 | ||
|
|
6b9f8cef45 | ||
|
|
48d2639bb9 | ||
|
|
64994af0c8 | ||
|
|
07b6b6ecd6 | ||
|
|
3550e538ab | ||
|
|
86c2d75db4 | ||
|
|
77020cee2a | ||
|
|
464ffb136e | ||
|
|
e6d0e9ffe9 | ||
|
|
50acca9503 | ||
|
|
1b544b0734 | ||
|
|
88b1a2319e | ||
|
|
96700aea6c | ||
|
|
77c7cdd174 | ||
|
|
bf3f8a4fc4 | ||
|
|
91adb94688 | ||
|
|
0a37f63736 | ||
|
|
5597ef2249 | ||
|
|
f60a63e20c |
@@ -1,22 +1,14 @@
|
||||
name: Prevent blocked
|
||||
on:
|
||||
# zizmor: ignore[dangerous-triggers]
|
||||
# Reason: This workflow does not checkout code or use secrets.
|
||||
# It only reads labels to set a failure status on the PR.
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
types: [opened, labeled, unlabeled, synchronize]
|
||||
|
||||
permissions:
|
||||
pull-requests: read
|
||||
# Required to fail the check on the PR
|
||||
statuses: write
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
prevent-blocked:
|
||||
name: Prevent blocked
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
pull-requests: read
|
||||
steps:
|
||||
- name: Add notice
|
||||
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
name: PR changelog label
|
||||
|
||||
on:
|
||||
# zizmor: ignore[dangerous-triggers]
|
||||
# This is safe because we do not use actions/checkout or execute untrusted code.
|
||||
# Using pull_request_target is necessary to allow status writes for PRs from forks.
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
types: [labeled, unlabeled, opened, synchronize]
|
||||
|
||||
permissions:
|
||||
pull-requests: read
|
||||
statuses: write
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
pr-changelog-label:
|
||||
|
||||
@@ -14,6 +14,8 @@ jobs:
|
||||
# Only run on labelling and skip forks.
|
||||
if: github.event.label.name == 'Claude-Review' && github.event.pull_request.head.repo.full_name == github.repository
|
||||
runs-on: ubuntu-24.04
|
||||
# The turn limit below is generous, so bound the job by time instead.
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
@@ -98,7 +100,8 @@ jobs:
|
||||
|
||||
Use Markdown links for anything that can be navigated to on GitHub such
|
||||
as files, commits, issues, pull requests, workflow runs, etc.
|
||||
# Set a generous turn limit. It's bounded by timeout-minutes above.
|
||||
claude_args: |
|
||||
--model claude-fable-5-1
|
||||
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(git log:*),Bash(git diff:*),Bash(git show:*)"
|
||||
--max-turns 50
|
||||
--max-turns 150
|
||||
|
||||
@@ -22,13 +22,21 @@ const LabelledButton = (): ReactNode => (
|
||||
</TooltipProvider>
|
||||
);
|
||||
|
||||
/** The container of Element Call's own that the button's tooltip floated into. */
|
||||
const labelPortal = (): Element | null => {
|
||||
const button = screen.getByRole("button", { name: "Microphone" });
|
||||
return document
|
||||
.getElementById(button.getAttribute("aria-labelledby")!)!
|
||||
.closest("[data-element-call-portal]");
|
||||
};
|
||||
|
||||
test("floats into the host document with no root", () => {
|
||||
render(
|
||||
<CallPortalRoot root={undefined}>
|
||||
<LabelledButton />
|
||||
</CallPortalRoot>,
|
||||
);
|
||||
expect(screen.getByRole("button", { name: "Microphone" })).toBeTruthy();
|
||||
expect(labelPortal()?.parentElement).toBe(document.body);
|
||||
});
|
||||
|
||||
test("floats into the root it is given", () => {
|
||||
@@ -39,19 +47,61 @@ test("floats into the root it is given", () => {
|
||||
<LabelledButton />
|
||||
</CallPortalRoot>,
|
||||
);
|
||||
const button = screen.getByRole("button", { name: "Microphone" });
|
||||
const label = document.getElementById(
|
||||
button.getAttribute("aria-labelledby")!,
|
||||
);
|
||||
expect(root.contains(label)).toBe(true);
|
||||
// Into a container of Element Call's own, for its stylesheets to find
|
||||
expect(labelPortal()?.parentElement).toBe(root);
|
||||
root.remove();
|
||||
});
|
||||
|
||||
test("waits for a root that is not available yet", () => {
|
||||
render(
|
||||
<CallPortalRoot root={null}>
|
||||
test("moves what floated along when the root changes", () => {
|
||||
const first = document.createElement("div");
|
||||
const second = document.createElement("div");
|
||||
document.body.append(first, second);
|
||||
const { rerender, unmount } = render(
|
||||
<CallPortalRoot root={first}>
|
||||
<LabelledButton />
|
||||
</CallPortalRoot>,
|
||||
);
|
||||
expect(screen.queryByRole("button", { name: "Microphone" })).toBeNull();
|
||||
rerender(
|
||||
<CallPortalRoot root={second}>
|
||||
<LabelledButton />
|
||||
</CallPortalRoot>,
|
||||
);
|
||||
expect(first.querySelector("[data-element-call-portal]")).toBeNull();
|
||||
expect(labelPortal()?.parentElement).toBe(second);
|
||||
unmount();
|
||||
expect(second.querySelector("[data-element-call-portal]")).toBeNull();
|
||||
first.remove();
|
||||
second.remove();
|
||||
});
|
||||
|
||||
test("waits for a root that is not available yet", () => {
|
||||
// Floated content mounted off the page would not show up in the document,
|
||||
// so record every mount of the tooltip's content, wherever it happens
|
||||
const mounted: HTMLElement[] = [];
|
||||
const probe = (
|
||||
<span
|
||||
ref={(node) => {
|
||||
if (node) mounted.push(node);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
const button = (
|
||||
<TooltipProvider>
|
||||
<Tooltip label="Microphone" caption={probe}>
|
||||
<button>🎤</button>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
);
|
||||
const { rerender } = render(
|
||||
<CallPortalRoot root={null}>{button}</CallPortalRoot>,
|
||||
);
|
||||
expect(mounted).toEqual([]);
|
||||
expect(document.querySelector("[data-element-call-portal]")).toBeNull();
|
||||
|
||||
const root = document.createElement("div");
|
||||
document.body.appendChild(root);
|
||||
rerender(<CallPortalRoot root={root}>{button}</CallPortalRoot>);
|
||||
expect(mounted.at(-1)?.isConnected).toBe(true);
|
||||
expect(labelPortal()?.parentElement).toBe(root);
|
||||
root.remove();
|
||||
});
|
||||
|
||||
@@ -5,22 +5,50 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { type FC, type ReactNode } from "react";
|
||||
import { type FC, type ReactNode, useLayoutEffect, useState } from "react";
|
||||
import { PortalRoot } from "@vector-im/compound-web";
|
||||
|
||||
import { PortalElementProvider } from "../src/RootElementContext";
|
||||
|
||||
interface Props {
|
||||
root: HTMLElement | null | undefined;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Where Compound floats the call's menus and tooltips. With no `root` the call
|
||||
* is not wrapped at all and they go into the host document's body; `null` is
|
||||
* Compound's "not available yet", and the floating parts wait for it.
|
||||
* Where Compound floats the call's menus and tooltips: a container of Element
|
||||
* Call's own inside `root`, or inside the host document's body with no `root`.
|
||||
* With `null`, the root is not available yet: Compound gets `null` too and
|
||||
* floats nothing until it is.
|
||||
*
|
||||
* The container is marked `data-element-call-portal` and carries the call's
|
||||
* theme and platform (see `useTheme`), so that Element Call's stylesheets reach
|
||||
* what floats out of its root just as they reach what stays inside.
|
||||
*/
|
||||
export const CallPortalRoot: FC<Props> = ({ root, children }): ReactNode =>
|
||||
root === undefined ? (
|
||||
children
|
||||
) : (
|
||||
<PortalRoot root={root}>{children}</PortalRoot>
|
||||
export const CallPortalRoot: FC<Props> = ({ root, children }): ReactNode => {
|
||||
// One container for the call's lifetime, moved to wherever the root is.
|
||||
// What Compound has floated into it moves along, even into another
|
||||
// document such as a Picture-in-Picture window's; Compound itself leaves
|
||||
// what it floated where it was when its root changes.
|
||||
const [container] = useState(() => {
|
||||
const element = document.createElement("div");
|
||||
element.setAttribute("data-element-call-portal", "");
|
||||
return element;
|
||||
});
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const parent = root === undefined ? document.body : root;
|
||||
// Left out of the document until the root is available
|
||||
if (parent === null) return;
|
||||
parent.append(container);
|
||||
return (): void => container.remove();
|
||||
}, [root, container]);
|
||||
|
||||
return (
|
||||
<PortalRoot root={root === null ? null : container}>
|
||||
<PortalElementProvider value={container}>
|
||||
{children}
|
||||
</PortalElementProvider>
|
||||
</PortalRoot>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -40,8 +40,8 @@ and overlays stay below the modals and toasts, which are portalled into the
|
||||
root and carry no layer of their own.
|
||||
|
||||
What Compound floats — tooltips, menus — is not in here at all: it goes into
|
||||
the host's body, as it would for any other component on the host's page, and is
|
||||
styled and layered by the host's copy of Compound. */
|
||||
Element Call's portal container in the host's `portalRoot` (see
|
||||
CallPortalRoot), where Element Call's scoped stylesheets still reach it. */
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
+6
-2
@@ -156,8 +156,12 @@ export interface ElementCallProps {
|
||||
/**
|
||||
* Where the parts of Element Call that float above it — its menus and
|
||||
* tooltips, which Compound portals out of the call — are rendered. Left out,
|
||||
* they go into the host document's body, as they do for any other component
|
||||
* on the host's page.
|
||||
* the host document's body.
|
||||
*
|
||||
* Element Call does not render them into this element directly: each mounted
|
||||
* call adds its own `div[data-element-call-portal]` here and floats into
|
||||
* that. The container carries the call's theme class, and Element Call's
|
||||
* scoped stylesheets reach it just as they reach the call's root.
|
||||
*
|
||||
* A host that moves Element Call's DOM into another document, such as a
|
||||
* Document Picture-in-Picture window, passes that document's body here so
|
||||
|
||||
@@ -8,10 +8,15 @@ Please see LICENSE in the repository root for full details.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import postcss from "postcss";
|
||||
|
||||
import { ROOT_SELECTOR, scopeStylesToRoot } from "./scopeStylesToRoot";
|
||||
import {
|
||||
PORTAL_SELECTOR,
|
||||
ROOT_SELECTOR,
|
||||
scopeStylesToRoot,
|
||||
} from "./scopeStylesToRoot";
|
||||
|
||||
const inRoot = `:where(${ROOT_SELECTOR}, ${ROOT_SELECTOR} *)`;
|
||||
const inRoot = `:where(${ROOT_SELECTOR}, ${ROOT_SELECTOR} *, ${PORTAL_SELECTOR}, ${PORTAL_SELECTOR} *)`;
|
||||
const isRoot = `:where(${ROOT_SELECTOR})`;
|
||||
const isRootOrPortal = `:where(${ROOT_SELECTOR}, ${PORTAL_SELECTOR})`;
|
||||
|
||||
async function scope(css: string, file = "base.css"): Promise<string> {
|
||||
const result = await postcss([scopeStylesToRoot()]).process(css, {
|
||||
@@ -26,7 +31,10 @@ describe("scopeStylesToRoot", () => {
|
||||
`${isRoot} { line-height: 1.15 }`,
|
||||
);
|
||||
expect(await scope("body { margin: 0 }")).toBe(`${isRoot} { margin: 0 }`);
|
||||
expect(await scope(":root { --a: 1 }")).toBe(`${isRoot} { --a: 1 }`);
|
||||
// The custom properties are needed by what floats out of the root too
|
||||
expect(await scope(":root { --a: 1 }")).toBe(
|
||||
`${isRootOrPortal} { --a: 1 }`,
|
||||
);
|
||||
expect(await scope("body.no-scroll-body { position: fixed }")).toBe(
|
||||
`${isRoot}.no-scroll-body { position: fixed }`,
|
||||
);
|
||||
@@ -66,9 +74,11 @@ describe("scopeStylesToRoot", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("leaves alone what already names the root", async () => {
|
||||
it("leaves alone what already names the root or the portal", async () => {
|
||||
const css = `${ROOT_SELECTOR}[data-platform="ios"] { --a: 1 }`;
|
||||
expect(await scope(css)).toBe(css);
|
||||
const portal = `${PORTAL_SELECTOR}[data-platform="ios"] { --a: 1 }`;
|
||||
expect(await scope(portal)).toBe(portal);
|
||||
});
|
||||
|
||||
it("reaches into layers and media queries", async () => {
|
||||
@@ -99,8 +109,8 @@ describe("scopeStylesToRoot", () => {
|
||||
expect(await scope("pre { font-size: 1px }", file)).toBe(
|
||||
`pre${inRoot} { font-size: 1px }`,
|
||||
);
|
||||
expect(await scope(".modal pre { font-size: 1px }", file)).toBe(
|
||||
`.modal pre${inRoot} { font-size: 1px }`,
|
||||
expect(await scope("[data-x] pre { font-size: 1px }", file)).toBe(
|
||||
`[data-x] pre${inRoot} { font-size: 1px }`,
|
||||
);
|
||||
expect(await scope(".box_abc12 { border: 0 }", file)).toBe(
|
||||
".box_abc12 { border: 0 }",
|
||||
@@ -108,6 +118,14 @@ describe("scopeStylesToRoot", () => {
|
||||
expect(await scope(".a .b_abc12:hover { border: 0 }", file)).toBe(
|
||||
".a .b_abc12:hover { border: 0 }",
|
||||
);
|
||||
// Confined by the class on an ancestor: these must still match in a menu
|
||||
// that Compound portals out of the root
|
||||
expect(await scope(".preview_abc12>video { inset: 0 }", file)).toBe(
|
||||
".preview_abc12>video { inset: 0 }",
|
||||
);
|
||||
expect(
|
||||
await scope(".menu_abc12 [role^=menuitem]:focus { outline: 0 }", file),
|
||||
).toBe(".menu_abc12 [role^=menuitem]:focus { outline: 0 }");
|
||||
});
|
||||
|
||||
it("leaves an excluded stylesheet as it is", async () => {
|
||||
|
||||
@@ -24,16 +24,27 @@ import selectorParser, {
|
||||
*/
|
||||
export const ROOT_SELECTOR = "[data-element-call-root]";
|
||||
|
||||
/**
|
||||
* How the stylesheets find the container that Element Call's menus and
|
||||
* tooltips float into, outside the root. `CallPortalRoot` creates it in the
|
||||
* host's document; it counts as Element Call's own, the way the root does.
|
||||
*/
|
||||
export const PORTAL_SELECTOR = "[data-element-call-portal]";
|
||||
|
||||
// Both are `:where()`, which has no specificity of its own, so the rules keep
|
||||
// exactly the weight they had before being scoped and nothing in Element Call's
|
||||
// cascade changes — only where it applies.
|
||||
//
|
||||
// The root, or anything inside it. Appended to the element a rule is about,
|
||||
// rather than prepended to the whole selector, so that a rule about the root
|
||||
// itself (its theme class, say) still matches.
|
||||
const IN_ROOT = `:where(${ROOT_SELECTOR}, ${ROOT_SELECTOR} *)`;
|
||||
// The root itself, standing in for the document.
|
||||
// The root or the portal container, or anything inside either. Appended to the
|
||||
// element a rule is about, rather than prepended to the whole selector, so that
|
||||
// a rule about the root itself (its theme class, say) still matches.
|
||||
const IN_ROOT = `:where(${ROOT_SELECTOR}, ${ROOT_SELECTOR} *, ${PORTAL_SELECTOR}, ${PORTAL_SELECTOR} *)`;
|
||||
// The root itself, standing in for the document's `html` and `body`. The page's
|
||||
// own furniture (its height, margin and background) is not the portal's.
|
||||
const IS_ROOT = `:where(${ROOT_SELECTOR})`;
|
||||
// The root and the portal container, standing in for `:root`: the custom
|
||||
// properties declared there are needed by whatever floats out of the root too.
|
||||
const IS_ROOT_OR_PORTAL = `:where(${ROOT_SELECTOR}, ${PORTAL_SELECTOR})`;
|
||||
|
||||
/**
|
||||
* Confines a stylesheet to Element Call's root element, for the build of
|
||||
@@ -45,15 +56,22 @@ const IS_ROOT = `:where(${ROOT_SELECTOR})`;
|
||||
* the host's document too. This rewrites every selector so that it matches only
|
||||
* the root or its descendants:
|
||||
*
|
||||
* - `html`, `body` and `:root` become the root element, which is what stands in
|
||||
* for the document inside a host.
|
||||
* - `html` and `body` become the root element, which is what stands in for the
|
||||
* document inside a host. `:root` becomes the root and the portal container
|
||||
* (see `PORTAL_SELECTOR`), so that its custom properties reach both.
|
||||
* - Everything else keeps its selector and gains `:where([data-element-call-root],
|
||||
* [data-element-call-root] *)` on the element it styles.
|
||||
* - Selectors that already name the root are left alone, as are keyframe
|
||||
* selectors and rules nested inside another rule, which are relative to it.
|
||||
* [data-element-call-root] *, [data-element-call-portal],
|
||||
* [data-element-call-portal] *)` on the element it styles, so that it applies
|
||||
* to the menus and tooltips Compound floats out of the root as well.
|
||||
* - Selectors that already name the root or the portal container are left
|
||||
* alone, as are keyframe selectors and rules nested inside another rule,
|
||||
* which are relative to it.
|
||||
*
|
||||
* CSS modules are scoped by their class names already, so only their selectors
|
||||
* that would match by element alone — `pre` rather than `.pre` — are touched.
|
||||
* without a class anywhere — `pre`, but neither `.pre` nor `.modal pre` — are
|
||||
* touched. A module class on an ancestor confines a rule as well as one on the
|
||||
* element it styles, and scoping such a rule would break it wherever Compound
|
||||
* portals that part of Element Call out of the root, as it does menus.
|
||||
*
|
||||
* The root's custom properties are still inherited by everything inside it,
|
||||
* the way they were from `:root`. Compound's own stylesheet — the design
|
||||
@@ -117,7 +135,8 @@ const scopeAll = processor(false);
|
||||
const scopeBare = processor(true);
|
||||
|
||||
function scopeSelector(selector: Selector, isModule: boolean): void {
|
||||
if (String(selector).includes(ROOT_SELECTOR)) return;
|
||||
const text = String(selector);
|
||||
if (text.includes(ROOT_SELECTOR) || text.includes(PORTAL_SELECTOR)) return;
|
||||
|
||||
const compounds = splitCompounds(selector);
|
||||
if (compounds.length === 0) return;
|
||||
@@ -125,12 +144,16 @@ function scopeSelector(selector: Selector, isModule: boolean): void {
|
||||
// Something said of the document is said of the root instead
|
||||
const document = compounds[0].find(isDocumentSelector);
|
||||
if (document !== undefined) {
|
||||
document.replaceWith(pseudo(IS_ROOT));
|
||||
document.replaceWith(
|
||||
pseudo(document.value === ":root" ? IS_ROOT_OR_PORTAL : IS_ROOT),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isModule && compounds.some((c) => c.some((n) => n.type === "class")))
|
||||
return;
|
||||
|
||||
const subject = compounds.at(-1)!;
|
||||
if (isModule && subject.some((node) => node.type === "class")) return;
|
||||
|
||||
// Pseudo-elements have to come last in a compound selector
|
||||
const pseudoElement = subject.find(isPseudoElement);
|
||||
|
||||
+5
-4
@@ -25,10 +25,11 @@ Please see LICENSE in the repository root for full details.
|
||||
//
|
||||
// Compound is not in here. The component uses the host's copy of it (a peer
|
||||
// dependency, left external by the build), and the host loads Compound's
|
||||
// stylesheet, design tokens and fonts along with it: what Compound floats into
|
||||
// the host's body — tooltips, menus — is then styled by the same stylesheet as
|
||||
// everything else there, and Element Call's root takes the tokens and fonts of
|
||||
// the theme class it carries, as any element on the host's page would.
|
||||
// stylesheet, design tokens and fonts along with it. Element Call's root takes
|
||||
// the tokens and fonts of the theme class it carries, as any element on the
|
||||
// host's page would. What Compound floats out of the root — tooltips, menus —
|
||||
// goes into Element Call's portal container (see CallPortalRoot), which carries
|
||||
// the same theme class and is reached by the same scoped stylesheets.
|
||||
//
|
||||
// Where these land relative to the component stylesheets is the bundler's
|
||||
// choice — the standalone app puts them first, this build puts them in the
|
||||
|
||||
@@ -19,10 +19,10 @@ services:
|
||||
- ./backend/playwright_homeserver-othersite.yaml:/data/cfg/homeserver.yaml:Z
|
||||
element-web:
|
||||
# Pin to a SHA so that upstream cannot break our tests. Renovate handles regular updates.
|
||||
image: ghcr.io/element-hq/element-web:develop@sha256:a781033bb89c63e390c37d6904d4bcf34726045cd9217d733d2015db83028ba5
|
||||
image: ghcr.io/element-hq/element-web:develop@sha256:5c9a8288deccb648e0d590776dff747ba674fe45c32cada6f804776800a38d2c
|
||||
element-web-1:
|
||||
# Pin to a SHA so that upstream cannot break our tests. Renovate handles regular updates.
|
||||
image: ghcr.io/element-hq/element-web:develop@sha256:a781033bb89c63e390c37d6904d4bcf34726045cd9217d733d2015db83028ba5
|
||||
image: ghcr.io/element-hq/element-web:develop@sha256:5c9a8288deccb648e0d590776dff747ba674fe45c32cada6f804776800a38d2c
|
||||
volumes:
|
||||
# The other site opens the embedded package under test in place of the
|
||||
# copy its image bundles (the first site opens the dev server's app.
|
||||
|
||||
@@ -4,6 +4,7 @@ This folder contains documentation for setup, usage, and development of Element
|
||||
|
||||
- [Embedded vs standalone mode](./embedded_standalone.md)
|
||||
- [Element Call as a React component (experimental)](../README.md#element-call-as-a-component-experimental)
|
||||
- [Component CSS in a host page](./component_css_host_setup.md)
|
||||
- [Url format and parameters](./url_params.md)
|
||||
- [Global JS controls](./controls.md)
|
||||
- [MatrixRTC modes](./matrix_rtc_modes.md)
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
# Component CSS in a host page
|
||||
|
||||
As a widget or standalone app, Element Call owns its document and loads
|
||||
`src/index.css` unchanged. As a [React component](../README.md#element-call-as-a-component)
|
||||
it shares the host's document and the host's copy of Compound, so its
|
||||
stylesheet must not touch the host, and the host's must not break Element Call.
|
||||
|
||||

|
||||
|
||||
## How it works
|
||||
|
||||
- **Build.** The component ships `src/base.css` (not `index.css`) plus the CSS
|
||||
modules as one `style.css`. `component/build/scopeStylesToRoot.ts` rewrites
|
||||
every selector:
|
||||
- `html` and `body` become `[data-element-call-root]`.
|
||||
- `:root` becomes the root or `[data-element-call-portal]`.
|
||||
- Everything else gets `:where(root, root *, portal, portal *)`.
|
||||
|
||||
`:where()` adds no specificity. In CSS modules only selectors without any
|
||||
class are scoped, since a module class already confines a rule.
|
||||
|
||||
- **Runtime.** `useTheme` sets `data-element-call-root`, `data-platform` and the
|
||||
`cpd-theme-*` class on the root element (`src/RootElementContext.ts`). The
|
||||
theme and platform also go on the portal container.
|
||||
- **Portal container.** `component/CallPortalRoot.tsx` creates
|
||||
`div[data-element-call-portal]` in the host's `portalRoot`. Compound floats
|
||||
tooltips and menus into it, so they get Element Call's styles too. Modals
|
||||
portal into the root itself.
|
||||
- **Containment.** `component/ElementCall.module.css` gives the root
|
||||
`isolation: isolate` and `contain: layout paint`, so `position: fixed` modals
|
||||
centre on the call, not the host window.
|
||||
|
||||
## What the host does
|
||||
|
||||
1. Provides Compound's design tokens, component styles and fonts, since the
|
||||
component does not bundle them.
|
||||
2. Declares Element Call's layers below Compound's, then imports
|
||||
`@element-hq/element-call-component/style.css` **unlayered**. In Element Web:
|
||||
|
||||
```css
|
||||
@layer normalize, compound-legacy, compound-tokens, compound-web, shared-components, app-web;
|
||||
```
|
||||
|
||||
For example, a Compound `<Button>` inside the call, such as the lobby's join
|
||||
button, meets two rules of equal specificity:
|
||||
|
||||
| Rule | From | Layer |
|
||||
| ---------------------------------------------------------- | --------------------- | -------------- |
|
||||
| `[type="button"]:where(…) { -webkit-appearance: button }` | normalize.css, scoped | `normalize` |
|
||||
| `._button_… { appearance: none; font: var(--cpd-font-…) }` | Compound | `compound-web` |
|
||||
|
||||
Without layers they tie, so the one loaded last wins: Element Call's
|
||||
stylesheet, loaded after the host's, and the button looks native (no styling). With
|
||||
them, `compound-web` beats `normalize` whatever the load order, and a rule
|
||||
in one of Element Call's CSS modules, being unlayered, would beat both.
|
||||
|
||||
3. Passes `portalRoot`: the page body, or the Picture-in-Picture window's body
|
||||
while the call is shown there, or `null` while that window is not ready.
|
||||
|
||||
## Rules for Element Call code
|
||||
|
||||
- Style `[data-element-call-root]`, never `body` or `:root` directly; see
|
||||
[code style](./agents/code-style.md#css).
|
||||
- Use container queries (`@container element-call`) and `cqw`/`cqh`, not
|
||||
`@media` or `vw`/`vh`.
|
||||
- Nothing in `base.css` may depend on its order relative to the CSS modules:
|
||||
the app and the component build put it in different places.
|
||||
- `pnpm dev:component` applies the same scoping, so the test host shows what a
|
||||
real host gets.
|
||||
@@ -0,0 +1,172 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1260" height="960" viewBox="0 0 1260 960" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif" font-size="12" fill="#1f2328">
|
||||
<defs>
|
||||
<style>
|
||||
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
|
||||
.b { font-weight: 600; }
|
||||
.tag { fill: #57606a; font-size: 11px; }
|
||||
.ok { fill: #2e7d32; font-weight: 700; font-size: 14px; }
|
||||
.no { fill: #c62828; font-weight: 700; font-size: 14px; }
|
||||
.lead { stroke: #8250df; stroke-width: 1.5; stroke-dasharray: 5 3; fill: none; }
|
||||
.dot { fill: #8250df; }
|
||||
.reach { stroke: #e36209; stroke-width: 1.5; stroke-dasharray: 6 4; fill: none; }
|
||||
</style>
|
||||
<marker id="arrow" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="8" markerHeight="8" orient="auto">
|
||||
<path d="M0 0 L8 4 L0 8 z" fill="#8250df"/>
|
||||
</marker>
|
||||
</defs>
|
||||
|
||||
<rect width="1260" height="960" fill="#ffffff"/>
|
||||
|
||||
<text x="30" y="34" font-size="17" class="b">Element Call as a component inside Element Web: the live DOM</text>
|
||||
|
||||
<!-- ================= DOM tree ================= -->
|
||||
|
||||
<!-- body -->
|
||||
<rect x="30" y="52" width="620" height="680" rx="6" fill="#fafafa" stroke="#8c959f"/>
|
||||
<text x="44" y="74" class="mono b"><body></text>
|
||||
<text x="100" y="74" class="tag">Element Web's document</text>
|
||||
|
||||
<!-- EW app UI -->
|
||||
<rect x="50" y="86" width="580" height="400" rx="5" fill="#eceff1" stroke="#90a4ae"/>
|
||||
<text x="64" y="106" class="b">EW app UI</text>
|
||||
|
||||
<!-- EW h3 -->
|
||||
<rect x="70" y="118" width="260" height="30" rx="4" fill="#ffffff" stroke="#90a4ae"/>
|
||||
<text x="82" y="138" class="mono"><h3></text>
|
||||
<text x="122" y="138">in EW's own UI</text>
|
||||
<text x="310" y="139" class="no">✗</text>
|
||||
|
||||
<!-- call tile -->
|
||||
<rect x="70" y="160" width="540" height="314" rx="5" fill="#f6f8fa" stroke="#b0bec5"/>
|
||||
<text x="84" y="180">call tile → <tspan class="mono">WrappedElementCallComponent</tspan> <tspan class="tag">(EW)</tspan></text>
|
||||
|
||||
<!-- EC root -->
|
||||
<rect x="88" y="192" width="504" height="270" rx="5" fill="#e8f5e9" stroke="#2e7d32" stroke-width="2"/>
|
||||
<text x="102" y="214" class="mono b">div.root</text>
|
||||
<text x="102" y="232" class="mono">[data-element-call-root] [data-platform] [data-background]</text>
|
||||
<text x="102" y="248" class="mono">.cpd-theme-dark</text>
|
||||
<text x="102" y="268" class="tag">class: component/ElementCall.module.css (isolation, contain: layout paint)</text>
|
||||
<text x="102" y="284" class="tag">attributes, theme: src/useTheme.ts, Decoration in component/index.tsx</text>
|
||||
|
||||
<!-- div.content -->
|
||||
<rect x="106" y="296" width="470" height="70" rx="4" fill="#ffffff" stroke="#66bb6a"/>
|
||||
<text x="120" y="316"><tspan class="mono">div.content</tspan> → CallView …</text>
|
||||
<rect x="124" y="326" width="200" height="28" rx="4" fill="#f1f8e9" stroke="#66bb6a"/>
|
||||
<text x="136" y="345" class="mono"><h3></text>
|
||||
<text x="176" y="345">in the call view</text>
|
||||
<text x="306" y="346" class="ok">✓</text>
|
||||
|
||||
<!-- Modal -->
|
||||
<rect x="106" y="378" width="470" height="72" rx="4" fill="#ffffff" stroke="#66bb6a"/>
|
||||
<text x="120" y="398">Modal / Drawer <tspan class="tag">src/Modal.tsx: Drawer.Portal container = root element</tspan></text>
|
||||
<rect x="124" y="410" width="200" height="28" rx="4" fill="#f1f8e9" stroke="#66bb6a"/>
|
||||
<text x="136" y="429" class="mono"><h3></text>
|
||||
<text x="176" y="429">modal title</text>
|
||||
<text x="306" y="430" class="ok">✓</text>
|
||||
|
||||
<!-- EC portal container -->
|
||||
<rect x="50" y="502" width="580" height="160" rx="5" fill="#e3f2fd" stroke="#1565c0" stroke-width="2"/>
|
||||
<text x="64" y="524" class="mono b">div[data-element-call-portal][data-platform].cpd-theme-dark</text>
|
||||
<text x="64" y="544" class="tag">created by component/CallPortalRoot.tsx, appended to EW's portalRoot:</text>
|
||||
<text x="64" y="558" class="tag">this body, or the PiP window's body while the call is in Picture-in-Picture</text>
|
||||
<text x="64" y="574" class="tag">theme + platform: src/useTheme.ts via usePortalElement (src/RootElementContext.ts)</text>
|
||||
|
||||
<rect x="70" y="586" width="540" height="64" rx="4" fill="#ffffff" stroke="#64b5f6"/>
|
||||
<text x="84" y="606">Compound tooltip / menu <tspan class="tag">floated here by Compound's PortalRoot</tspan></text>
|
||||
<rect x="88" y="614" width="220" height="28" rx="4" fill="#e8f4fd" stroke="#64b5f6"/>
|
||||
<text x="100" y="633" class="mono"><h3></text>
|
||||
<text x="140" y="633">in a floated menu</text>
|
||||
<text x="290" y="634" class="ok">✓</text>
|
||||
|
||||
<!-- EW's own floated UI -->
|
||||
<rect x="50" y="676" width="580" height="42" rx="5" fill="#eceff1" stroke="#90a4ae"/>
|
||||
<text x="64" y="702">EW's own Compound tooltips / menus <tspan class="tag">not inside EC's root or portal container</tspan></text>
|
||||
<text x="604" y="703" class="no">✗</text>
|
||||
|
||||
<!-- reach of EC's scoped selectors -->
|
||||
<rect x="82" y="186" width="516" height="282" rx="8" class="reach"/>
|
||||
<rect x="44" y="496" width="592" height="172" rx="8" class="reach"/>
|
||||
|
||||
<!-- ================= h3 notes ================= -->
|
||||
|
||||
<!-- 1 -->
|
||||
<rect x="750" y="52" width="490" height="174" rx="6" fill="#fbf8ff" stroke="#c297ff"/>
|
||||
<circle cx="770" cy="72" r="11" fill="#8250df"/>
|
||||
<text x="770" y="76" fill="#fff" text-anchor="middle" class="b">1</text>
|
||||
<text x="790" y="77" class="b">Source: Element Call's own stylesheets</text>
|
||||
<text x="790" y="100" class="tag"><tspan class="mono">src/base.css</tspan>, in <tspan class="mono">@layer compound-legacy</tspan></text>
|
||||
<text x="790" y="120" class="mono">h3 {</text>
|
||||
<text x="806" y="136" class="mono">font-weight: 600;</text>
|
||||
<text x="806" y="152" class="mono">font-size: var(--font-size-subtitle);</text>
|
||||
<text x="790" y="168" class="mono">}</text>
|
||||
<text x="790" y="192" class="tag"><tspan class="mono">src/room/InviteModal.module.css</tspan>, the modal's copy-link button</text>
|
||||
<text x="790" y="212" class="mono">.button { width: 100%; }</text>
|
||||
|
||||
<!-- 2 -->
|
||||
<rect x="750" y="238" width="490" height="308" rx="6" fill="#fbf8ff" stroke="#c297ff"/>
|
||||
<circle cx="770" cy="258" r="11" fill="#8250df"/>
|
||||
<text x="770" y="262" fill="#fff" text-anchor="middle" class="b">2</text>
|
||||
<text x="790" y="263" class="b">Component build: <tspan class="mono">component/build/scopeStylesToRoot.ts</tspan></text>
|
||||
<text x="790" y="286" class="mono">h3:where(</text>
|
||||
<text x="806" y="302" class="mono">[data-element-call-root],</text>
|
||||
<text x="806" y="318" class="mono">[data-element-call-root] *,</text>
|
||||
<text x="806" y="334" class="mono">[data-element-call-portal],</text>
|
||||
<text x="806" y="350" class="mono">[data-element-call-portal] *</text>
|
||||
<text x="790" y="366" class="mono">)</text>
|
||||
<text x="790" y="388"><tspan class="mono">:where()</tspan> adds no specificity: same weight as a plain <tspan class="mono">h3</tspan>.</text>
|
||||
<text x="790" y="412" class="mono">._button_1ibuh_15 { width: 100%; }</text>
|
||||
<text x="790" y="432">Not rewritten: the module class already confines it.</text>
|
||||
<line x1="764" y1="446" x2="1226" y2="446" stroke="#e1d4f5"/>
|
||||
<text x="764" y="464" class="b">Rules that get <tspan class="mono">:where()</tspan>, all from Element Call's own files:</text>
|
||||
<text x="764" y="482"><tspan class="mono">src/base.css</tspan> <tspan class="tag">root tokens, theme classes, typography</tspan></text>
|
||||
<text x="764" y="499"><tspan class="mono">normalize.css</tspan> <tspan class="tag">imported by base.css into @layer normalize</tspan></text>
|
||||
<text x="764" y="516"><tspan class="mono">*.module.css</tspan> <tspan class="tag">none: every selector there has a class</tspan></text>
|
||||
<text x="764" y="533" class="tag">Compound's and Element Web's stylesheets never go through it.</text>
|
||||
|
||||
<!-- 3 -->
|
||||
<rect x="750" y="558" width="490" height="126" rx="6" fill="#fbf8ff" stroke="#c297ff"/>
|
||||
<circle cx="770" cy="578" r="11" fill="#8250df"/>
|
||||
<text x="770" y="582" fill="#fff" text-anchor="middle" class="b">3</text>
|
||||
<text x="790" y="583" class="b">What it matches</text>
|
||||
<text x="764" y="610"><tspan class="no">✗</tspan> EW's own h3: it is in neither container</text>
|
||||
<text x="764" y="640"><tspan class="ok">✓</tspan> the h3 in the call view and in the modal (inside the root)</text>
|
||||
<text x="764" y="670"><tspan class="ok">✓</tspan> an h3 floated into the portal container</text>
|
||||
|
||||
<!-- 4 -->
|
||||
<rect x="750" y="696" width="490" height="120" rx="6" fill="#fbf8ff" stroke="#c297ff"/>
|
||||
<circle cx="770" cy="716" r="11" fill="#8250df"/>
|
||||
<text x="770" y="720" fill="#fff" text-anchor="middle" class="b">4</text>
|
||||
<text x="790" y="721" class="b">Cascade layer</text>
|
||||
<text x="790" y="742">Stays in <tspan class="mono">compound-legacy</tspan>. EW's <tspan class="mono">res/css/_index.pcss</tspan> orders:</text>
|
||||
<text x="790" y="762" class="mono">normalize, compound-legacy, compound-tokens,</text>
|
||||
<text x="790" y="778" class="mono">compound-web, shared-components, app-web</text>
|
||||
<text x="790" y="802">so Compound's styles win where both set the same property.</text>
|
||||
|
||||
<!-- leaders from the h3 nodes to note 3: one lane each, no crossings -->
|
||||
<!-- EW's own h3 → ✗ row -->
|
||||
<path class="lead" d="M330 133 H725 V610 H750" marker-end="url(#arrow)"/>
|
||||
<!-- call view + modal h3 → first ✓ row -->
|
||||
<path class="lead" d="M324 340 H700 V640 H750" marker-end="url(#arrow)"/>
|
||||
<path class="lead" d="M324 424 H700"/>
|
||||
<!-- floated menu h3 → second ✓ row -->
|
||||
<path class="lead" d="M308 628 H675 V670 H750" marker-end="url(#arrow)"/>
|
||||
<circle class="dot" cx="330" cy="133" r="3"/>
|
||||
<circle class="dot" cx="324" cy="340" r="3"/>
|
||||
<circle class="dot" cx="324" cy="424" r="3"/>
|
||||
<circle class="dot" cx="308" cy="628" r="3"/>
|
||||
<circle class="dot" cx="700" cy="424" r="2.5"/>
|
||||
|
||||
<!-- ================= legend ================= -->
|
||||
<rect x="750" y="830" width="490" height="112" rx="6" fill="#ffffff" stroke="#d0d7de"/>
|
||||
<text x="766" y="852" class="b">Legend</text>
|
||||
<rect x="766" y="864" width="18" height="12" fill="#eceff1" stroke="#90a4ae"/>
|
||||
<text x="792" y="875">Element Web</text>
|
||||
<rect x="896" y="864" width="18" height="12" fill="#e8f5e9" stroke="#2e7d32"/>
|
||||
<text x="922" y="875">EC root (the call)</text>
|
||||
<rect x="1056" y="864" width="18" height="12" fill="#e3f2fd" stroke="#1565c0"/>
|
||||
<text x="1082" y="875">EC portal container</text>
|
||||
<rect x="766" y="890" width="30" height="12" rx="3" class="reach"/>
|
||||
<text x="804" y="901">what EC's scoped selectors can reach</text>
|
||||
<path class="lead" d="M766 922 L796 922" marker-end="url(#arrow)"/>
|
||||
<text x="804" y="926">which h3 the rule in note 3 does or does not match</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 10 KiB |
+25
-25
@@ -46,31 +46,31 @@ possible to support encryption.
|
||||
|
||||
These parameters are relevant to both [widget](./embedded_standalone.md) and [standalone](./embedded_standalone.md) modes:
|
||||
|
||||
| Name | Values | Required for widget | Required for SPA | Description |
|
||||
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `intent` | `start_call`, `join_existing`, `start_call_voice`, `join_existing_voice`, `start_call_dm`, `join_existing_dm`, `start_call_dm_voice`, or `join_existing_dm_voice`. | No, defaults to `start_call` | No, defaults to `start_call` | The intent is a special url parameter that defines the defaults for all the other parameters. In most cases it should be enough to only set the intent to setup element-call. |
|
||||
| `allowIceFallback` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Allows use of fallback STUN servers for ICE if the user's homeserver doesn’t provide any. |
|
||||
| `posthogUserId` | Posthog analytics ID | No | No | Available only with user's consent for sharing telemetry in Element Web. |
|
||||
| `confineToRoom` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Keeps the user confined to the current call/room. |
|
||||
| `displayName` | | No | No | Display name used for auto-registration. |
|
||||
| `enableE2EE` (deprecated) | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Legacy flag to enable end-to-end encryption, not used in the `livekit` branch. |
|
||||
| `fontScale` | A decimal number such as `0.9` | No, defaults to `1.0` | No, defaults to `1.0` | Factor by which to scale the interface's font size. |
|
||||
| `fonts` | | No | No | Defines the font(s) used by the interface. Multiple font parameters can be specified: `?font=font-one&font=font-two...`. |
|
||||
| `header` | `none`, `standard` or `app_bar` | No, defaults to `standard` | No, defaults to `standard` | The style of headers to show. `standard` is the default arrangement, `none` hides the header entirely, and `app_bar` produces a header with a back button like you might see in mobile apps. The callback for the back button is `window.controls.onBackButtonPressed`. |
|
||||
| `hideScreensharing` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Hides the screen-sharing button. |
|
||||
| `homeserver` | | Not applicable | No | Homeserver for registering a new (guest) user, configures non-default guest user server when creating a spa link. |
|
||||
| `lang` | [BCP 47](https://www.rfc-editor.org/info/bcp47) code | No | No | The language the app should use. |
|
||||
| `password` | | No | No | E2EE password when using a shared secret. (For individual sender keys in embedded mode this is not required.) |
|
||||
| `controlledAudioDevices` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Whether the [global JS controls for audio devices](./controls.md#audio-devices) should be enabled, allowing the list of audio devices to be controlled by the app hosting Element Call. |
|
||||
| `roomId` | [Matrix Room ID](https://spec.matrix.org/v1.12/appendices/#room-ids) | Yes | No | Anything about what room we're pointed to should be from useRoomIdentifier which parses the path and resolves alias with respect to the default server name, however roomId is an exception as we need the room ID in embedded widget mode, and not the room alias (or even the via params because we are not trying to join it). This is also not validated, where it is in `useRoomIdentifier()`. |
|
||||
| `showControls` | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Displays controls like mute, screen-share, invite, and hangup buttons during a call. |
|
||||
| `skipLobby` (deprecated: use `intent` instead) | `true` or `false` | No. If `intent` is explicitly `start_call` then defaults to `true`. Otherwise defaults to `false` | No, defaults to `false` | Skips the lobby to join a call directly, can be combined with preload in widget. When `true` the audio and video inputs will be muted by default. (This means there currently is no way to start without muted video if one wants to skip the lobby. Also not in widget mode.) |
|
||||
| `theme` | One of: `light`, `dark`, `light-high-contrast`, `dark-high-contrast` | No, defaults to `dark` | No, defaults to `dark` | UI theme to use. |
|
||||
| `background` | One of: `solid`, `gradient` | No, defaults to `gradient` | No, defaults to `gradient` | Visual style of the page background. |
|
||||
| `viaServers` | Comma separated list of [Matrix Server Names](https://spec.matrix.org/v1.12/appendices/#server-name) | Not applicable | No | Homeserver for joining a room, non-empty value required for rooms not on the user’s default homeserver. |
|
||||
| `sendNotificationType` | `ring` or `notification` | No | No | Will send a "ring" or "notification" `m.rtc.notification` event if the user is the first one in the call. |
|
||||
| `autoLeave` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Whether the app should automatically leave the call when there is no one left in the call. |
|
||||
| `waitForCallPickup` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | When sending a notification, show UI that the app is awaiting an answer, play a dial tone, and (in widget mode) auto-close the widget once the notification expires. |
|
||||
| Name | Values | Required for widget | Required for SPA | Description |
|
||||
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `intent` | `start_call`, `join_existing`, `start_call_voice`, `join_existing_voice`, `start_call_dm`, `join_existing_dm`, `start_call_dm_voice`, `join_existing_dm_voice`, or `video_room`. | No, defaults to `start_call` | No, defaults to `start_call` | The intent is a special url parameter that defines the defaults for all the other parameters. In most cases it should be enough to only set the intent to setup element-call. |
|
||||
| `allowIceFallback` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Allows use of fallback STUN servers for ICE if the user's homeserver doesn’t provide any. |
|
||||
| `posthogUserId` | Posthog analytics ID | No | No | Available only with user's consent for sharing telemetry in Element Web. |
|
||||
| `confineToRoom` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Keeps the user confined to the current call/room. |
|
||||
| `displayName` | | No | No | Display name used for auto-registration. |
|
||||
| `enableE2EE` (deprecated) | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Legacy flag to enable end-to-end encryption, not used in the `livekit` branch. |
|
||||
| `fontScale` | A decimal number such as `0.9` | No, defaults to `1.0` | No, defaults to `1.0` | Factor by which to scale the interface's font size. |
|
||||
| `fonts` | | No | No | Defines the font(s) used by the interface. Multiple font parameters can be specified: `?font=font-one&font=font-two...`. |
|
||||
| `header` | `none`, `standard` or `app_bar` | No, defaults to `standard` | No, defaults to `standard` | The style of headers to show. `standard` is the default arrangement, `none` hides the header entirely, and `app_bar` produces a header with a back button like you might see in mobile apps. The callback for the back button is `window.controls.onBackButtonPressed`. |
|
||||
| `hideScreensharing` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Hides the screen-sharing button. |
|
||||
| `homeserver` | | Not applicable | No | Homeserver for registering a new (guest) user, configures non-default guest user server when creating a spa link. |
|
||||
| `lang` | [BCP 47](https://www.rfc-editor.org/info/bcp47) code | No | No | The language the app should use. |
|
||||
| `password` | | No | No | E2EE password when using a shared secret. (For individual sender keys in embedded mode this is not required.) |
|
||||
| `controlledAudioDevices` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Whether the [global JS controls for audio devices](./controls.md#audio-devices) should be enabled, allowing the list of audio devices to be controlled by the app hosting Element Call. |
|
||||
| `roomId` | [Matrix Room ID](https://spec.matrix.org/v1.12/appendices/#room-ids) | Yes | No | Anything about what room we're pointed to should be from useRoomIdentifier which parses the path and resolves alias with respect to the default server name, however roomId is an exception as we need the room ID in embedded widget mode, and not the room alias (or even the via params because we are not trying to join it). This is also not validated, where it is in `useRoomIdentifier()`. |
|
||||
| `showControls` | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Displays controls like mute, screen-share, invite, and hangup buttons during a call. |
|
||||
| `skipLobby` (deprecated: use `intent` instead) | `true` or `false` | No. If `intent` is explicitly `start_call` then defaults to `true`. Otherwise defaults to `false` | No, defaults to `false` | Skips the lobby to join a call directly, can be combined with preload in widget. When `true` the audio and video inputs will be muted by default. (This means there currently is no way to start without muted video if one wants to skip the lobby. Also not in widget mode.) |
|
||||
| `theme` | One of: `light`, `dark`, `light-high-contrast`, `dark-high-contrast` | No, defaults to `dark` | No, defaults to `dark` | UI theme to use. |
|
||||
| `background` | One of: `solid`, `gradient` | No, defaults to `gradient` | No, defaults to `gradient` | Visual style of the page background. |
|
||||
| `viaServers` | Comma separated list of [Matrix Server Names](https://spec.matrix.org/v1.12/appendices/#server-name) | Not applicable | No | Homeserver for joining a room, non-empty value required for rooms not on the user’s default homeserver. |
|
||||
| `sendNotificationType` | `ring` or `notification` | No | No | Will send a "ring" or "notification" `m.rtc.notification` event if the user is the first one in the call. |
|
||||
| `autoLeave` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Whether the app should automatically leave the call when there is no one left in the call. |
|
||||
| `waitForCallPickup` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | When sending a notification, show UI that the app is awaiting an answer, play a dial tone, and (in widget mode) auto-close the widget once the notification expires. |
|
||||
|
||||
### Widget-only parameters
|
||||
|
||||
|
||||
+2
-2
@@ -4,6 +4,7 @@
|
||||
},
|
||||
"action": {
|
||||
"add_background_image": "Add image",
|
||||
"adjust_view": "Adjust view",
|
||||
"close": "Close",
|
||||
"copy_link": "Copy link",
|
||||
"edit": "Edit",
|
||||
@@ -95,6 +96,7 @@
|
||||
},
|
||||
"mute_all_audio": "Mute all audio (participants, reactions, join sounds)",
|
||||
"show_connection_stats": "Show connection statistics",
|
||||
"throw_error_button": "Throw test error",
|
||||
"url_params": "URL parameters"
|
||||
},
|
||||
"disconnected_banner": "Connectivity to the server has been lost.",
|
||||
@@ -141,7 +143,6 @@
|
||||
},
|
||||
"handset": {
|
||||
"overlay_back_button": "Back to Speaker Mode",
|
||||
"overlay_description": "Only works while using app",
|
||||
"overlay_title": "Handset Mode"
|
||||
},
|
||||
"hangup_button_label": "End call",
|
||||
@@ -158,7 +159,6 @@
|
||||
},
|
||||
"layout_grid_label": "Grid",
|
||||
"layout_spotlight_label": "Spotlight",
|
||||
"layout_switch_label": "Layout",
|
||||
"lobby": {
|
||||
"ask_to_join": "Request to join call",
|
||||
"join_as_guest": "Join as guest",
|
||||
|
||||
+10
-3
@@ -27,10 +27,17 @@ process.env.NODE_EXTRA_CA_CERTS = join(
|
||||
"backend/dev_tls_local-ca.crt",
|
||||
);
|
||||
|
||||
const commonDeviceOptions = {
|
||||
// Disabling motion-based animations helps Playwright position the cursor
|
||||
// correctly when clicking on menus etc.
|
||||
reducedMotion: "reduce" as const,
|
||||
ignoreHTTPSErrors: true,
|
||||
};
|
||||
|
||||
const desktopChrome = {
|
||||
...devices["Desktop Chrome"],
|
||||
...commonDeviceOptions,
|
||||
permissions: ["clipboard-write", "clipboard-read", "microphone", "camera"],
|
||||
ignoreHTTPSErrors: true,
|
||||
launchOptions: {
|
||||
args: [
|
||||
"--use-fake-ui-for-media-stream",
|
||||
@@ -116,7 +123,7 @@ export default defineConfig({
|
||||
testIgnore: ["**/mobile/**", "**/widget/widget-rtc-sdk.spec.ts"],
|
||||
use: {
|
||||
...devices["Desktop Firefox"],
|
||||
ignoreHTTPSErrors: true,
|
||||
...commonDeviceOptions,
|
||||
launchOptions: {
|
||||
firefoxUserPrefs: {
|
||||
"permissions.default.microphone": 1,
|
||||
@@ -140,7 +147,7 @@ export default defineConfig({
|
||||
testMatch: "**/mobile/**",
|
||||
use: {
|
||||
...devices["Pixel 7"],
|
||||
ignoreHTTPSErrors: true,
|
||||
...commonDeviceOptions,
|
||||
permissions: [
|
||||
"clipboard-write",
|
||||
"clipboard-read",
|
||||
|
||||
@@ -62,8 +62,7 @@ test("Sign up a new account, then login, then logout", async ({ browser }) => {
|
||||
test("As a guest, create a call, share link and other join", async ({
|
||||
browser,
|
||||
}) => {
|
||||
// Use reduce motion to disable animations that are making the tests a bit flaky
|
||||
const creatorContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const creatorContext = await browser.newContext();
|
||||
const creatorPage = await creatorContext.newPage();
|
||||
|
||||
await creatorPage.goto("/");
|
||||
@@ -76,7 +75,8 @@ test("As a guest, create a call, share link and other join", async ({
|
||||
// join
|
||||
await creatorPage.getByTestId("lobby_joinCall").click();
|
||||
// Spotlight mode to make checking the test visually clearer
|
||||
await creatorPage.getByRole("radio", { name: "Spotlight" }).check();
|
||||
await creatorPage.getByRole("button", { name: "Adjust view" }).click();
|
||||
await creatorPage.getByRole("menuitemradio", { name: "Spotlight" }).click();
|
||||
|
||||
// Get the invite link
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(creatorPage);
|
||||
@@ -84,9 +84,7 @@ test("As a guest, create a call, share link and other join", async ({
|
||||
// ========
|
||||
// ACT: The other user use the invite link to join the call as a guest
|
||||
// ========
|
||||
const guestInviteeContext = await browser.newContext({
|
||||
reducedMotion: "reduce",
|
||||
});
|
||||
const guestInviteeContext = await browser.newContext();
|
||||
const guestPage = await guestInviteeContext.newPage();
|
||||
await SpaHelpers.joinCallFromInviteLink(guestPage, inviteLink);
|
||||
|
||||
|
||||
@@ -50,13 +50,13 @@ test.describe("the quick audio menu", () => {
|
||||
}) => {
|
||||
// Two browsers and a real call.
|
||||
test.slow();
|
||||
const hostContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const hostContext = await browser.newContext();
|
||||
const host = await hostContext.newPage();
|
||||
await installFakeDevices(host, { microphones: 3, speakers: 3 });
|
||||
await joinACall(host, "Host", "Device switch");
|
||||
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(host);
|
||||
const guestContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const guestContext = await browser.newContext();
|
||||
const guest = await guestContext.newPage();
|
||||
await SpaHelpers.joinCallFromInviteLink(guest, inviteLink, "Guest");
|
||||
await SpaHelpers.expectVideoTilesCount(guest, 2);
|
||||
@@ -85,13 +85,13 @@ test.describe("the quick audio menu", () => {
|
||||
}) => {
|
||||
// Two browsers and a real call.
|
||||
test.slow();
|
||||
const hostContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const hostContext = await browser.newContext();
|
||||
const host = await hostContext.newPage();
|
||||
await installFakeDevices(host);
|
||||
await joinACall(host, "Muted host", "Muted meter");
|
||||
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(host);
|
||||
const guestContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const guestContext = await browser.newContext();
|
||||
const guest = await guestContext.newPage();
|
||||
await SpaHelpers.joinCallFromInviteLink(guest, inviteLink, "Listener");
|
||||
await SpaHelpers.expectVideoTilesCount(guest, 2);
|
||||
|
||||
@@ -422,6 +422,9 @@ test.describe("a background of one's own", () => {
|
||||
).toBeVisible();
|
||||
await expect(mine).toHaveCount(0);
|
||||
await page.keyboard.press("Escape");
|
||||
// While it animates out the menu still counts as visible: addImage would
|
||||
// then leave it closed instead of opening it again
|
||||
await expect(page.getByRole("menu")).toBeHidden();
|
||||
|
||||
await addImage(page, red);
|
||||
await expect(mine).toBeVisible();
|
||||
|
||||
@@ -107,8 +107,6 @@ test("tracks the focus source of its own call, not the page", async ({
|
||||
await openDeviceList(page, pane);
|
||||
const menu = page.getByRole("menu");
|
||||
|
||||
// Asserted on the attribute: the component build's scoped stylesheet doesn't
|
||||
// reach the portalled menu, so its ring can't be read here.
|
||||
await expect(menu).toHaveAttribute("data-focus-source", "pointer");
|
||||
|
||||
// A key pressed in the other call says nothing about this menu.
|
||||
@@ -121,6 +119,12 @@ test("tracks the focus source of its own call, not the page", async ({
|
||||
|
||||
await page.keyboard.press("ArrowDown");
|
||||
await expect(menu).toHaveAttribute("data-focus-source", "keyboard");
|
||||
|
||||
// Asserted on the painted ring too: the rule is confined by the menu's module
|
||||
// class on an ancestor, and has to reach the menu where Compound portals it,
|
||||
// outside the call's root.
|
||||
const focused = menu.locator('[role^="menuitem"]:focus');
|
||||
await expect(focused).toHaveCSS("outline-style", "solid");
|
||||
});
|
||||
|
||||
/** Opens a component's microphone menu and returns its device list. */
|
||||
|
||||
@@ -30,15 +30,6 @@ import { SpaHelpers } from "../spa-helpers.ts";
|
||||
// are sized for that, so the tests have to be too
|
||||
test.describe.configure({ timeout: 180_000 });
|
||||
|
||||
/** The settings button, whichever of the two the footer is currently showing. */
|
||||
function settingsButton(pane: Locator): Locator {
|
||||
return pane
|
||||
.getByTestId("settings-bottom-left")
|
||||
.or(pane.getByTestId("settings-bottom-center"))
|
||||
.filter({ visible: true })
|
||||
.first();
|
||||
}
|
||||
|
||||
test("holds a call between two components on one page", async ({ page }) => {
|
||||
const { username, roomId } = await createUserAndRoom("twocomponents");
|
||||
const panes = await startHarness(page, username, roomId);
|
||||
@@ -81,7 +72,7 @@ test("keeps its modals inside the container it was given", async ({ page }) => {
|
||||
// rather than the container until it was made a containing block. The
|
||||
// settings dialog spilled over the host's interface; the reaction picker sat
|
||||
// at 82vh, which put it below the container entirely and so out of sight.
|
||||
await settingsButton(pane).click();
|
||||
await pane.getByTestId("settings-bottom").click();
|
||||
await expectWithin(pane.getByRole("dialog"), container);
|
||||
await pane.getByTestId("modal_close").click();
|
||||
|
||||
@@ -112,7 +103,8 @@ test("keeps the call inside the container, wherever the host put it", async ({
|
||||
// the container below a header of its own, so a grid offset measured from
|
||||
// the top of the page instead of from the root would land the tile on top of
|
||||
// the footer and out of the bottom of the container.
|
||||
await pane.getByRole("radio", { name: "Spotlight" }).check();
|
||||
await pane.getByRole("button", { name: "Adjust view" }).click();
|
||||
await page.getByRole("menuitemradio", { name: "Spotlight" }).click();
|
||||
const tile = pane.getByTestId("videoTile").first();
|
||||
await expect(tile).toBeVisible({ timeout: 60_000 });
|
||||
await expectWithin(tile, container);
|
||||
@@ -149,6 +141,51 @@ test("leaves the host's own page unstyled", async ({ page }) => {
|
||||
await expect(root).toHaveCSS("font-feature-settings", /"kern"/);
|
||||
});
|
||||
|
||||
test("styles its tooltips as its own, outside the container", async ({
|
||||
page,
|
||||
}) => {
|
||||
const { username, roomId } = await createUserAndRoom("portalstyles");
|
||||
const panes = await startHarness(page, username, roomId);
|
||||
const pane = panes.first();
|
||||
await expect(pane.getByTestId("lobby_joinCall")).toBeVisible({
|
||||
timeout: 60_000,
|
||||
});
|
||||
|
||||
const button = pane.getByTestId("settings-bottom");
|
||||
await button.hover();
|
||||
const labelId = await button.getAttribute("aria-labelledby");
|
||||
const label = page.locator(`[id="${labelId}"]`);
|
||||
await expect(label).toHaveText("Settings");
|
||||
|
||||
// The harness passes no portal root, so the tooltip floats out of the call's
|
||||
// root into a container of Element Call's own in the page's body. Each of the
|
||||
// harness's two calls has one, so pick the one holding this tooltip.
|
||||
const portal = page
|
||||
.locator("body > [data-element-call-portal]")
|
||||
.filter({ has: page.locator(`[id="${labelId}"]`) });
|
||||
await expect(portal).toHaveCount(1);
|
||||
await expect(portal.locator(`[id="${labelId}"]`)).toBeVisible();
|
||||
await expect(pane.locator(`[id="${labelId}"]`)).toHaveCount(0);
|
||||
|
||||
// That container carries the call's theme and platform, as the root does
|
||||
await expect(portal).toHaveClass(/\bcpd-theme-dark\b/);
|
||||
await expect(portal).toHaveAttribute("data-platform", "desktop");
|
||||
|
||||
// And Element Call's stylesheets reach it: `--font-scale` is declared on
|
||||
// `:root` in base.css, which the component build turns into the root and
|
||||
// this container. The host's page itself still has none of it.
|
||||
expect(
|
||||
await label.evaluate((element) =>
|
||||
getComputedStyle(element).getPropertyValue("--font-scale").trim(),
|
||||
),
|
||||
).toBe("1");
|
||||
expect(
|
||||
await page.evaluate(() =>
|
||||
getComputedStyle(document.body).getPropertyValue("--font-scale"),
|
||||
),
|
||||
).toBe("");
|
||||
});
|
||||
|
||||
test("tells its host what it is doing", async ({ page }) => {
|
||||
const { username, roomId } = await createUserAndRoom("hostbridge");
|
||||
const panes = await startHarness(page, username, roomId);
|
||||
|
||||
@@ -30,7 +30,7 @@ export const mobileTest = test.extend<MobileCreateFixtures>({
|
||||
async function createCallAndInvite(
|
||||
browser: Browser,
|
||||
): Promise<{ page: Page; inviteLink: string }> {
|
||||
const creatorContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const creatorContext = await browser.newContext();
|
||||
const creatorPage = await creatorContext.newPage();
|
||||
|
||||
await creatorPage.goto("/");
|
||||
|
||||
@@ -58,9 +58,7 @@ mobileTest(
|
||||
// ========
|
||||
// ACT: The other user use the invite link to join the call as a guest
|
||||
// ========
|
||||
const guestInviteeContext = await browser.newContext({
|
||||
reducedMotion: "reduce",
|
||||
});
|
||||
const guestInviteeContext = await browser.newContext();
|
||||
const guestPage = await guestInviteeContext.newPage();
|
||||
await guestPage.goto(inviteLink + "&controlledAudioDevices=true");
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@ test("When creator left, avoid reconnect to the same SFU", async ({
|
||||
browserName,
|
||||
}) => {
|
||||
test.skip(browserName === "firefox", "Browser independent");
|
||||
// Use reduce motion to disable animations that are making the tests a bit flaky
|
||||
const creatorContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const creatorContext = await browser.newContext();
|
||||
const creatorPage = await creatorContext.newPage();
|
||||
|
||||
await creatorPage.goto("/");
|
||||
@@ -31,7 +30,8 @@ test("When creator left, avoid reconnect to the same SFU", async ({
|
||||
// join
|
||||
await creatorPage.getByTestId("lobby_joinCall").click();
|
||||
// Spotlight mode to make checking the test visually clearer
|
||||
await creatorPage.getByRole("radio", { name: "Spotlight" }).check();
|
||||
await creatorPage.getByRole("button", { name: "Adjust view" }).click();
|
||||
await creatorPage.getByRole("menuitemradio", { name: "Spotlight" }).click();
|
||||
|
||||
// Get the invite link
|
||||
await creatorPage.getByRole("button", { name: "Invite" }).click();
|
||||
@@ -51,9 +51,7 @@ test("When creator left, avoid reconnect to the same SFU", async ({
|
||||
// ========
|
||||
// ACT: The other user use the invite link to join the call as a guest
|
||||
// ========
|
||||
const guestB = await browser.newContext({
|
||||
reducedMotion: "reduce",
|
||||
});
|
||||
const guestB = await browser.newContext();
|
||||
const guestBPage = await guestB.newPage();
|
||||
|
||||
await guestBPage.goto(inviteLink);
|
||||
@@ -61,14 +59,13 @@ test("When creator left, avoid reconnect to the same SFU", async ({
|
||||
await expect(guestBPage.getByTestId("joincall_joincall")).toBeVisible();
|
||||
await guestBPage.getByTestId("joincall_joincall").click();
|
||||
await guestBPage.getByTestId("lobby_joinCall").click();
|
||||
await guestBPage.getByRole("radio", { name: "Spotlight" }).check();
|
||||
await guestBPage.getByRole("button", { name: "Adjust view" }).click();
|
||||
await guestBPage.getByRole("menuitemradio", { name: "Spotlight" }).click();
|
||||
|
||||
// ========
|
||||
// ACT: add a third user to the call to reproduce the bug
|
||||
// ========
|
||||
const guestC = await browser.newContext({
|
||||
reducedMotion: "reduce",
|
||||
});
|
||||
const guestC = await browser.newContext();
|
||||
const guestCPage = await guestC.newPage();
|
||||
// Track WebSocket connections
|
||||
let wsConnectionCount = 0;
|
||||
@@ -85,7 +82,8 @@ test("When creator left, avoid reconnect to the same SFU", async ({
|
||||
await expect(guestCPage.getByTestId("joincall_joincall")).toBeVisible();
|
||||
await guestCPage.getByTestId("joincall_joincall").click();
|
||||
await guestCPage.getByTestId("lobby_joinCall").click();
|
||||
await guestCPage.getByRole("radio", { name: "Spotlight" }).check();
|
||||
await guestCPage.getByRole("button", { name: "Adjust view" }).click();
|
||||
await guestCPage.getByRole("menuitemradio", { name: "Spotlight" }).click();
|
||||
|
||||
await guestCPage.waitForTimeout(1000);
|
||||
if (wsConnectionCount === 2) {
|
||||
|
||||
@@ -46,9 +46,7 @@ async function setupTwoUserSpaCall(
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(page);
|
||||
|
||||
// Other
|
||||
const guestInviteeContext = await browser.newContext({
|
||||
reducedMotion: "reduce",
|
||||
});
|
||||
const guestInviteeContext = await browser.newContext();
|
||||
const guestPage = await guestInviteeContext.newPage();
|
||||
|
||||
await guestPage.goto("/");
|
||||
|
||||
@@ -88,7 +88,8 @@ async function joinCallFromInviteLink(
|
||||
}
|
||||
|
||||
await page.getByTestId("lobby_joinCall").click();
|
||||
await page.getByRole("radio", { name: "Spotlight" }).check();
|
||||
await page.getByRole("button", { name: "Adjust view" }).click();
|
||||
await page.getByRole("menuitemradio", { name: "Spotlight" }).click();
|
||||
}
|
||||
|
||||
async function setRtcModeFromSettings(
|
||||
|
||||
@@ -105,7 +105,7 @@ for (const { hostShape, guestShape, mode, hostFlows, guestFlows } of cases) {
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(page);
|
||||
|
||||
// The guest joins.
|
||||
const guestContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const guestContext = await browser.newContext();
|
||||
const guestPage = await guestContext.newPage();
|
||||
await advertiseTransport(guestPage, shapes[guestShape]);
|
||||
const guestRequests = recordAuthRequests(guestPage);
|
||||
@@ -178,7 +178,7 @@ test("Falls back to the JWT service for a url+legacy transport when the homeserv
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(page);
|
||||
|
||||
// The guest joins, and its C-S requests fail as well.
|
||||
const guestContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const guestContext = await browser.newContext();
|
||||
const guestPage = await guestContext.newPage();
|
||||
await advertiseTransport(guestPage, shapes["url+legacy"]);
|
||||
await rejectCsApiTokens(guestPage);
|
||||
@@ -224,13 +224,13 @@ test("Group call with all possible transport shapes at once", async ({
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(page);
|
||||
|
||||
// The guest with a legacy transport joins.
|
||||
const bobContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const bobContext = await browser.newContext();
|
||||
const bobPage = await bobContext.newPage();
|
||||
await advertiseTransport(bobPage, shapes.legacy);
|
||||
await SpaHelpers.joinCallFromInviteLink(bobPage, inviteLink, "Bob");
|
||||
|
||||
// The guest with a url+legacy transport joins.
|
||||
const carolContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const carolContext = await browser.newContext();
|
||||
const carolPage = await carolContext.newPage();
|
||||
await advertiseTransport(carolPage, shapes["url+legacy"]);
|
||||
await SpaHelpers.joinCallFromInviteLink(carolPage, inviteLink, "Carol");
|
||||
@@ -265,7 +265,7 @@ for (const { shape, via } of delegationCases) {
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(page);
|
||||
|
||||
// The guest joins.
|
||||
const guestContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const guestContext = await browser.newContext();
|
||||
const guestPage = await guestContext.newPage();
|
||||
await advertiseTransport(guestPage, shapes[shape]);
|
||||
const delayedLeave = recordDelayedLeave(guestPage);
|
||||
@@ -327,7 +327,7 @@ test("Subscribers get tokens for a remote homeserver's SFU over federation", asy
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(page);
|
||||
|
||||
// The guest lives on the default homeserver and joins over federation.
|
||||
const guestContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const guestContext = await browser.newContext();
|
||||
const guestPage = await guestContext.newPage();
|
||||
await advertiseTransport(guestPage, shapes.url);
|
||||
const guestRequests = recordAuthRequests(guestPage);
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
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 { expect, test } from "@playwright/test";
|
||||
|
||||
import { widgetTest } from "../fixtures/widget-user.ts";
|
||||
import { TestHelpers } from "./test-helpers.ts";
|
||||
|
||||
widgetTest.skip(
|
||||
({ browserName }) => browserName === "firefox",
|
||||
"Widget specs only run on Chromium, see simple-create.spec.ts",
|
||||
);
|
||||
|
||||
widgetTest(
|
||||
"Switching rooms away from a crashed call dismisses it for good",
|
||||
async ({ asWidget }) => {
|
||||
test.slow();
|
||||
const { brooks } = asWidget;
|
||||
const page = brooks.page;
|
||||
const call = page.locator('iframe[title="Element Call"]');
|
||||
const callFrame = call.contentFrame();
|
||||
|
||||
// Somewhere to switch to once the call has crashed
|
||||
await TestHelpers.createRoom("Other Room", page);
|
||||
await TestHelpers.switchToRoomNamed(page, "Welcome Room");
|
||||
|
||||
await TestHelpers.startCallInCurrentRoom(page);
|
||||
// A dev server compiles the widget on first load
|
||||
await expect(callFrame.getByTestId("lobby_joinCall")).toBeVisible({
|
||||
timeout: 30000,
|
||||
});
|
||||
await TestHelpers.joinCallFromLobby(page);
|
||||
await expect(
|
||||
callFrame.getByRole("button", { name: "End call" }),
|
||||
).toBeVisible();
|
||||
|
||||
// Crash the call from its developer settings
|
||||
await callFrame.getByRole("button", { name: "Settings" }).click();
|
||||
await callFrame.getByRole("tab", { name: "Preferences" }).click();
|
||||
await callFrame.getByText("Developer mode", { exact: true }).check();
|
||||
await callFrame.getByRole("tab", { name: "Developer" }).click();
|
||||
await callFrame.getByRole("button", { name: "Throw test error" }).click();
|
||||
await expect(callFrame.getByText("Something went wrong")).toBeVisible();
|
||||
|
||||
// Showing the call collapses the room list
|
||||
await TestHelpers.expandRoomList(page);
|
||||
await TestHelpers.switchToRoomNamed(page, "Other Room");
|
||||
await expect(
|
||||
page.getByRole("main").getByRole("heading", { name: "Other Room" }),
|
||||
).toBeVisible();
|
||||
|
||||
// The crashed call is gone and stays gone: no restart, no reconnect
|
||||
await expect(call).toHaveCount(0);
|
||||
await page.waitForTimeout(5000);
|
||||
await expect(call).toHaveCount(0);
|
||||
await expect(
|
||||
page.getByRole("main").getByRole("heading", { name: "Other Room" }),
|
||||
).toBeVisible();
|
||||
},
|
||||
);
|
||||
@@ -86,7 +86,11 @@ widgetTest("Sharing screen in group call", async ({ addUser, browserName }) => {
|
||||
const frame = alice.page
|
||||
.locator('iframe[title="Element Call"]')
|
||||
.contentFrame();
|
||||
await expect(frame.getByRole("radio", { name: "Grid" })).toBeChecked();
|
||||
await frame.getByRole("button", { name: "Adjust view" }).click();
|
||||
await expect(
|
||||
frame.getByRole("menuitemradio", { name: "Grid" }),
|
||||
).toBeChecked();
|
||||
await frame.getByRole("menu").press("Escape");
|
||||
}
|
||||
|
||||
// Others should have switched to spotlight
|
||||
@@ -95,7 +99,11 @@ widgetTest("Sharing screen in group call", async ({ addUser, browserName }) => {
|
||||
.locator('iframe[title="Element Call"]')
|
||||
.contentFrame();
|
||||
|
||||
await expect(frame.getByRole("radio", { name: "Spotlight" })).toBeChecked();
|
||||
await frame.getByRole("button", { name: "Adjust view" }).click();
|
||||
await expect(
|
||||
frame.getByRole("menuitemradio", { name: "Spotlight" }),
|
||||
).toBeChecked();
|
||||
await frame.getByRole("menu").press("Escape");
|
||||
}
|
||||
// await alice.page.pause();
|
||||
// await bob.page.pause();
|
||||
|
||||
@@ -123,9 +123,7 @@ export class TestHelpers {
|
||||
);
|
||||
|
||||
// STEP 2: Open browser and login
|
||||
const userContext = await browser.newContext({
|
||||
reducedMotion: "reduce",
|
||||
});
|
||||
const userContext = await browser.newContext();
|
||||
const page = await userContext.newPage();
|
||||
await page.goto(host);
|
||||
|
||||
|
||||
Generated
+7
-21
@@ -134,7 +134,7 @@ importers:
|
||||
version: 11.3.1(@types/react@19.3.3)(react@19.3.1)
|
||||
'@vector-im/compound-web':
|
||||
specifier: ^10.5.0
|
||||
version: 10.6.0(@fontsource/inconsolata@5.3.0)(@fontsource/inter@5.3.0)(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(@vector-im/compound-design-tokens@11.3.1(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)
|
||||
version: 10.7.0(@fontsource/inconsolata@5.3.0)(@fontsource/inter@5.3.0)(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(@vector-im/compound-design-tokens@11.3.1(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)
|
||||
'@vitejs/plugin-react':
|
||||
specifier: ^6.0.2
|
||||
version: 6.3.0(@rolldown/plugin-babel@0.3.1(@babel/core@7.29.16(supports-color@7.2.0))(@babel/runtime@8.0.8)(rolldown@1.2.19)(vite@8.3.8(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.108.2)(terser@5.46.1)(yaml@2.9.1)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.8(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.108.2)(terser@5.46.1)(yaml@2.9.1))
|
||||
@@ -3273,8 +3273,8 @@ packages:
|
||||
react:
|
||||
optional: true
|
||||
|
||||
'@vector-im/compound-web@10.6.0':
|
||||
resolution: {integrity: sha512-MNALzWkuo17qo6FWMvtqvkdGizkPzTeYp8J3yF+ZF2020jBxEVo9WLWNNBNig3K1inBMbSKQwxgOgu9Db6u6Sg==}
|
||||
'@vector-im/compound-web@10.7.0':
|
||||
resolution: {integrity: sha512-WP6/TcfxD2tuD8bw9FVAWIIGUti1WHKdojnble3MJmkC6fGRuEtl0p4Cz8ctmHY4XNkNKGGp5Nlax/Csry86IQ==}
|
||||
peerDependencies:
|
||||
'@fontsource/inconsolata': ^5
|
||||
'@fontsource/inter': ^5
|
||||
@@ -5997,18 +5997,6 @@ packages:
|
||||
resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
ws@8.23.0:
|
||||
resolution: {integrity: sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
peerDependencies:
|
||||
bufferutil: ^4.0.1
|
||||
utf-8-validate: '>=5.0.2'
|
||||
peerDependenciesMeta:
|
||||
bufferutil:
|
||||
optional: true
|
||||
utf-8-validate:
|
||||
optional: true
|
||||
|
||||
ws@8.23.1:
|
||||
resolution: {integrity: sha512-1rzWDSN0NOi3tpwgHsQExjWRoKUGtjCkJ2gZRaaRtzhYLboMytOI9pj9PU7yCgY37auqdd4OyLofZDbkeuZmPA==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
@@ -6205,7 +6193,7 @@ snapshots:
|
||||
|
||||
'@babel/helper-module-imports@7.29.7(supports-color@7.2.0)':
|
||||
dependencies:
|
||||
'@babel/traverse': 7.29.15(supports-color@7.2.0)
|
||||
'@babel/traverse': 7.29.16(supports-color@7.2.0)
|
||||
'@babel/types': 7.29.15
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -8635,7 +8623,7 @@ snapshots:
|
||||
'@types/react': 19.3.3
|
||||
react: 19.3.1
|
||||
|
||||
'@vector-im/compound-web@10.6.0(@fontsource/inconsolata@5.3.0)(@fontsource/inter@5.3.0)(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(@vector-im/compound-design-tokens@11.3.1(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)':
|
||||
'@vector-im/compound-web@10.7.0(@fontsource/inconsolata@5.3.0)(@fontsource/inter@5.3.0)(@types/react-dom@19.3.0(@types/react@19.3.3))(@types/react@19.3.3)(@vector-im/compound-design-tokens@11.3.1(@types/react@19.3.3)(react@19.3.1))(react-dom@19.3.1(react@19.3.1))(react@19.3.1)':
|
||||
dependencies:
|
||||
'@floating-ui/react': 0.27.20(react-dom@19.3.1(react@19.3.1))(react@19.3.1)
|
||||
'@floating-ui/react-dom': 2.1.9(react-dom@19.3.1(react@19.3.1))(react@19.3.1)
|
||||
@@ -8688,7 +8676,7 @@ snapshots:
|
||||
sirv: 3.0.2
|
||||
tinyrainbow: 3.2.0
|
||||
vitest: 4.1.12(@opentelemetry/api@1.9.1)(@types/node@26.6.11)(@vitest/browser-playwright@4.1.12)(@vitest/coverage-v8@4.1.12)(@vitest/ui@4.1.12)(jsdom@31.0.1)(vite@8.3.8(@types/node@26.6.11)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.108.2)(terser@5.46.1)(yaml@2.9.1))
|
||||
ws: 8.23.0
|
||||
ws: 8.23.1
|
||||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
- msw
|
||||
@@ -9423,7 +9411,7 @@ snapshots:
|
||||
'@humanfs/node': 0.16.8
|
||||
'@humanwhocodes/module-importer': 1.0.1
|
||||
'@humanwhocodes/retry': 0.4.3
|
||||
'@types/estree': 1.0.10
|
||||
'@types/estree': 1.0.11
|
||||
ajv: 6.15.0
|
||||
chalk: 4.1.2
|
||||
cross-spawn: 7.0.6
|
||||
@@ -11640,8 +11628,6 @@ snapshots:
|
||||
string-width: 4.2.3
|
||||
strip-ansi: 6.0.1
|
||||
|
||||
ws@8.23.0: {}
|
||||
|
||||
ws@8.23.1: {}
|
||||
|
||||
wsl-utils@0.1.0:
|
||||
|
||||
+4
-2
@@ -28,12 +28,14 @@
|
||||
{
|
||||
"groupName": "matrix-widget-api",
|
||||
"matchDepNames": ["matrix-widget-api"],
|
||||
"extends": ["schedule:weekly"]
|
||||
"extends": ["schedule:weekly"],
|
||||
"minimumReleaseAge": null
|
||||
},
|
||||
{
|
||||
"groupName": "Compound",
|
||||
"matchPackageNames": ["@vector-im/compound-{/,}**"],
|
||||
"extends": ["schedule:weekly"]
|
||||
"extends": ["schedule:weekly"],
|
||||
"minimumReleaseAge": null
|
||||
},
|
||||
{
|
||||
"groupName": "LiveKit client",
|
||||
|
||||
@@ -41,3 +41,19 @@ export const RootElementProvider = RootElementContext.Provider;
|
||||
*/
|
||||
export const useRootElement = (): HTMLElement =>
|
||||
use(RootElementContext) ?? document.body;
|
||||
|
||||
const PortalElementContext = createContext<HTMLElement | null>(null);
|
||||
|
||||
/**
|
||||
* Supplies the container that Compound floats Element Call's menus and tooltips
|
||||
* into when that is outside the root: the component build's `CallPortalRoot`.
|
||||
*/
|
||||
export const PortalElementProvider = PortalElementContext.Provider;
|
||||
|
||||
/**
|
||||
* The container that Element Call's menus and tooltips float into, if it is
|
||||
* not the root's own document body. It gets the root's theme and platform, so
|
||||
* that what floats out of the root looks as it would inside.
|
||||
*/
|
||||
export const usePortalElement = (): HTMLElement | null =>
|
||||
use(PortalElementContext);
|
||||
|
||||
@@ -41,6 +41,7 @@ export enum UserIntent {
|
||||
StartNewCallDMVoice = "start_call_dm_voice",
|
||||
JoinExistingCallDM = "join_existing_dm",
|
||||
JoinExistingCallDMVoice = "join_existing_dm_voice",
|
||||
VideoRoom = "video_room",
|
||||
Unknown = "unknown",
|
||||
}
|
||||
|
||||
@@ -143,6 +144,18 @@ export interface UrlConfiguration {
|
||||
* Defaults to true.
|
||||
*/
|
||||
noiseSuppression?: boolean;
|
||||
/**
|
||||
* Whether the user may start with the microphone on, whether or not the
|
||||
* lobby is shown. Set by the intent, not a URL parameter.
|
||||
* Defaults to true.
|
||||
*/
|
||||
initialAudioEnabled?: boolean;
|
||||
/**
|
||||
* Whether the user may start with the camera on, whether or not the lobby is
|
||||
* shown. Set by the intent, not a URL parameter.
|
||||
* Defaults to true.
|
||||
*/
|
||||
initialVideoEnabled?: boolean;
|
||||
|
||||
callIntent?: RTCCallIntent;
|
||||
}
|
||||
@@ -222,6 +235,14 @@ export function configurationForIntent(intent: UserIntent): UrlConfiguration {
|
||||
preset.autoLeaveWhenOthersLeft = true;
|
||||
preset.callIntent = preset.callIntent ?? RTC_CALL_INTENT_VIDEO;
|
||||
break;
|
||||
case UserIntent.VideoRoom:
|
||||
preset.skipLobby = false;
|
||||
preset.returnToLobby = true;
|
||||
preset.callIntent = RTC_CALL_INTENT_VIDEO;
|
||||
// Opening the room should not turn on the user's microphone or camera.
|
||||
preset.initialAudioEnabled = false;
|
||||
preset.initialVideoEnabled = false;
|
||||
break;
|
||||
// Non widget usecase defaults
|
||||
default:
|
||||
preset = {
|
||||
|
||||
@@ -318,6 +318,20 @@ describe("UrlParams", () => {
|
||||
).toMatchObject(joinExistingCallDefaults("desktop"));
|
||||
});
|
||||
|
||||
it("accepts video_room", () => {
|
||||
expect(
|
||||
computeUrlParams(
|
||||
"?intent=video_room&widgetId=1234&parentUrl=parent.org",
|
||||
),
|
||||
).toMatchObject({
|
||||
...joinExistingCallDefaults("desktop"),
|
||||
returnToLobby: true,
|
||||
callIntent: RTC_CALL_INTENT_VIDEO,
|
||||
initialAudioEnabled: false,
|
||||
initialVideoEnabled: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("accepts start_call_voice", () => {
|
||||
expect(
|
||||
computeUrlParams(
|
||||
@@ -408,6 +422,19 @@ describe("UrlParams", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe.each(["initialAudioEnabled", "initialVideoEnabled"] as const)(
|
||||
"%s",
|
||||
(name) => {
|
||||
it("is not read from the URL", () => {
|
||||
expect(
|
||||
computeUrlParams(
|
||||
`?${name}=false&intent=join_existing&widgetId=1234&parentUrl=parent.org`,
|
||||
)[name],
|
||||
).toBeUndefined();
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
describe("noiseSuppression", () => {
|
||||
it("defaults to true", () => {
|
||||
expect(computeUrlParams().noiseSuppression).toBe(true);
|
||||
|
||||
+7
-3
@@ -123,12 +123,16 @@ before using one further down the tree. */
|
||||
|
||||
/* On Android and iOS, prefer native system fonts. The global.css file of
|
||||
Compound Web is where these variables ultimately get consumed to set the page's
|
||||
font-family. */
|
||||
[data-element-call-root][data-platform="android"] {
|
||||
font-family. Also on the container that menus and tooltips float into, which
|
||||
is outside the root in the component build. */
|
||||
:is(
|
||||
[data-element-call-root],
|
||||
[data-element-call-portal]
|
||||
)[data-platform="android"] {
|
||||
--cpd-font-family-sans: "Roboto", "Noto", "Inter", sans-serif;
|
||||
}
|
||||
|
||||
[data-element-call-root][data-platform="ios"] {
|
||||
:is([data-element-call-root], [data-element-call-portal])[data-platform="ios"] {
|
||||
--cpd-font-family-sans:
|
||||
-apple-system, BlinkMacSystemFont, "Inter", sans-serif;
|
||||
}
|
||||
|
||||
+31
-32
@@ -25,11 +25,14 @@ import {
|
||||
OverflowVerticalIcon,
|
||||
VolumeOnSolidIcon,
|
||||
VolumeOffSolidIcon,
|
||||
SettingsSolidIcon,
|
||||
GridIcon,
|
||||
SpotlightViewIcon,
|
||||
} from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||
|
||||
import styles from "./Button.module.css";
|
||||
import callFooterStyles from "../components/CallFooter.module.css";
|
||||
import { platform } from "../Platform";
|
||||
import { type LayoutMode } from "../state/LayoutSwitchViewModel";
|
||||
|
||||
interface MicButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
enabled: boolean;
|
||||
@@ -149,6 +152,7 @@ interface LoudspeakerButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
size?: "md" | "lg";
|
||||
loudspeakerModeEnabled: boolean;
|
||||
}
|
||||
|
||||
export const LoudspeakerButton: FC<LoudspeakerButtonProps> = ({
|
||||
loudspeakerModeEnabled,
|
||||
...props
|
||||
@@ -171,36 +175,37 @@ export const LoudspeakerButton: FC<LoudspeakerButtonProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
function classNamesForScreenWidth(
|
||||
className?: string,
|
||||
forScreenWidth?: "wide" | "narrow",
|
||||
): string {
|
||||
return classNames(className, {
|
||||
[callFooterStyles.settingsOnlyShowWide]: forScreenWidth === "wide",
|
||||
[callFooterStyles.settingsOnlyShowNarrow]: forScreenWidth === "narrow",
|
||||
});
|
||||
interface LayoutSwitchButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
layout: LayoutMode;
|
||||
}
|
||||
|
||||
interface SettingsIconButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
/** If this buttons should be setup to be used in the app bar */
|
||||
showForScreenWidth?: "wide" | "narrow";
|
||||
kind?: "secondary" | "primary";
|
||||
}
|
||||
export const SettingsIconButton: FC<SettingsIconButtonProps> = ({
|
||||
showForScreenWidth,
|
||||
className,
|
||||
export const LayoutSwitchButton: FC<LayoutSwitchButtonProps> = ({
|
||||
layout,
|
||||
...props
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const Icon =
|
||||
platform === "android" ? OverflowVerticalIcon : OverflowHorizontalIcon;
|
||||
return (
|
||||
<Tooltip label={t("action.adjust_view")}>
|
||||
<CpdButton
|
||||
iconOnly
|
||||
Icon={layout === "grid" ? GridIcon : SpotlightViewIcon}
|
||||
kind="secondary"
|
||||
{...props}
|
||||
/>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
interface SettingsIconButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
kind?: "secondary" | "primary";
|
||||
}
|
||||
|
||||
export const SettingsIconButton: FC<SettingsIconButtonProps> = (props) => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Tooltip label={t("common.settings")}>
|
||||
<IconButton
|
||||
className={classNamesForScreenWidth(className, showForScreenWidth)}
|
||||
{...props}
|
||||
>
|
||||
<Icon aria-hidden />
|
||||
<IconButton {...props}>
|
||||
<SettingsSolidIcon aria-hidden />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
);
|
||||
@@ -208,19 +213,13 @@ export const SettingsIconButton: FC<SettingsIconButtonProps> = ({
|
||||
|
||||
interface SettingsButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
size?: "md" | "lg";
|
||||
/** If this buttons should be setup to be used in the app bar */
|
||||
showForScreenWidth?: "wide" | "narrow";
|
||||
}
|
||||
export const SettingsButton: FC<SettingsButtonProps> = ({
|
||||
showForScreenWidth,
|
||||
className,
|
||||
...props
|
||||
}) => {
|
||||
|
||||
export const SettingsButton: FC<SettingsButtonProps> = (props) => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Tooltip label={t("common.settings")}>
|
||||
<CpdButton
|
||||
className={classNamesForScreenWidth(className, showForScreenWidth)}
|
||||
iconOnly
|
||||
Icon={
|
||||
platform === "android" ? OverflowVerticalIcon : OverflowHorizontalIcon
|
||||
|
||||
@@ -24,7 +24,7 @@ import * as CallFooterStories from "./CallFooter.stories";
|
||||
|
||||
<Title> Call Footer </Title>
|
||||
|
||||
The footer compoentn contains all main interactions needed for a call.
|
||||
The footer component contains all main interactions needed for a call.
|
||||
|
||||
<Subtitle> Mobile layouts </Subtitle>
|
||||
|
||||
|
||||
@@ -9,9 +9,10 @@ Please see LICENSE in the repository root for full details.
|
||||
position: sticky;
|
||||
inset-block-end: 0;
|
||||
z-index: var(--call-view-header-footer-layer);
|
||||
pointer-events: none;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
grid-template-areas: ". buttons layout";
|
||||
grid-template-areas: ". buttons .";
|
||||
align-items: center;
|
||||
gap: var(--cpd-space-3x);
|
||||
/* Ensure that footer lies within the safe area */
|
||||
@@ -19,6 +20,10 @@ Please see LICENSE in the repository root for full details.
|
||||
padding-right: calc(env(safe-area-inset-right) + var(--cpd-space-6x));
|
||||
padding-block: var(--cpd-space-10x)
|
||||
calc(env(safe-area-inset-bottom) + var(--cpd-space-10x));
|
||||
|
||||
> * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.footer.hidden {
|
||||
@@ -26,21 +31,57 @@ Please see LICENSE in the repository root for full details.
|
||||
}
|
||||
|
||||
.footer.overlay {
|
||||
transition: opacity 0.18s;
|
||||
opacity: 0;
|
||||
|
||||
> .buttons {
|
||||
transition: transform 0.18s;
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
transform: translateY(var(--slide-distance));
|
||||
}
|
||||
}
|
||||
|
||||
> * {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes enable-pointer-events {
|
||||
0% {
|
||||
pointer-events: none;
|
||||
}
|
||||
100% {
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.footer.overlay:not(.hidden) {
|
||||
/* Note that the footer is still position: sticky in this case so that certain
|
||||
tiles can move up out of the way of the footer when visible. */
|
||||
opacity: 1;
|
||||
transition: opacity 0.15s;
|
||||
|
||||
> .buttons {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
> * {
|
||||
/* Enable pointer events after a short timeout, so that tapping to reveal the
|
||||
footer won't immediately cause any of the buttons to be pressed. */
|
||||
animation: enable-pointer-events 1ms;
|
||||
}
|
||||
}
|
||||
|
||||
.footer.overlay.hidden {
|
||||
display: grid;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
/* Switch to position: absolute so the footer takes up no space in the layout
|
||||
when hidden. */
|
||||
position: absolute;
|
||||
inset-block-end: 0;
|
||||
inset-inline: 0;
|
||||
|
||||
> * {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Keep the footer while it is in use: focus inside it, or a menu opened from
|
||||
@@ -48,10 +89,17 @@ Please see LICENSE in the repository root for full details.
|
||||
.footer.overlay:has(:focus-visible),
|
||||
.footer.overlay:has([aria-expanded="true"]) {
|
||||
opacity: 1;
|
||||
pointer-events: initial;
|
||||
|
||||
> .buttons {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
> * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.settingsLogoContainer {
|
||||
.logoContainer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--cpd-space-4x);
|
||||
@@ -70,13 +118,45 @@ Please see LICENSE in the repository root for full details.
|
||||
.buttons {
|
||||
grid-area: buttons;
|
||||
justify-self: center;
|
||||
background: var(--cpd-color-bg-canvas-default);
|
||||
border-radius: var(--cpd-radius-pill-effect);
|
||||
box-shadow: var(--big-drop-shadow);
|
||||
display: flex;
|
||||
gap: var(--cpd-space-3x);
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.layout {
|
||||
grid-area: layout;
|
||||
justify-self: end;
|
||||
:global(.cpd-theme-light),
|
||||
:global(.cpd-theme-light-hc) {
|
||||
.buttons {
|
||||
background: var(--cpd-color-bg-canvas-default);
|
||||
}
|
||||
}
|
||||
|
||||
/* Dark theme uses a different background color, since the drop shadow doesn't
|
||||
provide enough contrast */
|
||||
:global(.cpd-theme-dark),
|
||||
:global(.cpd-theme-dark-hc) {
|
||||
.buttons {
|
||||
background: var(--cpd-color-bg-subtle-primary);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.buttons {
|
||||
background: var(--cpd-color-bg-subtle-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.footer[data-button-size="md"] > .buttons {
|
||||
padding: var(--cpd-space-3x);
|
||||
gap: var(--cpd-space-2x);
|
||||
--slide-distance: var(--cpd-space-2x);
|
||||
}
|
||||
|
||||
.footer[data-button-size="lg"] > .buttons {
|
||||
padding: var(--cpd-space-4x);
|
||||
gap: var(--cpd-space-4x);
|
||||
--slide-distance: var(--cpd-space-4x);
|
||||
}
|
||||
|
||||
/*First hide the logo*/
|
||||
@@ -86,30 +166,16 @@ Please see LICENSE in the repository root for full details.
|
||||
}
|
||||
}
|
||||
|
||||
.settingsOnlyShowNarrow {
|
||||
display: none;
|
||||
}
|
||||
.settingsOnlyShowWide {
|
||||
display: inherit;
|
||||
}
|
||||
|
||||
/*
|
||||
With the logo hidden >500px is enough space to show overflow, buttons, layout.
|
||||
Once we exceed 500 we hide everything except the buttons.
|
||||
With the logo hidden >500px is enough space to show logo and buttons.
|
||||
Once we exceed 500 we hide the logo.
|
||||
*/
|
||||
@container element-call (max-width: 500px) {
|
||||
.footer {
|
||||
grid-template-areas: "buttons buttons buttons";
|
||||
}
|
||||
|
||||
.settingsOnlyShowNarrow {
|
||||
display: inherit;
|
||||
}
|
||||
.settingsOnlyShowWide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.settingsLogoContainer {
|
||||
.logoContainer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -156,9 +222,3 @@ Once we exceed 500 we hide everything except the buttons.
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@container element-call (min-width: 800px) {
|
||||
.buttons {
|
||||
gap: var(--cpd-space-4x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { expect, fn, userEvent, within } from "storybook/test";
|
||||
import { expect, fn, userEvent, waitFor, within } from "storybook/test";
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
import { type JSX, type ReactNode } from "react";
|
||||
import { Link } from "@vector-im/compound-web";
|
||||
@@ -172,7 +172,7 @@ export const Default: Story = {
|
||||
openSettings: fn(),
|
||||
toggleScreenSharing: fn(),
|
||||
hangup: fn(),
|
||||
buttonSize: "lg",
|
||||
buttonSize: "md",
|
||||
showFooter: true,
|
||||
hideControls: false,
|
||||
asOverlay: false,
|
||||
@@ -202,8 +202,11 @@ export const StaysWhileAMenuIsOpen: Story = {
|
||||
const footer = canvasElement.querySelector<HTMLElement>(
|
||||
'[data-testid="footer-container"]',
|
||||
)!;
|
||||
await userEvent.click(
|
||||
within(canvasElement).getByRole("button", { name: "Microphone" }),
|
||||
// Open microphone menu once footer becomes interactive
|
||||
await waitFor(async () =>
|
||||
userEvent.click(
|
||||
within(canvasElement).getByRole("button", { name: "Microphone" }),
|
||||
),
|
||||
);
|
||||
await expect(document.body.querySelector('[role="menu"]')).not.toBeNull();
|
||||
|
||||
@@ -232,8 +235,9 @@ export const SpotlightMode: Story = {
|
||||
layout: "spotlight",
|
||||
},
|
||||
play: async ({ args, canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.click(canvas.getByRole("radio", { name: "Grid" }));
|
||||
const canvas = within(canvasElement.parentElement!);
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Adjust view" }));
|
||||
await userEvent.click(canvas.getByRole("menuitemradio", { name: "Grid" }));
|
||||
await expect(args.setLayout).toHaveBeenCalledWith("grid");
|
||||
await userEvent.click(canvas.getByRole("switch", { name: "Share screen" }));
|
||||
await expect(args.toggleScreenSharing).toHaveBeenCalled();
|
||||
@@ -269,12 +273,11 @@ export const Pip: Story = {
|
||||
...Default,
|
||||
args: {
|
||||
...Default.args,
|
||||
buttonSize: "md",
|
||||
layout: null,
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
await expect(
|
||||
within(canvasElement).queryByRole("radio", { name: "Spotlight" }),
|
||||
within(canvasElement).queryByRole("button", { name: "Adjust view" }),
|
||||
).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
@@ -301,6 +304,7 @@ export const MobileLayout: Story = {
|
||||
args: {
|
||||
...Default.args,
|
||||
showLogo: false,
|
||||
buttonSize: "lg",
|
||||
|
||||
audioOutputSwitcher: { targetOutput: "speaker", switch: fn() },
|
||||
},
|
||||
@@ -332,6 +336,7 @@ export const LobbyRecentButtonMobile: Story = {
|
||||
...Default.args,
|
||||
children: <Link>Back To Recents</Link>,
|
||||
showLogo: false,
|
||||
buttonSize: "lg",
|
||||
layout: null,
|
||||
toggleScreenSharing: undefined,
|
||||
},
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
SettingsButton,
|
||||
ReactionToggleButton,
|
||||
LoudspeakerButton,
|
||||
SettingsIconButton,
|
||||
type ReactionData,
|
||||
} from "../button";
|
||||
import styles from "./CallFooter.module.css";
|
||||
@@ -37,13 +36,13 @@ export interface AudioOutputSwitcher {
|
||||
* The Snapshot combines all fields required to populate the view.
|
||||
*
|
||||
* It is a combination of Actions and State.
|
||||
* All Actions and State will be wrappen in behaviors.
|
||||
* This has the advantage, that actions can mutate.
|
||||
* (example: a device gets disconnected, the swicht action is not possible anymore, the actions becomes undefined)
|
||||
* With it being reactive we can use the existance of the action to update the rendering without
|
||||
* All Actions and State will be wrapped in behaviors.
|
||||
* This has the advantage that actions can mutate.
|
||||
* (example: a device gets disconnected, the switch action is not possible anymore, the action becomes undefined)
|
||||
* With it being reactive we can use the existence of the action to update the rendering without
|
||||
* requiring additional state.
|
||||
*
|
||||
* Comment: It might not make sense to seperate the two interfaces. Hence the seperation
|
||||
* Comment: It might not make sense to separate the two interfaces. Hence the separation
|
||||
* just happens on the syntax level with the `type = ... & ...` notation.
|
||||
*/
|
||||
export type FooterSnapshot = FooterActions & FooterState;
|
||||
@@ -120,20 +119,6 @@ export const CallFooter: FC<FooterProps> = ({
|
||||
|
||||
const buttons: JSX.Element[] = [];
|
||||
|
||||
if (openSettings !== undefined) {
|
||||
// Add the settings button to the center group so it's visible on small
|
||||
// screens. On larger screens the SettingsIconButton with
|
||||
// showForScreenWidth="wide" in the settingsLogoContainer is used instead.
|
||||
buttons.push(
|
||||
<SettingsButton
|
||||
key="settings"
|
||||
showForScreenWidth="narrow"
|
||||
onClick={openSettings}
|
||||
data-testid="settings-bottom-center"
|
||||
/>,
|
||||
);
|
||||
}
|
||||
|
||||
buttons.push(
|
||||
<MediaMenuButton
|
||||
key="audio"
|
||||
@@ -189,6 +174,28 @@ export const CallFooter: FC<FooterProps> = ({
|
||||
|
||||
if (audioOutputButton) buttons.push(audioOutputButton);
|
||||
|
||||
if (layoutSwitchVm !== null) {
|
||||
buttons.push(
|
||||
<LayoutSwitch
|
||||
key="layout"
|
||||
vm={layoutSwitchVm}
|
||||
className={styles.layout}
|
||||
size={buttonSize}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
|
||||
if (openSettings !== undefined) {
|
||||
buttons.push(
|
||||
<SettingsButton
|
||||
size={buttonSize}
|
||||
key="settings"
|
||||
onClick={openSettings}
|
||||
data-testid="settings-bottom"
|
||||
/>,
|
||||
);
|
||||
}
|
||||
|
||||
if (hangup)
|
||||
buttons.push(
|
||||
<EndCallButton
|
||||
@@ -221,28 +228,17 @@ export const CallFooter: FC<FooterProps> = ({
|
||||
<div
|
||||
ref={ref}
|
||||
data-testid="footer-container"
|
||||
data-button-size={buttonSize}
|
||||
className={classNames(className, styles.footer, {
|
||||
[styles.overlay]: asOverlay,
|
||||
[styles.hidden]: !showFooter,
|
||||
})}
|
||||
>
|
||||
<div className={styles.settingsLogoContainer}>
|
||||
{openSettings !== undefined && (
|
||||
<SettingsIconButton
|
||||
key="settings"
|
||||
kind="secondary"
|
||||
showForScreenWidth="wide"
|
||||
onClick={openSettings}
|
||||
data-testid="settings-bottom-left"
|
||||
/>
|
||||
)}
|
||||
<div className={styles.logoContainer}>
|
||||
{children}
|
||||
{(showLogo || debugTileLayout) && logoDebugContainer}
|
||||
</div>
|
||||
{!hideControls && <div className={styles.buttons}>{buttons}</div>}
|
||||
{!hideControls && layoutSwitchVm && (
|
||||
<LayoutSwitch vm={layoutSwitchVm} className={styles.layout} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -80,9 +80,7 @@ export function createCallFooterViewModel(
|
||||
hideControls$: constant(!showControls),
|
||||
showModals$: callModel.showModals$,
|
||||
asOverlay$: callModel.edgeToEdge$,
|
||||
buttonSize$: scope.behavior(
|
||||
isPip$.pipe(map<boolean, "md" | "lg">((pip) => (pip ? "md" : "lg"))),
|
||||
),
|
||||
buttonSize$: constant(platform === "desktop" ? "md" : "lg"),
|
||||
|
||||
openSettings$: scope.behavior(
|
||||
combineLatest([
|
||||
@@ -162,7 +160,7 @@ export function createLobbyFooterViewModel(
|
||||
hideControls: false,
|
||||
asOverlay: false,
|
||||
showModals: true,
|
||||
buttonSize: "lg",
|
||||
buttonSize: platform === "desktop" ? "md" : "lg",
|
||||
openSettings,
|
||||
hangup,
|
||||
debugTileLayout: false,
|
||||
|
||||
@@ -26,7 +26,7 @@ function MediaMenuButtonStoryWrapper({
|
||||
...snapshot
|
||||
}: MediaMenuSnapshot & { kind: "audio" | "video" }): ReactNode {
|
||||
const vm = useStaticViewModel(snapshot);
|
||||
return <MediaMenuButton kind={kind} vm={vm} size="lg" />;
|
||||
return <MediaMenuButton kind={kind} vm={vm} size="md" />;
|
||||
}
|
||||
|
||||
const meta = {
|
||||
|
||||
@@ -88,6 +88,7 @@ export const MediaMenuButton: FC<Props> = ({ vm, kind, size }) => {
|
||||
|
||||
return kind === "audio" ? (
|
||||
<MediaMuteAndSwitchButton
|
||||
size={size}
|
||||
iconsAndLabels="audio"
|
||||
enabled={enabled}
|
||||
busy={busy}
|
||||
@@ -102,6 +103,7 @@ export const MediaMenuButton: FC<Props> = ({ vm, kind, size }) => {
|
||||
/>
|
||||
) : (
|
||||
<MediaMuteAndSwitchButton
|
||||
size={size}
|
||||
iconsAndLabels="video"
|
||||
enabled={enabled}
|
||||
busy={busy}
|
||||
|
||||
@@ -16,12 +16,24 @@ Please see LICENSE in the repository root for full details.
|
||||
.containerOpen {
|
||||
background-color: var(--cpd-color-bg-action-primary-pressed);
|
||||
}
|
||||
.chevronIconOpen > svg {
|
||||
color: var(--cpd-color-icon-on-solid-primary);
|
||||
}
|
||||
.menuButton {
|
||||
width: 40px;
|
||||
background-color: transparent !important;
|
||||
|
||||
&[data-size="md"] {
|
||||
width: var(--cpd-space-8x);
|
||||
}
|
||||
&[data-size="lg"] {
|
||||
width: var(--cpd-space-10x);
|
||||
}
|
||||
|
||||
> svg {
|
||||
color: var(--cpd-color-icon-secondary);
|
||||
/* Nudge the icon toward the toggle button to perceptually center it */
|
||||
margin-inline-start: calc(-1 * var(--cpd-space-1x));
|
||||
}
|
||||
}
|
||||
.menuButton.chevronIconOpen > svg {
|
||||
color: var(--cpd-color-icon-on-solid-primary);
|
||||
}
|
||||
.itemIcon {
|
||||
color: var(--cpd-color-text-secondary);
|
||||
|
||||
@@ -57,6 +57,7 @@ export interface MenuOptions {
|
||||
}
|
||||
|
||||
export interface MediaMuteAndSwitchButtonProps {
|
||||
size?: "md" | "lg";
|
||||
/** If the Mute button is enabled */
|
||||
enabled?: boolean;
|
||||
/** Callback if the mute button is clicked */
|
||||
@@ -120,6 +121,7 @@ const MENU_MARGIN = 16;
|
||||
const PREVIEW_GAP = 12;
|
||||
|
||||
export const MediaMuteAndSwitchButton: FC<MediaMuteAndSwitchButtonProps> = ({
|
||||
size,
|
||||
enabled,
|
||||
busy,
|
||||
onMuteClick,
|
||||
@@ -276,6 +278,7 @@ export const MediaMuteAndSwitchButton: FC<MediaMuteAndSwitchButtonProps> = ({
|
||||
const MuteButton = audioMeter ? MicButton : VideoButton;
|
||||
const button = (
|
||||
<MuteButton
|
||||
size={size}
|
||||
enabled={enabled ?? false}
|
||||
busy={isBusy}
|
||||
onClick={(e) => {
|
||||
@@ -447,7 +450,7 @@ export const MediaMuteAndSwitchButton: FC<MediaMuteAndSwitchButtonProps> = ({
|
||||
})}
|
||||
Icon={menuOpen ? ChevronUpIcon : ChevronDownIcon}
|
||||
kind={"tertiary"}
|
||||
size="lg"
|
||||
size={size}
|
||||
aria-label={optionsButtonLabel}
|
||||
/>
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { type FC } from "react";
|
||||
import { BigIcon, Button, Heading, Text } from "@vector-im/compound-web";
|
||||
import { BigIcon, Button, Heading } from "@vector-im/compound-web";
|
||||
import { VoiceCallIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
@@ -27,7 +27,6 @@ export const EarpieceOverlay: FC<Props> = ({ show, onBackToVideoPressed }) => {
|
||||
<Heading as="h2" weight="semibold" size="md">
|
||||
{t("handset.overlay_title")}
|
||||
</Heading>
|
||||
<Text>{t("handset.overlay_description")}</Text>
|
||||
<Button
|
||||
kind="primary"
|
||||
size="md"
|
||||
|
||||
@@ -14,23 +14,6 @@ Please see LICENSE in the repository root for full details.
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* Normally the footer uses a transparent background to allow our expressive
|
||||
page gradients to shine through. However, we sometimes need to visually separate
|
||||
it from the content underneath. If the call layout is overflowing, or if the
|
||||
spotlight tile is maximised and displaying video, apply a gradient background. */
|
||||
.overflowing > .footer,
|
||||
.fixedGrid:has(
|
||||
> .tile[data-maximised="true"]
|
||||
.spotlightItem[data-background="transparent"][data-video-enabled="true"][aria-hidden="false"]
|
||||
)
|
||||
~ .footer {
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(0, 0, 0, 0) 0%,
|
||||
var(--cpd-color-bg-canvas-default) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.header {
|
||||
position: sticky;
|
||||
flex-shrink: 0;
|
||||
|
||||
+2
-11
@@ -416,7 +416,6 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
const screenShareError = useBehavior(vm.screenShareError$);
|
||||
const layout = useBehavior(vm.layout$);
|
||||
const edgeToEdge = useBehavior(vm.edgeToEdge$);
|
||||
const overflowing = useBehavior(vm.overflowing$);
|
||||
const showNameTags = useBehavior(vm.showNameTags$);
|
||||
const showHeader = useBehavior(vm.showHeader$);
|
||||
const showModals = useBehavior(vm.showModals$);
|
||||
@@ -639,7 +638,6 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
showRingingStatus={showRingingStatus}
|
||||
focusable={!contentObscured}
|
||||
className={classNames(className, styles.tile)}
|
||||
itemClassName={styles.spotlightItem}
|
||||
style={style}
|
||||
/>
|
||||
);
|
||||
@@ -665,7 +663,6 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
return (
|
||||
<SpotlightTile
|
||||
className={styles.tile}
|
||||
itemClassName={styles.spotlightItem}
|
||||
data-maximised
|
||||
vm={layout.spotlight}
|
||||
expanded
|
||||
@@ -756,10 +753,6 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
/>,
|
||||
);
|
||||
|
||||
// Only hide the settings button if we have an AppBar header and we are showing the header
|
||||
const footer = footerVm !== null && (
|
||||
<CallFooter className={styles.footer} ref={footerRef} vm={footerVm} />
|
||||
);
|
||||
const connectedTransports = useBehavior(vm.connectedTransports$);
|
||||
const localMember = useBehavior(vm.localMember$);
|
||||
const localTransport = useBehavior(
|
||||
@@ -771,9 +764,7 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
// and the footer is also viewable by moving focus into it, so this is fine.
|
||||
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
||||
<div
|
||||
className={classNames(styles.inRoom, {
|
||||
[styles.overflowing]: overflowing,
|
||||
})}
|
||||
className={styles.inRoom}
|
||||
ref={containerRef}
|
||||
// Which layout the call has settled on, for tests and for anyone
|
||||
// wondering why the call looks the way it does at the size it was given
|
||||
@@ -792,7 +783,7 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
{screenShareToast}
|
||||
{earpieceOverlay}
|
||||
<ReactionsOverlay vm={vm} />
|
||||
{footer}
|
||||
<CallFooter ref={footerRef} vm={footerVm} />
|
||||
{showModals && (
|
||||
<>
|
||||
<RageshakeRequestModal {...rageshakeRequestModalProps} />
|
||||
|
||||
+28
-23
@@ -5,40 +5,45 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { useId, type FC } from "react";
|
||||
import {
|
||||
SpotlightViewIcon,
|
||||
GridIcon,
|
||||
} from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||
import { type ReactNode, useState, type FC } from "react";
|
||||
|
||||
import { type LayoutSwitchViewModel } from "../state/LayoutSwitchViewModel";
|
||||
import {
|
||||
type LayoutMode,
|
||||
type LayoutSwitchViewModel,
|
||||
} from "../state/LayoutSwitchViewModel";
|
||||
import { useBehavior } from "../useBehavior";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Switch } from "@vector-im/compound-web";
|
||||
import { Menu, RadioMenuItem } from "@vector-im/compound-web";
|
||||
import { LayoutSwitchButton } from "../button";
|
||||
|
||||
interface Props {
|
||||
interface LayoutSwitchProps {
|
||||
vm: LayoutSwitchViewModel;
|
||||
className?: string;
|
||||
size?: "md" | "lg";
|
||||
}
|
||||
|
||||
export const LayoutSwitch: FC<Props> = ({ vm, className }) => {
|
||||
export const LayoutSwitch: FC<LayoutSwitchProps> = ({ vm, ...props }) => {
|
||||
const { t } = useTranslation();
|
||||
const layout = useBehavior(vm.layout$);
|
||||
const name = useId();
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<Switch<"spotlight", "grid">
|
||||
name={name}
|
||||
aria-label={t("layout_switch_label")}
|
||||
leftLabel={t("layout_spotlight_label")}
|
||||
leftValue="spotlight"
|
||||
leftIcon={SpotlightViewIcon}
|
||||
rightLabel={t("layout_grid_label")}
|
||||
rightValue="grid"
|
||||
rightIcon={GridIcon}
|
||||
className={className}
|
||||
value={layout}
|
||||
onChange={vm.setLayout}
|
||||
const menuItem = (label: string, value: LayoutMode): ReactNode => (
|
||||
<RadioMenuItem
|
||||
label={label}
|
||||
checked={layout === value}
|
||||
onSelect={() => vm.setLayout(value)}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<Menu
|
||||
title={t("action.adjust_view")}
|
||||
open={open}
|
||||
onOpenChange={setOpen}
|
||||
trigger={<LayoutSwitchButton layout={layout} {...props} />}
|
||||
>
|
||||
{menuItem(t("layout_grid_label"), "grid")}
|
||||
{menuItem(t("layout_spotlight_label"), "spotlight")}
|
||||
</Menu>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -145,11 +145,6 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
>
|
||||
Handset Mode
|
||||
</h2>
|
||||
<p
|
||||
class="_typography_6v6n8_153 _font-body-md-regular_6v6n8_50"
|
||||
>
|
||||
Only works while using app
|
||||
</p>
|
||||
<button
|
||||
class="_button_1nw83_8"
|
||||
data-kind="primary"
|
||||
@@ -167,39 +162,13 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
class="_container_8084b5"
|
||||
/>
|
||||
<div
|
||||
class="_footer_4e7ff8 _footer_20b7b4"
|
||||
class="_footer_20b7b4"
|
||||
data-button-size="md"
|
||||
data-testid="footer-container"
|
||||
>
|
||||
<div
|
||||
class="_settingsLogoContainer_20b7b4"
|
||||
class="_logoContainer_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_b_"
|
||||
class="_icon-button_1215g_8 _settingsOnlyShowWide_20b7b4"
|
||||
data-kind="secondary"
|
||||
data-testid="settings-bottom-left"
|
||||
role="button"
|
||||
style="--cpd-icon-button-size: 32px;"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="_indicator-icon_j097f_17"
|
||||
style="--cpd-icon-button-size: 100%;"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 14q-.824 0-1.412-.588A1.93 1.93 0 0 1 4 12q0-.825.588-1.412A1.93 1.93 0 0 1 6 10q.824 0 1.412.588Q8 11.175 8 12t-.588 1.412A1.93 1.93 0 0 1 6 14m6 0q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m6 0q-.824 0-1.413-.588A1.93 1.93 0 0 1 16 12q0-.825.587-1.412A1.93 1.93 0 0 1 18 10q.824 0 1.413.588Q20 11.175 20 12t-.587 1.412A1.93 1.93 0 0 1 18 14"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
<div
|
||||
class="_logo_20b7b4"
|
||||
>
|
||||
@@ -308,36 +277,14 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
<div
|
||||
class="_buttons_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_g_"
|
||||
class="_button_1nw83_8 _settingsOnlyShowNarrow_20b7b4 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom-center"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 14q-.824 0-1.412-.588A1.93 1.93 0 0 1 4 12q0-.825.588-1.412A1.93 1.93 0 0 1 6 10q.824 0 1.412.588Q8 11.175 8 12t-.588 1.412A1.93 1.93 0 0 1 6 14m6 0q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m6 0q-.824 0-1.413-.588A1.93 1.93 0 0 1 16 12q0-.825.587-1.412A1.93 1.93 0 0 1 18 10q.824 0 1.413.588Q20 11.175 20 12t-.587 1.412A1.93 1.93 0 0 1 18 14"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_l_"
|
||||
aria-labelledby="_r_b_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
data-size="md"
|
||||
data-testid="incall_mute"
|
||||
role="switch"
|
||||
tabindex="0"
|
||||
@@ -345,9 +292,9 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
width="20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
@@ -359,10 +306,10 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_q_"
|
||||
aria-labelledby="_r_g_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
data-size="md"
|
||||
data-testid="incall_videomute"
|
||||
role="switch"
|
||||
tabindex="0"
|
||||
@@ -370,9 +317,9 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
width="20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
@@ -384,19 +331,19 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
aria-disabled="false"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-labelledby="_r_v_"
|
||||
aria-labelledby="_r_l_"
|
||||
class="_button_1nw83_8 _raiseHand_20b7b4 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-size="md"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
width="20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
@@ -407,10 +354,59 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_17_"
|
||||
aria-disabled="false"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="menu"
|
||||
aria-labelledby="_r_v_"
|
||||
class="_button_1nw83_8 _layout_20b7b4 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="md"
|
||||
data-state="closed"
|
||||
id="radix-_r_t_"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
width="20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M4 11a.97.97 0 0 1-.712-.287A.97.97 0 0 1 3 10V4q0-.424.288-.712A.97.97 0 0 1 4 3h6q.424 0 .713.288Q11 3.575 11 4v6q0 .424-.287.713A.97.97 0 0 1 10 11zm5-2V5H5v4zm5 12a.97.97 0 0 1-.713-.288A.97.97 0 0 1 13 20v-6q0-.424.287-.713A.97.97 0 0 1 14 13h6q.424 0 .712.287.288.288.288.713v6q0 .424-.288.712A.97.97 0 0 1 20 21zm5-2v-4h-4v4zM4 21a.97.97 0 0 1-.712-.288A.97.97 0 0 1 3 20v-6q0-.424.288-.713A.97.97 0 0 1 4 13h6q.424 0 .713.287.287.288.287.713v6q0 .424-.287.712A.97.97 0 0 1 10 21zm5-2v-4H5v4zm5-8a.97.97 0 0 1-.713-.287A.97.97 0 0 1 13 10V4q0-.424.287-.712A.97.97 0 0 1 14 3h6q.424 0 .712.288Q21 3.575 21 4v6q0 .424-.288.713A.97.97 0 0 1 20 11zm5-2V5h-4v4z"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_14_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="md"
|
||||
data-testid="settings-bottom"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
width="20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 14q-.824 0-1.412-.588A1.93 1.93 0 0 1 4 12q0-.825.588-1.412A1.93 1.93 0 0 1 6 10q.824 0 1.412.588Q8 11.175 8 12t-.588 1.412A1.93 1.93 0 0 1 6 14m6 0q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m6 0q-.824 0-1.413-.588A1.93 1.93 0 0 1 16 12q0-.825.587-1.412A1.93 1.93 0 0 1 18 10q.824 0 1.413.588Q20 11.175 20 12t-.587 1.412A1.93 1.93 0 0 1 18 14"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_19_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53 _destructive_1nw83_110"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
data-size="md"
|
||||
data-testid="incall_leave"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@@ -418,9 +414,9 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
width="20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
@@ -429,51 +425,6 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<fieldset
|
||||
aria-label="Layout"
|
||||
class="_toggle_1kvhc_9 _layout_20b7b4"
|
||||
data-size="lg"
|
||||
>
|
||||
<input
|
||||
aria-labelledby="_r_1d_"
|
||||
name="_r_1c_"
|
||||
type="radio"
|
||||
value="spotlight"
|
||||
/>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
clip-rule="evenodd"
|
||||
d="M20 6H4v12h16zM4 4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2z"
|
||||
fill-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
<input
|
||||
aria-labelledby="_r_1i_"
|
||||
checked=""
|
||||
name="_r_1c_"
|
||||
type="radio"
|
||||
value="grid"
|
||||
/>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M4 11a.97.97 0 0 1-.712-.287A.97.97 0 0 1 3 10V4q0-.424.288-.712A.97.97 0 0 1 4 3h6q.424 0 .713.288Q11 3.575 11 4v6q0 .424-.287.713A.97.97 0 0 1 10 11zm5-2V5H5v4zm5 12a.97.97 0 0 1-.713-.288A.97.97 0 0 1 13 20v-6q0-.424.287-.713A.97.97 0 0 1 14 13h6q.424 0 .712.287.288.288.288.713v6q0 .424-.288.712A.97.97 0 0 1 20 21zm5-2v-4h-4v4zM4 21a.97.97 0 0 1-.712-.288A.97.97 0 0 1 3 20v-6q0-.424.288-.713A.97.97 0 0 1 4 13h6q.424 0 .713.287.287.288.287.713v6q0 .424-.287.712A.97.97 0 0 1 10 21zm5-2v-4H5v4zm5-8a.97.97 0 0 1-.713-.287A.97.97 0 0 1 13 10V4q0-.424.287-.712A.97.97 0 0 1 14 3h6q.424 0 .712.288Q21 3.575 21 4v6q0 .424-.288.713A.97.97 0 0 1 20 11zm5-2V5h-4v4z"
|
||||
/>
|
||||
</svg>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,7 @@ exports[`LobbyView > renders with AppBar android 1`] = `
|
||||
>
|
||||
<header>
|
||||
<button
|
||||
aria-labelledby="_r_36_"
|
||||
aria-labelledby="_r_2k_"
|
||||
class="_icon-button_1215g_8 _primaryButton_221541"
|
||||
data-kind="primary"
|
||||
role="button"
|
||||
@@ -96,69 +96,20 @@ exports[`LobbyView > renders with AppBar android 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="_footer_20b7b4"
|
||||
data-button-size="lg"
|
||||
data-testid="footer-container"
|
||||
>
|
||||
<div
|
||||
class="_settingsLogoContainer_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_3c_"
|
||||
class="_icon-button_1215g_8 _settingsOnlyShowWide_20b7b4"
|
||||
data-kind="secondary"
|
||||
data-testid="settings-bottom-left"
|
||||
role="button"
|
||||
style="--cpd-icon-button-size: 32px;"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="_indicator-icon_j097f_17"
|
||||
style="--cpd-icon-button-size: 100%;"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 20q-.825 0-1.412-.587A1.93 1.93 0 0 1 10 18q0-.824.588-1.413A1.93 1.93 0 0 1 12 16q.825 0 1.412.587Q14 17.176 14 18t-.588 1.413A1.93 1.93 0 0 1 12 20m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 6q0-.824.588-1.412A1.93 1.93 0 0 1 12 4q.825 0 1.412.588Q14 5.175 14 6q0 .824-.588 1.412A1.93 1.93 0 0 1 12 8"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
class="_logoContainer_20b7b4"
|
||||
/>
|
||||
<div
|
||||
class="_buttons_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_3h_"
|
||||
class="_button_1nw83_8 _settingsOnlyShowNarrow_20b7b4 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom-center"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 20q-.825 0-1.412-.587A1.93 1.93 0 0 1 10 18q0-.824.588-1.413A1.93 1.93 0 0 1 12 16q.825 0 1.412.587Q14 17.176 14 18t-.588 1.413A1.93 1.93 0 0 1 12 20m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 6q0-.824.588-1.412A1.93 1.93 0 0 1 12 4q.825 0 1.412.588Q14 5.175 14 6q0 .824-.588 1.412A1.93 1.93 0 0 1 12 8"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_3m_"
|
||||
aria-labelledby="_r_2q_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -183,7 +134,7 @@ exports[`LobbyView > renders with AppBar android 1`] = `
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_3r_"
|
||||
aria-labelledby="_r_2v_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -205,7 +156,29 @@ exports[`LobbyView > renders with AppBar android 1`] = `
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_40_"
|
||||
aria-labelledby="_r_34_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 20q-.825 0-1.412-.587A1.93 1.93 0 0 1 10 18q0-.824.588-1.413A1.93 1.93 0 0 1 12 16q.825 0 1.412.587Q14 17.176 14 18t-.588 1.413A1.93 1.93 0 0 1 12 20m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 6q0-.824.588-1.412A1.93 1.93 0 0 1 12 4q.825 0 1.412.588Q14 5.175 14 6q0 .824-.588 1.412A1.93 1.93 0 0 1 12 8"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_39_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53 _destructive_1nw83_110"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -239,7 +212,7 @@ exports[`LobbyView > renders with AppBar ios 1`] = `
|
||||
>
|
||||
<header>
|
||||
<button
|
||||
aria-labelledby="_r_4a_"
|
||||
aria-labelledby="_r_3i_"
|
||||
class="_icon-button_1215g_8 _primaryButton_221541"
|
||||
data-kind="primary"
|
||||
role="button"
|
||||
@@ -328,69 +301,20 @@ exports[`LobbyView > renders with AppBar ios 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="_footer_20b7b4"
|
||||
data-button-size="lg"
|
||||
data-testid="footer-container"
|
||||
>
|
||||
<div
|
||||
class="_settingsLogoContainer_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_4g_"
|
||||
class="_icon-button_1215g_8 _settingsOnlyShowWide_20b7b4"
|
||||
data-kind="secondary"
|
||||
data-testid="settings-bottom-left"
|
||||
role="button"
|
||||
style="--cpd-icon-button-size: 32px;"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="_indicator-icon_j097f_17"
|
||||
style="--cpd-icon-button-size: 100%;"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 14q-.824 0-1.412-.588A1.93 1.93 0 0 1 4 12q0-.825.588-1.412A1.93 1.93 0 0 1 6 10q.824 0 1.412.588Q8 11.175 8 12t-.588 1.412A1.93 1.93 0 0 1 6 14m6 0q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m6 0q-.824 0-1.413-.588A1.93 1.93 0 0 1 16 12q0-.825.587-1.412A1.93 1.93 0 0 1 18 10q.824 0 1.413.588Q20 11.175 20 12t-.587 1.412A1.93 1.93 0 0 1 18 14"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
class="_logoContainer_20b7b4"
|
||||
/>
|
||||
<div
|
||||
class="_buttons_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_4l_"
|
||||
class="_button_1nw83_8 _settingsOnlyShowNarrow_20b7b4 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom-center"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 14q-.824 0-1.412-.588A1.93 1.93 0 0 1 4 12q0-.825.588-1.412A1.93 1.93 0 0 1 6 10q.824 0 1.412.588Q8 11.175 8 12t-.588 1.412A1.93 1.93 0 0 1 6 14m6 0q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m6 0q-.824 0-1.413-.588A1.93 1.93 0 0 1 16 12q0-.825.587-1.412A1.93 1.93 0 0 1 18 10q.824 0 1.413.588Q20 11.175 20 12t-.587 1.412A1.93 1.93 0 0 1 18 14"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_4q_"
|
||||
aria-labelledby="_r_3o_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -415,7 +339,7 @@ exports[`LobbyView > renders with AppBar ios 1`] = `
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_4v_"
|
||||
aria-labelledby="_r_3t_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -437,7 +361,29 @@ exports[`LobbyView > renders with AppBar ios 1`] = `
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_54_"
|
||||
aria-labelledby="_r_42_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 14q-.824 0-1.412-.588A1.93 1.93 0 0 1 4 12q0-.825.588-1.412A1.93 1.93 0 0 1 6 10q.824 0 1.412.588Q8 11.175 8 12t-.588 1.412A1.93 1.93 0 0 1 6 14m6 0q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m6 0q-.824 0-1.413-.588A1.93 1.93 0 0 1 16 12q0-.825.587-1.412A1.93 1.93 0 0 1 18 10q.824 0 1.413.588Q20 11.175 20 12t-.587 1.412A1.93 1.93 0 0 1 18 14"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_47_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53 _destructive_1nw83_110"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -606,38 +552,12 @@ exports[`LobbyView > renders with header and participant count 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="_footer_20b7b4"
|
||||
data-button-size="lg"
|
||||
data-testid="footer-container"
|
||||
>
|
||||
<div
|
||||
class="_settingsLogoContainer_20b7b4"
|
||||
class="_logoContainer_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_6_"
|
||||
class="_icon-button_1215g_8 _settingsOnlyShowWide_20b7b4"
|
||||
data-kind="secondary"
|
||||
data-testid="settings-bottom-left"
|
||||
role="button"
|
||||
style="--cpd-icon-button-size: 32px;"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="_indicator-icon_j097f_17"
|
||||
style="--cpd-icon-button-size: 100%;"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 20q-.825 0-1.412-.587A1.93 1.93 0 0 1 10 18q0-.824.588-1.413A1.93 1.93 0 0 1 12 16q.825 0 1.412.587Q14 17.176 14 18t-.588 1.413A1.93 1.93 0 0 1 12 20m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 6q0-.824.588-1.412A1.93 1.93 0 0 1 12 4q.825 0 1.412.588Q14 5.175 14 6q0 .824-.588 1.412A1.93 1.93 0 0 1 12 8"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
<div
|
||||
class="_logo_20b7b4"
|
||||
>
|
||||
@@ -746,33 +666,11 @@ exports[`LobbyView > renders with header and participant count 1`] = `
|
||||
<div
|
||||
class="_buttons_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_b_"
|
||||
class="_button_1nw83_8 _settingsOnlyShowNarrow_20b7b4 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom-center"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 20q-.825 0-1.412-.587A1.93 1.93 0 0 1 10 18q0-.824.588-1.413A1.93 1.93 0 0 1 12 16q.825 0 1.412.587Q14 17.176 14 18t-.588 1.413A1.93 1.93 0 0 1 12 20m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 6q0-.824.588-1.412A1.93 1.93 0 0 1 12 4q.825 0 1.412.588Q14 5.175 14 6q0 .824-.588 1.412A1.93 1.93 0 0 1 12 8"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_g_"
|
||||
aria-labelledby="_r_6_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -797,7 +695,7 @@ exports[`LobbyView > renders with header and participant count 1`] = `
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_l_"
|
||||
aria-labelledby="_r_b_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -819,7 +717,29 @@ exports[`LobbyView > renders with header and participant count 1`] = `
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_q_"
|
||||
aria-labelledby="_r_g_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 20q-.825 0-1.412-.587A1.93 1.93 0 0 1 10 18q0-.824.588-1.413A1.93 1.93 0 0 1 12 16q.825 0 1.412.587Q14 17.176 14 18t-.588 1.413A1.93 1.93 0 0 1 12 20m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 6q0-.824.588-1.412A1.93 1.93 0 0 1 12 4q.825 0 1.412.588Q14 5.175 14 6q0 .824-.588 1.412A1.93 1.93 0 0 1 12 8"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_l_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53 _destructive_1nw83_110"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
|
||||
@@ -30,6 +30,9 @@ import {
|
||||
} from "@element-hq/matrixrtc-sdk";
|
||||
import type * as MatrixRTCSdk from "@element-hq/matrixrtc-sdk";
|
||||
import { exampleTransport, mockConfig } from "../utils/test";
|
||||
import { GroupCallErrorBoundary } from "../room/GroupCallErrorBoundary";
|
||||
import { LeaveToHomeProvider } from "../LeaveToHomeContext";
|
||||
import { ElementCallError, ErrorCode } from "../utils/errors";
|
||||
|
||||
// Mock url params hook to avoid environment-dependent snapshot churn.
|
||||
vi.mock("../UrlParams", () => ({
|
||||
@@ -541,4 +544,38 @@ describe("DeveloperSettingsTab", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
describe("throw test error", () => {
|
||||
it("throws an ElementCallError that the error boundary shows", async () => {
|
||||
const user = userEvent.setup();
|
||||
const client = createMockMatrixClient();
|
||||
const onError = vi.fn();
|
||||
|
||||
render(
|
||||
<LeaveToHomeProvider value={vi.fn()}>
|
||||
<GroupCallErrorBoundary
|
||||
onError={onError}
|
||||
recoveryActionHandler={vi.fn()}
|
||||
>
|
||||
<TooltipProvider>
|
||||
<DeveloperSettingsTab
|
||||
client={client}
|
||||
env={{} as unknown as ImportMetaEnv}
|
||||
vm={outOfCallDeveloperSettingsTabViewModel}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
</GroupCallErrorBoundary>
|
||||
</LeaveToHomeProvider>,
|
||||
);
|
||||
|
||||
await user.click(
|
||||
screen.getByRole("button", { name: "Throw test error" }),
|
||||
);
|
||||
|
||||
expect(await screen.findByText("Something went wrong")).toBeVisible();
|
||||
expect(onError).toHaveBeenCalledOnce();
|
||||
const error = onError.mock.calls[0][0] as unknown;
|
||||
expect(error).toBeInstanceOf(ElementCallError);
|
||||
expect((error as ElementCallError).code).toBe(ErrorCode.UNKNOWN_ERROR);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
import { logger } from "matrix-js-sdk/lib/logger";
|
||||
import { type UnstableLivekitTransport } from "matrix-js-sdk/lib/matrixrtc";
|
||||
import {
|
||||
Button,
|
||||
EditInPlace,
|
||||
ErrorMessage,
|
||||
Root as Form,
|
||||
@@ -72,6 +73,7 @@ import {
|
||||
} from "@element-hq/matrixrtc-sdk";
|
||||
import { useBehavior } from "../useBehavior";
|
||||
import { type ViewModel } from "../state/ViewModel.ts";
|
||||
import { type ElementCallError, UnknownCallError } from "../utils/errors.ts";
|
||||
|
||||
/**
|
||||
* The state of MatrixRTC's media key rotation.
|
||||
@@ -212,6 +214,22 @@ export const DeveloperSettingsTab: FC<Props> = ({
|
||||
|
||||
const urlParams = useUrlParams();
|
||||
|
||||
// An error thrown from a click handler never reaches an error boundary, so
|
||||
// the button only records it and the next render throws it instead.
|
||||
const [errorToThrow, setErrorToThrow] = useState<ElementCallError | null>(
|
||||
null,
|
||||
);
|
||||
const throwTestError = useCallback(
|
||||
() =>
|
||||
setErrorToThrow(
|
||||
new UnknownCallError(
|
||||
new Error("Test error thrown from the developer settings"),
|
||||
),
|
||||
),
|
||||
[],
|
||||
);
|
||||
if (errorToThrow !== null) throw errorToThrow;
|
||||
|
||||
const MediaQualitySettings: React.FC<{
|
||||
id: string;
|
||||
header: string;
|
||||
@@ -678,6 +696,10 @@ export const DeveloperSettingsTab: FC<Props> = ({
|
||||
<Separator />
|
||||
<AudioProcessingSettings />
|
||||
<Separator />
|
||||
<Button kind="secondary" destructive onClick={throwTestError}>
|
||||
{t("developer_mode.throw_error_button")}
|
||||
</Button>
|
||||
<Separator />
|
||||
<p>{t("developer_mode.environment_variables")}</p>
|
||||
<pre className={styles.pre}>{JSON.stringify(env, null, 2)}</pre>
|
||||
<p>{t("developer_mode.url_params")}</p>
|
||||
|
||||
@@ -635,6 +635,21 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = `
|
||||
data-orientation="horizontal"
|
||||
role="separator"
|
||||
/>
|
||||
<button
|
||||
class="_button_1nw83_8 _destructive_1nw83_110"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Throw test error
|
||||
</button>
|
||||
<div
|
||||
class="_separator_13qwf_8"
|
||||
data-kind="primary"
|
||||
data-orientation="horizontal"
|
||||
role="separator"
|
||||
/>
|
||||
<p>
|
||||
Environment variables
|
||||
</p>
|
||||
|
||||
@@ -304,7 +304,6 @@ const showFooterMs = 4000;
|
||||
|
||||
interface LayoutScanState {
|
||||
layout: Layout | null;
|
||||
overflowing: boolean;
|
||||
tiles: TileStore;
|
||||
}
|
||||
|
||||
@@ -457,10 +456,6 @@ export interface CallViewModel {
|
||||
* and header as overlays.
|
||||
*/
|
||||
edgeToEdge$: Behavior<boolean>;
|
||||
/**
|
||||
* Whether the call layout is overflowing the interface (causing it to scroll).
|
||||
*/
|
||||
overflowing$: Behavior<boolean>;
|
||||
|
||||
/**
|
||||
* Whether modals such as settings and reactions should be accessible at all.
|
||||
@@ -1341,7 +1336,6 @@ export function createCallViewModel$(
|
||||
let layout: Layout;
|
||||
let newTiles: TileStore;
|
||||
let pip: GridTileViewModel | undefined;
|
||||
let overflowing = false;
|
||||
switch (media.type) {
|
||||
case "grid":
|
||||
case "spotlight-landscape":
|
||||
@@ -1353,7 +1347,6 @@ export function createCallViewModel$(
|
||||
setVisibleTiles,
|
||||
prevTiles,
|
||||
);
|
||||
overflowing = newTiles.gridTiles.length > visibleTiles;
|
||||
break;
|
||||
case "spotlight-expanded":
|
||||
[layout, newTiles] = spotlightExpandedLayout(
|
||||
@@ -1387,9 +1380,9 @@ export function createCallViewModel$(
|
||||
tile.setShowOutline(tile === pip);
|
||||
}
|
||||
|
||||
return { layout, overflowing, tiles: newTiles };
|
||||
return { layout, tiles: newTiles };
|
||||
},
|
||||
{ layout: null, overflowing: false, tiles: TileStore.empty() },
|
||||
{ layout: null, tiles: TileStore.empty() },
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -1405,10 +1398,6 @@ export function createCallViewModel$(
|
||||
),
|
||||
);
|
||||
|
||||
const overflowing$ = scope.behavior<boolean>(
|
||||
layoutInternals$.pipe(map(({ overflowing }) => overflowing)),
|
||||
);
|
||||
|
||||
/**
|
||||
* The current generation of the tile store, exposed for debugging purposes.
|
||||
*/
|
||||
@@ -1652,7 +1641,6 @@ export function createCallViewModel$(
|
||||
settingsOpen$: settingsOpen$,
|
||||
setSettingsOpen$: setSettingsOpen$,
|
||||
edgeToEdge$,
|
||||
overflowing$,
|
||||
earpieceMode$: earpieceMode$,
|
||||
audioOutputSwitcher$: audioOutputSwitcher$,
|
||||
reconnecting$,
|
||||
|
||||
@@ -31,6 +31,8 @@ test.each<{
|
||||
false,
|
||||
callIntent,
|
||||
allowJoinUnmutedViaIntent,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
expect(audioEnabled).toBe(true);
|
||||
expect(videoEnabled).toBe(callIntent !== RTC_CALL_INTENT_AUDIO);
|
||||
@@ -50,6 +52,8 @@ test.each<{
|
||||
true,
|
||||
callIntent,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
expect(audioEnabled).toBe(false);
|
||||
expect(videoEnabled).toBe(false);
|
||||
@@ -69,8 +73,32 @@ test.each<{
|
||||
true,
|
||||
callIntent,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
expect(audioEnabled).toBe(true);
|
||||
expect(videoEnabled).toBe(callIntent !== RTC_CALL_INTENT_AUDIO);
|
||||
},
|
||||
);
|
||||
|
||||
test.each<{
|
||||
initialAudioEnabled: boolean;
|
||||
initialVideoEnabled: boolean;
|
||||
}>([
|
||||
{ initialAudioEnabled: false, initialVideoEnabled: true },
|
||||
{ initialAudioEnabled: true, initialVideoEnabled: false },
|
||||
{ initialAudioEnabled: false, initialVideoEnabled: false },
|
||||
])(
|
||||
"Should start the devices the intent disables muted, even if allowed unmuted (initialAudioEnabled: $initialAudioEnabled, initialVideoEnabled: $initialVideoEnabled)",
|
||||
({ initialAudioEnabled, initialVideoEnabled }) => {
|
||||
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
||||
false,
|
||||
RTC_CALL_INTENT_VIDEO,
|
||||
true,
|
||||
initialAudioEnabled,
|
||||
initialVideoEnabled,
|
||||
);
|
||||
expect(audioEnabled).toBe(initialAudioEnabled);
|
||||
expect(videoEnabled).toBe(initialVideoEnabled);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -21,14 +21,20 @@ import {
|
||||
* @param allowJoinUnmutedViaIntent Whether the host vouches for the intent
|
||||
* enough to start the user unmuted without a lobby (see
|
||||
* `HostBridge.allowJoinUnmutedViaIntent`).
|
||||
* @param initialAudioEnabled Whether the intent lets the microphone start on
|
||||
* (see `UrlConfiguration.initialAudioEnabled`). Only ever turns it off.
|
||||
* @param initialVideoEnabled Whether the intent lets the camera start on (see
|
||||
* `UrlConfiguration.initialVideoEnabled`). Only ever turns it off.
|
||||
*/
|
||||
export function calculateInitialMuteState(
|
||||
skipLobby: boolean,
|
||||
callIntent: RTCCallIntent | undefined,
|
||||
allowJoinUnmutedViaIntent: boolean,
|
||||
initialAudioEnabled: boolean,
|
||||
initialVideoEnabled: boolean,
|
||||
): { audioEnabled: boolean; videoEnabled: boolean } {
|
||||
logger.debug(
|
||||
`calculateInitialMuteState: skipLobby=${skipLobby}, callIntent=${callIntent} allowJoinUnmutedViaIntent=${allowJoinUnmutedViaIntent}`,
|
||||
`calculateInitialMuteState: skipLobby=${skipLobby}, callIntent=${callIntent} allowJoinUnmutedViaIntent=${allowJoinUnmutedViaIntent} initialAudioEnabled=${initialAudioEnabled} initialVideoEnabled=${initialVideoEnabled}`,
|
||||
);
|
||||
|
||||
if (skipLobby && !allowJoinUnmutedViaIntent) {
|
||||
@@ -44,9 +50,9 @@ export function calculateInitialMuteState(
|
||||
// A host that vouches for the intent is a trusted environment, so it allows
|
||||
// unmuted by default. Same for when showing a lobby, as users can adjust
|
||||
// their settings there. Additionally, if the call intent is "m.audio", we
|
||||
// disable video by default.
|
||||
// disable video by default. The intent can still start either off.
|
||||
return {
|
||||
audioEnabled: true,
|
||||
videoEnabled: callIntent != RTC_CALL_INTENT_AUDIO,
|
||||
audioEnabled: initialAudioEnabled,
|
||||
videoEnabled: initialVideoEnabled && callIntent != RTC_CALL_INTENT_AUDIO,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ export function useMuteStates(): MuteStates | null {
|
||||
urlParams.skipLobby,
|
||||
urlParams.callIntent,
|
||||
hostBridge.allowJoinUnmutedViaIntent,
|
||||
urlParams.initialAudioEnabled ?? true,
|
||||
urlParams.initialVideoEnabled ?? true,
|
||||
),
|
||||
hostBridge,
|
||||
),
|
||||
|
||||
@@ -392,10 +392,6 @@ interface Props {
|
||||
showRingingStatus: boolean;
|
||||
focusable: boolean;
|
||||
className?: string;
|
||||
/**
|
||||
* CSS class of the individual spotlight items.
|
||||
*/
|
||||
itemClassName?: string;
|
||||
style?: ComponentProps<typeof animated.div>["style"];
|
||||
}
|
||||
|
||||
@@ -411,7 +407,6 @@ export const SpotlightTile: FC<Props> = ({
|
||||
showRingingStatus,
|
||||
focusable = true,
|
||||
className,
|
||||
itemClassName,
|
||||
style,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -535,7 +530,6 @@ export const SpotlightTile: FC<Props> = ({
|
||||
// remove all scroll snap points except for just the one media
|
||||
// that we want to bring into view
|
||||
snap={scrollToId === null || scrollToId === vm.id}
|
||||
className={itemClassName}
|
||||
aria-hidden={(scrollToId ?? visibleId) !== vm.id}
|
||||
/>
|
||||
))}
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
} from "vitest";
|
||||
|
||||
import { useTheme } from "./useTheme";
|
||||
import { PortalElementProvider } from "./RootElementContext";
|
||||
import { platform } from "./Platform";
|
||||
import { useUrlParams } from "./UrlParams";
|
||||
import {
|
||||
@@ -103,6 +104,24 @@ describe("useTheme", () => {
|
||||
expect(document.body.getAttribute("data-platform")).toBe(platform);
|
||||
});
|
||||
|
||||
test("gives the portal container the theme and platform too", () => {
|
||||
const portal = document.createElement("div");
|
||||
const withPortal: FC<PropsWithChildren> = ({ children }) =>
|
||||
createElement(
|
||||
wrapper,
|
||||
null,
|
||||
createElement(PortalElementProvider, { value: portal }, children),
|
||||
);
|
||||
renderHook(() => useTheme(), { wrapper: withPortal });
|
||||
|
||||
expect(portal.classList.contains("cpd-theme-dark")).toBe(true);
|
||||
expect(portal.getAttribute("data-platform")).toBe(platform);
|
||||
|
||||
act(() => themeChange$.next({ data: { name: "light" }, reply: vi.fn() }));
|
||||
expect(portal.classList.contains("cpd-theme-dark")).toBe(false);
|
||||
expect(portal.classList.contains("cpd-theme-light")).toBe(true);
|
||||
});
|
||||
|
||||
test("theme changes in response to host requests", () => {
|
||||
renderHook(() => useTheme(), { wrapper });
|
||||
|
||||
|
||||
+19
-8
@@ -8,12 +8,13 @@ Please see LICENSE in the repository root for full details.
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
||||
|
||||
import { useUrlParams } from "./UrlParams";
|
||||
import { useRootElement } from "./RootElementContext";
|
||||
import { usePortalElement, useRootElement } from "./RootElementContext";
|
||||
import { platform } from "./Platform";
|
||||
import { useHostBridge } from "./HostBridge";
|
||||
|
||||
export const useTheme = (): void => {
|
||||
const rootElement = useRootElement();
|
||||
const portalElement = usePortalElement();
|
||||
const hostBridge = useHostBridge();
|
||||
const { theme } = useUrlParams();
|
||||
const [requestedTheme, setRequestedTheme] = useState(theme);
|
||||
@@ -37,13 +38,14 @@ export const useTheme = (): void => {
|
||||
rootElement.setAttribute("data-platform", platform);
|
||||
}, [rootElement]);
|
||||
|
||||
// If no theme has been explicitly requested we default to dark
|
||||
const lightness = requestedTheme?.includes("light") ? "light" : "dark";
|
||||
const themeHighContrast = requestedTheme?.includes("high-contrast")
|
||||
? "-hc"
|
||||
: "";
|
||||
const themeString = "cpd-theme-" + lightness + themeHighContrast;
|
||||
|
||||
useLayoutEffect(() => {
|
||||
// If no theme has been explicitly requested we default to dark
|
||||
const theme = requestedTheme?.includes("light") ? "light" : "dark";
|
||||
const themeHighContrast = requestedTheme?.includes("high-contrast")
|
||||
? "-hc"
|
||||
: "";
|
||||
const themeString = "cpd-theme-" + theme + themeHighContrast;
|
||||
if (themeString !== previousTheme.current) {
|
||||
rootElement.classList.remove(
|
||||
"cpd-theme-light",
|
||||
@@ -55,5 +57,14 @@ export const useTheme = (): void => {
|
||||
previousTheme.current = themeString;
|
||||
}
|
||||
rootElement.classList.remove("no-theme");
|
||||
}, [previousTheme, requestedTheme, rootElement]);
|
||||
}, [previousTheme, themeString, rootElement]);
|
||||
|
||||
// The menus and tooltips floating outside the root get its theme and
|
||||
// platform too, so that they look as they would inside it.
|
||||
useLayoutEffect(() => {
|
||||
if (portalElement === null) return;
|
||||
portalElement.setAttribute("data-platform", platform);
|
||||
portalElement.classList.add(themeString);
|
||||
return (): void => portalElement.classList.remove(themeString);
|
||||
}, [portalElement, themeString]);
|
||||
};
|
||||
|
||||
+15
-35
@@ -6,16 +6,11 @@ Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { describe, expect, vi, it, beforeEach } from "vitest";
|
||||
import {
|
||||
createRoomWidgetClient,
|
||||
EventType,
|
||||
UNSTABLE_ELEMENT_FUNCTIONAL_USERS,
|
||||
} from "matrix-js-sdk";
|
||||
import { createRoomWidgetClient } from "matrix-js-sdk";
|
||||
|
||||
import { getUrlParams } from "./UrlParams";
|
||||
import { initializeWidget } from "./widget";
|
||||
import { Config } from "./config/Config";
|
||||
import { ElementCallReactionEventType } from "./reactions";
|
||||
|
||||
vi.mock("matrix-js-sdk", { spy: true });
|
||||
const createRoomWidgetClientSpy = vi.mocked(createRoomWidgetClient);
|
||||
@@ -59,23 +54,17 @@ describe("widget", () => {
|
||||
});
|
||||
expect(widget).toBeDefined();
|
||||
expect(configInitSpy).toHaveBeenCalled();
|
||||
const sendEvent = [
|
||||
EventType.CallNotify, // Sent as a deprecated fallback
|
||||
EventType.RTCNotification,
|
||||
];
|
||||
const sendEvent = ["org.matrix.msc4075.rtc.notification"];
|
||||
const receiveEvent = ["org.matrix.msc4310.rtc.decline"];
|
||||
const sendRecvEvent = [
|
||||
"org.matrix.rageshake_request",
|
||||
EventType.CallEncryptionKeysPrefix,
|
||||
EventType.Reaction,
|
||||
EventType.RoomRedaction,
|
||||
ElementCallReactionEventType,
|
||||
EventType.RTCDecline,
|
||||
EventType.RTCMembership,
|
||||
"m.reaction",
|
||||
"m.room.redaction",
|
||||
"io.element.call.reaction",
|
||||
"m.rtc.member",
|
||||
];
|
||||
|
||||
const sendState = [
|
||||
{ eventType: "org.matrix.msc3401.call.member", stateKey: "myYser" }, // Legacy call membership events
|
||||
{
|
||||
eventType: "org.matrix.msc3401.call.member",
|
||||
stateKey: `_myYser_AAAAA_ANYRTCAPP`,
|
||||
@@ -86,32 +75,23 @@ describe("widget", () => {
|
||||
}, // The above with no leading underscore, for room versions whose auth rules allow it
|
||||
];
|
||||
const receiveState = [
|
||||
{ eventType: EventType.RoomCreate },
|
||||
{ eventType: EventType.RoomName },
|
||||
{ eventType: EventType.RoomMember },
|
||||
{ eventType: EventType.RoomEncryption },
|
||||
{ eventType: UNSTABLE_ELEMENT_FUNCTIONAL_USERS.name },
|
||||
{ eventType: EventType.GroupCallMemberPrefix },
|
||||
{ eventType: "m.room.create" },
|
||||
{ eventType: "m.room.name" },
|
||||
{ eventType: "m.room.member" },
|
||||
{ eventType: "m.room.encryption" },
|
||||
{ eventType: "io.element.functional_members" },
|
||||
{ eventType: "org.matrix.msc3401.call.member" },
|
||||
{ eventType: "org.matrix.msc4143.rtc.slot" },
|
||||
];
|
||||
|
||||
const sendRecvToDevice = [
|
||||
EventType.CallInvite,
|
||||
EventType.CallCandidates,
|
||||
EventType.CallAnswer,
|
||||
EventType.CallHangup,
|
||||
EventType.CallReject,
|
||||
EventType.CallSelectAnswer,
|
||||
EventType.CallNegotiate,
|
||||
EventType.CallSDPStreamMetadataChanged,
|
||||
EventType.CallSDPStreamMetadataChangedPrefix,
|
||||
EventType.CallReplaces,
|
||||
EventType.CallEncryptionKeysPrefix,
|
||||
"io.element.call.encryption_keys",
|
||||
"m.rtc.encryption_key",
|
||||
];
|
||||
|
||||
expect(createRoomWidgetClientSpy.mock.calls[0][1]).toStrictEqual({
|
||||
sendEvent: [...sendEvent, ...sendRecvEvent],
|
||||
receiveEvent: sendRecvEvent,
|
||||
receiveEvent: [...receiveEvent, ...sendRecvEvent],
|
||||
sendState,
|
||||
receiveState,
|
||||
sendToDevice: sendRecvToDevice,
|
||||
|
||||
+9
-23
@@ -68,7 +68,7 @@ export interface WidgetHelpers {
|
||||
* @returns A point of access to the widget API, or null if Element Call is not
|
||||
* running as a widget.
|
||||
*/
|
||||
// this needs to be a seperate call and cannot be done on import to allow us to spy on methods in here before
|
||||
// this needs to be a separate call and cannot be done on import to allow us to spy on methods in here before
|
||||
// execution.
|
||||
export const initializeWidget = (
|
||||
rtcApplication: string = "m.call",
|
||||
@@ -118,26 +118,21 @@ export const initializeWidget = (
|
||||
// request, and is responsible for starting the transport (should it be?)
|
||||
|
||||
// These are all the event types the app uses
|
||||
const sendEvent = [
|
||||
EventType.CallNotify, // Sent as a deprecated fallback
|
||||
EventType.RTCNotification,
|
||||
];
|
||||
const sendEvent = [EventType.RTCNotification];
|
||||
if (sendRoomEvents) {
|
||||
sendEvent.push(EventType.RoomMessage);
|
||||
}
|
||||
// Declines are sent by the host (the ringing client), we only watch for them
|
||||
const receiveEvent = [EventType.RTCDecline];
|
||||
const sendRecvEvent = [
|
||||
"org.matrix.rageshake_request",
|
||||
EventType.CallEncryptionKeysPrefix,
|
||||
EventType.Reaction,
|
||||
EventType.RoomRedaction,
|
||||
ElementCallReactionEventType,
|
||||
EventType.RTCDecline,
|
||||
EventType.RTCMembership,
|
||||
"m.rtc.member",
|
||||
EventType.RTCMembershipStable, // Sticky membership events
|
||||
];
|
||||
|
||||
const sendState = [
|
||||
userId, // Legacy call membership events
|
||||
`_${userId}_${deviceId}_${rtcApplication}`, // Session membership events
|
||||
`${userId}_${deviceId}_${rtcApplication}`, // The above with no leading underscore, for room versions whose auth rules allow it
|
||||
].map((stateKey) => ({
|
||||
@@ -151,28 +146,19 @@ export const initializeWidget = (
|
||||
{ eventType: EventType.RoomEncryption },
|
||||
{ eventType: UNSTABLE_ELEMENT_FUNCTIONAL_USERS.name },
|
||||
{ eventType: EventType.GroupCallMemberPrefix },
|
||||
{ eventType: EventType.RTCSlot }, // Whether the slot is open or closed
|
||||
];
|
||||
|
||||
const sendRecvToDevice = [
|
||||
EventType.CallInvite,
|
||||
EventType.CallCandidates,
|
||||
EventType.CallAnswer,
|
||||
EventType.CallHangup,
|
||||
EventType.CallReject,
|
||||
EventType.CallSelectAnswer,
|
||||
EventType.CallNegotiate,
|
||||
EventType.CallSDPStreamMetadataChanged,
|
||||
EventType.CallSDPStreamMetadataChangedPrefix,
|
||||
EventType.CallReplaces,
|
||||
EventType.CallEncryptionKeysPrefix,
|
||||
"m.rtc.encryption_key",
|
||||
EventType.CallEncryptionKeysPrefix, // For members that only understand the legacy key event
|
||||
EventType.RTCEncryptionKey,
|
||||
];
|
||||
|
||||
const client = createRoomWidgetClient(
|
||||
api,
|
||||
{
|
||||
sendEvent: [...sendEvent, ...sendRecvEvent],
|
||||
receiveEvent: sendRecvEvent,
|
||||
receiveEvent: [...receiveEvent, ...sendRecvEvent],
|
||||
sendState,
|
||||
receiveState,
|
||||
sendToDevice: sendRecvToDevice,
|
||||
|
||||
+12
-11
@@ -114,6 +114,7 @@ async function loadConfig(): Promise<WidgetConfig> {
|
||||
function connectWidget(
|
||||
params: URLSearchParams,
|
||||
application: string,
|
||||
slotId: string,
|
||||
): { api: WidgetApi; client: MatrixClient; roomId: string } {
|
||||
const required = (name: string): string => {
|
||||
const value = params.get(name);
|
||||
@@ -131,29 +132,29 @@ function connectWidget(
|
||||
api.requestCapability(MatrixCapabilities.AlwaysOnScreen);
|
||||
|
||||
const sendRecvEvent = [
|
||||
EventType.CallEncryptionKeysPrefix,
|
||||
EventType.RTCDecline,
|
||||
EventType.RTCMembership,
|
||||
"m.rtc.member",
|
||||
EventType.RTCMembershipStable, // Sticky membership events
|
||||
];
|
||||
const sendRecvToDevice = [
|
||||
EventType.CallEncryptionKeysPrefix,
|
||||
"m.rtc.encryption_key",
|
||||
EventType.CallEncryptionKeysPrefix, // For members that only understand the legacy key event
|
||||
EventType.RTCEncryptionKey,
|
||||
];
|
||||
// The js-sdk drops the slot id from the state key of the default call slot
|
||||
const stateKeySlot =
|
||||
application === "m.call" && slotId === "ROOM"
|
||||
? application
|
||||
: `${application}${slotId}`;
|
||||
const client = createRoomWidgetClient(
|
||||
api,
|
||||
{
|
||||
sendEvent: [
|
||||
...sendRecvEvent,
|
||||
EventType.CallNotify, // Sent as a deprecated fallback
|
||||
EventType.RTCNotification,
|
||||
EventType.RoomMessage, // For sendRoomMessage
|
||||
],
|
||||
receiveEvent: sendRecvEvent,
|
||||
sendState: [
|
||||
userId, // Legacy call membership events
|
||||
`_${userId}_${deviceId}_${application}`, // Session membership events
|
||||
`${userId}_${deviceId}_${application}`, // The above with no leading underscore, for room versions whose auth rules allow it
|
||||
`_${userId}_${deviceId}_${stateKeySlot}`, // Session membership events
|
||||
`${userId}_${deviceId}_${stateKeySlot}`, // The above with no leading underscore, for room versions whose auth rules allow it
|
||||
].map((stateKey) => ({
|
||||
eventType: EventType.GroupCallMemberPrefix,
|
||||
stateKey,
|
||||
@@ -191,7 +192,7 @@ export async function createMatrixRTCSdk(
|
||||
): Promise<MatrixRTCSdk> {
|
||||
const logger = rootLogger.getChild("[MatrixRTCSdk]");
|
||||
const params = widgetParams();
|
||||
const { api, client, roomId } = connectWidget(params, application);
|
||||
const { api, client, roomId } = connectWidget(params, application, id);
|
||||
const config = await loadConfig();
|
||||
await client.startClient();
|
||||
const room = client.getRoom(roomId);
|
||||
|
||||
Reference in New Issue
Block a user