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

fix: truncate username #348

Merged
merged 6 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/Sidebar/panels/Notifications/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Notification = ({
</h4>
<h5 className="text-xs text-primary">{timestamp}</h5>
</header>
<p className="text-primary">{body}</p>
<p className="text-primary text-ellipsis overflow-hidden">{body}</p>
<div className="card-actions justify-end">
<DismissButton notificationId={notificationId} />
</div>
Expand Down
19 changes: 14 additions & 5 deletions components/profile/ProfileHead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@ const ProfileHead = ({
<ProfileImage username={username} isProfilePage hideLink />
</a>
<div className="flex flex-col">
<h2 className="normal-case font-bold">
{!displayName || username === displayName
? username
: `${displayName} — ${username}`}
</h2>
{!displayName || username === displayName ? (
<h2 className="normal-case font-bold overflow-hidden text-ellipsis">
{username}
</h2>
) : (
<div className="flex flex-col min-w-[200px] lg:max-w-[700px] md:max-w-[500px] sm:max-w-[300px]">
<h2 className="normal-case font-bold overflow-hidden text-ellipsis">
{displayName}
</h2>
<h2 className="normal-case font-bold overflow-hidden text-ellipsis">
{username}
</h2>
</div>
)}
{followers && (
<h3 className="normal-case">{formatNumber(followers)} followers</h3>
)}
Expand Down
14 changes: 8 additions & 6 deletions components/ui/UsernameLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ const UsernameLink = ({
username: string;
children?: React.ReactNode;
}) => (
<Link
className="link link-hover link-primary"
href={`/app/profile/${username}`}
>
{children ?? username}
</Link>
<h5 className="link-primary text-ellipsis overflow-hidden">
<Link
className="link link-hover link-primary"
href={`/app/profile/${username}`}
>
{children ?? username}
</Link>
</h5>
);

export default UsernameLink;