uibee 2.9.0 → 2.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,10 +7,11 @@ export type NavbarProps = {
|
|
|
7
7
|
theme?: string;
|
|
8
8
|
disableThemeToggle?: boolean;
|
|
9
9
|
token?: string | null;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
profilePath?: string;
|
|
11
|
+
loginPath: string;
|
|
12
|
+
logoutPath: string;
|
|
12
13
|
className?: string;
|
|
13
14
|
innerClassName?: string;
|
|
14
15
|
children: React.ReactNode;
|
|
15
16
|
};
|
|
16
|
-
export default function Navbar({ lang, onlyLogo, disableLanguageToggle, disableThemeToggle, token,
|
|
17
|
+
export default function Navbar({ lang, onlyLogo, disableLanguageToggle, disableThemeToggle, token, profilePath, loginPath, logoutPath, className, innerClassName, children, }: NavbarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,10 +11,13 @@ function hamburgerStyle(isOpen, isSecond) {
|
|
|
11
11
|
? `top-6 ${isSecond ? 'rotate-45' : '-rotate-45'}`
|
|
12
12
|
: isSecond ? 'top-7' : 'top-4'}`;
|
|
13
13
|
}
|
|
14
|
-
export default function Navbar({ lang, onlyLogo, disableLanguageToggle, disableThemeToggle, token,
|
|
14
|
+
export default function Navbar({ lang, onlyLogo, disableLanguageToggle, disableThemeToggle, token, profilePath, loginPath, logoutPath, className, innerClassName, children, }) {
|
|
15
15
|
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
|
|
16
16
|
return (_jsx("div", { className: `${isMobileMenuOpen ? 'bg-[#181818f0]' : 'bg-[#18181899]'} backdrop-blur-xl fixed top-0 z-900 w-full ${className}`, children: _jsxs("div", { className: `flex w-full max-w-6xl m-auto p-2 transition duration-500 800px:justify-between 800px:p-4 ${isMobileMenuOpen ? 'h-screen bg-login-900/20 800px:h-20' : ''} ${innerClassName}
|
|
17
|
-
`, children: [_jsx("div", { className: 'block h-12 p-1 800px:p-0', children: _jsx(Link, { href: '/', onClick: () => setIsMobileMenuOpen(false), children: _jsx(LogoSmall, {}) }) }), onlyLogo ? null : (_jsxs(_Fragment, { children: [_jsx("nav", { className: 'hidden 800px:flex 800px:justify-between 800px:items-center 800px:w-fill max-w-200', children: children }), _jsxs("nav", { className: 'flex w-[calc(100vw-8rem)] justify-end h-12 800px:w-fit', children: [!disableThemeToggle &&
|
|
17
|
+
`, children: [_jsx("div", { className: 'block h-12 p-1 800px:p-0', children: _jsx(Link, { href: '/', onClick: () => setIsMobileMenuOpen(false), children: _jsx(LogoSmall, {}) }) }), onlyLogo ? null : (_jsxs(_Fragment, { children: [_jsx("nav", { className: 'hidden 800px:flex 800px:justify-between 800px:items-center 800px:w-fill max-w-200', children: children }), _jsxs("nav", { className: 'flex w-[calc(100vw-8rem)] justify-end h-12 800px:w-fit', children: [!disableThemeToggle &&
|
|
18
|
+
_jsx(ThemeToggle, {}), !disableLanguageToggle &&
|
|
19
|
+
_jsx(LanguageToggle, { language: lang }), loginPath && logoutPath &&
|
|
20
|
+
_jsx(AuthButton, { profilePath: profilePath, token: token, loginPath: loginPath, logoutPath: logoutPath })] }), _jsxs("button", { className: 'w-12 h-12 relative cursor-pointer bg-none border-none 800px:hidden', onClick: () => setIsMobileMenuOpen(!isMobileMenuOpen), children: [_jsx("div", { className: hamburgerStyle(isMobileMenuOpen) }), _jsx("div", { className: hamburgerStyle(isMobileMenuOpen, true) })] }), _jsx("nav", { className: `fixed top-16 w-[calc(100%-2rem)] max-w-140 mx-auto left-0 right-0 800px:hidden
|
|
18
21
|
transition-all duration-500 ease-in-out overflow-hidden
|
|
19
22
|
${isMobileMenuOpen ? 'max-h-[calc(100vh-4rem)] opacity-100' : 'max-h-0 opacity-0'}`, onClick: () => setIsMobileMenuOpen(false), children: React.Children.map(children, (child, index) => (_jsx("div", { className: `transition-all duration-500 ease-out ${isMobileMenuOpen
|
|
20
23
|
? 'opacity-100 transform translate-y-0'
|
|
@@ -22,10 +25,11 @@ export default function Navbar({ lang, onlyLogo, disableLanguageToggle, disableT
|
|
|
22
25
|
transitionDelay: isMobileMenuOpen ? `${index * 80}ms` : '0ms'
|
|
23
26
|
}, children: child }, index))) })] }))] }) }));
|
|
24
27
|
}
|
|
25
|
-
function AuthButton({
|
|
26
|
-
return (_jsx("div", { className: 'rounded-[0.3rem] hover:bg-login-300/20 h-12 w-12', children: token ? (_jsxs(_Fragment, { children: [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
function AuthButton({ profilePath, logoutPath, loginPath, token }) {
|
|
29
|
+
return (_jsx("div", { className: 'rounded-[0.3rem] hover:bg-login-300/20 h-12 w-12', children: token ? (_jsxs(_Fragment, { children: [logoutPath &&
|
|
30
|
+
_jsx(Link, { href: logoutPath, prefetch: false, onClick: (e) => {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
window.location.href = logoutPath;
|
|
33
|
+
}, className: 'grid items-center justify-center h-full w-full', children: _jsx(LogOut, { size: 24 }) }), profilePath &&
|
|
34
|
+
_jsx(Link, { href: profilePath, className: 'grid items-center justify-center h-full w-full', children: _jsx(User, { size: 24 }) })] })) : (_jsx(Link, { href: loginPath, className: 'grid items-center justify-center h-full w-full', children: _jsx(User, { size: 24 }) })) }));
|
|
31
35
|
}
|
package/package.json
CHANGED
|
@@ -24,8 +24,9 @@ export type NavbarProps = {
|
|
|
24
24
|
theme?: string
|
|
25
25
|
disableThemeToggle?: boolean
|
|
26
26
|
token?: string | null
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
profilePath?: string
|
|
28
|
+
loginPath: string
|
|
29
|
+
logoutPath: string
|
|
29
30
|
className?: string
|
|
30
31
|
innerClassName?: string
|
|
31
32
|
children: React.ReactNode
|
|
@@ -37,8 +38,9 @@ export default function Navbar({
|
|
|
37
38
|
disableLanguageToggle,
|
|
38
39
|
disableThemeToggle,
|
|
39
40
|
token,
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
profilePath,
|
|
42
|
+
loginPath,
|
|
43
|
+
logoutPath,
|
|
42
44
|
className,
|
|
43
45
|
innerClassName,
|
|
44
46
|
children,
|
|
@@ -69,9 +71,22 @@ export default function Navbar({
|
|
|
69
71
|
|
|
70
72
|
{/* Controls */}
|
|
71
73
|
<nav className='flex w-[calc(100vw-8rem)] justify-end h-12 800px:w-fit'>
|
|
72
|
-
{!disableThemeToggle &&
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
{!disableThemeToggle &&
|
|
75
|
+
<ThemeToggle />
|
|
76
|
+
}
|
|
77
|
+
{!disableLanguageToggle &&
|
|
78
|
+
<LanguageToggle
|
|
79
|
+
language={lang}
|
|
80
|
+
/>
|
|
81
|
+
}
|
|
82
|
+
{loginPath && logoutPath &&
|
|
83
|
+
<AuthButton
|
|
84
|
+
profilePath={profilePath}
|
|
85
|
+
token={token}
|
|
86
|
+
loginPath={loginPath}
|
|
87
|
+
logoutPath={logoutPath}
|
|
88
|
+
/>
|
|
89
|
+
}
|
|
75
90
|
</nav>
|
|
76
91
|
|
|
77
92
|
{/* Mobile Menu Button */}
|
|
@@ -111,26 +126,35 @@ export default function Navbar({
|
|
|
111
126
|
)
|
|
112
127
|
}
|
|
113
128
|
|
|
114
|
-
|
|
129
|
+
type AuthButtonProps = {
|
|
130
|
+
profilePath?: string
|
|
131
|
+
logoutPath: string
|
|
132
|
+
loginPath: string
|
|
133
|
+
token?: string | null
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function AuthButton({ profilePath, logoutPath, loginPath, token }: AuthButtonProps) {
|
|
115
137
|
|
|
116
138
|
return (
|
|
117
139
|
<div className='rounded-[0.3rem] hover:bg-login-300/20 h-12 w-12'>
|
|
118
140
|
{token ? (
|
|
119
141
|
<>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
e
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
142
|
+
{logoutPath &&
|
|
143
|
+
<Link
|
|
144
|
+
href={logoutPath}
|
|
145
|
+
prefetch={false}
|
|
146
|
+
onClick={(e) => {
|
|
147
|
+
e.preventDefault()
|
|
148
|
+
window.location.href = logoutPath
|
|
149
|
+
}}
|
|
150
|
+
className='grid items-center justify-center h-full w-full'
|
|
151
|
+
>
|
|
152
|
+
<LogOut size={24} />
|
|
153
|
+
</Link>
|
|
154
|
+
}
|
|
155
|
+
{profilePath &&
|
|
132
156
|
<Link
|
|
133
|
-
href={
|
|
157
|
+
href={profilePath}
|
|
134
158
|
className='grid items-center justify-center h-full w-full'
|
|
135
159
|
>
|
|
136
160
|
<User size={24} />
|
|
@@ -139,7 +163,7 @@ function AuthButton({ profileURL, token }: { profileURL?: string, token?: string
|
|
|
139
163
|
</>
|
|
140
164
|
) : (
|
|
141
165
|
<Link
|
|
142
|
-
href=
|
|
166
|
+
href={loginPath}
|
|
143
167
|
className='grid items-center justify-center h-full w-full'
|
|
144
168
|
>
|
|
145
169
|
<User size={24} />
|