add: mirror other user's theme when viewing other user profiles

fix: community/profile name sizing
This commit is contained in:
trisua 2025-04-09 19:25:41 -04:00
parent f49cc80886
commit b78508ee15
13 changed files with 70 additions and 34 deletions

8
Cargo.lock generated
View file

@ -3155,7 +3155,7 @@ dependencies = [
[[package]] [[package]]
name = "tetratto" name = "tetratto"
version = "0.1.0" version = "1.0.0"
dependencies = [ dependencies = [
"axum", "axum",
"axum-extra", "axum-extra",
@ -3179,7 +3179,7 @@ dependencies = [
[[package]] [[package]]
name = "tetratto-core" name = "tetratto-core"
version = "0.1.0" version = "1.0.0"
dependencies = [ dependencies = [
"async-recursion", "async-recursion",
"bb8-postgres", "bb8-postgres",
@ -3198,7 +3198,7 @@ dependencies = [
[[package]] [[package]]
name = "tetratto-l10n" name = "tetratto-l10n"
version = "0.1.0" version = "1.0.0"
dependencies = [ dependencies = [
"pathbufd", "pathbufd",
"serde", "serde",
@ -3207,7 +3207,7 @@ dependencies = [
[[package]] [[package]]
name = "tetratto-shared" name = "tetratto-shared"
version = "0.1.0" version = "1.0.0"
dependencies = [ dependencies = [
"ammonia", "ammonia",
"chrono", "chrono",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "tetratto" name = "tetratto"
version = "0.1.0" version = "1.0.0"
edition = "2024" edition = "2024"
[features] [features]

View file

@ -158,15 +158,16 @@ p {
} }
.name { .name {
max-width: 200px; max-width: 250px;
overflow: hidden; overflow: hidden;
overflow-wrap: break-word; /* overflow-wrap: break-word; */
overflow-wrap: anywhere;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
@media screen and (min-width: 901px) { @media screen and (min-width: 901px) {
.name.shorter { .name.shorter {
max-width: 180px; max-width: 215px;
} }
.name.lg\:long { .name.lg\:long {

View file

@ -38,7 +38,7 @@
<div class="w-full flex gap-4 flex-collapse"> <div class="w-full flex gap-4 flex-collapse">
<div <div
class="lhs flex flex-col gap-2 sm:w-full" class="lhs flex flex-col gap-2 sm:w-full"
style="width: 20rem; min-width: 20rem" style="width: 22rem; min-width: 22rem"
> >
<div class="card-nest w-full"> <div class="card-nest w-full">
<div class="card flex gap-2" id="community_avatar_and_name"> <div class="card flex gap-2" id="community_avatar_and_name">

View file

@ -190,20 +190,26 @@
</div> </div>
<form <form
class="card flex gap-2 flex-row flex-wrap items-center" class="card flex flex-col gap-2"
method="post" method="post"
enctype="multipart/form-data" enctype="multipart/form-data"
onsubmit="upload_banner(event)" onsubmit="upload_banner(event)"
> >
<input <div class="flex gap-2 flex-row flex-wrap items-center">
id="banner_file" <input
name="file" id="banner_file"
type="file" name="file"
accept="image/png,image/jpeg,image/avif,image/webp" type="file"
class="w-content" accept="image/png,image/jpeg,image/avif,image/webp"
/> class="w-content"
/>
<button class="primary">{{ icon "check" }}</button> <button class="primary">{{ icon "check" }}</button>
</div>
<span class="fade"
>Use an image of 1100x350px for the best results.</span
>
</form> </form>
</div> </div>
</div> </div>

View file

@ -30,7 +30,7 @@ border_radius="var(--radius)") -%}
title="{{ username }}'s banner" title="{{ username }}'s banner"
src="/api/v1/auth/user/{{ username }}/banner" src="/api/v1/auth/user/{{ username }}/banner"
alt="@{{ username }}'s banner" alt="@{{ username }}'s banner"
class="banner shadow" class="banner shadow w-full"
loading="lazy" loading="lazy"
style="border-radius: {{ border_radius }};" style="border-radius: {{ border_radius }};"
/> />
@ -294,7 +294,7 @@ show_community and post.community != config.town_square %}
{{ icon "check" }} {{ icon "check" }}
<span>{{ text "notifs:action.mark_as_read" }}</span> <span>{{ text "notifs:action.mark_as_read" }}</span>
</button> </button>
{% endif %} {% endif %}b
<button <button
class="red tertiary" class="red tertiary"
@ -464,4 +464,20 @@ user.settings.theme_hue %}
--lit: {{ user.settings.theme_lit }} !important; --lit: {{ user.settings.theme_lit }} !important;
} }
</style> </style>
<script>
function match_user_theme() {
const pref = "{{ profile.settings.theme_preference }}".toLowercase();
if (pref === "auto") {
return;
}
document.documentElement.className = pref;
}
setTimeout(() => {
match_user_theme();
}, 150);
</script>
{% endif %} {%- endmacro %} {% endif %} {%- endmacro %}

View file

@ -38,7 +38,7 @@
<div class="w-full flex gap-4 flex-collapse"> <div class="w-full flex gap-4 flex-collapse">
<div <div
class="lhs flex flex-col gap-2 sm:w-full" class="lhs flex flex-col gap-2 sm:w-full"
style="width: 20rem; min-width: 20rem" style="width: 22rem; min-width: 22rem"
> >
<div class="card-nest w-full"> <div class="card-nest w-full">
<div class="card flex gap-2" id="user_avatar_and_name"> <div class="card flex gap-2" id="user_avatar_and_name">

View file

@ -256,20 +256,26 @@
</div> </div>
<form <form
class="card flex gap-2 flex-row flex-wrap items-center" class="card flex flex-col gap-2"
method="post" method="post"
enctype="multipart/form-data" enctype="multipart/form-data"
onsubmit="upload_banner(event)" onsubmit="upload_banner(event)"
> >
<input <div class="flex gap-2 flex-row flex-wrap items-center">
id="banner_file" <input
name="file" id="banner_file"
type="file" name="file"
accept="image/png,image/jpeg,image/avif,image/webp" type="file"
class="w-content" accept="image/png,image/jpeg,image/avif,image/webp"
/> class="w-content"
/>
<button class="primary">{{ icon "check" }}</button> <button class="primary">{{ icon "check" }}</button>
</div>
<span class="fade"
>Use an image of 1100x350px for the best results.</span
>
</form> </form>
</div> </div>
</div> </div>
@ -654,6 +660,7 @@
ui.generate_settings_ui( ui.generate_settings_ui(
profile_settings, profile_settings,
[ [
[[], "Privacy", "title"],
[ [
[ [
"private_profile", "private_profile",
@ -675,6 +682,7 @@
"{{ profile.settings.private_last_seen }}", "{{ profile.settings.private_last_seen }}",
"checkbox", "checkbox",
], ],
[[], "Theme", "title"],
[ [
["theme_hue", "Theme hue (integer 0-255)"], ["theme_hue", "Theme hue (integer 0-255)"],
"{{ profile.settings.theme_hue }}", "{{ profile.settings.theme_hue }}",

View file

@ -751,6 +751,11 @@ media_theme_pref();
}); });
self.define("render_settings_ui_field", (_, into_element, option) => { self.define("render_settings_ui_field", (_, into_element, option) => {
if (option.input_element_type === "title") {
into_element.innerHTML += `<hr class="margin" /><b>${option.value}</b>`;
return;
}
if (option.input_element_type === "checkbox") { if (option.input_element_type === "checkbox") {
into_element.innerHTML += `<div class="card flex gap-2"> into_element.innerHTML += `<div class="card flex gap-2">
<input <input

View file

@ -1,6 +1,6 @@
[package] [package]
name = "tetratto-core" name = "tetratto-core"
version = "0.1.0" version = "1.0.0"
edition = "2024" edition = "2024"
[features] [features]

View file

@ -1,6 +1,6 @@
[package] [package]
name = "tetratto-l10n" name = "tetratto-l10n"
version = "0.1.0" version = "1.0.0"
edition = "2024" edition = "2024"
authors.workspace = true authors.workspace = true
repository.workspace = true repository.workspace = true

View file

@ -1,6 +1,6 @@
[package] [package]
name = "tetratto-shared" name = "tetratto-shared"
version = "0.1.0" version = "1.0.0"
edition = "2024" edition = "2024"
authors.workspace = true authors.workspace = true
repository.workspace = true repository.workspace = true

View file

@ -3,8 +3,8 @@ description = "🐇 tetratto!"
color = "#c9b1bc" color = "#c9b1bc"
port = 4118 port = 4118
banned_hosts = [] banned_hosts = []
no_track = []
host = "http://localhost:4118" host = "http://localhost:4118"
no_track = []
banned_usernames = [ banned_usernames = [
"admin", "admin",
"owner", "owner",