theme: Rename dark_theme.ts -> theme.ts.

The dark_theme module now contains logic for light, dark, and automatic
theme switching. Thus, we rename it a more generic name, `theme.ts`.
This commit is contained in:
Sayam Samal 2024-06-20 01:59:48 +05:30 committed by Tim Abbott
parent 05c61037c8
commit 2417155828
7 changed files with 14 additions and 14 deletions

View File

@ -91,7 +91,6 @@ EXEMPT_FILES = make_set(
"web/src/css_variables.d.ts",
"web/src/css_variables.js",
"web/src/custom_profile_fields_ui.ts",
"web/src/dark_theme.ts",
"web/src/debug.ts",
"web/src/demo_organizations_ui.js",
"web/src/deprecated_feature_notice.ts",
@ -248,6 +247,7 @@ EXEMPT_FILES = make_set(
"web/src/stream_ui_updates.js",
"web/src/submessage.ts",
"web/src/subscriber_api.ts",
"web/src/theme.ts",
"web/src/timerender.ts",
"web/src/tippyjs.ts",
"web/src/todo_widget.js",

View File

@ -5,11 +5,11 @@ import render_navbar_gear_menu_popover from "../templates/popovers/navbar/navbar
import * as blueslip from "./blueslip";
import * as channel from "./channel";
import * as dark_theme from "./dark_theme";
import * as popover_menus from "./popover_menus";
import * as popover_menus_data from "./popover_menus_data";
import * as popovers from "./popovers";
import * as settings_preferences from "./settings_preferences";
import * as theme from "./theme";
import {parse_html} from "./ui_util";
/*
@ -159,7 +159,7 @@ export function initialize() {
$popper.on("change", "input[name='theme-select']", (e) => {
const theme_code = Number.parseInt($(e.currentTarget).attr("data-theme-code"), 10);
requestAnimationFrame(() => {
dark_theme.set_theme_for_spectator(theme_code);
theme.set_theme_for_spectator(theme_code);
});
});
},

View File

@ -15,7 +15,6 @@ import * as compose_call_ui from "./compose_call_ui";
import * as compose_pm_pill from "./compose_pm_pill";
import * as compose_recipient from "./compose_recipient";
import * as compose_state from "./compose_state";
import * as dark_theme from "./dark_theme";
import * as emoji from "./emoji";
import * as emoji_picker from "./emoji_picker";
import * as gear_menu from "./gear_menu";
@ -77,6 +76,7 @@ import * as stream_topic_history from "./stream_topic_history";
import * as stream_ui_updates from "./stream_ui_updates";
import * as sub_store from "./sub_store";
import * as submessage from "./submessage";
import * as theme from "./theme";
import * as typing_events from "./typing_events";
import * as unread_ops from "./unread_ops";
import * as unread_ui from "./unread_ui";
@ -791,7 +791,7 @@ export function dispatch_normal_event(event) {
}
if (event.property === "color_scheme") {
requestAnimationFrame(() => {
dark_theme.set_theme_and_update(event.value);
theme.set_theme_and_update(event.value);
});
}
if (event.property === "starred_message_counts") {

View File

@ -35,7 +35,6 @@ import * as compose_tooltips from "./compose_tooltips";
import * as composebox_typeahead from "./composebox_typeahead";
import * as condense from "./condense";
import * as copy_and_paste from "./copy_and_paste";
import * as dark_theme from "./dark_theme";
import * as desktop_integration from "./desktop_integration";
import * as desktop_notifications from "./desktop_notifications";
import * as drafts from "./drafts";
@ -126,6 +125,7 @@ import * as stream_settings_ui from "./stream_settings_ui";
import * as stream_topic_history from "./stream_topic_history";
import * as stream_topic_history_util from "./stream_topic_history_util";
import * as sub_store from "./sub_store";
import * as theme from "./theme";
import * as timerender from "./timerender";
import * as tippyjs from "./tippyjs";
import * as topic_list from "./topic_list";
@ -422,7 +422,7 @@ export function initialize_everything(state_data) {
sidebar_ui.restore_sidebar_toggle_status();
information_density.initialize();
if (page_params.is_spectator) {
dark_theme.initialize_theme_for_spectator();
theme.initialize_theme_for_spectator();
}
i18n.initialize({language_list: page_params.language_list});

View File

@ -3,11 +3,11 @@ import {z} from "zod";
import * as channel from "./channel";
import * as compose_banner from "./compose_banner";
import * as dark_theme from "./dark_theme";
import * as feedback_widget from "./feedback_widget";
import {$t} from "./i18n";
import * as markdown from "./markdown";
import * as settings_config from "./settings_config";
import * as theme from "./theme";
/*
@ -68,7 +68,7 @@ export function switch_to_light_theme(): void {
on_success(raw_data) {
const data = data_schema.parse(raw_data);
requestAnimationFrame(() => {
dark_theme.set_theme_and_update(settings_config.color_scheme_values.day.code);
theme.set_theme_and_update(settings_config.color_scheme_values.day.code);
});
feedback_widget.show({
populate($container) {
@ -93,7 +93,7 @@ export function switch_to_dark_theme(): void {
on_success(raw_data) {
const data = data_schema.parse(raw_data);
requestAnimationFrame(() => {
dark_theme.set_theme_and_update(settings_config.color_scheme_values.night.code);
theme.set_theme_and_update(settings_config.color_scheme_values.night.code);
});
feedback_widget.show({
populate($container) {

View File

@ -29,7 +29,7 @@ const attachments_ui = mock_esm("../src/attachments_ui");
const audible_notifications = mock_esm("../src/audible_notifications");
const bot_data = mock_esm("../src/bot_data");
const compose_pm_pill = mock_esm("../src/compose_pm_pill");
const dark_theme = mock_esm("../src/dark_theme");
const theme = mock_esm("../src/theme");
const emoji_picker = mock_esm("../src/emoji_picker");
const gear_menu = mock_esm("../src/gear_menu");
const information_density = mock_esm("../src/information_density");
@ -969,7 +969,7 @@ run_test("user_settings", ({override}) => {
const stub = make_stub();
event = event_fixtures.user_settings__color_scheme_automatic;
user_settings.color_scheme = 2;
override(dark_theme, "set_theme_and_update", stub.f); // automatically checks if called
override(theme, "set_theme_and_update", stub.f); // automatically checks if called
dispatch(event);
const args = stub.get_args("color_scheme_code");
assert.equal(stub.num_calls, 1);
@ -980,7 +980,7 @@ run_test("user_settings", ({override}) => {
const stub = make_stub();
event = event_fixtures.user_settings__color_scheme_dark;
user_settings.color_scheme = 1;
override(dark_theme, "set_theme_and_update", stub.f); // automatically checks if called
override(theme, "set_theme_and_update", stub.f); // automatically checks if called
dispatch(event);
const args = stub.get_args("color_scheme_code");
assert.equal(stub.num_calls, 1);
@ -991,7 +991,7 @@ run_test("user_settings", ({override}) => {
const stub = make_stub();
event = event_fixtures.user_settings__color_scheme_light;
user_settings.color_scheme = 1;
override(dark_theme, "set_theme_and_update", stub.f); // automatically checks if called
override(theme, "set_theme_and_update", stub.f); // automatically checks if called
dispatch(event);
const args = stub.get_args("color_scheme_code");
assert.equal(stub.num_calls, 1);