mirror of https://github.com/zulip/zulip.git
dark_theme: Re-render realm-logo on prefers-color-scheme changes.
We already re-rendered the realm-logo when the user selects either the light or dark color scheme, but on `color-scheme-automatic`, we didn't have any event handlers to trigger a render. This commit adds a handler to listen for changes to `prefers-color-scheme` property. Fixes #23548.
This commit is contained in:
parent
a3c5c97488
commit
7e883add5b
|
@ -99,3 +99,16 @@ export function render() {
|
||||||
$night_file_input,
|
$night_file_input,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function initialize() {
|
||||||
|
// render once
|
||||||
|
render();
|
||||||
|
|
||||||
|
// Rerender the realm-logo when the browser detects color scheme changes.
|
||||||
|
const dark_mode_media_query_list = window.matchMedia("(prefers-color-scheme: dark)");
|
||||||
|
dark_mode_media_query_list.addEventListener("change", () => {
|
||||||
|
if ($("body").hasClass("color-scheme-automatic")) {
|
||||||
|
render();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -609,8 +609,8 @@ export function initialize_everything() {
|
||||||
settings.initialize();
|
settings.initialize();
|
||||||
initialize_navbar();
|
initialize_navbar();
|
||||||
initialize_message_feed_errors();
|
initialize_message_feed_errors();
|
||||||
realm_logo.render();
|
|
||||||
|
|
||||||
|
realm_logo.initialize();
|
||||||
message_lists.initialize();
|
message_lists.initialize();
|
||||||
alert_words.initialize(alert_words_params);
|
alert_words.initialize(alert_words_params);
|
||||||
emojisets.initialize();
|
emojisets.initialize();
|
||||||
|
|
Loading…
Reference in New Issue