settings: Add automatic theme detection feature.

With this implementation of the feature of the automatic theme
detection, we make the following changes in the backend, frontend and
documentation.

This replaces the previous night_mode boolean with an enum, with the
default value being to use the prefers-color-scheme feature of the
operating system to determine which theme to use.

Fixes: #14451.

Co-authored-by: @kPerikou <44238834+kPerikou@users.noreply.github.com>
This commit is contained in:
MariaGkoulta
2020-05-16 14:13:59 +03:00
committed by Tim Abbott
parent 9bd8ead32d
commit b10f156250
25 changed files with 185 additions and 61 deletions

View File

@@ -29,6 +29,8 @@ exports.set_up = function () {
$("#demote_inactive_streams").val(page_params.demote_inactive_streams);
$("#color_scheme").val(page_params.color_scheme);
$("#twenty_four_hour_time").val(JSON.stringify(page_params.twenty_four_hour_time));
$(".emojiset_choice[value=" + page_params.emojiset + "]").prop("checked", true);
@@ -82,6 +84,11 @@ exports.set_up = function () {
change_display_setting(data, '#display-settings-status');
});
$('#color_scheme').change(function () {
const data = {color_scheme: this.value};
change_display_setting(data, '#display-settings-status');
});
$('body').on('click', '.reload_link', function () {
window.location.reload();
});
@@ -146,8 +153,8 @@ exports.update_page = function () {
$("#left_side_userlist").prop('checked', page_params.left_side_userlist);
$("#default_language_name").text(page_params.default_language_name);
$("#translate_emoticons").prop('checked', page_params.translate_emoticons);
$("#night_mode").prop('checked', page_params.night_mode);
$("#twenty_four_hour_time").val(JSON.stringify(page_params.twenty_four_hour_time));
$("#color_scheme").val(JSON.stringify(page_params.color_scheme));
// TODO: Set emojiset selector here.
// Longer term, we'll want to automate this function