Allow the Login screen to use the dark theme (#31293)
* Allow the Login screen to use the dark theme There is a whole bunch of code dedicated to attempting to force a "light" theme onto the login view, even if the deployment is configured to prioritise the dark theme. Apparently this was done because, in the old days, the login view looked rubbish with the dark theme, but now it looks fine. Fixes https://github.com/element-hq/element-web/issues/31292 * Fix up background colour of auth screen in dark theme In dark theme, the background of the login/register/welcome box needs to be translucent black rather than translucent white. To make this work, I've moved the style from inline to CSS, and used a PostCSS variable to define the colour. * Fix up Welcome page colours in dark theme Make the text and image white, not black, in short. * Fix incorrect merge that will teach me to use the Github UI to address merge conflicts.
This commit is contained in:
committed by
GitHub
parent
8753a9136f
commit
5f07fbbc1b
@@ -47,7 +47,6 @@ import PageType from "../../PageTypes";
|
||||
import createRoom, { type IOpts } from "../../createRoom";
|
||||
import { _t, _td } from "../../languageHandler";
|
||||
import SettingsStore from "../../settings/SettingsStore";
|
||||
import ThemeController from "../../settings/controllers/ThemeController";
|
||||
import { startAnyRegistrationFlow } from "../../Registration";
|
||||
import AutoDiscoveryUtils from "../../utils/AutoDiscoveryUtils";
|
||||
import { calculateRoomVia, makeRoomPermalink } from "../../utils/permalinks/Permalinks";
|
||||
@@ -1016,8 +1015,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||
newState.isMobileRegistration = isMobileRegistration;
|
||||
|
||||
this.setStateForNewView(newState);
|
||||
ThemeController.isLogin = true;
|
||||
this.themeWatcher?.recheck();
|
||||
this.notifyNewScreen(isMobileRegistration ? "mobile_register" : "register");
|
||||
}
|
||||
|
||||
@@ -1089,8 +1086,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||
roomJustCreatedOpts: roomInfo.justCreatedOpts,
|
||||
},
|
||||
() => {
|
||||
ThemeController.isLogin = false;
|
||||
this.themeWatcher?.recheck();
|
||||
this.notifyNewScreen("room/" + presentedId, replaceLast);
|
||||
},
|
||||
);
|
||||
@@ -1115,8 +1110,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||
view: Views.WELCOME,
|
||||
});
|
||||
this.notifyNewScreen("welcome");
|
||||
ThemeController.isLogin = true;
|
||||
this.themeWatcher?.recheck();
|
||||
}
|
||||
|
||||
private viewLogin(otherState?: any): void {
|
||||
@@ -1125,8 +1118,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||
...otherState,
|
||||
});
|
||||
this.notifyNewScreen("login");
|
||||
ThemeController.isLogin = true;
|
||||
this.themeWatcher?.recheck();
|
||||
}
|
||||
|
||||
private viewHome(justRegistered = false): void {
|
||||
@@ -1138,8 +1129,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||
});
|
||||
this.setPage(PageType.HomePage);
|
||||
this.notifyNewScreen("home");
|
||||
ThemeController.isLogin = false;
|
||||
this.themeWatcher?.recheck();
|
||||
}
|
||||
|
||||
private viewUser(userId: string, subAction: string): void {
|
||||
@@ -1414,8 +1403,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||
* crypto is disabled.) XXX: is this a bug or a feature?
|
||||
*/
|
||||
private async onLoggedIn(): Promise<void> {
|
||||
ThemeController.isLogin = false;
|
||||
this.themeWatcher?.recheck();
|
||||
StorageManager.tryPersistStorage();
|
||||
|
||||
await this.onShowPostLoginScreen();
|
||||
|
||||
@@ -14,5 +14,5 @@ const matrixSvg = require("../../../res/img/matrix.svg").default;
|
||||
* Intended to replace $matrixLogo in the welcome page.
|
||||
*/
|
||||
export const MATRIX_LOGO_HTML = `<a href="https://matrix.org" target="_blank" rel="noreferrer noopener">
|
||||
<img width="79" height="34" alt="Matrix" style="padding-left: 1px;vertical-align: middle" src="${matrixSvg}"/>
|
||||
<img class="mx_WelcomePage_logo" width="79" height="34" alt="Matrix" style="padding-left: 1px;vertical-align: middle" src="${matrixSvg}"/>
|
||||
</a>`;
|
||||
|
||||
@@ -75,9 +75,8 @@ export default class AuthPage extends React.PureComponent<React.PropsWithChildre
|
||||
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.
|
||||
// and blurs it out.
|
||||
modalBlur = <div className="mx_AuthPage_modalBlur" style={blurStyle} />;
|
||||
modalContentStyle.background = "rgba(255, 255, 255, 0.59)";
|
||||
}
|
||||
|
||||
const modalClasses = classNames({
|
||||
|
||||
@@ -12,8 +12,6 @@ import { DEFAULT_THEME, enumerateThemes } from "../../theme";
|
||||
import { type SettingLevel } from "../SettingLevel";
|
||||
|
||||
export default class ThemeController extends SettingController {
|
||||
public static isLogin = false;
|
||||
|
||||
public getValueOverride(
|
||||
level: SettingLevel,
|
||||
roomId: string,
|
||||
@@ -22,8 +20,6 @@ export default class ThemeController extends SettingController {
|
||||
): any {
|
||||
if (!calculatedValue) return null; // Don't override null themes
|
||||
|
||||
if (ThemeController.isLogin) return "light";
|
||||
|
||||
const themes = enumerateThemes();
|
||||
// Override in case some no longer supported theme is stored here
|
||||
if (!themes[calculatedValue]) {
|
||||
|
||||
@@ -13,7 +13,6 @@ import { TypedEventEmitter } from "matrix-js-sdk/src/matrix";
|
||||
import SettingsStore from "../SettingsStore";
|
||||
import dis from "../../dispatcher/dispatcher";
|
||||
import { Action } from "../../dispatcher/actions";
|
||||
import ThemeController from "../controllers/ThemeController";
|
||||
import { findHighContrastTheme } from "../../theme";
|
||||
import { type ActionPayload } from "../../dispatcher/payloads";
|
||||
import { SettingLevel } from "../SettingLevel";
|
||||
@@ -88,15 +87,6 @@ export default class ThemeWatcher extends TypedEventEmitter<ThemeWatcherEvent, T
|
||||
public getEffectiveTheme(): string {
|
||||
// Dev note: Much of this logic is replicated in the AppearanceUserSettingsTab
|
||||
|
||||
// XXX: checking the isLight flag here makes checking it in the ThemeController
|
||||
// itself completely redundant since we just override the result here and we're
|
||||
// now effectively just using the ThemeController as a place to store the static
|
||||
// variable. The system theme setting probably ought to have an equivalent
|
||||
// controller that honours the same flag, although probably better would be to
|
||||
// have the theme logic in one place rather than split between however many
|
||||
// different places.
|
||||
if (ThemeController.isLogin) return "light";
|
||||
|
||||
// If the user has specifically enabled the system matching option (excluding default),
|
||||
// then use that over anything else. We pick the lowest possible level for the setting
|
||||
// to ensure the ordering otherwise works.
|
||||
|
||||
Reference in New Issue
Block a user