diff --git a/src/App.js b/src/App.js index 79162a0..9fbfa87 100644 --- a/src/App.js +++ b/src/App.js @@ -1,6 +1,6 @@ // src/App.jsx import { useEffect, useRef } from 'react'; -import { BrowserRouter, Routes, Route, useLocation, Navigate } from 'react-router-dom'; +import { BrowserRouter, Routes, Route, useLocation, Navigate, useParams } from 'react-router-dom'; import { AuthProvider } from './context/AuthContext'; import { ThemeProvider } from './context/ThemeContext'; import { useAuthContext } from './context/AuthContext'; @@ -12,7 +12,11 @@ import ChatPage from './pages/ChatPage'; import ChatListPage from './pages/ChatListPage'; import ReviewsPage from './pages/ReviewsPage'; import AdminAdsPage from './pages/AdminAdsPage'; +import DesktopChats from './components/desktop/DesktopChats'; +import { useIsDesktop } from './hooks/useIsDesktop'; import './styles/chat.css'; +// Десктопный слой (>= 900px) — последним, чтобы переопределять базовые стили. +import './styles/desktop.css'; function ScrollToTop() { const { pathname } = useLocation(); @@ -48,6 +52,17 @@ function AdminRoute({ children }) { return children; } +// Чаты: на десктопе — один двухпанельный мессенджер для всех трёх адресов +// (список не перемонтируется при переключении чатов), на мобильном — +// прежние отдельные страницы списка и переписки. +function ChatsRoute() { + const isDesktop = useIsDesktop(); + const { chatId } = useParams(); + const { pathname } = useLocation(); + if (isDesktop) return ; + return chatId || pathname === '/chats/new' ? : ; +} + function App() { return ( @@ -59,9 +74,9 @@ function App() { } /> } /> } /> - } /> - } /> - } /> + } /> + } /> + } /> } /> } /> diff --git a/src/components/MapView.jsx b/src/components/MapView.jsx index 9e84cea..60eb4cb 100644 --- a/src/components/MapView.jsx +++ b/src/components/MapView.jsx @@ -11,13 +11,13 @@ const MARKER_COLORS = { FOUND: "#34c759", }; -function createMarkerLayout(color, imageUrl) { +function createMarkerLayout(color, imageUrl, pinId) { const bgStyle = imageUrl ? `background-image:url('${escapeCssUrl(imageUrl)}');background-size:cover;background-position:center;` : ""; return window.ymaps.templateLayoutFactory.createClass( - `
void, onBack?: () => void, + * onMarkersChange?: (markers: any[]) => void, onMarkerHover?: (id: string | null) => void, + * highlightId?: string | null, focusTarget?: { lat: number, lng: number, zoom?: number } | null, + * }} props + */ export default function MapView({ focusPostId, focusLat, @@ -119,6 +128,14 @@ export default function MapView({ category = null, onPostClick, onBack, + // Необязательные пропсы десктопной карты (на мобильном не передаются): + // onMarkersChange — список меток в видимой области после каждой загрузки, + // onMarkerHover — наведение на метку (id | null), highlightId — подсветка + // метки, focusTarget — {lat, lng, zoom?} плавный перелёт к точке. + onMarkersChange, + onMarkerHover, + highlightId = null, + focusTarget = null, }) { const { t } = useTranslation(); // tRef нужен, чтобы читать перевод из эффектов, не добавляя t в их deps: @@ -137,6 +154,11 @@ export default function MapView({ const onPostClickRef = useRef(onPostClick); onPostClickRef.current = onPostClick; + const onMarkersChangeRef = useRef(onMarkersChange); + onMarkersChangeRef.current = onMarkersChange; + const onMarkerHoverRef = useRef(onMarkerHover); + onMarkerHoverRef.current = onMarkerHover; + const placemarksRef = useRef(new Map()); // Фильтры читаются через ref: их смена не должна пересоздавать карту, // они просто уезжают вместе с границами в том же самом запросе. @@ -161,6 +183,7 @@ export default function MapView({ if (!collection) return placemarksById; collection.removeAll(); + placemarksRef.current = new Map(); markers.forEach((m) => { if (m.latitude == null || m.longitude == null) return; @@ -171,14 +194,18 @@ export default function MapView({ if (m.id != null) { const postId = String(m.id); placemarksById.set(postId, [m.latitude, m.longitude]); + placemarksRef.current.set(postId, placemark); placemark.events.add("click", () => { if (onPostClickRef.current) { onPostClickRef.current(postId); } }); + placemark.events.add("mouseenter", () => onMarkerHoverRef.current?.(postId)); + placemark.events.add("mouseleave", () => onMarkerHoverRef.current?.(null)); } }); + onMarkersChangeRef.current?.(markers.filter((m) => m.latitude != null && m.longitude != null)); return placemarksById; }; renderMarkersRef.current = renderMarkers; @@ -362,8 +389,11 @@ export default function MapView({ // Смена фильтров type/category: догружаем маркеры для текущих границ, // карту при этом не пересоздаём. + const prevFiltersRef = useRef({ type, category }); useEffect(() => { - if (type == null && category == null) return; + const prev = prevFiltersRef.current; + prevFiltersRef.current = { type, category }; + if (prev.type === type && prev.category === category) return; const map = ymapRef.current; if (!map) return; const bounds = map.getBounds(); @@ -380,6 +410,31 @@ export default function MapView({ return () => clearTimeout(timer); }, [type, category]); + // Подсветка метки (наведение на карточку в списке десктопной карты): + // класс на DOM-узле лейаута + zIndex, чтобы метка была поверх соседних. + useEffect(() => { + if (highlightId == null) return undefined; + const id = String(highlightId); + const placemark = placemarksRef.current.get(id); + placemark?.options.set("zIndex", 1000); + const node = mapRef.current?.querySelector(`[data-pin-id="${CSS.escape(id)}"]`); + node?.classList.add("is-hl"); + return () => { + placemark?.options.unset("zIndex"); + node?.classList.remove("is-hl"); + }; + }, [highlightId]); + + // Программный перелёт к точке (клик по карточке в списке десктопной карты). + useEffect(() => { + if (!focusTarget) return; + const map = ymapRef.current; + if (!map) return; + const { lat, lng, zoom } = focusTarget; + if (!Number.isFinite(lat) || !Number.isFinite(lng)) return; + map.setCenter([lat, lng], Math.max(map.getZoom(), zoom ?? FOCUS_ZOOM - 1), { duration: 300 }); + }, [focusTarget]); + // Геолокация: если юзер разрешил и карта уже создана — центр на его месте. // Не трогаем, если карта была открыта с фокусом на конкретном объявлении. const hasFocus = focusPostId != null || (Number.isFinite(focusLat) && Number.isFinite(focusLng)); diff --git a/src/components/RightSidebar.jsx b/src/components/RightSidebar.jsx index 2e2c989..4468e0d 100644 --- a/src/components/RightSidebar.jsx +++ b/src/components/RightSidebar.jsx @@ -1,90 +1,160 @@ -import { useState } from "react"; -import { useTranslation } from 'react-i18next'; +import { useMemo, useState } from "react"; +import { useTranslation } from "react-i18next"; import ProfileAvatar from "./profile/ProfileAvatar"; +import SupportModal from "./SupportModal"; +import { DesktopIcons } from "./desktop/DesktopIcons"; +import { getImageUrl } from "../config/authConstants"; +import { POST_STATUS_CLOSED } from "../config/postConstants"; +import { formatRelativeTime } from "../utils/relativeTime"; -function FollowButton() { - const [following, setFollowing] = useState(false); - const { t } = useTranslation(); - return ( - - ); -} +const FRESH_LIMIT = 5; -export default function RightSidebar({ ads, profileData, isAuthenticated, onProfileClick, onLoginClick, onNavClick }) { - const { t } = useTranslation(); +/** + * RightSidebar — правая колонка десктопной ленты (>= 1280px, ниже скрыта CSS): + * карточка профиля, CTA размещения, переход на карту и свежие объявления. + * На мобильной раскладке не отображается. + * + * @param {{ + * ads: any[], profileData: any, isAuthenticated: boolean, + * onProfileClick: () => void, onLoginClick: () => void, onNavClick?: (key: string) => void, + * onCreatePost?: () => void, onMapClick?: () => void, onPostClick?: (id: any) => void, + * onRulesClick?: () => void, onReviewsClick?: () => void, + * }} props + */ +export default function RightSidebar({ + ads, + profileData, + isAuthenticated, + onProfileClick, + onLoginClick, + onNavClick, + onCreatePost, + onMapClick, + onPostClick, + onRulesClick, + onReviewsClick, +}) { + const { t, i18n } = useTranslation(); + const [supportOpen, setSupportOpen] = useState(false); - const suggestions = [...(ads || [])] - .sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt)) - .slice(0, 4); + // Свежие активные объявления: по дате создания, найденные не показываем. + const fresh = useMemo(() => ( + [...(ads || [])] + .filter((ad) => ad.status !== POST_STATUS_CLOSED) + .sort((a, b) => new Date(b.createdAt || 0) - new Date(a.createdAt || 0)) + .slice(0, FRESH_LIMIT) + ), [ads]); const profileName = isAuthenticated ? `${profileData?.firstName || ""} ${profileData?.lastName || ""}`.trim() || profileData?.login : null; return ( -
-
+
+
+ + + + © {new Date().getFullYear()} {t("app.name")} +
+ + {supportOpen && setSupportOpen(false)} />} + ); } diff --git a/src/components/Sidebar.jsx b/src/components/Sidebar.jsx index 4107545..926d5d8 100644 --- a/src/components/Sidebar.jsx +++ b/src/components/Sidebar.jsx @@ -15,7 +15,16 @@ import SupportModal from "./SupportModal"; import UploadAdModal from "./UploadAdModal"; import ProfileAvatar from "./profile/ProfileAvatar"; import NahodkaLogo from "./MainNahodkaLogo"; +import DesktopSidebar from "./desktop/DesktopSidebar"; +/** + * @param {{ + * open: boolean, activeNav: string, onClose: () => void, onNavClick: (key: string) => void, + * isAuthenticated: boolean, onLoginClick: () => void, onRulesClick?: () => void, + * onReviewsClick?: () => void, onCreatePost?: () => void, onProfileClick?: () => void, + * onMapClick?: () => void, profileData: any, + * }} props + */ export default function Sidebar({ open, activeNav, @@ -27,6 +36,7 @@ export default function Sidebar({ onReviewsClick, onCreatePost, onProfileClick, + onMapClick, profileData, }) { const navigate = useNavigate(); @@ -42,6 +52,25 @@ export default function Sidebar({ const [uploadAdOpen, setUploadAdOpen] = useState(false); const HelpIcon = NavIcons.help; + // Десктоп (>= 900px) — отдельная навигация с картой, CTA и свёрткой в рейку. + // Мобильный drawer ниже остаётся без изменений. + if (isDesktop) { + return ( + navigate("/reviews"))} + onCreatePost={onCreatePost} + onProfileClick={onProfileClick} + onMapClick={onMapClick} + profileData={profileData} + /> + ); + } + const handleNavItem = (itemKey) => { if (!isAuthenticated && itemKey === "myads") { onLoginClick(); diff --git a/src/components/desktop/DesktopChats.jsx b/src/components/desktop/DesktopChats.jsx new file mode 100644 index 0000000..471e69a --- /dev/null +++ b/src/components/desktop/DesktopChats.jsx @@ -0,0 +1,191 @@ +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { useLocation, useNavigate, useParams } from "react-router-dom"; +import { useTranslation } from "react-i18next"; +import Sidebar from "../Sidebar"; +import ChatListItem from "../chat/ChatListItem"; +import Toast from "../Toast"; +import AuthModal from "../AuthModal"; +import { ProfileModal } from "../profile"; +import RulesModal from "../../pages/RulesModal"; +import ChatPage from "../../pages/ChatPage"; +import { DesktopIcons } from "./DesktopIcons"; +import { useChatList } from "../../hooks/useChatList"; +import { useProfileData } from "../../hooks/useProfileData"; +import { useAuthContext } from "../../context/AuthContext"; +import { getPostForChat } from "../../stores/chatPostStore"; +import { getChatDisplayInfo } from "../../utils/chatDisplay"; + +/** + * DesktopChats — двухпанельный мессенджер десктопа: список чатов слева, + * открытая переписка справа. Один компонент обслуживает /chats, /chats/new + * и /chats/:chatId, поэтому список не перезагружается при переключении чатов. + */ +export default function DesktopChats() { + const { t } = useTranslation(); + const navigate = useNavigate(); + const location = useLocation(); + const { chatId } = useParams(); + const isDraft = location.pathname === "/chats/new"; + const { user } = useAuthContext(); + const profileData = useProfileData(user); + const { + chats, loading, fetchChats, unreadMap, isAuthenticated, + handleDeleteChat, deleteError, clearDeleteError, + } = useChatList(); + const [query, setQuery] = useState(""); + const [modal, setModal] = useState(null); + + // Новое сообщение в открытом чате → обновляем превью в списке + // (с небольшой задержкой, чтобы сервер успел сохранить сообщение). + const refreshTimerRef = useRef(null); + const refreshList = useCallback(() => { + clearTimeout(refreshTimerRef.current); + refreshTimerRef.current = setTimeout(() => fetchChats({ silent: true }), 700); + }, [fetchChats]); + useEffect(() => () => clearTimeout(refreshTimerRef.current), []); + + const items = useMemo(() => { + const q = query.trim().toLowerCase(); + return chats + .map((chat) => { + const post = getPostForChat(chat.id); + const info = getChatDisplayInfo(chat, post, unreadMap, t); + return { chat, post, info }; + }) + .filter(({ info }) => !q + || String(info.title || "").toLowerCase().includes(q) + || String(info.preview || "").toLowerCase().includes(q)); + }, [chats, unreadMap, query, t]); + + const onDelete = async (id) => { + const deleted = await handleDeleteChat(id); + if (deleted && String(id) === String(chatId)) navigate("/chats", { replace: true }); + }; + + const goFeed = (state) => navigate("/feed", state ? { state } : undefined); + + return ( +
+ {}} + onNavClick={(key) => goFeed({ desktopNav: key })} + isAuthenticated={isAuthenticated} + onLoginClick={() => setModal("auth")} + onRulesClick={() => setModal("rules")} + onReviewsClick={() => navigate("/reviews")} + onCreatePost={() => (isAuthenticated ? goFeed({ desktopAction: "create" }) : setModal("auth"))} + onProfileClick={() => setModal("profile")} + onMapClick={() => navigate("/feed?view=map")} + profileData={profileData} + /> + +
+
+
+

+ {t("chat.chats")} + {chats.length > 0 && {chats.length}} +

+ {isAuthenticated && chats.length > 0 && ( + + )} +
+ +
+ {!isAuthenticated ? ( +
+
{t("chat.loginToSee")}
+
+ ) : loading ? ( + Array.from({ length: 7 }, (_, i) => ( + + )) + ) : chats.length === 0 && !isDraft ? ( +
+
+
{t("chat.noChats")}
+
+ ) : items.length === 0 && !isDraft ? ( +
+
{t("desktop.chats.nothingFound")}
+
+ ) : ( + <> + {isDraft && ( +
+
+
+
+
{location.state?.post?.title || t("desktop.chats.newChat")}
+
{t("desktop.chats.newChat")}
+
+
+
+ )} + {items.map(({ chat, post }) => ( +
+ navigate(`/chats/${id}`)} + onDelete={onDelete} + /> +
+ ))} + + )} +
+
+ +
+ {!isAuthenticated ? ( +
+
+
{t("chat.loginToSee")}
+ +
+ ) : chatId || isDraft ? ( + + ) : ( +
+
+
{t("desktop.chats.selectTitle")}
+
{t("desktop.chats.selectSub")}
+
+ )} +
+
+ + {deleteError && } + {modal === "auth" && setModal(null)} />} + {modal === "rules" && setModal(null)} />} + {modal === "profile" && isAuthenticated && ( + setModal(null)} initialData={profileData} /> + )} +
+ ); +} diff --git a/src/components/desktop/DesktopFeedHeader.jsx b/src/components/desktop/DesktopFeedHeader.jsx new file mode 100644 index 0000000..80526e7 --- /dev/null +++ b/src/components/desktop/DesktopFeedHeader.jsx @@ -0,0 +1,131 @@ +import { useTranslation } from "react-i18next"; +import FeedSearchBar from "../feed/FeedSearchBar"; +import CityFilter from "../CityFilter"; +import { DesktopIcons } from "./DesktopIcons"; + +const TITLE_KEYS = { + home: "nav.home", + items: "nav.items", + pets: "nav.pets", + myads: "nav.myAds", +}; + +/** + * Сегментированный переключатель «Все / Потери / Находки». + * Индикатор активного сегмента — отдельный слой, который едет под кнопками. + */ +export function TypeSegment({ value, onChange, size = "md" }) { + const { t } = useTranslation(); + const options = [ + { key: null, label: t("desktop.typeAll") }, + { key: "loss", label: t("feed.filterLoss"), tone: "loss" }, + { key: "found", label: t("feed.filterFound"), tone: "found" }, + ]; + const activeIndex = Math.max(0, options.findIndex((o) => o.key === value)); + + return ( +
+
+ ); +} + +/** + * DesktopFeedHeader — шапка ленты на десктопе: заголовок раздела, счётчик, + * фильтр «потеря/находка», поиск с подсказками и мультивыбор городов. + * На мобильном не рендерится (там FeedTopBar + шапка поиска). + */ +export default function DesktopFeedHeader({ + activeNav, + typeFilter, + onTypeFilterChange, + searchQuery, + onSearchChange, + cities, + selectedCities, + onCitiesChange, + count, + loading, + onMapClick, +}) { + const { t } = useTranslation(); + const searching = searchQuery.trim().length > 0 || selectedCities.length > 0; + const titleKey = TITLE_KEYS[activeNav] || "nav.home"; + const showSearch = activeNav !== "myads"; + const hasFilters = searching || typeFilter != null; + + const reset = () => { + onSearchChange(""); + onCitiesChange([]); + onTypeFilterChange(null); + }; + + return ( +
+
+
+
+

+ {searching ? t("desktop.searchResults") : t(titleKey)} +

+

+ {t(`desktop.feedSub.${TITLE_KEYS[activeNav] ? activeNav : "home"}`)} + {!loading && count > 0 && ( + <> + + {t("desktop.shown", { count })} + + )} +

+
+
+ {hasFilters && ( + + )} + {onMapClick && ( + + )} +
+
+ +
+ + {showSearch && ( +
+ +
+ )} + {activeNav === "home" && ( +
+ +
+ )} +
+
+
+ ); +} diff --git a/src/components/desktop/DesktopIcons.jsx b/src/components/desktop/DesktopIcons.jsx new file mode 100644 index 0000000..eed198f --- /dev/null +++ b/src/components/desktop/DesktopIcons.jsx @@ -0,0 +1,82 @@ +// Линейные иконки десктопной раскладки (единый стиль: 24×24, stroke 2). +const base = { + viewBox: "0 0 24 24", + fill: "none", + stroke: "currentColor", + strokeWidth: 2, + strokeLinecap: "round", + strokeLinejoin: "round", + "aria-hidden": true, +}; + +const Svg = ({ size = 20, children, ...rest }) => ( + {children} +); + +export const DesktopIcons = { + Map: (p) => ( + + + + + + ), + Plus: (p) => ( + + + + + ), + User: (p) => ( + + + + + ), + Pin: (p) => ( + + + + + ), + ArrowRight: (p) => ( + + + + + ), + ChevronRight: (p) => ( + + + + ), + Search: (p) => ( + + + + + ), + Message: (p) => ( + + + + ), + Close: (p) => ( + + + + + ), + Sparkles: (p) => ( + + + + ), + Image: (p) => ( + + + + + + ), +}; diff --git a/src/components/desktop/DesktopMapView.jsx b/src/components/desktop/DesktopMapView.jsx new file mode 100644 index 0000000..f87a328 --- /dev/null +++ b/src/components/desktop/DesktopMapView.jsx @@ -0,0 +1,163 @@ +import { useCallback, useEffect, useRef, useState } from "react"; +import { useTranslation } from "react-i18next"; +import MapView from "../MapView"; +import { TypeSegment } from "./DesktopFeedHeader"; +import { DesktopIcons } from "./DesktopIcons"; +import { getImageUrl } from "../../config/authConstants"; +import { CATEGORIES } from "../../config/feedConstants"; + +// Список рендерим ограниченным: в крупном масштабе в область могут попасть +// сотни меток, а пользователю всё равно нужен ближайший десяток. +const LIST_LIMIT = 150; + +/** + * DesktopMapView — карта объявлений для десктопа: слева панель с фильтрами + * и списком объявлений из видимой области, справа карта. + * Наведение на карточку подсвечивает метку и наоборот; клик по карточке + * открывает объявление, кнопка с пином — плавно перелетает к метке. + */ +export default function DesktopMapView({ focusPostId, focusLat, focusLng, onPostClick }) { + const { t } = useTranslation(); + const [type, setType] = useState(null); + const [category, setCategory] = useState(null); + const [markers, setMarkers] = useState(null); + const [hoverId, setHoverId] = useState(null); + const [focusTarget, setFocusTarget] = useState(null); + const listRef = useRef(null); + + const handleMarkers = useCallback((list) => setMarkers(list), []); + + // Наведение на метку карты: подсвечиваем карточку и докручиваем к ней список. + const handleMarkerHover = useCallback((id) => { + setHoverId(id); + if (id == null) return; + const node = listRef.current?.querySelector(`[data-item-id="${CSS.escape(String(id))}"]`); + node?.scrollIntoView({ block: "nearest", behavior: "smooth" }); + }, []); + + // Открытие с фокусом на объявлении — сразу подсвечиваем его в списке. + useEffect(() => { + if (focusPostId != null) setHoverId(String(focusPostId)); + }, [focusPostId]); + + const visible = markers ? markers.slice(0, LIST_LIMIT) : []; + + return ( +
+ + +
+ +
+
+ ); +} diff --git a/src/components/desktop/DesktopSidebar.jsx b/src/components/desktop/DesktopSidebar.jsx new file mode 100644 index 0000000..2abcac8 --- /dev/null +++ b/src/components/desktop/DesktopSidebar.jsx @@ -0,0 +1,240 @@ +import { useState } from "react"; +import { useNavigate } from "react-router-dom"; +import { useTranslation } from "react-i18next"; +import { NavIcons } from "../icons/NavIcons"; +import SunIcon from "../icons/SunIcon"; +import MoonIcon from "../icons/MoonIcon"; +import GlobeIcon from "../icons/GlobeIcon"; +import NahodkaLogo from "../MainNahodkaLogo"; +import ProfileAvatar from "../profile/ProfileAvatar"; +import SupportModal from "../SupportModal"; +import UploadAdModal from "../UploadAdModal"; +import { useTheme } from "../../context/ThemeContext"; +import { useUnread } from "../../context/UnreadContext"; +import { useAuthContext } from "../../context/AuthContext"; +import { useLanguageToggle } from "../../hooks/useLanguageToggle"; +import { DesktopIcons } from "./DesktopIcons"; + +// Порядок пунктов основной навигации десктопа. «Карта» есть только здесь: +// на мобильном она живёт в нижней панели (BottomNav). +const MAIN_NAV = [ + { key: "home", labelKey: "nav.home", icon: () => NavIcons.grid() }, + { key: "items", labelKey: "nav.items", icon: () => NavIcons.box() }, + { key: "pets", labelKey: "nav.pets", icon: () => NavIcons.paw() }, + { key: "map", labelKey: "nav.map", icon: () => }, + { key: "myads", labelKey: "nav.myAds", icon: () => NavIcons.file() }, + { key: "chat", labelKey: "nav.chat", icon: () => NavIcons.chat() }, +]; + +const ADMIN_NAV = [ + { key: "admin-campaigns", labelKey: "adminPanel.campaignsNav", icon: () => NavIcons.grid(), to: "/admin/ads" }, + { key: "admin-posts", labelKey: "adminPanel.postsNav", icon: () => NavIcons.rules(), to: "/admin/ads?tab=posts" }, + { key: "admin-posts-rejected", labelKey: "adminPanel.postsRejectedNav", icon: () => NavIcons.rules(), to: "/admin/ads?tab=rejected" }, +]; + +/** + * DesktopSidebar — левая навигация десктопной раскладки (>= 900px). + * + * На 900–1199px автоматически сворачивается в узкую «рейку» с иконками + * (подписи скрываются CSS-ом, остаются title-подсказки), на >= 1200px — + * полная панель с подписями. Мобильный drawer — отдельный компонент Sidebar. + */ +export default function DesktopSidebar({ + activeNav, + onNavClick, + isAuthenticated, + onLoginClick, + onRulesClick, + onReviewsClick, + onCreatePost, + onProfileClick, + onMapClick, + profileData, +}) { + const navigate = useNavigate(); + const { t } = useTranslation(); + const { isAdmin } = useAuthContext(); + const { theme, toggle: toggleTheme } = useTheme(); + const { totalUnread } = useUnread(); + const { language, toggleLanguage } = useLanguageToggle(); + const [supportOpen, setSupportOpen] = useState(false); + const [uploadAdOpen, setUploadAdOpen] = useState(false); + + const profileName = `${profileData?.firstName || ""} ${profileData?.lastName || ""}`.trim(); + + const handleMain = (key) => { + if (key === "chat") { + if (!isAuthenticated) onLoginClick(); + else navigate("/chats"); + return; + } + if (key === "myads" && !isAuthenticated) { + onLoginClick(); + return; + } + if (key === "map") { + if (onMapClick) onMapClick(); + else navigate("/feed?view=map"); + return; + } + onNavClick(key); + }; + + const handleProfile = () => { + if (!isAuthenticated) onLoginClick(); + else onProfileClick?.(); + }; + + return ( + <> + + {supportOpen && setSupportOpen(false)} />} + {uploadAdOpen && setUploadAdOpen(false)} />} + + ); +} diff --git a/src/hooks/useChatList.js b/src/hooks/useChatList.js new file mode 100644 index 0000000..0f8fdb0 --- /dev/null +++ b/src/hooks/useChatList.js @@ -0,0 +1,67 @@ +import { useCallback, useEffect, useRef, useState } from "react"; +import { useTranslation } from "react-i18next"; +import { useChats } from "./useChats"; +import { useDeleteChat } from "./useDeleteChat"; +import { useAuthContext } from "../context/AuthContext"; +import { useUnread } from "../context/UnreadContext"; + +/** + * Список чатов текущего пользователя: загрузка, фоновое обновление при новых + * непрочитанных (WS) и удаление с подтверждением. Общая логика мобильной + * страницы списка (ChatListPage) и десктопного двухпанельного мессенджера. + */ +export function useChatList() { + const { t } = useTranslation(); + const { chats, loading, fetchChats } = useChats(); + const { isAuthenticated } = useAuthContext(); + const { unreadMap, totalUnread } = useUnread(); + const { deleteChat } = useDeleteChat(); + const [deleteError, setDeleteError] = useState(""); + // Пропускаем первый прогон эффекта по totalUnread: на маунте список уже + // грузится первым эффектом, и без этого guard'а через 500 мс уходил бы + // второй, повторный запрос (страница "моргала" и грузилась дважды). + const unreadWatcherReadyRef = useRef(false); + + useEffect(() => { + if (isAuthenticated) { + fetchChats(); + } + }, [isAuthenticated, fetchChats]); + + // При поступлении непрочитанного сообщения (WS) обновляем список, чтобы + // превью показывало новое сообщение и подсветку, не дожидаясь ручного обновления. + useEffect(() => { + if (!isAuthenticated) return; + if (!unreadWatcherReadyRef.current) { + unreadWatcherReadyRef.current = true; + return; + } + const timer = setTimeout(() => fetchChats({ silent: true }), 500); + return () => clearTimeout(timer); + // totalUnread — числовое значение, поэтому изменение состава чатов с той же + // суммой не создаст цикл обновлений. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [totalUnread, isAuthenticated, fetchChats]); + + const handleDeleteChat = useCallback(async (chatId) => { + if (!window.confirm(t('chat.confirmDeleteChat'))) return false; + const result = await deleteChat(chatId); + if (result.success) { + fetchChats({ silent: true }); + return true; + } + setDeleteError(result.error); + return false; + }, [t, deleteChat, fetchChats]); + + return { + chats, + loading, + fetchChats, + unreadMap, + isAuthenticated, + handleDeleteChat, + deleteError, + clearDeleteError: () => setDeleteError(""), + }; +} diff --git a/src/hooks/useProfileData.js b/src/hooks/useProfileData.js new file mode 100644 index 0000000..0dbc098 --- /dev/null +++ b/src/hooks/useProfileData.js @@ -0,0 +1,22 @@ +import { useMemo } from "react"; +import { getImageUrl } from "../config/authConstants"; + +/** + * Данные профиля для навигации/аватаров из пользователя AuthContext + * (та же нормализация, что в ленте и на странице отзывов). + */ +export function useProfileData(user) { + return useMemo(() => { + if (!user) return {}; + const nameParts = (user.name || "").trim().split(/\s+/); + return { + login: user.login || "", + firstName: user.firstName || nameParts[0] || "", + lastName: user.lastName || nameParts.slice(1).join(" ") || "", + email: user.email || "", + phone: user.phone || "", + avatar: getImageUrl(user.avatar), + id: user.id, + }; + }, [user]); +} diff --git a/src/locales/en.json b/src/locales/en.json index 04bbf66..60fa77b 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -617,5 +617,51 @@ "openLink": "Open ad in a new tab", "closeIn": "Close in {{seconds}}s", "close": "Close ad" + }, + "desktop": { + "createPost": "Post a listing", + "typeAll": "All", + "feedSub": { + "home": "Lost and found items and pets", + "items": "Documents, keys, electronics, bags and more", + "pets": "Lost and found animals", + "myads": "Your listings: edit, close or bring them back to the feed" + }, + "shown": "Showing {{count}}", + "searchResults": "Search results", + "resetFilters": "Reset filters", + "ctaTitle": "Lost or found something?", + "ctaText": "Post a listing in a minute — people nearby will see it.", + "mapCardTitle": "Listings on the map", + "mapCardText": "See where things were lost and found nearby", + "mapCardBtn": "Open map", + "fresh": "Fresh listings", + "seeAll": "All", + "freshEmpty": "No new listings yet", + "guestTitle": "Welcome", + "guestText": "Sign in to post listings and message authors", + "myProfile": "My profile", + "settings": "Settings", + "collapse": "Collapse menu", + "expand": "Expand menu", + "map": { + "title": "Listings map", + "inArea": "In this area: {{count}}", + "emptyArea": "No listings here yet", + "emptyAreaSub": "Zoom out or move to another area", + "catAll": "All categories", + "loading": "Loading listings…", + "showOnMap": "Show on map", + "open": "Open" + }, + "chats": { + "selectTitle": "Select a chat", + "selectSub": "Open a conversation on the left to keep talking with the listing author", + "search": "Search chats", + "nothingFound": "Nothing found", + "newChat": "New chat" + }, + "adminSection": "Administration", + "reviewsSub": "What people think about Nakhodka — and a place for your opinion" } } diff --git a/src/locales/ru.json b/src/locales/ru.json index 9f46a67..45ded83 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -617,5 +617,51 @@ "openLink": "Открыть рекламу в новой вкладке", "closeIn": "Закрыть через {{seconds}}с", "close": "Закрыть рекламу" + }, + "desktop": { + "createPost": "Разместить объявление", + "typeAll": "Все", + "feedSub": { + "home": "Потерянные и найденные вещи и питомцы", + "items": "Документы, ключи, электроника, сумки и другое", + "pets": "Потерявшиеся и найденные животные", + "myads": "Ваши объявления: редактируйте, закрывайте, возвращайте в ленту" + }, + "shown": "Показано {{count}}", + "searchResults": "Результаты поиска", + "resetFilters": "Сбросить фильтры", + "ctaTitle": "Потеряли или нашли?", + "ctaText": "Разместите объявление за минуту — его увидят люди рядом с вами.", + "mapCardTitle": "Объявления на карте", + "mapCardText": "Смотрите, где теряли и находили вещи поблизости", + "mapCardBtn": "Открыть карту", + "fresh": "Свежие объявления", + "seeAll": "Все", + "freshEmpty": "Пока нет новых объявлений", + "guestTitle": "Добро пожаловать", + "guestText": "Войдите, чтобы размещать объявления и писать авторам", + "myProfile": "Мой профиль", + "settings": "Настройки", + "collapse": "Свернуть меню", + "expand": "Развернуть меню", + "map": { + "title": "Карта объявлений", + "inArea": "В этой области: {{count}}", + "emptyArea": "Здесь пока нет объявлений", + "emptyAreaSub": "Отдалите карту или переместитесь в другой район", + "catAll": "Все категории", + "loading": "Загружаем объявления…", + "showOnMap": "Показать на карте", + "open": "Открыть" + }, + "chats": { + "selectTitle": "Выберите чат", + "selectSub": "Откройте переписку слева, чтобы продолжить общение с автором объявления", + "search": "Поиск по чатам", + "nothingFound": "Ничего не найдено", + "newChat": "Новый чат" + }, + "adminSection": "Администрирование", + "reviewsSub": "Что пользователи думают о Находке — и место для вашего мнения" } } diff --git a/src/pages/ChatListPage.jsx b/src/pages/ChatListPage.jsx index 63fb759..9613392 100644 --- a/src/pages/ChatListPage.jsx +++ b/src/pages/ChatListPage.jsx @@ -1,11 +1,7 @@ -import { useEffect, useState, useCallback, useRef } from "react"; import { useNavigate } from "react-router-dom"; import { useTranslation } from 'react-i18next'; -import { useChats } from "../hooks/useChats"; -import { useAuthContext } from "../context/AuthContext"; -import { useUnread } from "../context/UnreadContext"; import { getPostForChat } from "../stores/chatPostStore"; -import { useDeleteChat } from "../hooks/useDeleteChat"; +import { useChatList } from "../hooks/useChatList"; import ChatHeader from "../components/chat/ChatHeader"; import ChatListItem from "../components/chat/ChatListItem"; import Toast from "../components/Toast"; @@ -13,46 +9,10 @@ import Toast from "../components/Toast"; export default function ChatListPage() { const { t } = useTranslation(); const navigate = useNavigate(); - const { chats, loading, fetchChats } = useChats(); - const { isAuthenticated } = useAuthContext(); - const { unreadMap, totalUnread } = useUnread(); - const { deleteChat } = useDeleteChat(); - const [deleteError, setDeleteError] = useState(""); - // Пропускаем первый прогон эффекта по totalUnread: на маунте список уже - // грузится первым эффектом, и без этого guard'а через 500 мс уходил бы - // второй, повторный запрос (страница "моргала" и грузилась дважды). - const unreadWatcherReadyRef = useRef(false); - - useEffect(() => { - if (isAuthenticated) { - fetchChats(); - } - }, [isAuthenticated, fetchChats]); - - // При поступлении непрочитанного сообщения (WS) обновляем список, чтобы - // превью показывало новое сообщение и подсветку, не дожидаясь ручного обновления. - useEffect(() => { - if (!isAuthenticated) return; - if (!unreadWatcherReadyRef.current) { - unreadWatcherReadyRef.current = true; - return; - } - const timer = setTimeout(() => fetchChats({ silent: true }), 500); - return () => clearTimeout(timer); - // totalUnread — числовое значение, поэтому изменение состава чатов с той же - // суммой не создаст цикл обновлений. - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [totalUnread, isAuthenticated, fetchChats]); - - const handleDeleteChat = useCallback(async (chatId) => { - if (!window.confirm(t('chat.confirmDeleteChat'))) return; - const result = await deleteChat(chatId); - if (result.success) { - fetchChats({ silent: true }); - } else { - setDeleteError(result.error); - } - }, [t, deleteChat, fetchChats]); + const { + chats, loading, unreadMap, isAuthenticated, + handleDeleteChat, deleteError, clearDeleteError, + } = useChatList(); const goBack = () => navigate("/feed"); const openChat = (chatId) => navigate(`/chats/${chatId}`); @@ -100,9 +60,9 @@ export default function ChatListPage() { setDeleteError("")} + onDismiss={clearDeleteError} /> )}
); -} \ No newline at end of file +} diff --git a/src/pages/ChatPage.jsx b/src/pages/ChatPage.jsx index ddc6ce0..efa8a4c 100644 --- a/src/pages/ChatPage.jsx +++ b/src/pages/ChatPage.jsx @@ -15,7 +15,14 @@ import MessageBubble from "../components/chat/MessageBubble"; import ChatInputBar from "../components/chat/ChatInputBar"; import Toast from "../components/Toast"; -export default function ChatPage() { +/** + * Открытый чат. На мобильном — отдельная страница; на десктопе встраивается + * правой панелью мессенджера (embedded): без собственной обёртки .f-app, + * а onActivity сообщает списку чатов, что превью пора обновить. + * + * @param {{ embedded?: boolean, onActivity?: () => void }} [props] + */ +export default function ChatPage({ embedded = false, onActivity } = {}) { const { t } = useTranslation(); const { chatId } = useParams(); const navigate = useNavigate(); @@ -122,6 +129,7 @@ export default function ChatPage() { startChat(draft.otherUserId, draft.postId, trimmed, draft.post) .then((chat) => { setInput(""); + onActivity?.(); navigate(`/chats/${chat.id}`, { replace: true }); }) // 429 — лимит начала чатов; 400 — чат с собой, чужое объявление и т.п. @@ -136,14 +144,15 @@ export default function ChatPage() { return; } setInput(""); - }, [input, sendMessage, t, draft, startingChat, startChat, navigate]); + onActivity?.(); + }, [input, sendMessage, t, draft, startingChat, startChat, navigate, onActivity]); const post = draft ? draft.post : getPostForChat(chatId); const postImg = getImageUrl(post?.images?.[0]); - return ( -
-
+ const content = ( + <> +
navigate("/chats")} @@ -181,6 +190,8 @@ export default function ChatPage() { onDismiss={() => setSendError("")} /> )} -
+ ); + + return embedded ? content :
{content}
; } \ No newline at end of file diff --git a/src/pages/MainFeed.tsx b/src/pages/MainFeed.tsx index 95e3256..a51a890 100644 --- a/src/pages/MainFeed.tsx +++ b/src/pages/MainFeed.tsx @@ -18,6 +18,8 @@ import CityQuickFilterLegacy from "../components/feed/CityQuickFilter"; import FeedContent from "../components/feed/FeedContent"; import PullToRefresh from "../components/feed/PullToRefresh"; import MapView from "../components/MapView"; +import DesktopFeedHeaderLegacy from "../components/desktop/DesktopFeedHeader"; +import DesktopMapViewLegacy from "../components/desktop/DesktopMapView"; import PostDetailModal from "../components/PostDetailModal"; import { useAuthContext } from "../context/AuthContext"; import { useCities } from "../hooks/useCities"; @@ -42,6 +44,8 @@ import type { ComponentType } from "react"; const CityFilter = CityFilterLegacy as unknown as ComponentType; const CityQuickFilter = CityQuickFilterLegacy as unknown as ComponentType; const CreateUpdatePost = CreateUpdatePostLegacy as unknown as ComponentType; +const DesktopFeedHeader = DesktopFeedHeaderLegacy as unknown as ComponentType; +const DesktopMapView = DesktopMapViewLegacy as unknown as ComponentType; // eslint-disable-next-line @typescript-eslint/no-explicit-any type AnyAds = any[]; @@ -198,6 +202,21 @@ export default function MainFeed() { } }, [location.state]); // eslint-disable-line react-hooks/exhaustive-deps + // Десктопная навигация с других страниц (чаты, отзывы): раздел ленты + // или сразу форма создания объявления. + useEffect(() => { + const state = location.state as { desktopNav?: string; desktopAction?: string } | null; + if (!state?.desktopNav && !state?.desktopAction) return; + if (state.desktopNav && ["home", "items", "pets", "myads"].includes(state.desktopNav)) { + setActiveNav(state.desktopNav); + } + if (state.desktopAction === "create") { + if (isAuthenticated) modals.open("create"); + else modals.open("auth"); + } + navigate(`${location.pathname}${location.search}`, { replace: true, state: null }); + }, [location.state]); // eslint-disable-line react-hooks/exhaustive-deps + // При загрузке приложения подтягиваем свежие данные профиля (аватар и т.д.) // с бэка, чтобы нижняя навигация и профиль отражали изменения с других // устройств, а не устаревший кэш контекста. Дергаем один раз на пользователя. @@ -226,6 +245,9 @@ export default function MainFeed() { // вкладки (вещи/питомцы) и фильтра «потеря/находка» — их применяет сервер. useEffect(() => { if (activeNav === "myads" || activeNav === "map") return; + // На десктопе поиск и фильтры живут прямо в ленте — загрузкой занимается + // отдельный эффект ниже (desktopLoadKeyRef), здесь запрос не дублируем. + if (isDesktop && !isSearchView) return; if (!isSearchView && selectedCities.length === 0 && !searchQuery.trim()) { feed.loadFeed(0, "", false, feedFilters); } @@ -244,6 +266,28 @@ export default function MainFeed() { // eslint-disable-next-line react-hooks/exhaustive-deps }, [searchQuery, feedFiltersKey, isSearchView]); + // Десктоп: поиск и города всегда в шапке ленты (без отдельной вкладки + // «Поиск»), поэтому текст/города/фильтры применяются сразу, текст — с + // дебаунсом. Ключ последней загрузки не даёт перезапрашивать ленту при + // возврате с карты, если фильтры не менялись. + const desktopLoadKeyRef = useRef(null); + useEffect(() => { + if (!isDesktop || isSearchView) { + desktopLoadKeyRef.current = null; + return; + } + if (activeNav === "myads" || activeNav === "map") return; + const q = searchQuery.trim(); + const key = `${q}|${feedFiltersKey}`; + if (key === desktopLoadKeyRef.current) return; + const timer = setTimeout(() => { + desktopLoadKeyRef.current = key; + feed.loadFeed(0, q, false, feedFilters); + }, q ? 400 : 0); + return () => clearTimeout(timer); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [isDesktop, isSearchView, searchQuery, feedFiltersKey, activeNav]); + // Когда переключаемся на «Мои объявления» — подгружаем с бэкенда useEffect(() => { if (activeNav === "myads" && isAuthenticated && user?.id) { @@ -442,11 +486,27 @@ export default function MainFeed() { onReviewsClick={() => navigate("/reviews")} onCreatePost={handleCreatePost} onProfileClick={() => modals.open("profile")} + onMapClick={handleMapClick} profileData={profileData} />
- {/* Шапка поиска: на мобильном сворачивается при скролле вниз (grid 1fr → 0fr) */} + {isDesktop ? (!isMapView && ( + + )) : ( + /* Шапка поиска: на мобильном сворачивается при скролле вниз (grid 1fr → 0fr) */
{isSearchView && ( @@ -471,9 +531,17 @@ export default function MainFeed() {
+ )}
- {isMapView ? ( + {isMapView && isDesktop ? ( + + ) : isMapView ? ( + {isDesktop ? ( +
+ 0} + error={listError} + filteredAds={filteredAds} + activeNav={activeNav} + searchPrompt={searchPrompt} + showAds={showAds} + onEdit={handleEdit} + onDelete={actions.handleDelete} + onMarkFound={actions.handleMarkFound} + onReopen={actions.handleReopen} + onLocationClick={handleLocationClick} + onAuthRequired={() => modals.open("auth")} + t={t} + /> +
+ ) : ( 0} @@ -514,6 +602,7 @@ export default function MainFeed() { onAuthRequired={() => modals.open("auth")} t={t} /> + )} {infiniteFeed && !feed.loading && (
)} @@ -544,6 +633,11 @@ export default function MainFeed() { setSelectedCities([]); if (isMapView || isSearchView) navigate("/feed"); }} + onCreatePost={handleCreatePost} + onMapClick={handleMapClick} + onPostClick={(postId: number) => modals.open("postDetail", { postId })} + onRulesClick={() => modals.open("rules")} + onReviewsClick={() => navigate("/reviews")} /> )} diff --git a/src/pages/ReviewsPage.jsx b/src/pages/ReviewsPage.jsx index 8c4761d..063df5d 100644 --- a/src/pages/ReviewsPage.jsx +++ b/src/pages/ReviewsPage.jsx @@ -15,12 +15,14 @@ import { useReviews } from "../hooks/useReviews"; import "../styles/reviews.css"; import { useTranslation } from 'react-i18next'; import { useProfile } from "../hooks/useProfile"; +import { useIsDesktop } from "../hooks/useIsDesktop"; export default function ReviewsPage() { const { t } = useTranslation(); const navigate = useNavigate(); const { user, isAuthenticated, updateUser } = useAuthContext(); const { fetchProfile } = useProfile(); + const isDesktop = useIsDesktop(); const [sidebarOpen, setSidebarOpen] = useState(false); const [profileModalOpen, setProfileModalOpen] = useState(false); @@ -88,16 +90,25 @@ export default function ReviewsPage() { open={sidebarOpen} activeNav="reviews" onClose={() => setSidebarOpen(false)} - onNavClick={(key) => navigate("/feed")} + onNavClick={(key) => navigate("/feed", isDesktop ? { state: { desktopNav: key } } : undefined)} isAuthenticated={isAuthenticated} onLoginClick={() => setAuthModalOpen(true)} onRulesClick={() => setRulesModalOpen(true)} - onCreatePost={() => navigate("/feed")} + onCreatePost={() => navigate("/feed", isDesktop ? { state: { desktopAction: "create" } } : undefined)} + onMapClick={() => navigate("/feed?view=map")} onProfileClick={() => setProfileModalOpen(true)} profileData={profileData} />
+ {isDesktop ? ( +
+
+

{t('reviews.title')}

+

{t('desktop.reviewsSub')}

+
+
+ ) : ( setSidebarOpen((v) => !v)} isAuthenticated={isAuthenticated} @@ -108,6 +119,7 @@ export default function ReviewsPage() { centerContent={

{t('reviews.title')}

} hideWordmark /> + )}
diff --git a/src/styles/desktop.css b/src/styles/desktop.css new file mode 100644 index 0000000..011ae49 --- /dev/null +++ b/src/styles/desktop.css @@ -0,0 +1,1053 @@ +/* ═════════════════════════════════════════════════════════════════════ + ДЕСКТОПНАЯ РАСКЛАДКА (>= 900px) + ───────────────────────────────────────────────────────────────────── + Все правила файла живут внутри media-запросов от 900px: мобильная + версия этот слой не видит вообще. Классы fd-* принадлежат только + десктопным компонентам (src/components/desktop/*), а переопределения + общих классов (f-*) ограничены этим же брейкпоинтом. + + Брейкпоинты: + 900–1199 — левая навигация свёрнута в рейку с иконками; + >= 1200 — полная левая навигация с подписями; + >= 1320 — появляется правая колонка (профиль, CTA, карта, свежие). + ═════════════════════════════════════════════════════════════════════ */ + +@media (min-width: 900px) { + :root { + --fd-bg: #f5f6f8; + --fd-surface: #ffffff; + --fd-surface-2: #f1f2f5; + --fd-surface-hover: #f6f7f9; + --fd-border: rgba(16, 24, 40, .08); + --fd-border-strong: rgba(16, 24, 40, .14); + --fd-text: #14161a; + --fd-text-2: #5b6170; + --fd-text-3: #8b909c; + --fd-accent: var(--teal); + --fd-accent-soft: rgba(var(--teal-rgb), .1); + --fd-brand: linear-gradient(135deg, #ff8e6b 0%, #f1503a 100%); + --fd-brand-solid: #f2603f; + --fd-loss: #e5484d; + --fd-loss-soft: rgba(229, 72, 77, .1); + --fd-found: #2f9e5e; + --fd-found-soft: rgba(47, 158, 94, .11); + --fd-radius-lg: 20px; + --fd-radius: 14px; + --fd-radius-sm: 10px; + --fd-shadow-xs: 0 1px 2px rgba(16, 24, 40, .05); + --fd-shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .05); + --fd-shadow-md: 0 4px 12px rgba(16, 24, 40, .06), 0 16px 32px -8px rgba(16, 24, 40, .12); + --fd-shadow-lg: 0 24px 64px -12px rgba(16, 24, 40, .25); + --fd-ease: cubic-bezier(.2, .8, .2, 1); + --fd-sidebar-w: 264px; + --fd-header-blur: saturate(180%) blur(16px); + } + + [data-theme="dark"] { + --fd-bg: #0a0a0b; + --fd-surface: #151518; + --fd-surface-2: #1d1d21; + --fd-surface-hover: #1b1b1f; + --fd-border: rgba(255, 255, 255, .07); + --fd-border-strong: rgba(255, 255, 255, .13); + --fd-text: #f3f4f6; + --fd-text-2: #a7abb5; + --fd-text-3: #747985; + --fd-accent-soft: rgba(var(--teal-rgb), .16); + --fd-loss-soft: rgba(229, 72, 77, .16); + --fd-found-soft: rgba(47, 158, 94, .18); + --fd-shadow-xs: 0 1px 2px rgba(0, 0, 0, .4); + --fd-shadow-sm: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .3); + --fd-shadow-md: 0 4px 12px rgba(0, 0, 0, .35), 0 16px 32px -8px rgba(0, 0, 0, .6); + --fd-shadow-lg: 0 24px 64px -12px rgba(0, 0, 0, .8); + } + + /* ── Оболочка ─────────────────────────────────────────────────────── */ + .f-app { background: var(--fd-bg); color: var(--fd-text); } + .f-main { background: var(--fd-bg); } + + /* Мобильные элементы, которых на десктопе быть не должно */ + .f-main-feed .f-topbar-dropdown-wrap, + .f-bottom-nav { display: none !important; } + + /* ── Левая навигация ──────────────────────────────────────────────── */ + .fd-sidebar { + position: relative; + z-index: 30; + flex: 0 0 var(--fd-sidebar-w); + width: var(--fd-sidebar-w); + height: 100vh; height: 100dvh; + display: flex; flex-direction: column; + padding: 18px 14px 14px; + background: var(--fd-surface); + border-right: 1px solid var(--fd-border); + overflow-y: auto; overflow-x: hidden; + scrollbar-width: none; + } + .fd-sidebar::-webkit-scrollbar { display: none; } + + .fd-sb-head { padding: 2px 8px 18px; } + .fd-sb-logo { + display: flex; align-items: center; + background: none; border: none; padding: 0; cursor: pointer; + border-radius: 10px; + transition: transform .2s var(--fd-ease), filter .2s; + } + .fd-sb-logo:hover { filter: brightness(1.06); } + .fd-sb-logo:active { transform: scale(.97); } + .fd-sb-logo:focus-visible { outline: 2px solid var(--fd-accent); outline-offset: 4px; } + .fd-sb-logo-full { width: auto; height: 34px; display: block; } + .fd-sb-logo-mark { display: none; width: 40px; height: 40px; border-radius: 12px; } + [data-theme="dark"] .fd-sb-logo-full .f-logo-word { fill: url(#nahodkaLogoCoral); } + [data-theme="dark"] .fd-sb-logo-full .f-logo-heart { fill: #ff4b3a; } + + .fd-sb-cta { + display: flex; align-items: center; justify-content: center; gap: 8px; + height: 46px; margin: 0 2px 18px; + border: none; border-radius: 14px; + background: var(--fd-brand); + color: #fff; + font: 700 .92rem/1 var(--font); + cursor: pointer; + box-shadow: 0 6px 18px -6px rgba(241, 80, 58, .6), inset 0 1px 0 rgba(255, 255, 255, .25); + transition: transform .2s var(--fd-ease), box-shadow .2s, filter .2s; + } + .fd-sb-cta:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 10px 24px -8px rgba(241, 80, 58, .7), inset 0 1px 0 rgba(255, 255, 255, .25); } + .fd-sb-cta:active { transform: translateY(0) scale(.98); } + + /* Кнопки «Разместить объявление»: фраза по центру кнопки, «+» — ровно + посередине между левым краем кнопки и началом фразы (три колонки: + левая и правая равны, поэтому подпись остаётся в центре). */ + .fd-sb-cta, + .fd-btn.fd-cta-btn { + display: grid; + grid-template-columns: minmax(36px, 1fr) minmax(0, auto) minmax(0, 1fr); + align-items: center; + gap: 0; + padding: 0; + } + .fd-sb-cta > svg, + .fd-cta-btn > svg { justify-self: center; } + .fd-sb-cta > .fd-sb-label, + .fd-cta-btn-label { flex: none; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .fd-sb-cta:focus-visible { outline: 2px solid var(--fd-brand-solid); outline-offset: 3px; } + + .fd-sb-nav { display: flex; flex-direction: column; gap: 2px; } + .fd-sb-section { + margin: 18px 12px 6px; + font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; + color: var(--fd-text-3); + white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + } + + .fd-sb-item { + position: relative; + display: flex; align-items: center; gap: 12px; + width: 100%; min-height: 42px; + padding: 0 12px; + border: none; border-radius: 12px; + background: transparent; + color: var(--fd-text-2); + font: 500 .92rem/1.2 var(--font); + text-align: left; + cursor: pointer; + transition: background .15s, color .15s; + } + .fd-sb-item:hover { background: var(--fd-surface-2); color: var(--fd-text); } + .fd-sb-item:focus-visible { outline: 2px solid var(--fd-accent); outline-offset: -2px; } + .fd-sb-item.is-active { + background: var(--fd-accent-soft); + color: var(--fd-accent); + font-weight: 700; + } + .fd-sb-item.is-active::before { + content: ""; + position: absolute; left: -14px; top: 10px; bottom: 10px; + width: 3px; border-radius: 0 3px 3px 0; + background: var(--fd-accent); + } + .fd-sb-item-sm { min-height: 38px; font-size: .86rem; } + .fd-sb-icon { + position: relative; + display: inline-flex; align-items: center; justify-content: center; + width: 22px; height: 22px; flex-shrink: 0; + } + .fd-sb-icon svg { width: 20px; height: 20px; } + .fd-sb-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .fd-sb-badge { + min-width: 20px; height: 20px; padding: 0 6px; + display: inline-flex; align-items: center; justify-content: center; + border-radius: 999px; + background: #ff3040; color: #fff; + font-size: .7rem; font-weight: 800; + } + .fd-sb-dot { + display: none; + position: absolute; top: -2px; right: -3px; + width: 9px; height: 9px; border-radius: 50%; + background: #ff3040; + box-shadow: 0 0 0 2px var(--fd-surface); + } + + .fd-sb-bottom { + margin-top: auto; + padding-top: 14px; + display: flex; flex-direction: column; gap: 2px; + } + .fd-sb-prefs { + display: flex; gap: 6px; + margin: 10px 0 10px; + padding: 10px 0 0; + border-top: 1px solid var(--fd-border); + } + .fd-sb-pref { + flex: 1; + display: inline-flex; align-items: center; justify-content: center; gap: 6px; + height: 38px; + border: 1px solid var(--fd-border); + border-radius: 11px; + background: var(--fd-surface); + color: var(--fd-text-2); + font: 700 .78rem/1 var(--font); + cursor: pointer; + transition: background .15s, color .15s, border-color .15s; + } + .fd-sb-pref svg { width: 17px; height: 17px; } + .fd-sb-pref:hover { background: var(--fd-surface-2); color: var(--fd-text); border-color: var(--fd-border-strong); } + + .fd-sb-profile { + display: flex; align-items: center; gap: 10px; + width: 100%; + padding: 8px; + border: 1px solid var(--fd-border); + border-radius: 14px; + background: var(--fd-surface); + cursor: pointer; text-align: left; + font-family: var(--font); + transition: background .15s, border-color .15s; + } + .fd-sb-profile:hover { background: var(--fd-surface-2); border-color: var(--fd-border-strong); } + .fd-sb-profile .f-profile-avatar, + .fd-sb-profile .f-profile-avatar-placeholder, + .fd-sb-profile-guest { + width: 38px; height: 38px; flex-shrink: 0; + border-radius: 11px; border: none; + } + .fd-sb-profile-guest { + display: inline-flex; align-items: center; justify-content: center; + background: var(--fd-surface-2); color: var(--fd-text-2); + } + .fd-sb-profile-info { display: flex; flex-direction: column; gap: 2px; } + .fd-sb-profile-name { + color: var(--fd-text); font-size: .86rem; font-weight: 700; + white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + } + .fd-sb-profile-sub { + color: var(--fd-text-3); font-size: .74rem; + white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + } + + /* ── Шапка ленты ──────────────────────────────────────────────────── */ + .fd-feed-header { + position: relative; z-index: 20; + flex-shrink: 0; + padding: 26px 32px 18px; + background: var(--fd-bg); + border-bottom: 1px solid var(--fd-border); + } + .fd-feed-header-inner { max-width: 1240px; margin: 0 auto; } + .fd-feed-title-row { + display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; + margin-bottom: 18px; + } + .fd-feed-title-block { min-width: 0; } + .fd-feed-title { + margin: 0; + font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; + color: var(--fd-text); + } + .fd-feed-sub { + margin: 6px 0 0; + font-size: .9rem; color: var(--fd-text-2); + display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; + } + .fd-sep { color: var(--fd-text-3); } + .fd-feed-count { color: var(--fd-text-3); font-variant-numeric: tabular-nums; } + .fd-feed-title-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; } + + .fd-feed-controls { display: flex; align-items: center; gap: 12px; } + .fd-feed-search { flex: 1 1 340px; min-width: 220px; } + .fd-feed-city { flex: 0 1 320px; min-width: 220px; } + .fd-feed-search .f-search-bar, + .fd-feed-city .f-city-ms-control { + min-height: 44px; + background: var(--fd-surface); + border-color: var(--fd-border); + box-shadow: var(--fd-shadow-xs); + } + .fd-feed-search .f-search-bar:hover, + .fd-feed-city .f-city-ms-control:hover { border-color: var(--fd-border-strong); } + .fd-feed-city .f-city-filter-wrap, + .fd-feed-city .f-city-multiselect { min-width: 0; } + .fd-feed-city .f-city-ms-dropdown, + .fd-feed-search .f-search-suggest { + border-color: var(--fd-border); + border-radius: 14px; + box-shadow: var(--fd-shadow-md); + background: var(--fd-surface); + } + + /* ── Сегментированный переключатель ───────────────────────────────── */ + .fd-segment { + --fd-seg-pad: 4px; + position: relative; + display: inline-grid; + grid-auto-flow: column; grid-auto-columns: 1fr; + flex-shrink: 0; + padding: var(--fd-seg-pad); + border-radius: 13px; + background: var(--fd-surface-2); + border: 1px solid var(--fd-border); + } + .fd-segment-thumb { + position: absolute; + top: var(--fd-seg-pad); bottom: var(--fd-seg-pad); left: var(--fd-seg-pad); + width: calc((100% - var(--fd-seg-pad) * 2) / var(--fd-seg-count)); + transform: translateX(calc(100% * var(--fd-seg-index))); + border-radius: 10px; + background: var(--fd-surface); + box-shadow: var(--fd-shadow-sm); + transition: transform .28s var(--fd-ease); + } + [data-theme="dark"] .fd-segment-thumb { background: #2a2a30; } + .fd-segment-btn { + position: relative; z-index: 1; + display: inline-flex; align-items: center; justify-content: center; gap: 7px; + height: 34px; padding: 0 16px; + border: none; background: none; + color: var(--fd-text-2); + font: 600 .86rem/1 var(--font); + white-space: nowrap; + cursor: pointer; + transition: color .15s; + } + .fd-segment-btn:hover { color: var(--fd-text); } + .fd-segment-btn.is-active { color: var(--fd-text); } + .fd-segment-btn:focus-visible { outline: 2px solid var(--fd-accent); outline-offset: -2px; border-radius: 10px; } + .fd-segment-sm .fd-segment-btn { height: 30px; padding: 0 12px; font-size: .82rem; } + .fd-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; } + .fd-dot-loss { background: var(--fd-loss); } + .fd-dot-found { background: var(--fd-found); } + + /* ── Кнопки ───────────────────────────────────────────────────────── */ + .fd-btn { + display: inline-flex; align-items: center; justify-content: center; gap: 8px; + height: 42px; padding: 0 18px; + border: 1px solid transparent; border-radius: 12px; + font: 700 .88rem/1 var(--font); + cursor: pointer; + transition: transform .15s var(--fd-ease), background .15s, box-shadow .15s, filter .15s; + } + .fd-btn:active { transform: scale(.98); } + .fd-btn-block { width: 100%; } + .fd-btn-primary { background: var(--fd-accent); color: #fff; } + .fd-btn-primary:hover { background: var(--teal2); } + .fd-btn-brand { + background: var(--fd-brand); color: #fff; + box-shadow: 0 6px 16px -6px rgba(241, 80, 58, .55), inset 0 1px 0 rgba(255, 255, 255, .25); + } + .fd-btn-brand:hover { filter: brightness(1.06); } + + .fd-ghost-btn { + display: inline-flex; align-items: center; gap: 8px; + height: 40px; padding: 0 14px; + border: 1px solid var(--fd-border); + border-radius: 12px; + background: var(--fd-surface); + color: var(--fd-text); + font: 600 .86rem/1 var(--font); + cursor: pointer; + box-shadow: var(--fd-shadow-xs); + transition: background .15s, border-color .15s, transform .15s; + } + .fd-ghost-btn:hover { background: var(--fd-surface-hover); border-color: var(--fd-border-strong); } + .fd-ghost-btn:active { transform: scale(.98); } + + .fd-link-btn { + display: inline-flex; align-items: center; gap: 6px; + padding: 6px 8px; + border: none; border-radius: 8px; + background: none; + color: var(--fd-accent); + font: 600 .82rem/1 var(--font); + cursor: pointer; + transition: background .15s; + } + .fd-link-btn:hover { background: var(--fd-accent-soft); } + + .fd-icon-btn { + display: inline-flex; align-items: center; justify-content: center; + width: 36px; height: 36px; flex-shrink: 0; + border: 1px solid var(--fd-border); + border-radius: 10px; + background: var(--fd-surface); + color: var(--fd-text-2); + cursor: pointer; + transition: background .15s, color .15s, border-color .15s; + } + .fd-icon-btn:hover { background: var(--fd-accent-soft); color: var(--fd-accent); border-color: transparent; } + + /* ── Лента: сетка карточек ────────────────────────────────────────── */ + .f-main-feed .f-wrap { min-height: 0; } + .f-main-feed .f-feed { max-width: none; margin: 0; } + .f-main-feed .f-feed-scroll { + padding: 24px 32px 48px; + gap: 0; + -webkit-mask-image: none; + mask-image: none; + scrollbar-gutter: stable; + } + .f-main-feed .f-feed-scroll::-webkit-scrollbar { width: 10px; } + .f-main-feed .f-feed-scroll::-webkit-scrollbar-thumb { + background: var(--fd-border-strong); + border: 3px solid var(--fd-bg); + border-radius: 10px; + } + + .fd-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); + gap: 22px; + width: 100%; + max-width: 1240px; + margin: 0 auto; + align-items: stretch; + } + .fd-grid > .f-center { + grid-column: 1 / -1; + min-height: 52vh; + } + .fd-grid > .ad-slot-placeholder { display: none; } + + /* Карточка объявления в сетке */ + .fd-grid .f-card { + display: flex; flex-direction: column; + border: 1px solid var(--fd-border); + border-radius: var(--fd-radius-lg); + background: var(--fd-surface); + box-shadow: var(--fd-shadow-sm); + overflow: hidden; + cursor: default; + transition: transform .25s var(--fd-ease), box-shadow .25s var(--fd-ease), border-color .25s; + animation: fd-rise .45s var(--fd-ease) both; + } + .fd-grid .f-card:hover { + transform: translateY(-3px); + box-shadow: var(--fd-shadow-md); + border-color: var(--fd-border-strong); + } + .fd-grid .f-card-loss, + .fd-grid .f-card-found, + .fd-grid .f-card-closed.f-card-loss, + .fd-grid .f-card-closed.f-card-found { box-shadow: var(--fd-shadow-sm); } + .fd-grid .f-card-loss:hover, + .fd-grid .f-card-found:hover { box-shadow: var(--fd-shadow-md); } + + /* Цветная полоска типа сверху вместо кольца вокруг всей карточки */ + .fd-grid .f-card-head { position: relative; padding: 14px 16px 12px; gap: 10px; } + .fd-grid .f-card-head::before { + content: ""; + position: absolute; left: 0; right: 0; top: 0; height: 3px; + background: var(--fd-loss); + opacity: .85; + } + .fd-grid .f-card-found .f-card-head::before { background: var(--fd-found); } + .fd-grid .f-card-closed .f-card-head::before { background: var(--fd-found); opacity: .5; } + .fd-grid .f-card-author-name { + font-size: 1rem; font-weight: 700; line-height: 1.3; letter-spacing: -.005em; + display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; + } + .fd-grid .f-type-badge, + .fd-grid .f-head-loss .f-type-badge, + .fd-grid .f-head-found .f-type-badge { + padding: 4px 10px; + border: none; + font-size: .72rem; font-weight: 700; + } + .fd-grid .f-head-loss .f-type-badge { background: var(--fd-loss-soft); color: var(--fd-loss); } + .fd-grid .f-head-found .f-type-badge { background: var(--fd-found-soft); color: var(--fd-found); } + + .fd-grid .f-card-img { aspect-ratio: 4 / 3.2; } + .fd-grid .f-card-img-filled { background: var(--fd-surface); } + .fd-grid .f-card-img img { transition: transform .5s var(--fd-ease); } + .fd-grid .f-card:hover .f-card-img > img { transform: scale(1.03); } + + .fd-grid .f-card-actions { padding: 12px 16px 2px; } + .fd-grid .f-meta-pill { + border: none; + background: var(--fd-surface-2); + color: var(--fd-text-2); + font-size: .76rem; font-weight: 500; + padding: 5px 10px; + } + .fd-grid .f-loc-pill:hover { background: var(--fd-accent-soft); color: var(--fd-accent); } + .fd-grid .f-date-pill:hover { background: var(--fd-surface-hover); color: var(--fd-text); } + + .fd-grid .f-card-caption { padding: 8px 16px 4px; font-size: .88rem; color: var(--fd-text-2); } + .fd-grid .f-card-caption-text { color: var(--fd-text-2); } + .fd-grid .f-card-meta { padding: 6px 16px 0; } + .fd-grid .f-card-meta:empty { display: none; } + + .fd-grid .f-card-foot { + margin-top: auto; + padding: 12px 16px 16px; + } + .fd-grid .f-card-phone { font-size: .84rem; font-weight: 600; color: var(--fd-text); } + .fd-grid .f-card-phone svg { color: var(--fd-text-3); } + .fd-grid .f-card-contact { + padding: 10px 20px; + border: none; + border-radius: 11px; + background: var(--fd-accent); + color: #fff; + font-size: .86rem; font-weight: 700; + box-shadow: 0 4px 12px -4px rgba(var(--teal-rgb), .55); + } + .fd-grid .f-card-contact:hover { background: var(--teal2); } + .fd-grid .f-card-found-wrap { padding: 0 16px 16px; } + + /* Реклама в сетке — занимает ячейку как обычная карточка */ + .fd-grid > .ad-slot { min-width: 0; } + .fd-grid > .ad-slot .ad-card { height: 100%; border-radius: var(--fd-radius-lg); } + + /* Пустые состояния / загрузка */ + .fd-grid .f-center-icon { font-size: 2.4rem; opacity: .5; } + .fd-grid .f-center-title { font-size: 1.1rem; color: var(--fd-text); } + .fd-grid .f-center-sub { font-size: .9rem; color: var(--fd-text-2); max-width: 380px; } + + /* ── Правая колонка ───────────────────────────────────────────────── */ + .fd-right { + width: 340px; min-width: 340px; + padding: 24px 24px 24px 0; + gap: 16px; + background: transparent; + border: none; + scrollbar-width: none; + } + .fd-right::-webkit-scrollbar { display: none; } + .fd-right > * { flex-shrink: 0; } + + .fd-card { + position: relative; + display: block; + width: 100%; + padding: 18px; + border: 1px solid var(--fd-border); + border-radius: var(--fd-radius-lg); + background: var(--fd-surface); + box-shadow: var(--fd-shadow-xs); + color: var(--fd-text); + font-family: var(--font); + text-align: left; + } + .fd-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; } + .fd-card-title { font-size: .95rem; font-weight: 700; color: var(--fd-text); } + + .fd-profile-card { padding: 8px; } + .fd-profile-row { + display: flex; align-items: center; gap: 12px; + width: 100%; padding: 8px; + border: none; border-radius: 14px; + background: none; color: var(--fd-text-3); + font-family: var(--font); text-align: left; + cursor: pointer; + transition: background .15s; + } + .fd-profile-row:hover { background: var(--fd-surface-2); } + .fd-profile-row .f-profile-avatar, + .fd-profile-row .f-profile-avatar-placeholder { width: 46px; height: 46px; border-radius: 14px; border: none; } + .fd-profile-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; } + .fd-profile-name { color: var(--fd-text); font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .fd-profile-sub { color: var(--fd-text-3); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + + .fd-guest { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px; } + .fd-guest-icon { + width: 46px; height: 46px; border-radius: 14px; + display: inline-flex; align-items: center; justify-content: center; + background: var(--fd-accent-soft); color: var(--fd-accent); + } + .fd-guest-text { flex: 1; min-width: 0; } + .fd-guest-title { font-weight: 700; font-size: .95rem; color: var(--fd-text); } + .fd-guest-sub { font-size: .8rem; color: var(--fd-text-2); margin-top: 2px; line-height: 1.4; } + + .fd-cta-card { + overflow: hidden; + padding: 20px; + background: + radial-gradient(120% 90% at 100% 0%, rgba(255, 142, 107, .18) 0%, transparent 60%), + var(--fd-surface); + } + .fd-cta-glow { + position: absolute; right: -40px; top: -40px; + width: 140px; height: 140px; border-radius: 50%; + background: var(--fd-brand); + opacity: .12; filter: blur(30px); + pointer-events: none; + } + .fd-cta-icon { + width: 40px; height: 40px; border-radius: 12px; + display: inline-flex; align-items: center; justify-content: center; + background: var(--fd-brand); color: #fff; + box-shadow: 0 6px 16px -6px rgba(241, 80, 58, .6); + margin-bottom: 14px; + } + .fd-cta-title { font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; } + .fd-cta-text { margin: 6px 0 16px; font-size: .86rem; line-height: 1.5; color: var(--fd-text-2); } + + .fd-map-card { + padding: 0; + overflow: hidden; + cursor: pointer; + transition: transform .25s var(--fd-ease), box-shadow .25s, border-color .25s; + } + .fd-map-card:hover { transform: translateY(-2px); box-shadow: var(--fd-shadow-md); border-color: var(--fd-border-strong); } + .fd-map-card:focus-visible { outline: 2px solid var(--fd-accent); outline-offset: 2px; } + .fd-map-art { + position: relative; display: block; + height: 120px; + background: + linear-gradient(0deg, rgba(var(--teal-rgb), .06), rgba(var(--teal-rgb), .06)), + repeating-linear-gradient(0deg, transparent 0 23px, var(--fd-border) 23px 24px), + repeating-linear-gradient(90deg, transparent 0 23px, var(--fd-border) 23px 24px), + var(--fd-surface-2); + border-bottom: 1px solid var(--fd-border); + } + .fd-map-road { + position: absolute; display: block; + background: var(--fd-surface); + box-shadow: 0 0 0 1px var(--fd-border); + border-radius: 6px; + } + .fd-map-road-1 { left: -10%; right: -10%; top: 46%; height: 10px; transform: rotate(-8deg); } + .fd-map-road-2 { top: -20%; bottom: -20%; left: 44%; width: 9px; transform: rotate(14deg); } + .fd-map-road-3 { left: 50%; right: -10%; top: 78%; height: 7px; transform: rotate(18deg); } + .fd-map-pin { + position: absolute; display: block; + width: 18px; height: 18px; + border-radius: 50% 50% 50% 0; + transform: translate(-50%, -100%) rotate(-45deg); + border: 3px solid var(--fd-surface); + box-shadow: 0 4px 10px rgba(0, 0, 0, .2); + transition: transform .3s var(--fd-ease); + } + .fd-map-pin-loss { background: var(--fd-loss); } + .fd-map-pin-found { background: var(--fd-found); } + .fd-map-card:hover .fd-map-pin { transform: translate(-50%, -125%) rotate(-45deg); } + .fd-map-body { display: flex; flex-direction: column; gap: 4px; padding: 14px 18px 16px; } + .fd-map-title { font-weight: 700; font-size: .95rem; color: var(--fd-text); } + .fd-map-text { font-size: .82rem; color: var(--fd-text-2); line-height: 1.45; } + .fd-map-link { + display: inline-flex; align-items: center; gap: 6px; + margin-top: 6px; + color: var(--fd-accent); font-weight: 700; font-size: .84rem; + } + .fd-map-link svg { transition: transform .2s var(--fd-ease); } + .fd-map-card:hover .fd-map-link svg { transform: translateX(3px); } + + .fd-fresh { padding: 16px 10px 10px; } + .fd-fresh .fd-card-head { padding: 0 8px; } + .fd-fresh-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; } + .fd-fresh-item { + display: flex; align-items: center; gap: 12px; + width: 100%; padding: 8px; + border: none; border-radius: 12px; + background: none; + font-family: var(--font); text-align: left; + cursor: pointer; + transition: background .15s; + } + .fd-fresh-item:hover { background: var(--fd-surface-2); } + .fd-fresh-thumb { + position: relative; + width: 48px; height: 48px; flex-shrink: 0; + border-radius: 12px; + background: var(--fd-surface-2); + display: inline-flex; align-items: center; justify-content: center; + font-size: 1.3rem; + } + .fd-fresh-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; } + .fd-fresh-type { + position: absolute; right: -2px; bottom: -2px; + width: 12px; height: 12px; border-radius: 50%; + border: 2px solid var(--fd-surface); + } + .fd-fresh-type-loss { background: var(--fd-loss); } + .fd-fresh-type-found { background: var(--fd-found); } + .fd-fresh-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; } + .fd-fresh-title { color: var(--fd-text); font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .fd-fresh-sub { color: var(--fd-text-3); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + .fd-fresh-empty { padding: 12px 8px; color: var(--fd-text-3); font-size: .85rem; } + + .fd-right-foot { + display: flex; flex-wrap: wrap; gap: 4px 14px; + padding: 2px 6px; + } + .fd-right-foot button, + .fd-right-foot span { + padding: 0; border: none; background: none; + font: 500 .75rem/1.6 var(--font); + color: var(--fd-text-3); + } + .fd-right-foot button { cursor: pointer; } + .fd-right-foot button:hover { color: var(--fd-text); text-decoration: underline; } + + /* ── Карта ────────────────────────────────────────────────────────── */ + .fd-map { + display: flex; + flex: 1; min-width: 0; min-height: 0; + height: 100%; + } + .fd-map-panel { + display: flex; flex-direction: column; + width: 380px; flex-shrink: 0; + min-height: 0; + background: var(--fd-surface); + border-right: 1px solid var(--fd-border); + } + .fd-map-panel-head { + display: flex; flex-direction: column; gap: 14px; + padding: 24px 20px 16px; + border-bottom: 1px solid var(--fd-border); + } + .fd-map-panel-head .fd-segment { align-self: stretch; } + .fd-map-title-h { margin: 0; font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; color: var(--fd-text); } + .fd-chips { display: flex; flex-wrap: wrap; gap: 6px; } + .fd-chip { + height: 32px; padding: 0 12px; + border: 1px solid var(--fd-border); + border-radius: 999px; + background: var(--fd-surface); + color: var(--fd-text-2); + font: 600 .8rem/1 var(--font); + cursor: pointer; + transition: background .15s, color .15s, border-color .15s; + } + .fd-chip:hover { border-color: var(--fd-border-strong); color: var(--fd-text); } + .fd-chip.is-active { background: var(--fd-text); border-color: var(--fd-text); color: var(--fd-surface); } + .fd-map-count { font-size: .8rem; font-weight: 600; color: var(--fd-text-3); font-variant-numeric: tabular-nums; } + + .fd-map-list { + flex: 1; min-height: 0; + overflow-y: auto; + padding: 10px; + display: flex; flex-direction: column; gap: 4px; + scrollbar-width: thin; + } + .fd-map-item { + display: flex; align-items: center; gap: 8px; + padding: 6px 8px 6px 6px; + border: 1px solid transparent; + border-radius: 14px; + transition: background .15s, border-color .15s; + } + .fd-map-item.is-hl { background: var(--fd-surface-2); border-color: var(--fd-border); } + .fd-map-item-main { + flex: 1; min-width: 0; + display: flex; align-items: center; gap: 12px; + padding: 0; border: none; background: none; + text-align: left; font-family: var(--font); + cursor: pointer; + } + .fd-map-item-thumb { + width: 60px; height: 60px; flex-shrink: 0; + border-radius: 12px; overflow: hidden; + display: inline-flex; align-items: center; justify-content: center; + background: var(--fd-surface-2); color: var(--fd-text-3); + } + .fd-map-item-thumb img { width: 100%; height: 100%; object-fit: cover; } + .fd-map-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; } + .fd-map-item-title { + max-width: 100%; + color: var(--fd-text); font-weight: 600; font-size: .9rem; line-height: 1.3; + display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; + } + .fd-map-item-locate { opacity: 0; transition: opacity .15s, background .15s, color .15s; } + .fd-map-item:hover .fd-map-item-locate, + .fd-map-item.is-hl .fd-map-item-locate, + .fd-map-item-locate:focus-visible { opacity: 1; } + + .fd-badge { + display: inline-flex; align-items: center; + height: 22px; padding: 0 9px; + border-radius: 999px; + font-size: .72rem; font-weight: 700; + } + .fd-badge-loss { background: var(--fd-loss-soft); color: var(--fd-loss); } + .fd-badge-found { background: var(--fd-found-soft); color: var(--fd-found); } + + .fd-map-canvas { position: relative; flex: 1; min-width: 0; display: flex; } + .fd-map-canvas .f-mapview { border-radius: 0; } + .fd-map-canvas .f-mapview-geo { top: 16px; box-shadow: var(--fd-shadow-md); border-color: var(--fd-border); } + + /* Метки карты: подсветка при наведении на карточку списка */ + .f-map-pin { transition: transform .18s var(--fd-ease), box-shadow .18s; transform-origin: center; } + .f-map-pin.is-hl { transform: scale(1.3); box-shadow: 0 0 0 4px rgba(var(--teal-rgb), .35), 0 6px 16px rgba(0, 0, 0, .35) !important; } + + /* Скелетоны */ + .fd-skeleton { + display: block; + background: linear-gradient(90deg, var(--fd-surface-2) 25%, var(--fd-surface-hover) 50%, var(--fd-surface-2) 75%); + background-size: 200% 100%; + animation: shimmer 1.4s linear infinite; + border-radius: 8px; + } + .fd-skeleton-item { pointer-events: none; } + .fd-skeleton-item .fd-map-item-body { gap: 8px; } + .fd-skeleton-line { width: 85%; height: 12px; } + .fd-skeleton-line-short { width: 40%; } + + .fd-empty { + display: flex; flex-direction: column; align-items: center; justify-content: center; + gap: 8px; padding: 48px 24px; + text-align: center; + } + .fd-empty-sm { padding: 40px 16px; } + .fd-empty-icon { + width: 56px; height: 56px; border-radius: 18px; + display: inline-flex; align-items: center; justify-content: center; + background: var(--fd-surface-2); color: var(--fd-text-3); + margin-bottom: 6px; + } + .fd-empty-title { font-size: 1rem; font-weight: 700; color: var(--fd-text); } + .fd-empty-sub { font-size: .86rem; color: var(--fd-text-2); max-width: 320px; line-height: 1.5; } + + /* ── Модалки на десктопе: мягкий фон и тени ──────────────────────── */ + .f-modal-bg { + background: rgba(10, 12, 16, .45); + -webkit-backdrop-filter: blur(6px); + backdrop-filter: blur(6px); + } + .f-modal { + border-radius: 22px; + box-shadow: var(--fd-shadow-lg); + } + + @keyframes fd-rise { + from { opacity: 0; transform: translateY(8px); } + to { opacity: 1; transform: none; } + } +} + +/* ── 900–1199: левая навигация свёрнута в рейку ─────────────────────── */ +@media (min-width: 900px) and (max-width: 1199px) { + :root { --fd-sidebar-w: 80px; } + .fd-sidebar { padding: 16px 12px; align-items: center; } + .fd-sb-head { padding: 0 0 16px; } + .fd-sb-logo-full { display: none; } + .fd-sb-logo-mark { display: block; } + .fd-sb-cta { display: flex; justify-content: center; width: 48px; height: 48px; padding: 0; margin: 0 0 16px; border-radius: 15px; } + .fd-sb-nav, .fd-sb-bottom { width: 100%; align-items: center; } + .fd-sb-label, .fd-sb-badge, .fd-sb-section { display: none; } + .fd-sb-item { width: 48px; min-height: 46px; padding: 0; justify-content: center; } + .fd-sb-item.is-active::before { left: -12px; } + .fd-sb-dot { display: block; } + .fd-sb-prefs { flex-direction: column; width: 48px; } + .fd-sb-pref-lang span { display: none; } + .fd-sb-profile { width: 48px; padding: 4px; justify-content: center; border: none; } + .fd-feed-header { padding: 22px 24px 16px; } + .f-main-feed .f-feed-scroll { padding: 20px 24px 40px; } + .fd-map-panel { width: 330px; } +} + +/* Правая колонка — только на широких экранах */ +@media (min-width: 900px) and (max-width: 1319px) { + .fd-right { display: none; } +} + +@media (min-width: 900px) and (max-width: 1100px) { + .fd-feed-controls { flex-wrap: wrap; } + .fd-feed-search { flex-basis: 100%; order: -1; } + .fd-feed-city { flex: 1 1 260px; } +} + +@media (min-width: 1600px) { + .fd-grid { grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 26px; } +} + +@media (min-width: 900px) and (prefers-reduced-motion: reduce) { + .fd-grid .f-card { animation: none; } + .fd-grid .f-card, + .fd-grid .f-card-img img, + .fd-segment-thumb { transition: none; } +} + +/* ── Мессенджер (двухпанельные чаты) ───────────────────────────────── */ +@media (min-width: 900px) { + .fd-chats-app { background: var(--fd-bg); } + .fd-chats { + flex: 1; min-width: 0; + display: flex; + height: 100vh; height: 100dvh; + } + .fd-chats-list { + width: 360px; flex-shrink: 0; + display: flex; flex-direction: column; + min-height: 0; + background: var(--fd-surface); + border-right: 1px solid var(--fd-border); + } + .fd-chats-list-head { + display: flex; flex-direction: column; gap: 14px; + padding: 24px 18px 14px; + border-bottom: 1px solid var(--fd-border); + } + .fd-chats-title { + display: flex; align-items: center; gap: 10px; + margin: 0; + font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; + color: var(--fd-text); + } + .fd-chats-count { + min-width: 26px; height: 22px; padding: 0 8px; + display: inline-flex; align-items: center; justify-content: center; + border-radius: 999px; + background: var(--fd-surface-2); color: var(--fd-text-2); + font-size: .76rem; font-weight: 700; + } + .fd-chats-search { + display: flex; align-items: center; gap: 8px; + height: 40px; padding: 0 12px; + border: 1px solid var(--fd-border); + border-radius: 12px; + background: var(--fd-surface-2); + color: var(--fd-text-3); + transition: border-color .15s, box-shadow .15s, background .15s; + } + .fd-chats-search:focus-within { + background: var(--fd-surface); + border-color: rgba(var(--teal-rgb), .5); + box-shadow: 0 0 0 3px rgba(var(--teal-rgb), .12); + } + .fd-chats-search input { + flex: 1; min-width: 0; + border: none; outline: none; background: none; + color: var(--fd-text); + font: 400 .88rem/1 var(--font); + } + .fd-chats-search input::placeholder { color: var(--fd-text-3); } + + .fd-chats-scroll { + flex: 1; min-height: 0; + overflow-y: auto; + padding: 8px; + scrollbar-width: thin; + } + .fd-chat-row { position: relative; border-radius: 14px; } + .fd-chat-row .chat-list-item { + gap: 12px; + padding: 10px 12px; + border: none; + border-radius: 14px; + background: none; + transition: background .15s; + } + .fd-chat-row .chat-list-item:hover { background: var(--fd-surface-2); } + .fd-chat-row.is-active .chat-list-item { background: var(--fd-accent-soft); } + .fd-chat-row.is-active .chat-list-name { color: var(--fd-accent); } + .fd-chat-row .chat-list-avatar { + width: 48px; height: 48px; flex-shrink: 0; + border-radius: 14px; border: none; + background: var(--fd-surface-2); + overflow: hidden; + } + .fd-chat-row .chat-list-avatar-img { border-radius: 14px; } + .fd-chat-row .chat-list-name { font-size: .9rem; font-weight: 700; color: var(--fd-text); } + .fd-chat-row .chat-list-preview { font-size: .8rem; color: var(--fd-text-3); } + .fd-chat-row .chat-list-delete-btn { border-radius: 10px; } + .fd-chat-draft { cursor: default; } + .fd-chat-draft .chat-list-avatar { color: var(--fd-accent); } + + .fd-chat-skeleton { display: flex; align-items: center; gap: 12px; padding: 10px 12px; } + .fd-chat-skeleton-avatar { width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0; } + .fd-chat-skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; } + + .fd-chats-main { + position: relative; + flex: 1; min-width: 0; + display: flex; + } + .fd-chats-main .chat-page--embedded { height: 100%; } + .fd-chats-main .chat-page--embedded .chat-back-btn { + width: 36px; height: 36px; padding: 0; + display: inline-flex; align-items: center; justify-content: center; + border-color: var(--fd-border); + background: var(--fd-surface); + font-size: 1rem; + } + .fd-chats-main .chat-page--embedded .chat-header { padding: 14px 24px; } + .fd-chats-main .chat-page--embedded .chat-header-title { font-size: 1.02rem; } + .fd-chats-main .chat-page--embedded .chat-messages { + padding-left: max(24px, calc((100% - 820px) / 2)); + padding-right: max(24px, calc((100% - 820px) / 2)); + } + .fd-chats-main .chat-page--embedded .chat-input-row { + max-width: 820px; margin: 0 auto; width: 100%; + padding-left: 24px; padding-right: 24px; + } + + .fd-chats-placeholder { + flex: 1; + display: flex; flex-direction: column; align-items: center; justify-content: center; + gap: 10px; padding: 40px; + text-align: center; + background: + radial-gradient(60% 50% at 50% 40%, rgba(var(--teal-rgb), .06) 0%, transparent 70%), + var(--fd-bg); + } + .fd-chats-placeholder-icon { + width: 72px; height: 72px; border-radius: 24px; + display: inline-flex; align-items: center; justify-content: center; + background: var(--fd-surface); + color: var(--fd-accent); + box-shadow: var(--fd-shadow-md); + margin-bottom: 8px; + } + .fd-chats-placeholder .fd-btn { margin-top: 8px; } +} + +@media (min-width: 900px) and (max-width: 1199px) { + .fd-chats-list { width: 300px; } + .fd-sb-pref { flex: 0 0 38px; width: 48px; } +} + +/* ── Отзывы ─────────────────────────────────────────────────────────── */ +@media (min-width: 900px) { + .fd-page-header .fd-feed-header-inner { max-width: 1040px; } + .fd-page-header .fd-feed-sub { margin-bottom: 4px; } + .rv-scroll { background: var(--fd-bg); } + .rv-layout { max-width: 1040px; padding: 28px 32px 48px; gap: 28px; align-items: flex-start; } + .rv-sidebar { position: sticky; top: 28px; width: 340px; min-width: 300px; } + .rv-summary, .rv-form, .rv-login-prompt { + background: var(--fd-surface); + border: 1px solid var(--fd-border); + border-radius: var(--fd-radius-lg); + box-shadow: var(--fd-shadow-xs); + } + .rv-form-textarea { + background: var(--fd-surface-2); + border-color: var(--fd-border); + border-radius: 12px; + } + .rv-form-submit, .rv-login-btn { border-radius: 11px; } + .rv-list { gap: 14px; } + .rv-card { + background: var(--fd-surface); + border: 1px solid var(--fd-border); + border-radius: var(--fd-radius-lg); + box-shadow: var(--fd-shadow-xs); + padding: 20px 22px; + transition: border-color .2s, box-shadow .2s, transform .2s var(--fd-ease); + } + .rv-card:hover { border-color: var(--fd-border-strong); box-shadow: var(--fd-shadow-sm); transform: translateY(-1px); } + .rv-card-text { color: var(--fd-text-2); line-height: 1.55; } +} diff --git a/src/utils/relativeTime.js b/src/utils/relativeTime.js new file mode 100644 index 0000000..c878e71 --- /dev/null +++ b/src/utils/relativeTime.js @@ -0,0 +1,27 @@ +const UNITS = [ + ["year", 365 * 24 * 3600], + ["month", 30 * 24 * 3600], + ["week", 7 * 24 * 3600], + ["day", 24 * 3600], + ["hour", 3600], + ["minute", 60], +]; + +/** + * «5 минут назад», «вчера», «2 недели назад» — по языку интерфейса. + * Возвращает null для пустой/некорректной даты. + */ +export function formatRelativeTime(value, language = "ru", now = Date.now()) { + if (!value) return null; + const time = new Date(value).getTime(); + if (!Number.isFinite(time)) return null; + + const diffSec = Math.round((time - now) / 1000); + const abs = Math.abs(diffSec); + const rtf = new Intl.RelativeTimeFormat(language, { numeric: "auto" }); + + for (const [unit, sec] of UNITS) { + if (abs >= sec) return rtf.format(Math.round(diffSec / sec), unit); + } + return rtf.format(0, "minute"); +}