فهرست منبع

add hidePopover

visuddhinanda 1 سال پیش
والد
کامیت
ee3da38b86
1فایلهای تغییر یافته به همراه22 افزوده شده و 15 حذف شده
  1. 22 15
      dashboard-v4/dashboard/src/components/auth/User.tsx

+ 22 - 15
dashboard-v4/dashboard/src/components/auth/User.tsx

@@ -18,6 +18,7 @@ interface IWidget {
   showAvatar?: boolean;
   showName?: boolean;
   showUserName?: boolean;
+  hidePopover?: boolean;
 }
 const UserWidget = ({
   nickName,
@@ -26,8 +27,27 @@ const UserWidget = ({
   showAvatar = true,
   showName = true,
   showUserName = false,
+  hidePopover = false,
 }: IWidget) => {
-  return (
+  const inner = (
+    <Space>
+      {showAvatar ? (
+        <Avatar
+          size={"small"}
+          src={avatar}
+          style={{ backgroundColor: getAvatarColor(nickName) }}
+        >
+          {nickName?.slice(0, 2)}
+        </Avatar>
+      ) : undefined}
+      {showName ? <Text>{nickName}</Text> : undefined}
+      {showName && showUserName ? <Text>@</Text> : undefined}
+      {showUserName ? <Text>{userName}</Text> : undefined}
+    </Space>
+  );
+  return hidePopover ? (
+    inner
+  ) : (
     <Popover
       content={
         <div>
@@ -44,20 +64,7 @@ const UserWidget = ({
         </div>
       }
     >
-      <Space>
-        {showAvatar ? (
-          <Avatar
-            size={"small"}
-            src={avatar}
-            style={{ backgroundColor: getAvatarColor(nickName) }}
-          >
-            {nickName?.slice(0, 2)}
-          </Avatar>
-        ) : undefined}
-        {showName ? <Text>{nickName}</Text> : undefined}
-        {showName && showUserName ? <Text>@</Text> : undefined}
-        {showUserName ? <Text>{userName}</Text> : undefined}
-      </Space>
+      {inner}
     </Popover>
   );
 };