Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/url_params.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ These parameters are relevant to both [widget](./embedded_standalone.md) and [st
| `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. |
Expand Down
6 changes: 6 additions & 0 deletions playwright/widget/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ export class TestHelpers {
break;
}
}

// Also dismiss the release announcement
await page
.getByRole("dialog", { name: "Introducing Sections" })
.getByRole("button", { name: "OK" })
.click();
Comment thread
robintown marked this conversation as resolved.
Outdated
}

public static async createRoom(
Expand Down
18 changes: 8 additions & 10 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { useTheme } from "./useTheme";
import { ProcessorProvider } from "./livekit/TrackProcessorContext";
import { type AppViewModel } from "./state/AppViewModel";
import { MediaDevicesContext } from "./MediaDevicesContext";
import { getUrlParams, HeaderStyle } from "./UrlParams";
import { getUrlParams, HeaderStyle, useUrlParams } from "./UrlParams";
import { AppBar } from "./AppBar";

const SentryRoute = Sentry.withSentryReactRouterV7Routing(Route);
Expand All @@ -41,19 +41,17 @@ interface SimpleProviderProps {

const BackgroundProvider: FC<SimpleProviderProps> = ({ children }) => {
const { pathname } = useLocation();
const { background } = useUrlParams();

useEffect(() => {
let backgroundImage = "";
if (!["/login", "/register"].includes(pathname) && !widget) {
backgroundImage = "var(--background-gradient)";
}
document
.getElementsByTagName("body")[0]
.setAttribute("data-background", background);
}, [pathname, background]);

document.getElementsByTagName("body")[0].style.backgroundImage =
backgroundImage;
}, [pathname]);

return <>{children}</>;
return children;
};

const ThemeProvider: FC<SimpleProviderProps> = ({ children }) => {
useTheme();
return children;
Expand Down
12 changes: 12 additions & 0 deletions src/UrlParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export enum HeaderStyle {
AppBar = "app_bar",
}

export enum BackgroundStyle {
Solid = "solid",
Gradient = "gradient",
}

/**
* The UrlProperties are used to pass required data to the widget.
* Those are different in different rooms, users, devices. They do not configure the behavior of the
Expand Down Expand Up @@ -145,6 +150,10 @@ export interface UrlProperties {
* can be "light", "dark", "light-high-contrast" or "dark-high-contrast".
*/
theme: string | null;
/**
* The visual style of the page background.
*/
background: BackgroundStyle;
}

/**
Expand Down Expand Up @@ -452,6 +461,9 @@ export const computeUrlParams = (search = "", hash = ""): UrlParams => {
fonts: parser.getAllParams("font"),
fontScale: Number.isNaN(fontScale) ? null : fontScale,
theme: parser.getParam("theme"),
background:
parser.getEnumParam("background", BackgroundStyle) ??
BackgroundStyle.Gradient,
viaServers: !isWidget ? parser.getParam("viaServers") : null,
homeserver: !isWidget ? parser.getParam("homeserver") : null,
posthogApiHost: parser.getParam("posthogApiHost"),
Expand Down
48 changes: 0 additions & 48 deletions src/graphics/loggedOutGradient.svg

This file was deleted.

86 changes: 86 additions & 0 deletions src/graphics/mobile-gradient.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 16 additions & 4 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ layer(compound);
--small-drop-shadow: 0px 1.2px 2.4px 0px rgba(0, 0, 0, 0.15);
--big-drop-shadow: 0px 0px 24px 0px #1b1d221a;
--subtle-drop-shadow: 0px 1px 2px 0px rgba(16, 24, 40, 0.05);
--background-gradient: url("graphics/backgroundGradient.svg");

--call-view-overlay-layer: 1;
--call-view-header-footer-layer: 2;
Expand All @@ -74,9 +73,6 @@ layer(compound);

body {
background-color: var(--cpd-color-bg-canvas-default);
background-size: calc(max(1440px, 100vw)) calc(max(800px, 100vh));
background-repeat: no-repeat;
background-position: center;
color: var(--cpd-color-text-primary);
color-scheme: dark;
margin: 0;
Expand All @@ -85,6 +81,22 @@ body {
-webkit-tap-highlight-color: transparent;
}

body[data-background="gradient"]::before {
content: "";
position: fixed;
inset: 0;
background-image: url("graphics/mobile-gradient.svg");
background-size: auto;
background-position: bottom;
background-repeat: no-repeat;
}

body[data-background="gradient"][data-platform="desktop"]::before {
background-image: url("graphics/desktop-gradient.svg");
background-size: calc(max(1440px, 100vw)) calc(max(800px, 100vh));
background-position: center;
}

/* This prohibits the view to scroll for pages smaller than 122px in width
we use this for mobile pip webviews */
.no-scroll-body {
Expand Down
2 changes: 1 addition & 1 deletion src/state/OneOnOnePortraitLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function oneOnOnePortraitLayout(
prevTiles: TileStore,
): [OneOnOnePortraitLayout, TileStore] {
const update = prevTiles.from(media.pip === undefined ? 0 : 1);
update.registerSpotlight([media.spotlight], true);
update.registerSpotlight([media.spotlight], true, "transparent");
if (media.pip !== undefined) update.registerGridTile(media.pip);
const tiles = update.build();

Expand Down
1 change: 1 addition & 0 deletions src/state/PipLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function pipLayout(
update.registerSpotlight(
media.spotlight,
platform === "desktop" ? false : true,
"transparent",
);
const tiles = update.build();
return [
Expand Down
2 changes: 1 addition & 1 deletion src/state/SpotlightExpandedLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function spotlightExpandedLayout(
prevTiles: TileStore,
): [SpotlightExpandedLayout, TileStore] {
const update = prevTiles.from(1);
update.registerSpotlight(media.spotlight, true);
update.registerSpotlight(media.spotlight, true, "transparent");
if (media.pip !== undefined) update.registerPipTile(media.pip);
const tiles = update.build();

Expand Down
30 changes: 26 additions & 4 deletions src/state/TileStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,29 @@ class SpotlightTileData {
this.maximised$.next(value);
}

private readonly bgStyle$: BehaviorSubject<"solid" | "transparent">;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Maybe worth extracting a type given that "solid" | "transparent" occurs in multiple places?

public get bgStyle(): "solid" | "transparent" {
return this.bgStyle$.value;
}
public set bgStyle(value: "solid" | "transparent") {
this.bgStyle$.next(value);
}

public readonly vm: SpotlightTileViewModel;

public constructor(media: MediaViewModel[], maximised: boolean) {
public constructor(
media: MediaViewModel[],
maximised: boolean,
bgStyle: "solid" | "transparent",
) {
this.media$ = new BehaviorSubject(media);
this.maximised$ = new BehaviorSubject(maximised);
this.vm = new SpotlightTileViewModel(this.media$, this.maximised$);
this.bgStyle$ = new BehaviorSubject(bgStyle);
this.vm = new SpotlightTileViewModel(
this.media$,
this.maximised$,
this.bgStyle$,
);
}
}

Expand Down Expand Up @@ -157,7 +174,11 @@ export class TileStoreBuilder {
* Sets the contents of the spotlight tile. If this is never called, there
* will be no spotlight tile.
*/
public registerSpotlight(media: MediaViewModel[], maximised: boolean): void {
public registerSpotlight(
media: MediaViewModel[],
maximised: boolean,
bgStyle: "solid" | "transparent" = "solid",
): void {
if (DEBUG_ENABLED)
logger.debug(
`[TileStore, ${this.generation}] register spotlight: ${media.map((m) => m.displayName$.value)}`,
Expand All @@ -169,11 +190,12 @@ export class TileStoreBuilder {

// Reuse the previous spotlight tile if it exists
if (this.prevSpotlight === null) {
this.spotlight = new SpotlightTileData(media, maximised);
this.spotlight = new SpotlightTileData(media, maximised, bgStyle);
} else {
this.spotlight = this.prevSpotlight;
this.spotlight.media = media;
this.spotlight.maximised = maximised;
this.spotlight.bgStyle = bgStyle;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/state/TileViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class SpotlightTileViewModel {
public constructor(
public readonly media$: Behavior<MediaViewModel[]>,
public readonly maximised$: Behavior<boolean>,
public readonly bgStyle$: Behavior<"solid" | "transparent">,
) {}
}

Expand Down
5 changes: 4 additions & 1 deletion src/tile/MediaView.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ Please see LICENSE in the repository root for full details.

.bg {
grid-area: content;
background-color: var(--video-tile-background);
inline-size: 100%;
block-size: 100%;
border-radius: inherit;
contain: strict;
}

.media[data-bg-style="solid"] .bg {
background-color: var(--video-tile-background);
}

.avatar {
position: absolute;
top: 50%;
Expand Down
Loading