Files
nahodka-front/src/components/layout/AppTopBar.jsx
2026-10-19 01:33:26 +03:00

47 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import MenuIcon from "../icons/MenuIcon";
import ProfileAvatar from "../profile/ProfileAvatar";
import { useTranslation } from 'react-i18next';
/**
* Общая верхняя панель приложения (мобильная версия Instagram-style):
* бургер-меню слева, название сервиса, контент по центру, профиль/логин справа.
*/
export default function AppTopBar({
onMenuClick,
centerContent,
isAuthenticated,
profileData,
onProfileClick,
onLoginClick,
loginLabel,
hideProfile = false,
hideWordmark = false,
}) {
const { t } = useTranslation();
return (
// Без названия сервиса — заголовок строго по центру экрана (см. .f-topbar-centered),
// иначе он центрировался бы между кнопками разной ширины и уезжал влево
<div className={`f-topbar${hideWordmark ? " f-topbar-centered" : ""}`}>
<button className="f-menu-btn" onClick={onMenuClick}>
<MenuIcon />
</button>
{!hideWordmark && <span className="f-topbar-wordmark">{t('app.name')}</span>}
<div className="f-topbar-center">{centerContent}</div>
{hideProfile ? (
<span className="f-topbar-spacer" />
) : isAuthenticated ? (
<div className="f-topbar-profile" onClick={onProfileClick}>
<ProfileAvatar
avatar={profileData.avatar}
name={`${profileData.firstName || ""} ${profileData.lastName || ""}`}
/>
</div>
) : (
<button className="f-login-btn" onClick={onLoginClick}>
{loginLabel}
</button>
)}
</div>
);
}