Add URL params to control fonts

This was also a good chance to switch to the semantic font size names used in Compound.
This commit is contained in:
Robin Townsend 2022-12-09 14:25:02 -05:00
commit acc41c532e
19 changed files with 156 additions and 58 deletions

View file

@ -21,30 +21,60 @@ export interface UrlParams {
roomAlias: string | null;
roomId: string | null;
viaServers: string[];
// Whether the app is running in embedded mode, and should keep the user
// confined to the current room
/**
* Whether the app is running in embedded mode, and should keep the user
* confined to the current room.
*/
isEmbedded: boolean;
// Whether the app should pause before joining the call until it sees an
// io.element.join widget action, allowing it to be preloaded
/**
* Whether the app should pause before joining the call until it sees an
* io.element.join widget action, allowing it to be preloaded.
*/
preload: boolean;
// Whether to hide the room header when in a call
/**
* Whether to hide the room header when in a call.
*/
hideHeader: boolean;
// Whether to hide the screen-sharing button
/**
* Whether to hide the screen-sharing button.
*/
hideScreensharing: boolean;
// Whether to start a walkie-talkie call instead of a video call
/**
* Whether to start a walkie-talkie call instead of a video call.
*/
isPtt: boolean;
// Whether to use end-to-end encryption
/**
* Whether to use end-to-end encryption.
*/
e2eEnabled: boolean;
// The user's ID (only used in matryoshka mode)
/**
* The user's ID (only used in matryoshka mode).
*/
userId: string | null;
// The display name to use for auto-registration
/**
* The display name to use for auto-registration.
*/
displayName: string | null;
// The device's ID (only used in matryoshka mode)
/**
* The device's ID (only used in matryoshka mode).
*/
deviceId: string | null;
// The base URL of the homeserver to use for media lookups in matryoshka mode
/**
* The base URL of the homeserver to use for media lookups in matryoshka mode.
*/
baseUrl: string | null;
// The BCP 47 code of the language the app should use
/**
* The BCP 47 code of the language the app should use.
*/
lang: string | null;
/**
* The fonts which the interface should use, if not empty.
*/
fonts: string[];
/**
* The factor by which to scale the interface's font size.
*/
fontScale: number | null;
}
/**
@ -81,6 +111,8 @@ export const getUrlParams = (
? fragment
: fragment.substring(0, fragmentQueryStart);
const fontScale = parseFloat(getParam("fontScale") ?? "");
return {
roomAlias: fragmentRoute.length > 1 ? fragmentRoute : null,
roomId: getParam("roomId"),
@ -96,6 +128,8 @@ export const getUrlParams = (
deviceId: getParam("deviceId"),
baseUrl: getParam("baseUrl"),
lang: getParam("lang"),
fonts: getAllParams("font"),
fontScale: Number.isNaN(fontScale) ? null : fontScale,
};
};