-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Expand file tree
/
Copy pathmenu.tsx
More file actions
96 lines (94 loc) · 3.36 KB
/
Copy pathmenu.tsx
File metadata and controls
96 lines (94 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { motion } from "framer-motion"
// function ThemeToggle() {
// const { isDark, toggleDark } = useDark()
// return (
// <li onClick={toggleDark} className="cursor-pointer [&_*]:cursor-pointer transition-all">
// <span className={$("inline-block", isDark ? "i-ph-moon-stars-duotone" : "i-ph-sun-dim-duotone")} />
// <span>
// {isDark ? "浅色模式" : "深色模式"}
// </span>
// </li>
// )
// }
export function Menu() {
const { loggedIn, login, logout, userInfo, enableLogin } = useLogin()
const [shown, show] = useState(false)
return (
<span className="relative" onMouseEnter={() => show(true)} onMouseLeave={() => show(false)}>
<span className="flex items-center scale-90">
{
enableLogin && loggedIn && userInfo.avatar
? (
<button
type="button"
className="h-6 w-6 rounded-full bg-cover"
style={
{
backgroundImage: `url(${userInfo.avatar}&s=24)`,
}
}
>
</button>
)
: <button type="button" className="btn i-si:more-muted-horiz-circle-duotone" />
}
</span>
{shown && (
<div className="absolute right-0 z-99 bg-transparent pt-4 top-4">
<motion.div
id="dropdown-menu"
className={$([
"w-200px",
"bg-primary backdrop-blur-5 bg-op-70! rounded-lg shadow-xl",
])}
initial={{
scale: 0.9,
}}
animate={{
scale: 1,
}}
>
<ol className="bg-base bg-op-70! backdrop-blur-md p-2 rounded-lg color-base text-base">
{enableLogin && (loggedIn
? (
<li onClick={logout}>
<span className="i-ph:sign-out-duotone inline-block" />
<span>退出登录</span>
</li>
)
: (
<li onClick={login}>
<span className="i-ph:sign-in-duotone inline-block" />
<span>Github 账号登录</span>
</li>
))}
{/* <ThemeToggle /> */}
<li onClick={() => window.open(Homepage)} className="cursor-pointer [&_*]:cursor-pointer transition-all">
<span className="i-ph:github-logo-duotone inline-block" />
<span>Star on Github </span>
</li>
<li className="flex gap-2 items-center">
<a
href="https://github.com"
>
<img
alt="GitHub stars badge"
src="https://img.shields.io/github/stars/ourongxing/newsnow?logo=github&style=flat&labelColor=%235e3c40&color=%23614447"
/>
</a>
<a
href="https://github.com"
>
<img
alt="GitHub forks badge"
src="https://img.shields.io/github/forks/ourongxing/newsnow?logo=github&style=flat&labelColor=%235e3c40&color=%23614447"
/>
</a>
</li>
</ol>
</motion.div>
</div>
)}
</span>
)
}