added blur on topBar

This commit is contained in:
SlimusMinus
2026-09-09 23:42:03 +03:00
parent 800cb8233a
commit 4021840429
6 changed files with 847 additions and 642 deletions

View File

@@ -1,120 +0,0 @@
import { useState, useRef, useEffect } from "react";
import { motion, AnimatePresence } from "framer-motion";
import { useTranslation } from "react-i18next";
import MenuIcon from "../icons/MenuIcon";
import NahodkaLogo from "../NahodkaLogo";
/**
* TopBar ленты (Telegram-style):
* слева — круглая стеклянная кнопка-логотип (открывает фильтр типа),
* справа — squircle-кнопка-гамбургер (открывает SideBar).
*/
export default function FeedTopBar({ onMenuClick, typeFilter, onTypeFilterChange }) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const menuRef = useRef(null);
const btnRef = useRef(null);
const options = [
{ key: "loss", label: t("feed.filterLoss") },
{ key: null, label: t("feed.filterAll") },
{ key: "found", label: t("feed.filterFound") },
];
useEffect(() => {
if (!open) return;
const handler = (e) => {
if (
menuRef.current && !menuRef.current.contains(e.target) &&
btnRef.current && !btnRef.current.contains(e.target)
) {
setOpen(false);
}
};
document.addEventListener("mousedown", handler);
return () => document.removeEventListener("mousedown", handler);
}, [open]);
const handleSelect = (key) => {
onTypeFilterChange(key);
setOpen(false);
};
return (
<div className="f-topbar-dropdown-wrap">
<div className="f-topbar">
<button
type="button"
className="f-menu-btn"
onClick={onMenuClick}
aria-label={t("feed.openMenu")}
>
<MenuIcon />
</button>
<button
ref={btnRef}
type="button"
className="f-logo-btn"
onClick={() => setOpen((v) => !v)}
aria-label={t("feed.openFilter")}
aria-haspopup="menu"
aria-expanded={open}
>
<NahodkaLogo className="f-topbar-logo" />
<svg
className={`f-topbar-chevron${open ? " open" : ""}`}
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
>
<polyline points="6 9 12 15 18 9" />
</svg>
</button>
<span className="f-topbar-spacer" />
</div>
<AnimatePresence>
{open && (
<motion.div
className="f-topbar-dropdown-overlay"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.15 }}
onClick={() => setOpen(false)}
/>
)}
</AnimatePresence>
<AnimatePresence>
{open && (
<motion.div
ref={menuRef}
className="f-topbar-dropdown-menu"
initial={{ opacity: 0, scale: 0.95, y: -8 }}
animate={{ opacity: 1, scale: 1, y: 0 }}
exit={{ opacity: 0, scale: 0.95, y: -8 }}
transition={{ duration: 0.18, ease: "easeOut" }}
>
{options.map((opt) => (
<button
key={opt.key ?? "all"}
type="button"
className={`f-topbar-dropdown-item${typeFilter === opt.key ? " active" : ""}`}
onClick={() => handleSelect(opt.key)}
>
{opt.label}
</button>
))}
</motion.div>
)}
</AnimatePresence>
</div>
);
}