fix theme select for prod

This commit is contained in:
Luna D. 2024-07-03 22:00:12 +02:00
parent 2b13d6ebc3
commit db88434d80
No known key found for this signature in database
GPG key ID: 4B1C63448394F688
3 changed files with 32 additions and 1 deletions

View file

@ -13,6 +13,11 @@ export function setupSettings() {
const localCheckboxes = $$<HTMLInputElement>('[data-tab="local"] input[type="checkbox"]');
const themeSelect = assertNotNull($<HTMLSelectElement>('#user_theme_name'));
const themeColorSelect = assertNotNull($<HTMLSelectElement>('#user_theme_color'));
const themePaths: Record<string, string> = JSON.parse(
assertNotUndefined(
assertNotNull($<HTMLDivElement>('#js-theme-paths')).dataset.themePaths
)
);
const styleSheet = assertNotNull($<HTMLLinkElement>('#js-theme-stylesheet'));
// Local settings
@ -27,7 +32,7 @@ export function setupSettings() {
const themeName = assertNotUndefined(themeSelect.options[themeSelect.selectedIndex].value);
const themeColor = assertNotUndefined(themeColorSelect.options[themeColorSelect.selectedIndex].value);
styleSheet.href = `/css/${themeName}-${themeColor}.css`;
styleSheet.href = themePaths[`${themeName}-${themeColor}`];
};
themeSelect.addEventListener('change', themePreviewCallback);

View file

@ -93,6 +93,7 @@ h1 Content Settings
=> select f, :theme_color, theme_colors(), class: "input"
= error_tag f, :theme_color
.fieldlabel: i Color of the theme, don't forget to save settings to apply the theme
.hidden#js-theme-paths data-theme-paths=theme_paths_json()
.field
=> label f, :scale_large_images
.with-error

View file

@ -22,6 +22,31 @@ defmodule PhilomenaWeb.SettingView do
]
end
def theme_paths_json do
Jason.encode!(
%{
"dark-red": ~p"/css/dark-red.css",
"dark-orange": ~p"/css/dark-orange.css",
"dark-yellow": ~p"/css/dark-yellow.css",
"dark-blue": ~p"/css/dark-blue.css",
"dark-green": ~p"/css/dark-green.css",
"dark-purple": ~p"/css/dark-purple.css",
"dark-cyan": ~p"/css/dark-cyan.css",
"dark-pink": ~p"/css/dark-pink.css",
"dark-silver": ~p"/css/dark-silver.css",
"light-red": ~p"/css/light-red.css",
"light-orange": ~p"/css/light-orange.css",
"light-yellow": ~p"/css/light-yellow.css",
"light-blue": ~p"/css/light-blue.css",
"light-green": ~p"/css/light-green.css",
"light-purple": ~p"/css/light-purple.css",
"light-cyan": ~p"/css/light-cyan.css",
"light-pink": ~p"/css/light-pink.css",
"light-silver": ~p"/css/light-silver.css"
}
)
end
def scale_options do
[
[key: "Load full images on image pages", value: "false"],