feat: use dynamic units, minor refactoring

This commit is contained in:
JustTemmie 2025-06-11 17:42:35 +02:00
parent 22b43cde79
commit 5560680635
Signed by: justtemmie
SSH key fingerprint: SHA256:nBO+OwpTkd8LYhe38PIqdxmDvkIg9Vw2EbrRZM97dkU
12 changed files with 66 additions and 76 deletions

View file

@ -1,14 +1,13 @@
<template> <template>
<div> <div>
<input id="hidden-pfp-uploader" type="file" accept="image/*" style="display: none;">
<h1>My Account</h1> <h1>My Account</h1>
<div class="profile-and-user-data-fields"> <div class="profile-and-user-data-fields">
<div class="user-data-fields"> <div class="user-data-fields">
<p class="subtitle">AVATAR</p> <p class="subtitle">AVATAR</p>
<Button text="Change Avatar" :callback="changeAvatar"></Button> <Button text="Change Avatar" :callback="changeAvatar" style="margin-right: 0.8dvw;"></Button>
<Button text="Remove Avatar" :callback="removeAvatar" <Button text="Remove Avatar" :callback="removeAvatar" style="background-color: grey;"></Button>
style="margin-left: 10px; background-color: grey;"></Button>
<label for="profile-display-name-input" class="subtitle">DISPLAY NAME</label> <label for="profile-display-name-input" class="subtitle">DISPLAY NAME</label>
<input id="profile-display-name-input" class="profile-data-input" type="text" v-model="user.display_name" placeholder="Enter display name" /> <input id="profile-display-name-input" class="profile-data-input" type="text" v-model="user.display_name" placeholder="Enter display name" />
<label for="profile-username-input" class="subtitle">USERNAME</label> <label for="profile-username-input" class="subtitle">USERNAME</label>
@ -19,19 +18,13 @@
<input id="profile-about-me-input" class="profile-data-input" type="text" v-model="user.about" placeholder="About me" /> <input id="profile-about-me-input" class="profile-data-input" type="text" v-model="user.about" placeholder="About me" />
<br> <br>
<br> <Button style="margin-top: 1dvh" text="Save Changes" :callback="saveChanges"></Button>
<Button text="Save Changes" :callback="saveChanges"></Button>
</div> </div>
<Userpopup :user=user_me class="profile"></Userpopup>
<UserPopup :user=user class="profile-popup"></UserPopup>
</div> </div>
<!-- i love html --> <h2 style="margin-top: 8dvh">Password (and eventually authenticator)</h2>
<br>
<br>
<br>
<br>
<h2>Password (and eventually authenticator)</h2>
<Button text="Reset Password (tbd)" :callback=resetPassword></Button> <Button text="Reset Password (tbd)" :callback=resetPassword></Button>
<h2>Account Deletion</h2> <h2>Account Deletion</h2>
@ -41,22 +34,27 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import Button from '~/components/buttons/Button.vue'; import Button from '~/components/Buttons/Button.vue';
import ButtonScary from '~/components/buttons/ButtonScary.vue'; import ButtonScary from '~/components/Buttons/ButtonScary.vue';
import type { UserResponse } from '~/types/interfaces';
const { fetchUser } = useAuth(); const { fetchUser } = useAuth();
const user_me = await fetchUser() const user_me = await fetchUser()
let user_reference = Object.assign({}, user_me) if (user_me === undefined) {
const user = user_me! alert("could not fetch user info, aborting :(")
}
let new_pfp_file: any = null let userReference = Object.assign({}, user_me)
const user: UserResponse = user_me!
let newPfpFile: any = null
const saveChanges = async () => { const saveChanges = async () => {
const formData = new FormData() const formData = new FormData()
if (new_pfp_file !== null) { if (newPfpFile !== null) {
formData.append("avatar", new_pfp_file) formData.append("avatar", newPfpFile)
} }
const bytes = new TextEncoder().encode(JSON.stringify({ const bytes = new TextEncoder().encode(JSON.stringify({
@ -73,7 +71,7 @@ const saveChanges = async () => {
body: formData body: formData
}) })
user_reference = Object.assign({}, await fetchUser()) userReference = Object.assign({}, await fetchUser())
alert('success!!') alert('success!!')
} catch (error: any) { } catch (error: any) {
if (error?.response?.status !== 200) { if (error?.response?.status !== 200) {
@ -93,12 +91,12 @@ const changeAvatar = async () => {
input.type = 'file'; input.type = 'file';
input.accept = 'image/*'; input.accept = 'image/*';
input.onchange = async (e) => { input.addEventListener("change", (e: Event) => {
if (input.files?.length && input.files.length > 0) { if (input.files?.length && input.files.length > 0) {
const file = input.files[0]; const file = input.files[0];
if (!file) return; if (!file) return;
new_pfp_file = file newPfpFile = file
const reader = new FileReader(); const reader = new FileReader();
reader.onload = (e) => { reader.onload = (e) => {
@ -108,7 +106,7 @@ const changeAvatar = async () => {
}; };
reader.readAsDataURL(file); reader.readAsDataURL(file);
} }
} })
input.click() input.click()
} }
@ -124,38 +122,35 @@ const deleteAccount = async () => {
</script> </script>
<style scoped> <style scoped>
.profile-container {
min-width: 250px;
min-height: 200px;
padding: 8px;
border-radius: 8px;
}
.profile-and-user-data-fields { .profile-and-user-data-fields {
display: flex; display: flex;
} }
.profile-container,
.user-data-fields {
min-width: 350px;
}
.subtitle { .subtitle {
display: block; display: block;
font-size: 14px; font-size: 0.8em;
font-weight: 800; font-weight: 800;
margin: 12px 0; margin: 1.5dvh 0 0.5dvh 0.25dvw;
}
.user-data-fields {
min-width: 35dvw;
max-width: 35dvw;
} }
.profile-data-input { .profile-data-input {
min-width: 300px; min-width: 30dvw;
margin: 2px; margin: 2px;
padding: 2px 10px; padding: 0.1dvh 0.7dvw;
height: 40px; height: 2.5em;
font-size: 16px; font-size: 1em;
border-radius: 8px; border-radius: 8px;
border: none; border: none;
color: white; color: white;
background-color: #54361b; background-color: #54361b;
} }
.profile-popup {
margin-left: 2dvw;
}
</style> </style>

View file

@ -5,7 +5,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import Button from '~/components/buttons/Button.vue'; import Button from '~/components/Buttons/Button.vue';
</script> </script>
<style scoped> <style scoped>

View file

@ -4,13 +4,14 @@
<div id="cover-colour"></div> <div id="cover-colour"></div>
<div id="main-body"> <div id="main-body">
<p id="display-name"> <p id="display-name">
<strong>{{ props.user.display_name || "display_name" }}</strong> <strong>{{ props.user.display_name }}</strong>
</p> </p>
<p id="username-and-pronouns"> <p id="username-and-pronouns">
{{ props.user.username || "username" }} - {{ props.user.pronouns || "un/defined" }} {{ props.user.username }}
<span v-if="props.user.pronouns"> - {{ props.user.pronouns }}</span>
</p> </p>
<div id="about-me"> <div id="about-me">
{{ props.user.about || "about me" }} {{ props.user.about }}
</div> </div>
</div> </div>
</div> </div>
@ -22,7 +23,7 @@ import type { UserResponse } from '~/types/interfaces';
const { fetchMembers } = useApi(); const { fetchMembers } = useApi();
const props = defineProps<{ const props = defineProps<{
user: UserResponse | any, // actually UserResponse | null but TS is yelling at me again user: UserResponse
}>(); }>();
</script> </script>

View file

@ -26,7 +26,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { ref } from 'vue';
import ButtonScary from '~/components/buttons/ButtonScary.vue'; import ButtonScary from '~/components/Buttons/ButtonScary.vue';
const { logout } = useAuth() const { logout } = useAuth()
@ -40,15 +40,15 @@ interface Category {
pages: Page[]; pages: Page[];
} }
import Account from '~/components/settings/user_settings/Account.vue'; import Account from '~/components/Settings/UserSettings/Account.vue';
import Privacy from '~/components/settings/user_settings/Privacy.vue'; import Privacy from '~/components/Settings/UserSettings/Privacy.vue';
import Devices from '~/components/settings/user_settings/Devices.vue'; import Devices from '~/components/Settings/UserSettings/Devices.vue';
import Connections from '~/components/settings/user_settings/Connections.vue'; import Connections from '~/components/Settings/UserSettings/Connections.vue';
import Appearance from '~/components/settings/app_settings/Appearance.vue'; import Appearance from '~/components/Settings/AppSettings/Appearance.vue';
import Notifications from '~/components/settings/app_settings/Notifications.vue'; import Notifications from '~/components/Settings/AppSettings/Notifications.vue';
import Keybinds from '~/components/settings/app_settings/Keybinds.vue'; import Keybinds from '~/components/Settings/AppSettings/Keybinds.vue';
import Language from '~/components/settings/app_settings/Language.vue'; import Language from '~/components/Settings/AppSettings/Language.vue';
const settingsCategories = { const settingsCategories = {
user_settings: { user_settings: {
@ -97,11 +97,11 @@ const selectCategory = (_category: Category, page: Page) => {
} }
#sidebar { #sidebar {
min-width: 250px; min-width: 25dvw;
max-width: 250px; max-width: 25dvw;
background-color: #2f3136; background-color: #2f3136;
color: white; color: white;
padding: 10px; padding: 1dvh 1dvw;
margin-left: auto; margin-left: auto;
overflow-y: auto; overflow-y: auto;
@ -109,8 +109,8 @@ const selectCategory = (_category: Category, page: Page) => {
} }
#sidebar h2 { #sidebar h2 {
font-size: 2em; font-size: 0.8rem;
padding: 0 8px; padding: 0 0.8dvw;
} }
#sidebar ul { #sidebar ul {
@ -121,9 +121,8 @@ const selectCategory = (_category: Category, page: Page) => {
#sidebar li { #sidebar li {
border-radius: 8px; border-radius: 8px;
padding: 8px; padding: 0.8dvh 0.8dvw;
font-size: 1.3em; font-size: 1.1em;
margin: 2px 0;
cursor: pointer; cursor: pointer;
transition: background-color 0.3s; transition: background-color 0.3s;
} }
@ -138,8 +137,9 @@ const selectCategory = (_category: Category, page: Page) => {
#sub_page { #sub_page {
flex-grow: 1; flex-grow: 1;
max-width: 800px; min-width: 70dvw;
margin-left: 1.5rem; max-width: 70dvw;
padding-left: 1.5rem;
margin-right: auto; margin-right: auto;
overflow-y: auto; overflow-y: auto;
@ -149,18 +149,12 @@ const selectCategory = (_category: Category, page: Page) => {
.spacer { .spacer {
height: 2px; height: 2px;
display: block; display: block;
margin: 8px 10px; margin: 0.8dvh 1dvw;
background-color: #2c2e32; background-color: #2c2e32;
} }
.setting-item { /* applies to child pages too */
margin-bottom: 15px; :deep(h5) {
}
</style>
<!-- not scoped, these are used by children] -->
<style>
h5 {
color: red; color: red;
} }
</style> </style>