From e59ce136a631d71e7f41b601a3db057250ba2dc7 Mon Sep 17 00:00:00 2001 From: Ashraf Chowdury Date: Fri, 8 Nov 2024 11:18:49 +0600 Subject: [PATCH 1/2] fix(frontend): avatar profiles color --- agenta-web/src/components/Avatar/Avatar.tsx | 27 +++++++++++ agenta-web/src/components/Sidebar/Sidebar.tsx | 39 +++------------- .../evaluationCompare/EvaluationCompare.tsx | 10 ++--- agenta-web/src/lib/helpers/colors.ts | 45 ++++++++----------- 4 files changed, 56 insertions(+), 65 deletions(-) create mode 100644 agenta-web/src/components/Avatar/Avatar.tsx diff --git a/agenta-web/src/components/Avatar/Avatar.tsx b/agenta-web/src/components/Avatar/Avatar.tsx new file mode 100644 index 0000000000..8ac926b56c --- /dev/null +++ b/agenta-web/src/components/Avatar/Avatar.tsx @@ -0,0 +1,27 @@ +import React from "react" +import {Avatar as MainAvatar} from "antd" +import {getColorPairFromStr} from "@/lib/helpers/colors" +import {getInitials} from "@/lib/helpers/utils" + +type Props = { + name: string +} & React.ComponentProps + +const Avatar: React.FC = ({name, ...props}) => { + const color = getColorPairFromStr(name || "") + + return ( + + {getInitials(name)} + + ) +} + +export default Avatar diff --git a/agenta-web/src/components/Sidebar/Sidebar.tsx b/agenta-web/src/components/Sidebar/Sidebar.tsx index d9106b2aa5..a90e43fef6 100644 --- a/agenta-web/src/components/Sidebar/Sidebar.tsx +++ b/agenta-web/src/components/Sidebar/Sidebar.tsx @@ -1,17 +1,6 @@ import React, {useEffect, useMemo, useState} from "react" import {useRouter} from "next/router" -import { - Avatar, - Button, - Divider, - Dropdown, - Layout, - Menu, - Space, - Tag, - Tooltip, - Typography, -} from "antd" +import {Button, Divider, Dropdown, Layout, Menu, Space, Tag, Tooltip, Typography} from "antd" import Logo from "../Logo/Logo" import Link from "next/link" import {useAppTheme} from "../Layout/ThemeContextProvider" @@ -20,13 +9,13 @@ import {createUseStyles} from "react-jss" import {useLocalStorage} from "usehooks-ts" import {SidebarConfig, useSidebarConfig} from "./config" import {JSSTheme} from "@/lib/Types" -import {getColorFromStr} from "@/lib/helpers/colors" -import {getInitials, isDemo} from "@/lib/helpers/utils" +import {isDemo} from "@/lib/helpers/utils" import {useProfileData} from "@/contexts/profile.context" import {useSession} from "@/hooks/useSession" import {CaretDown, Gear, SignOut} from "@phosphor-icons/react" import AlertPopup from "../AlertPopup/AlertPopup" import {dynamicContext} from "@/lib/helpers/dynamic" +import Avatar from "@/components/Avatar/Avatar" const {Sider} = Layout const {Text} = Typography @@ -117,10 +106,6 @@ const useStyles = createUseStyles((theme: JSSTheme) => ({ }, }, }, - userAvatar: { - backgroundColor: theme.colorPrimaryBgHover, - color: theme.colorPrimary, - }, menuHeader: { padding: `${theme.paddingXS}px ${theme.padding}px`, color: theme.colorTextDescription, @@ -375,13 +360,7 @@ const Sidebar: React.FC = () => { key: org.id, label: ( - - {getInitials(org.name)} - + {org.name} ), @@ -428,15 +407,7 @@ const Sidebar: React.FC = () => { >