mirror of
https://github.com/element-hq/element-web.git
synced 2025-12-05 01:10:40 +00:00
* Improve screen reader accessibility of auth pages Using a combination of auto-focus + aria-live to ensure content is read as the states progress For https://element-io.atlassian.net/browse/PSB-971 Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update snapshot Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update snapshots Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix double landmark Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update screenshot Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
106 lines
3.4 KiB
TypeScript
106 lines
3.4 KiB
TypeScript
/*
|
|
Copyright 2019-2024 New Vector Ltd.
|
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import React from "react";
|
|
import classNames from "classnames";
|
|
|
|
import SdkConfig from "../../../SdkConfig";
|
|
import AuthFooter from "./AuthFooter";
|
|
|
|
interface IProps {
|
|
/**
|
|
* Whether to add a blurred shadow around the modal.
|
|
*
|
|
* If the modal component provides its own shadow or blurring, this can be
|
|
* disabled. Defaults to `true`.
|
|
*/
|
|
addBlur?: boolean;
|
|
}
|
|
|
|
export default class AuthPage extends React.PureComponent<React.PropsWithChildren<IProps>> {
|
|
private static welcomeBackgroundUrl?: string;
|
|
|
|
// cache the url as a static to prevent it changing without refreshing
|
|
private static getWelcomeBackgroundUrl(): string {
|
|
if (AuthPage.welcomeBackgroundUrl) return AuthPage.welcomeBackgroundUrl;
|
|
|
|
const brandingConfig = SdkConfig.getObject("branding");
|
|
AuthPage.welcomeBackgroundUrl = "themes/element/img/backgrounds/lake.jpg";
|
|
|
|
const configuredUrl = brandingConfig?.get("welcome_background_url");
|
|
if (configuredUrl) {
|
|
if (Array.isArray(configuredUrl)) {
|
|
const index = Math.floor(Math.random() * configuredUrl.length);
|
|
AuthPage.welcomeBackgroundUrl = configuredUrl[index];
|
|
} else {
|
|
AuthPage.welcomeBackgroundUrl = configuredUrl;
|
|
}
|
|
}
|
|
|
|
return AuthPage.welcomeBackgroundUrl;
|
|
}
|
|
|
|
public render(): React.ReactElement {
|
|
const pageStyle = {
|
|
background: `center/cover fixed url(${AuthPage.getWelcomeBackgroundUrl()})`,
|
|
};
|
|
|
|
const modalStyle: React.CSSProperties = {
|
|
position: "relative",
|
|
background: "initial",
|
|
};
|
|
|
|
const blurStyle: React.CSSProperties = {
|
|
position: "absolute",
|
|
top: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
left: 0,
|
|
filter: "blur(40px)",
|
|
background: pageStyle.background,
|
|
};
|
|
|
|
const modalContentStyle: React.CSSProperties = {
|
|
display: "flex",
|
|
zIndex: 1,
|
|
borderRadius: "8px",
|
|
};
|
|
|
|
let modalBlur;
|
|
if (this.props.addBlur !== false) {
|
|
// Blur out the background: add a `div` which covers the content behind the modal,
|
|
// and blurs it out, and make the modal's background semitransparent.
|
|
modalBlur = <div className="mx_AuthPage_modalBlur" style={blurStyle} />;
|
|
modalContentStyle.background = "rgba(255, 255, 255, 0.59)";
|
|
}
|
|
|
|
const modalClasses = classNames({
|
|
mx_AuthPage_modal: true,
|
|
mx_AuthPage_modal_withBlur: this.props.addBlur !== false,
|
|
});
|
|
|
|
return (
|
|
<div className="mx_AuthPage" style={pageStyle}>
|
|
<div className={modalClasses} style={modalStyle}>
|
|
{modalBlur}
|
|
<main
|
|
className="mx_AuthPage_modalContent"
|
|
style={modalContentStyle}
|
|
tabIndex={-1}
|
|
aria-live="polite"
|
|
>
|
|
{this.props.children}
|
|
</main>
|
|
</div>
|
|
<AuthFooter />
|
|
</div>
|
|
);
|
|
}
|
|
}
|