Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIXED: Text overflows in the user management card details #9532 #9541

63 changes: 50 additions & 13 deletions src/components/Users/UserListAndCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import { useTranslation } from "react-i18next";
import Card from "@/CAREUI/display/Card";
import CareIcon from "@/CAREUI/icons/CareIcon";

import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";

import { Avatar } from "@/components/Common/Avatar";
import Tabs from "@/components/Common/Tabs";
import SearchInput from "@/components/Form/SearchInput";
Expand Down Expand Up @@ -77,30 +84,60 @@ const getNameAndStatusCard = (
showDetailsButton = false,
) => {
return (
<div>
<div className="w-full">
<div className="flex flex-row justify-between gap-x-3">
<div className="flex flex-col">
<div className="flex flex-col min-w-0 flex-1">
<div className="flex items-center gap-x-3">
<h1 id={`name-${user.username}`} className="text-base font-bold">
{formatName(user)}
</h1>
<div className="min-w-0 max-w-full sm:max-w-[200px] md:max-w-[300px] lg:max-w-[400px]">
<TooltipProvider delayDuration={200}>
<Tooltip>
<TooltipTrigger asChild>
<h1
id={`name-${user.username}`}
className="text-base font-bold text-ellipsis overflow-hidden whitespace-nowrap"
>
{formatName(user)}
</h1>
</TooltipTrigger>
<TooltipContent>
<p className="max-w-sm break-words">{formatName(user)}</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>

<div
className={classNames(
"flex items-center gap-2 rounded-full px-3 py-1",
"flex items-center gap-2 rounded-full px-3 py-1 shrink-0",
cur_online ? "bg-green-100" : "bg-gray-100",
)}
>
<UserStatusIndicator user={user} />
</div>
</div>
<span
className="text-sm text-gray-500"
id={`username-${user.username}`}
>
{user.username}
</span>

<div className="min-w-0 max-w-full sm:max-w-[200px] md:max-w-[300px] lg:max-w-[400px]">
<TooltipProvider delayDuration={200}>
<Tooltip>
<TooltipTrigger asChild>
<span
className="text-sm text-gray-500 block text-ellipsis overflow-hidden whitespace-nowrap"
id={`username-${user.username}`}
>
{user.username}
</span>
</TooltipTrigger>
<TooltipContent>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest a bit more styling to the tooltip content. Check the tooltip for Occupancy Badge in Facility for instance:

image

Copy link
Author

@piyushyadav0191 piyushyadav0191 Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I just added more styling and dynamic transitions on state and side. @Jacobjeevan

<p className="max-w-sm break-words">{user.username}</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
</div>

<div className="shrink-0">
{showDetailsButton && GetDetailsButton(user.username)}
</div>
<div>{showDetailsButton && GetDetailsButton(user.username)}</div>
</div>
</div>
);
Expand Down
Loading