review fixes

This commit is contained in:
Luna D. 2024-12-17 19:35:47 +01:00
parent 6ca1c4bb74
commit 16540f57f0
No known key found for this signature in database
GPG key ID: 4B1C63448394F688
35 changed files with 103 additions and 112 deletions

View file

@ -6,6 +6,10 @@ $max-limited-desktop-width: 1150px;
$min-desktop-width: 800px; $min-desktop-width: 800px;
$limited-layout-width: 980px; $limited-layout-width: 980px;
$min-desktop-thumb-width: 700px; $min-desktop-thumb-width: 700px;
$image-tiny-size: 64px;
$image-small-size: 128px;
$image-medium-size: 256px;
$image-large-size: 512px;
:root { :root {
--medium-layout-width: $medium-layout-width; --medium-layout-width: $medium-layout-width;
@ -22,10 +26,10 @@ $min-desktop-thumb-width: 700px;
--padding-normal: 1em; --padding-normal: 1em;
--centered-margin: 24px; --centered-margin: 24px;
--normal-margin: 12px; --normal-margin: 12px;
--image-tiny-size: 64px; --image-tiny-size: $image-tiny-size;
--image-small-size: 128px; --image-small-size: $image-small-size;
--image-medium-size: 256px; --image-medium-size: $image-medium-size;
--image-large-size: 512px; --image-large-size: $image-large-size;
--header-height: 36px; --header-height: 36px;
--header-field-height: 28px; --header-field-height: 28px;
--header-sub-height: 32px; --header-sub-height: 32px;

View file

@ -1,8 +1,8 @@
@define-mixin image-alt-size $name, $size { @define-mixin image-alt-size $name, $size {
@media (min-width: $(size)) { @media (min-width: $size) {
img[alt="$(name)"] { img[alt="$(name)"] {
max-height: $(size) !important; max-height: $size !important;
max-width: $(size) !important; max-width: $size !important;
} }
} }
} }

View file

@ -329,10 +329,12 @@ blockquote blockquote blockquote blockquote blockquote blockquote {
margin-bottom: 6px; margin-bottom: 6px;
} }
@mixin image-alt-size tiny, var(--image-tiny-size); /* We need to use $variables here because @media tags
@mixin image-alt-size small, var(--image-small-size); * do not work with CSS3 custom properties (variables) */
@mixin image-alt-size medium, var(--image-medium-size); @mixin image-alt-size tiny, $image-tiny-size;
@mixin image-alt-size large, var(--image-large-size); @mixin image-alt-size small, $image-small-size;
@mixin image-alt-size medium, $image-medium-size;
@mixin image-alt-size large, $image-large-size;
/* code styling */ /* code styling */
/* You might be asking what's up with this silly mixin /* You might be asking what's up with this silly mixin

View file

@ -65,7 +65,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -64,7 +64,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -64,7 +64,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -64,7 +64,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -64,7 +64,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -65,7 +65,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -66,7 +66,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -64,7 +64,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -64,7 +64,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -48,7 +48,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -45,7 +45,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -46,7 +46,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -45,7 +45,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -45,7 +45,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -45,7 +45,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -45,7 +45,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -45,7 +45,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -45,7 +45,7 @@ $image-overlay-background-color: #000000;
/* Put any color variable overrides here. /* Put any color variable overrides here.
* *
* Note: due to (probably unintentional) behavior of Vite, * Note: due to (intentional and bad) behavior of Vite,
* this needs to contain something unique that the other * this needs to contain something unique that the other
* themes do not have, as Vite does not compile what it considers * themes do not have, as Vite does not compile what it considers
* "inputs with identical contents", and it does not seem to care * "inputs with identical contents", and it does not seem to care

View file

@ -347,10 +347,7 @@ defmodule Philomena.Users.User do
:show_sidebar_and_watched_images :show_sidebar_and_watched_images
]) ])
|> TagList.propagate_tag_list(:watched_tag_list, :watched_tag_ids) |> TagList.propagate_tag_list(:watched_tag_list, :watched_tag_ids)
|> validate_inclusion( |> validate_inclusion(:theme, themes())
:theme,
~W(dark-red dark-orange dark-yellow dark-blue dark-green dark-purple dark-cyan dark-pink dark-silver light-red light-orange light-yellow light-blue light-green light-purple light-cyan light-pink light-silver)
)
|> validate_inclusion(:images_per_page, 1..50) |> validate_inclusion(:images_per_page, 1..50)
|> validate_inclusion(:comments_per_page, 1..100) |> validate_inclusion(:comments_per_page, 1..100)
|> validate_inclusion(:scale_large_images, ["false", "partscaled", "true"]) |> validate_inclusion(:scale_large_images, ["false", "partscaled", "true"])
@ -606,4 +603,18 @@ defmodule Philomena.Users.User do
defp remove_backup_code(user, token), defp remove_backup_code(user, token),
do: user.otp_backup_codes |> Enum.reject(&Password.verify_pass(token, &1)) do: user.otp_backup_codes |> Enum.reject(&Password.verify_pass(token, &1))
def theme_colors do
~W(red orange yellow blue green purple cyan pink silver)
end
def theme_names do
~W(dark light)
end
def themes do
for name <- theme_names(), color <- theme_colors() do
"#{name}-#{color}"
end
end
end end

View file

@ -86,8 +86,9 @@ h1 Content Settings
label> Theme color label> Theme color
=> select f, :theme_color, theme_colors(), class: "input" => select f, :theme_color, theme_colors(), class: "input"
= error_tag f, :theme_color = error_tag f, :theme_color
.fieldlabel: i Color of the theme, don't forget to save settings to apply the theme .fieldlabel: i Color of the theme
.hidden#js-theme-paths data-theme-paths=theme_paths_json() .fieldlabel: strong Don't forget to save the settings to apply the theme!
.hidden#js-theme-paths data-theme-paths=theme_paths_json(@conn)
.field .field
=> label f, :scale_large_images => label f, :scale_large_images
=> select f, :scale_large_images, scale_options(), class: "input" => select f, :scale_large_images, scale_options(), class: "input"

View file

@ -4,8 +4,11 @@ defmodule PhilomenaWeb.LayoutView do
import PhilomenaWeb.Config import PhilomenaWeb.Config
alias PhilomenaWeb.ImageView alias PhilomenaWeb.ImageView
alias Philomena.Config alias Philomena.Config
alias Philomena.Users.User
alias Plug.Conn alias Plug.Conn
@themes User.themes()
def layout_class(conn) do def layout_class(conn) do
conn.assigns[:layout_class] || "layout--narrow" conn.assigns[:layout_class] || "layout--narrow"
end end
@ -70,26 +73,7 @@ defmodule PhilomenaWeb.LayoutView do
end end
def stylesheet_path(conn, %{theme: theme}) def stylesheet_path(conn, %{theme: theme})
when theme in [ when theme in @themes,
"dark-red",
"dark-orange",
"dark-yellow",
"dark-blue",
"dark-green",
"dark-purple",
"dark-cyan",
"dark-pink",
"dark-silver",
"light-red",
"light-orange",
"light-yellow",
"light-blue",
"light-green",
"light-purple",
"light-cyan",
"light-pink",
"light-silver"
],
do: static_path(conn, "/css/#{theme}.css") do: static_path(conn, "/css/#{theme}.css")
def stylesheet_path(_conn, _user), def stylesheet_path(_conn, _user),

View file

@ -1,5 +1,6 @@
defmodule PhilomenaWeb.SettingView do defmodule PhilomenaWeb.SettingView do
use PhilomenaWeb, :view use PhilomenaWeb, :view
alias Philomena.Users.User
def themes do def themes do
[ [
@ -9,40 +10,20 @@ defmodule PhilomenaWeb.SettingView do
end end
def theme_colors do def theme_colors do
[ Enum.map(User.theme_colors(), fn name ->
Red: "red", case name do
Orange: "orange", "silver" -> {"Silver/Charcoal", name}
Yellow: "yellow", _ -> {String.capitalize(name), name}
Green: "green", end
Blue: "blue", end)
Purple: "purple",
Cyan: "cyan",
Pink: "pink",
"Silver/Charcoal": "silver"
]
end end
def theme_paths_json do def theme_paths_json(conn) do
Jason.encode!(%{ User.themes()
"dark-red": ~p"/css/dark-red.css", |> Map.new(fn name ->
"dark-orange": ~p"/css/dark-orange.css", {name, static_path(conn, "/css/#{name}.css")}
"dark-yellow": ~p"/css/dark-yellow.css", end)
"dark-blue": ~p"/css/dark-blue.css", |> Jason.encode!()
"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 end
def scale_options do def scale_options do

View file

@ -5,11 +5,19 @@ defmodule Philomena.Repo.Migrations.ConvertUserThemes do
execute("update users set theme = 'light-blue' where theme = 'default';") execute("update users set theme = 'light-blue' where theme = 'default';")
execute("update users set theme = 'dark-blue' where theme = 'dark';") execute("update users set theme = 'dark-blue' where theme = 'dark';")
execute("update users set theme = 'dark-red' where theme = 'red';") execute("update users set theme = 'dark-red' where theme = 'red';")
alter table("users") do
modify :theme, :varchar, default: "dark-blue"
end
end end
def down do def down do
execute("update users set theme = 'default' where theme like 'light%';") execute("update users set theme = 'default' where theme like 'light%';")
execute("update users set theme = 'red' where theme = 'dark-red';") execute("update users set theme = 'red' where theme = 'dark-red';")
execute("update users set theme = 'dark' where theme like 'dark%';") execute("update users set theme = 'dark' where theme like 'dark%';")
alter table("users") do
modify :theme, :varchar, default: "default"
end
end end
end end