feat: avatars

This commit is contained in:
2025-05-12 16:16:26 +03:00
parent ac1b7338f8
commit c72ce9baa4
9 changed files with 30 additions and 3 deletions

BIN
src/assets/status/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1012 KiB

BIN
src/assets/status/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
src/assets/status/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 KiB

BIN
src/assets/status/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
src/assets/status/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 973 KiB

View File

@@ -1,5 +1,6 @@
import { useAppContext } from "@/providers/AuthProvider"; import { useAppContext } from "@/providers/AuthProvider";
import apiClient from "@/services/api"; import apiClient from "@/services/api";
import { getAvatarPicUrl } from "@/services/avatar-pic";
import { cn } from "@/utils/class-merge"; import { cn } from "@/utils/class-merge";
import { CalendarDaysIcon, ListBulletIcon, UserIcon } from "@heroicons/react/24/solid"; import { CalendarDaysIcon, ListBulletIcon, UserIcon } from "@heroicons/react/24/solid";
import { FunctionComponent, h } from "preact"; import { FunctionComponent, h } from "preact";
@@ -84,7 +85,9 @@ const Avatar: FunctionComponent = () => {
"h-full flex-row items-center justify-around rounded-[3rem] bg-[linear-gradient(180.00deg,rgba(249,134,143,0.5)_3.053%,rgb(228,242,252)_96.183%)] px-5 py-5 md:flex" "h-full flex-row items-center justify-around rounded-[3rem] bg-[linear-gradient(180.00deg,rgba(249,134,143,0.5)_3.053%,rgb(228,242,252)_96.183%)] px-5 py-5 md:flex"
)} )}
> >
<div class="my-5 aspect-square h-full rounded-full bg-white"></div> <div class="my-5 aspect-square h-full rounded-full">
<img class="size-full rounded-full" src={getAvatarPicUrl(status)} alt="avatar" />
</div>
<div class="flex flex-col items-center justify-center"> <div class="flex flex-col items-center justify-center">
<p class="text-3xl font-semibold">{username}</p> <p class="text-3xl font-semibold">{username}</p>
<div class="rounded-[1rem] bg-white px-5 leading-5 font-light italic">{status}</div> <div class="rounded-[1rem] bg-white px-5 leading-5 font-light italic">{status}</div>

View File

@@ -5,7 +5,7 @@
} }
#avatar { #avatar {
@apply flex aspect-square h-[7rem] flex-col items-center justify-center rounded-full bg-white; @apply flex aspect-square h-[7rem] flex-col items-center justify-center rounded-full;
} }
.profile_container { .profile_container {

View File

@@ -4,6 +4,7 @@ import { withTitle } from "@/constructors/Component";
import { UrlsTitle } from "@/enums/urls"; import { UrlsTitle } from "@/enums/urls";
import { useAppContext } from "@/providers/AuthProvider"; import { useAppContext } from "@/providers/AuthProvider";
import apiClient from "@/services/api"; import apiClient from "@/services/api";
import { getAvatarPicUrl } from "@/services/avatar-pic";
import { cn } from "@/utils/class-merge"; import { cn } from "@/utils/class-merge";
import { ArrowRightStartOnRectangleIcon, Cog8ToothIcon } from "@heroicons/react/24/outline"; import { ArrowRightStartOnRectangleIcon, Cog8ToothIcon } from "@heroicons/react/24/outline";
import { FunctionComponent } from "preact"; import { FunctionComponent } from "preact";
@@ -72,7 +73,9 @@ const ProfileSettings: FunctionComponent = () => {
<div class={classes.container}> <div class={classes.container}>
<ModalSettings isOpen={isSettingsOpen} setIsOpen={setIsSettingsOpen} onClose={fetchUserData} /> <ModalSettings isOpen={isSettingsOpen} setIsOpen={setIsSettingsOpen} onClose={fetchUserData} />
<div class="flex w-full flex-col items-center rounded-[4rem] bg-[linear-gradient(180.00deg,rgb(251,194,199),rgba(206,232,251,0.72)_100%)] px-7 py-5 shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] md:flex-row"> <div class="flex w-full flex-col items-center rounded-[4rem] bg-[linear-gradient(180.00deg,rgb(251,194,199),rgba(206,232,251,0.72)_100%)] px-7 py-5 shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] md:flex-row">
<div id={classes.avatar}>"Аватар"</div> <div id={classes.avatar}>
<img class="size-28 rounded-full" src={getAvatarPicUrl(userData.status)} alt="avatar" />
</div>
<div class={classes.header_block__name}> <div class={classes.header_block__name}>
<p class="text-4xl font-semibold">{userData.username}</p> <p class="text-4xl font-semibold">{userData.username}</p>
<p class="text-2xl font-light">{userData.status}</p> <p class="text-2xl font-light">{userData.status}</p>

View File

@@ -0,0 +1,21 @@
import Status1 from "@/assets/status/1.png";
import Status2 from "@/assets/status/2.png";
import Status3 from "@/assets/status/3.png";
import Status4 from "@/assets/status/4.png";
import Status5 from "@/assets/status/5.png";
export const getAvatarPicUrl = (status: string) => {
switch (true) {
case status.includes("точно"):
return Status1;
case status.includes("плана нет"):
return Status2;
case status.includes("прокрастинации"):
return Status3;
case status.includes("3000"):
return Status4;
case status.includes("планирования"):
return Status5;
default:
return Status1;
}
};