mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
fix theme select for prod
This commit is contained in:
parent
2b13d6ebc3
commit
db88434d80
3 changed files with 32 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"],
|
||||
|
|
Loading…
Reference in a new issue