feat: 모바일 하단 내비게이션·설정 패널 도입
This commit is contained in:
1 parent
bb0ab91bcc
commit
54e5d14127
11 files changed
+613
-375
No files matched your search
@@ -0,0 +1,67 @@
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { UserMeResponse } from '../types/api';
|
||||
import { NAV_ITEMS, SETTINGS_ID } from './navItems';
|
||||
import SettingsPanel from './SettingsPanel';
|
||||
|
||||
interface BottomNavProps {
|
||||
activeItem: string;
|
||||
onNavigate: (id: string) => void;
|
||||
userInfo?: UserMeResponse | null;
|
||||
onLogout?: () => void;
|
||||
credits?: number | null;
|
||||
isGuest: boolean;
|
||||
onLoginClick: () => void;
|
||||
}
|
||||
|
||||
const BottomNav: React.FC<BottomNavProps> = ({ activeItem, onNavigate, userInfo, onLogout, credits, isGuest, onLoginClick }) => {
|
||||
const { t } = useTranslation();
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
const settingsAnchorRef = useRef<HTMLButtonElement>(null);
|
||||
|
||||
const handleItemClick = (id: string) => {
|
||||
if (id === SETTINGS_ID) {
|
||||
setSettingsOpen(v => !v);
|
||||
return;
|
||||
}
|
||||
onNavigate(id);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{settingsOpen && <div className="settings-backdrop" onClick={() => setSettingsOpen(false)} />}
|
||||
{settingsOpen && (
|
||||
<SettingsPanel
|
||||
variant="bottom"
|
||||
onClose={() => setSettingsOpen(false)}
|
||||
onNavigate={onNavigate}
|
||||
activeItem={activeItem}
|
||||
userInfo={userInfo}
|
||||
credits={credits}
|
||||
isGuest={isGuest}
|
||||
onLogout={onLogout}
|
||||
onLoginClick={onLoginClick}
|
||||
anchorRef={settingsAnchorRef}
|
||||
/>
|
||||
)}
|
||||
<nav className="bottom-nav">
|
||||
{NAV_ITEMS.map(item => {
|
||||
const isActive = item.id === SETTINGS_ID ? settingsOpen : activeItem === item.id;
|
||||
return (
|
||||
<button
|
||||
key={item.id}
|
||||
ref={item.id === SETTINGS_ID ? settingsAnchorRef : undefined}
|
||||
className={`bottom-nav-item ${isActive ? 'active' : ''}`}
|
||||
onClick={() => handleItemClick(item.id)}
|
||||
>
|
||||
{item.icon}
|
||||
<span>{t(item.labelKey)}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default BottomNav;
|
||||
Reference in new issue
Block a user