fix: separate header avatar from username
This commit is contained in:
1 parent
06cd0cfe42
commit
0bd2ac6707
4 files changed
+51
-10
No files matched your search
@@ -0,0 +1,21 @@
|
|||||||
|
import { renderToStaticMarkup } from "react-dom/server";
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { HeaderUserIdentity } from "./header-user-identity";
|
||||||
|
|
||||||
|
describe("HeaderUserIdentity", () => {
|
||||||
|
it("keeps the 40px head separated from the username", () => {
|
||||||
|
const html = renderToStaticMarkup(
|
||||||
|
<HeaderUserIdentity
|
||||||
|
figure="hd-180-1.hr-828-45"
|
||||||
|
username="Life"
|
||||||
|
textColor="#ffffff"
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(html).toContain("gap-2");
|
||||||
|
expect(html).toContain('width="40"');
|
||||||
|
expect(html).toContain('height="40"');
|
||||||
|
expect(html).toContain(">Life</span>");
|
||||||
|
expect(html).not.toContain("-ml-");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { UserAvatarThumbnail } from "@/components/shared/user-avatar-thumbnail";
|
||||||
|
|
||||||
|
interface HeaderUserIdentityProps {
|
||||||
|
figure: string;
|
||||||
|
username: string;
|
||||||
|
textColor: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function HeaderUserIdentity({
|
||||||
|
figure,
|
||||||
|
username,
|
||||||
|
textColor,
|
||||||
|
}: HeaderUserIdentityProps) {
|
||||||
|
return (
|
||||||
|
<span className="flex items-center gap-2">
|
||||||
|
<UserAvatarThumbnail figure={figure} alt="" options={{ direction: 2 }} />
|
||||||
|
<span
|
||||||
|
className="hidden sm:inline font-semibold"
|
||||||
|
style={{ color: textColor }}
|
||||||
|
>
|
||||||
|
{username}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ import { resolve } from "node:path";
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
const compactCallSites = new Map<string, number>([
|
const compactCallSites = new Map<string, number>([
|
||||||
["src/components/top-header.tsx", 2],
|
["src/components/top-header.tsx", 1],
|
||||||
["src/app/(site)/friends/page.tsx", 1],
|
["src/app/(site)/friends/page.tsx", 1],
|
||||||
["src/app/(site)/guilds/[id]/page.tsx", 1],
|
["src/app/(site)/guilds/[id]/page.tsx", 1],
|
||||||
["src/app/(site)/leaderboard/page.tsx", 1],
|
["src/app/(site)/leaderboard/page.tsx", 1],
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import Image from "next/image";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import type { Session } from "next-auth";
|
import type { Session } from "next-auth";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import { HeaderUserIdentity } from "@/components/header-user-identity";
|
||||||
import { RoomQuickEntry } from "@/components/room-quick-entry";
|
import { RoomQuickEntry } from "@/components/room-quick-entry";
|
||||||
import { UserAvatarThumbnail } from "@/components/shared/user-avatar-thumbnail";
|
import { UserAvatarThumbnail } from "@/components/shared/user-avatar-thumbnail";
|
||||||
import { signOut } from "@/lib/auth";
|
import { signOut } from "@/lib/auth";
|
||||||
@@ -317,17 +318,11 @@ export async function TopHeader({ session }: { session: Session | null }) {
|
|||||||
aria-label="User menu"
|
aria-label="User menu"
|
||||||
className="list-none cursor-pointer flex items-center [&::-webkit-details-marker]:hidden"
|
className="list-none cursor-pointer flex items-center [&::-webkit-details-marker]:hidden"
|
||||||
>
|
>
|
||||||
<UserAvatarThumbnail
|
<HeaderUserIdentity
|
||||||
figure={look}
|
figure={look}
|
||||||
alt=""
|
username={session.user.name ?? ""}
|
||||||
options={{ direction: 2 }}
|
textColor={textColor}
|
||||||
/>
|
/>
|
||||||
<span
|
|
||||||
className="hidden sm:inline font-semibold"
|
|
||||||
style={{ color: textColor }}
|
|
||||||
>
|
|
||||||
{session.user.name}
|
|
||||||
</span>
|
|
||||||
</summary>
|
</summary>
|
||||||
<div
|
<div
|
||||||
role="menu"
|
role="menu"
|
||||||
|
|||||||
Reference in new issue
Block a user