Skip to content

Commit 77bd79b

Browse files
committed
Fix: avatar UI display error issue
1 parent 1450e81 commit 77bd79b

File tree

6 files changed

+60
-41
lines changed

6 files changed

+60
-41
lines changed

CHANGE_LOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
> 2023-09-13
66
7+
### Fixed
8+
9+
- Fix avatar UI display error issue
10+
711
### Changed
812

913
- Reconstruct some page module UI and migrate to shadcn/ui

CHANGE_LOG.zh_CN.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
> 2023-09-13
66
7+
### 修复
8+
9+
- 修复 avatar UI 显示错误问题
10+
711
### 调整
812

913
- 重构部分页面模块 UI,迁移到 shadcn/ui

src/components/menu/pc/handler/index.tsx

-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from "react";
2-
import type { DropdownOption } from "@ltopx/lx-ui";
32
import { checkAuth } from "@/lib/checkEnv";
43
import Tokens from "@/components/site/tokens";
54
import LicenseActivate from "./licenseActivate";
@@ -9,13 +8,6 @@ import Notice from "../../notice";
98
import Github from "./github";
109
import Telegram from "./telegram";
1110

12-
export const languages: DropdownOption[] = [
13-
{ label: "🇺🇸 English", value: "en" },
14-
{ label: "🇨🇳 简体中文", value: "zh-CN" },
15-
{ label: "🇭🇰 繁体中文", value: "zh-HK" },
16-
// { label: "🇯🇵 日本語", value: "ja" },
17-
];
18-
1911
export default function Handler() {
2012
return (
2113
<div className="border-t flex flex-col pt-2 gap-1 dark:border-white/20">
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import React from "react";
22
import { useLocale } from "next-intl";
33
import { useRouter } from "next-intl/client";
4-
import { Dropdown, DropdownOption } from "@ltopx/lx-ui";
4+
import { DropdownOption } from "@ltopx/lx-ui";
55
import Icon from "@/components/icon";
66
import { cn } from "@/lib";
77
import { useOpenStore } from "@/hooks/useOpen";
8+
import {
9+
DropdownMenu,
10+
DropdownMenuContent,
11+
DropdownMenuRadioGroup,
12+
DropdownMenuRadioItem,
13+
DropdownMenuTrigger,
14+
} from "@/components/ui/dropdown-menu";
815

916
export const languages: DropdownOption[] = [
1017
{ label: "🇺🇸 English", value: "en" },
@@ -34,28 +41,37 @@ export default function LanguageSelect({
3441
};
3542

3643
return (
37-
<Dropdown
38-
selectable
39-
side="top"
40-
options={languages}
41-
value={locale}
42-
onSelect={onLocaleChange}
43-
>
44-
<div className="flex flex-1 justify-center">
45-
<div
46-
className={cn(
47-
"w-8 h-8 flex justify-center items-center cursor-pointer transition-colors rounded-md",
48-
"hover:bg-gray-200/60",
49-
"dark:hover:bg-slate-700/70"
50-
)}
51-
>
52-
{loadingChangeLang ? (
53-
<Icon icon="loading_line" size={20} className="animate-spin" />
54-
) : (
55-
<Icon icon="translate_2_line" size={24} />
56-
)}
44+
<DropdownMenu>
45+
<DropdownMenuTrigger asChild>
46+
<div className="flex flex-1 justify-center">
47+
<div
48+
className={cn(
49+
"w-8 h-8 flex justify-center items-center cursor-pointer transition-colors rounded-md",
50+
"hover:bg-gray-200/60",
51+
"dark:hover:bg-slate-700/70"
52+
)}
53+
>
54+
{loadingChangeLang ? (
55+
<Icon icon="loading_line" size={20} className="animate-spin" />
56+
) : (
57+
<Icon icon="translate_2_line" size={24} />
58+
)}
59+
</div>
5760
</div>
58-
</div>
59-
</Dropdown>
61+
</DropdownMenuTrigger>
62+
<DropdownMenuContent>
63+
<DropdownMenuRadioGroup value={locale} onValueChange={onLocaleChange}>
64+
{languages.map((item) => (
65+
<DropdownMenuRadioItem
66+
className="cursor-pointer"
67+
key={item.value}
68+
value={item.value}
69+
>
70+
{item.label}
71+
</DropdownMenuRadioItem>
72+
))}
73+
</DropdownMenuRadioGroup>
74+
</DropdownMenuContent>
75+
</DropdownMenu>
6076
);
6177
}

src/components/site/avatar.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,13 @@ export default function Avatar() {
143143
if (!user) return null;
144144
return (
145145
<>
146-
<div className="font-medium text-sm">
147-
{user.name || user.email?.split("@")[0]}
148-
</div>
149-
<div className="text-xs">{user.email}</div>
146+
<DropdownMenuLabel>
147+
<div className="font-medium text-sm">
148+
{user.name || user.email?.split("@")[0]}
149+
</div>
150+
<div className="text-xs">{user.email}</div>
151+
</DropdownMenuLabel>
152+
<DropdownMenuSeparator />
150153
</>
151154
);
152155
};
@@ -185,7 +188,7 @@ export default function Avatar() {
185188
return (
186189
<div className="flex items-center">
187190
<DropdownMenu>
188-
<DropdownMenuTrigger className="outline-none">
191+
<DropdownMenuTrigger className="outline-none" disabled={disabled}>
189192
{session.data?.user ? (
190193
<div className="cursor-pointer">
191194
{session.data.user.image ? (
@@ -212,8 +215,7 @@ export default function Avatar() {
212215
)}
213216
</DropdownMenuTrigger>
214217
<DropdownMenuContent>
215-
<DropdownMenuLabel>{renderLabel()}</DropdownMenuLabel>
216-
<DropdownMenuSeparator />
218+
{renderLabel()}
217219
{menus.map((item) => {
218220
if (item.type === "seperate")
219221
return <DropdownMenuSeparator key={item.value} />;

src/styles/globals.css

+4-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ input[type="number"] {
5858
--card-foreground: 224 71.4% 4.1%;
5959
--popover: 0 0% 100%;
6060
--popover-foreground: 224 71.4% 4.1%;
61-
--primary: 220.9 39.3% 11%;
61+
--primary: 199 93% 61%;
62+
/* --primary: 220.9 39.3% 11%; */
6263
--primary-foreground: 210 20% 98%;
6364
--secondary: 220 14.3% 95.9%;
6465
--secondary-foreground: 220.9 39.3% 11%;
@@ -70,7 +71,7 @@ input[type="number"] {
7071
--destructive-foreground: 210 20% 98%;
7172
--border: 220 13% 91%;
7273
--input: 220 13% 91%;
73-
--ring: 199, 93%, 61%;
74+
--ring: 199 93% 61%;
7475
/* --ring: 224 71.4% 4.1%; */
7576
--radius: 0.5rem;
7677
}
@@ -94,7 +95,7 @@ input[type="number"] {
9495
--destructive-foreground: 210 20% 98%;
9596
--border: 215 27.9% 16.9%;
9697
--input: 215 27.9% 16.9%;
97-
--ring: 203, 80%, 57%;
98+
--ring: 203 80% 57%;
9899
/* --ring: 216 12.2% 83.9%; */
99100
}
100101
}

0 commit comments

Comments
 (0)