From 7373cbf1b95ccf1846cf68ab0a3634b5a06b610f Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Wed, 26 Jun 2024 23:20:26 +0100 Subject: [PATCH] Update custom avatar --- .../components/layouts/global/top-menu.tsx | 12 +++---- .../src/components/ui/custom-avatar.tsx | 32 +++++++++++++++++ apps/client/src/components/ui/user-avatar.tsx | 35 ------------------- .../comment/components/comment-dialog.tsx | 5 ++- .../comment/components/comment-list-item.tsx | 5 ++- .../group/components/group-members.tsx | 4 +-- .../group/components/multi-user-select.tsx | 5 ++- .../page-history/components/history-item.tsx | 5 ++- .../space/components/multi-member-select.tsx | 4 +-- .../features/space/components/space-grid.tsx | 10 ++++-- .../features/space/components/space-list.tsx | 8 +++-- .../space/components/space-members.tsx | 4 +-- .../user/components/account-avatar.tsx | 5 ++- .../components/workspace-invites-table.tsx | 2 +- .../components/workspace-members-table.tsx | 4 +-- 15 files changed, 68 insertions(+), 72 deletions(-) create mode 100644 apps/client/src/components/ui/custom-avatar.tsx delete mode 100644 apps/client/src/components/ui/user-avatar.tsx diff --git a/apps/client/src/components/layouts/global/top-menu.tsx b/apps/client/src/components/layouts/global/top-menu.tsx index 7c82f23..8977580 100644 --- a/apps/client/src/components/layouts/global/top-menu.tsx +++ b/apps/client/src/components/layouts/global/top-menu.tsx @@ -11,7 +11,7 @@ import { currentUserAtom } from "@/features/user/atoms/current-user-atom.ts"; import { Link } from "react-router-dom"; import APP_ROUTE from "@/lib/app-route.ts"; import useAuth from "@/features/auth/hooks/use-auth.ts"; -import { UserAvatar } from "@/components/ui/user-avatar.tsx"; +import { CustomAvatar } from "@/components/ui/custom-avatar.tsx"; export default function TopMenu() { const [currentUser] = useAtom(currentUserAtom); @@ -29,12 +29,11 @@ export default function TopMenu() { - {workspace.name} @@ -80,8 +79,7 @@ export default function TopMenu() { Account - (({ avatarUrl, name, ...props }: CustomAvatarProps, ref) => { + const avatarLink = getAvatarUrl(avatarUrl); + + return ( + + ); +}); diff --git a/apps/client/src/components/ui/user-avatar.tsx b/apps/client/src/components/ui/user-avatar.tsx deleted file mode 100644 index 17b5513..0000000 --- a/apps/client/src/components/ui/user-avatar.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React, { useRef } from "react"; -import { Avatar } from "@mantine/core"; -import { getAvatarUrl } from "@/lib/config.ts"; - -interface UserAvatarProps { - avatarUrl: string; - name: string; - color?: string; - size?: string | number; - radius?: string | number; - style?: any; - component?: any; -} - -export const UserAvatar = React.forwardRef( - ({ avatarUrl, name, ...props }: UserAvatarProps, ref) => { - const avatar = getAvatarUrl(avatarUrl); - - const getInitials = (name: string) => { - const names = name?.split(" "); - return names - ?.slice(0, 2) - .map((n) => n[0]) - .join(""); - }; - - return avatar ? ( - - ) : ( - - {getInitials(name)} - - ); - }, -); diff --git a/apps/client/src/features/comment/components/comment-dialog.tsx b/apps/client/src/features/comment/components/comment-dialog.tsx index 312b89b..58b40e2 100644 --- a/apps/client/src/features/comment/components/comment-dialog.tsx +++ b/apps/client/src/features/comment/components/comment-dialog.tsx @@ -13,7 +13,7 @@ import { currentUserAtom } from "@/features/user/atoms/current-user-atom"; import { useCreateCommentMutation } from "@/features/comment/queries/comment-query"; import { asideStateAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom"; import { useEditor } from "@tiptap/react"; -import { UserAvatar } from "@/components/ui/user-avatar.tsx"; +import { CustomAvatar } from "@/components/ui/custom-avatar.tsx"; interface CommentDialogProps { editor: ReturnType; @@ -94,8 +94,7 @@ function CommentDialog({ editor, pageId }: CommentDialogProps) { > - - - +
{user.name} diff --git a/apps/client/src/features/group/components/multi-user-select.tsx b/apps/client/src/features/group/components/multi-user-select.tsx index fe05c3f..ba08aaa 100644 --- a/apps/client/src/features/group/components/multi-user-select.tsx +++ b/apps/client/src/features/group/components/multi-user-select.tsx @@ -3,7 +3,7 @@ import { useDebouncedValue } from "@mantine/hooks"; import { useWorkspaceMembersQuery } from "@/features/workspace/queries/workspace-query.ts"; import { IUser } from "@/features/user/types/user.types.ts"; import { Group, MultiSelect, MultiSelectProps, Text } from "@mantine/core"; -import { UserAvatar } from "@/components/ui/user-avatar.tsx"; +import { CustomAvatar } from "@/components/ui/custom-avatar.tsx"; interface MultiUserSelectProps { onChange: (value: string[]) => void; @@ -14,11 +14,10 @@ const renderMultiSelectOption: MultiSelectProps["renderOption"] = ({ option, }) => ( -
{option.label} diff --git a/apps/client/src/features/page-history/components/history-item.tsx b/apps/client/src/features/page-history/components/history-item.tsx index e4fefdf..eb348bd 100644 --- a/apps/client/src/features/page-history/components/history-item.tsx +++ b/apps/client/src/features/page-history/components/history-item.tsx @@ -1,5 +1,5 @@ import { Text, Group, UnstyledButton } from "@mantine/core"; -import { UserAvatar } from "@/components/ui/user-avatar"; +import { CustomAvatar } from "@/components/ui/custom-avatar.tsx"; import { formattedDate } from "@/lib/time"; import classes from "./history.module.css"; import clsx from "clsx"; @@ -25,8 +25,7 @@ function HistoryItem({ historyItem, onSelect, isActive }: HistoryItemProps) {
- ( {option["type"] === "user" && ( - - - {space.name.charAt(0).toUpperCase()} - + {space.name} diff --git a/apps/client/src/features/space/components/space-list.tsx b/apps/client/src/features/space/components/space-list.tsx index 49b287f..af3f8ad 100644 --- a/apps/client/src/features/space/components/space-list.tsx +++ b/apps/client/src/features/space/components/space-list.tsx @@ -34,9 +34,11 @@ export default function SpaceList() { > - - {space.name.charAt(0).toUpperCase()} - +
{space.name} diff --git a/apps/client/src/features/space/components/space-members.tsx b/apps/client/src/features/space/components/space-members.tsx index 042c083..e33d757 100644 --- a/apps/client/src/features/space/components/space-members.tsx +++ b/apps/client/src/features/space/components/space-members.tsx @@ -3,7 +3,7 @@ import { useParams } from "react-router-dom"; import React from "react"; import { IconDots } from "@tabler/icons-react"; import { modals } from "@mantine/modals"; -import { UserAvatar } from "@/components/ui/user-avatar.tsx"; +import { CustomAvatar } from "@/components/ui/custom-avatar.tsx"; import { useChangeSpaceMemberRoleMutation, useRemoveSpaceMemberMutation, @@ -109,7 +109,7 @@ export default function SpaceMembersList({ {member.type === "user" && ( - diff --git a/apps/client/src/features/user/components/account-avatar.tsx b/apps/client/src/features/user/components/account-avatar.tsx index ecb65a4..2bbeb01 100644 --- a/apps/client/src/features/user/components/account-avatar.tsx +++ b/apps/client/src/features/user/components/account-avatar.tsx @@ -2,7 +2,7 @@ import { focusAtom } from "jotai-optics"; import { currentUserAtom } from "@/features/user/atoms/current-user-atom.ts"; import { useState } from "react"; import { useAtom } from "jotai"; -import { UserAvatar } from "@/components/ui/user-avatar.tsx"; +import { CustomAvatar } from "@/components/ui/custom-avatar.tsx"; import { FileButton, Tooltip } from "@mantine/core"; import { uploadAvatar } from "@/features/user/services/user-service.ts"; @@ -37,10 +37,9 @@ export default function AccountAvatar() { {(props) => ( - - +
{invitation.email} diff --git a/apps/client/src/features/workspace/components/members/components/workspace-members-table.tsx b/apps/client/src/features/workspace/components/members/components/workspace-members-table.tsx index 841f5a1..a2b6e79 100644 --- a/apps/client/src/features/workspace/components/members/components/workspace-members-table.tsx +++ b/apps/client/src/features/workspace/components/members/components/workspace-members-table.tsx @@ -3,7 +3,7 @@ import { useChangeMemberRoleMutation, useWorkspaceMembersQuery, } from "@/features/workspace/queries/workspace-query.ts"; -import { UserAvatar } from "@/components/ui/user-avatar.tsx"; +import { CustomAvatar } from "@/components/ui/custom-avatar.tsx"; import React from "react"; import RoleSelectMenu from "@/components/ui/role-select-menu.tsx"; import { @@ -51,7 +51,7 @@ export default function WorkspaceMembersTable() { - +
{user.name}