Add first-visit tip and how-to guide for guests
- guests in the feed see a "New here?" tip with a waving hand: swipe up to dismiss on mobile (top), close button on desktop (bottom right); shown once, remembered in localStorage - GuideModal: six short steps (feed and map, map pins, posting, chat with photos/video, phone reveal, marking as returned) plus safety tips; guests get a sign-in button - "How it works" item in the mobile menu and the desktop sidebar - ru/en texts, tests, README Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
12
README.md
12
README.md
@@ -196,13 +196,13 @@ src/
|
||||
│ ├── admin/ PostsTab, AdvertisingCreate/EditModal, CampaignCreate/EditModal, ...
|
||||
│ ├── landing/ Hero, Navbar, StepsSection, RadarBeacon, FinalCta, Footer, Icon
|
||||
│ ├── icons/ NavIcons + Calendar/Close/Globe/Menu/Moon/Phone/Pin/Sun/Trash
|
||||
│ └── … AuthModal, Toast, MapView, PostDetailModal, AdCard, AdSlot, ...
|
||||
│ └── … AuthModal, Toast, MapView, PostDetailModal, GuideModal, GuestGuideBanner, AdCard, AdSlot, ...
|
||||
│
|
||||
├── styles/
|
||||
│ ├── index.css # Точка входа CSS
|
||||
│ ├── base.css # Переменные, сброс, keyframes
|
||||
│ ├── layout.css, sidebar.css, card.css, modal.css, ui.css
|
||||
│ ├── chat.css, desktop.css
|
||||
│ ├── chat.css, desktop.css, guide.css
|
||||
│ └── reviews.css, rules.css, admin.css, NakhodkaLanding.css
|
||||
│
|
||||
└── locales/
|
||||
@@ -715,6 +715,14 @@ CSS-переменные в `base.css`:
|
||||
загрузку → `PUT` прямо в MinIO с процентом → подтверждение → в ленте заглушка
|
||||
«обрабатывается», через несколько секунд по сокету приходит готовый плеер.
|
||||
|
||||
**Первый визит.** Гость открывает ленту → через секунду появляется подсказка
|
||||
«Ты здесь впервые?» (`GuestGuideBanner`: на телефоне сверху, смахивается вверх; на
|
||||
десктопе справа внизу, закрывается крестиком) → «Как пользоваться» открывает
|
||||
`GuideModal` — шесть шагов (лента и карта, объявление, чат, номер, «вернулось») и правила безопасности. Закрытая или открытая подсказка
|
||||
больше не показывается (`localStorage`, ключ `nakhodka:guideBannerDismissed`).
|
||||
Инструкция всегда доступна из меню: пункт «Инструкция» в мобильном меню и в
|
||||
десктопной навигации.
|
||||
|
||||
**Показ номера.** «Показать номер» → `GET …/phone/challenge` → браузер решает задачу
|
||||
(доли секунды) → `POST …/phone` → номер-ссылка `tel:`.
|
||||
|
||||
|
||||
118
src/components/GuestGuide.test.jsx
Normal file
118
src/components/GuestGuide.test.jsx
Normal file
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* Подсказка гостю «Ты здесь впервые?» и инструкция: появление с задержкой,
|
||||
* закрытие крестиком и смахиванием вверх, запоминание, открытие инструкции.
|
||||
*/
|
||||
import { render, screen, fireEvent, act } from "@testing-library/react";
|
||||
import "@testing-library/jest-dom";
|
||||
import "../i18n";
|
||||
import i18n from "../i18n";
|
||||
import GuestGuideBanner, { GUIDE_BANNER_KEY } from "./GuestGuideBanner";
|
||||
import GuideModal from "./GuideModal";
|
||||
|
||||
beforeAll(() => i18n.changeLanguage("ru"));
|
||||
|
||||
beforeEach(() => {
|
||||
localStorage.clear();
|
||||
jest.useFakeTimers();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
function showBanner(props = {}) {
|
||||
render(<GuestGuideBanner onOpenGuide={jest.fn()} {...props} />);
|
||||
act(() => {
|
||||
jest.advanceTimersByTime(1500);
|
||||
});
|
||||
}
|
||||
|
||||
test("подсказка появляется не сразу, а через секунду", () => {
|
||||
render(<GuestGuideBanner onOpenGuide={jest.fn()} />);
|
||||
expect(screen.queryByText("Ты здесь впервые?")).toBeNull();
|
||||
|
||||
act(() => {
|
||||
jest.advanceTimersByTime(1500);
|
||||
});
|
||||
expect(screen.getByText("Ты здесь впервые?")).toBeInTheDocument();
|
||||
expect(screen.getByText(/Посмотри, как пользоваться приложением/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test("крестик закрывает подсказку навсегда", () => {
|
||||
showBanner();
|
||||
|
||||
fireEvent.click(screen.getByLabelText("Скрыть подсказку"));
|
||||
act(() => {
|
||||
jest.advanceTimersByTime(300);
|
||||
});
|
||||
|
||||
expect(screen.queryByText("Ты здесь впервые?")).toBeNull();
|
||||
expect(localStorage.getItem(GUIDE_BANNER_KEY)).toBe("1");
|
||||
});
|
||||
|
||||
test("закрытая подсказка больше не показывается", () => {
|
||||
localStorage.setItem(GUIDE_BANNER_KEY, "1");
|
||||
showBanner();
|
||||
|
||||
expect(screen.queryByText("Ты здесь впервые?")).toBeNull();
|
||||
});
|
||||
|
||||
test("смахивание вверх закрывает, короткое движение — нет", () => {
|
||||
showBanner();
|
||||
const banner = screen.getByRole("status");
|
||||
|
||||
// Чуть-чуть потянули — карточка возвращается на место
|
||||
fireEvent.touchStart(banner, { touches: [{ clientY: 100 }] });
|
||||
fireEvent.touchMove(banner, { touches: [{ clientY: 85 }] });
|
||||
fireEvent.touchEnd(banner);
|
||||
expect(localStorage.getItem(GUIDE_BANNER_KEY)).toBeNull();
|
||||
expect(screen.getByText("Ты здесь впервые?")).toBeInTheDocument();
|
||||
|
||||
// Смахнули вверх — закрылась и запомнилась
|
||||
fireEvent.touchStart(banner, { touches: [{ clientY: 100 }] });
|
||||
fireEvent.touchMove(banner, { touches: [{ clientY: 30 }] });
|
||||
fireEvent.touchEnd(banner);
|
||||
act(() => {
|
||||
jest.advanceTimersByTime(300);
|
||||
});
|
||||
expect(screen.queryByText("Ты здесь впервые?")).toBeNull();
|
||||
expect(localStorage.getItem(GUIDE_BANNER_KEY)).toBe("1");
|
||||
});
|
||||
|
||||
test("кнопка открывает инструкцию и убирает подсказку", () => {
|
||||
const onOpenGuide = jest.fn();
|
||||
showBanner({ onOpenGuide });
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Как пользоваться" }));
|
||||
|
||||
expect(onOpenGuide).toHaveBeenCalledTimes(1);
|
||||
expect(screen.queryByText("Ты здесь впервые?")).toBeNull();
|
||||
expect(localStorage.getItem(GUIDE_BANNER_KEY)).toBe("1");
|
||||
});
|
||||
|
||||
test("инструкция: шаги, безопасность и вход для гостя", () => {
|
||||
const onClose = jest.fn();
|
||||
const onLoginClick = jest.fn();
|
||||
render(<GuideModal onClose={onClose} onLoginClick={onLoginClick} />);
|
||||
|
||||
expect(screen.getByRole("dialog", { name: "Как пользоваться Находкой" })).toBeInTheDocument();
|
||||
// 6 шагов + 4 совета по безопасности
|
||||
expect(screen.getAllByRole("listitem")).toHaveLength(6 + 4);
|
||||
expect(screen.getByText("Ищи в ленте или на карте")).toBeInTheDocument();
|
||||
expect(screen.getByText("Смотри на карте")).toBeInTheDocument();
|
||||
expect(screen.getByText("Пиши автору")).toBeInTheDocument();
|
||||
expect(screen.getByText("Будь осторожен", { exact: false })).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Войти или зарегистрироваться" }));
|
||||
expect(onLoginClick).toHaveBeenCalledTimes(1);
|
||||
|
||||
fireEvent.keyDown(window, { key: "Escape" });
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test("инструкция для вошедшего — без кнопки входа", () => {
|
||||
render(<GuideModal onClose={jest.fn()} />);
|
||||
|
||||
expect(screen.queryByRole("button", { name: "Войти или зарегистрироваться" })).toBeNull();
|
||||
expect(screen.getByRole("button", { name: "Понятно" })).toBeInTheDocument();
|
||||
});
|
||||
124
src/components/GuestGuideBanner.jsx
Normal file
124
src/components/GuestGuideBanner.jsx
Normal file
@@ -0,0 +1,124 @@
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import CloseIcon from "./icons/CloseIcon";
|
||||
import "../styles/guide.css";
|
||||
|
||||
export const GUIDE_BANNER_KEY = "nakhodka:guideBannerDismissed";
|
||||
/** Подсказка появляется не сразу: сначала человек видит ленту. */
|
||||
const SHOW_DELAY_MS = 1200;
|
||||
/** Насколько смахнуть вверх, чтобы карточка закрылась, px. */
|
||||
const SWIPE_DISMISS_PX = 40;
|
||||
const LEAVE_ANIMATION_MS = 250;
|
||||
|
||||
export function isGuideBannerDismissed() {
|
||||
try {
|
||||
return localStorage.getItem(GUIDE_BANNER_KEY) === "1";
|
||||
} catch {
|
||||
return false; // приватный режим — просто покажем ещё раз
|
||||
}
|
||||
}
|
||||
|
||||
function rememberDismissed() {
|
||||
try {
|
||||
localStorage.setItem(GUIDE_BANNER_KEY, "1");
|
||||
} catch {
|
||||
// нет хранилища — подсказка вернётся при следующем визите, это не страшно
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ненавязчивая подсказка для гостя в ленте: «Ты здесь впервые?» с кнопкой
|
||||
* инструкции. На телефоне смахивается вверх, на десктопе закрывается крестиком
|
||||
* (крестик есть и на телефоне — смахивание доступно не всем). Закрытая или
|
||||
* открытая один раз подсказка больше не показывается.
|
||||
*
|
||||
* @param {{ onOpenGuide: () => void }} props
|
||||
*/
|
||||
export default function GuestGuideBanner({ onOpenGuide }) {
|
||||
const { t } = useTranslation();
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [leaving, setLeaving] = useState(false);
|
||||
const [drag, setDrag] = useState(0);
|
||||
const [dragging, setDragging] = useState(false);
|
||||
const startYRef = useRef(null);
|
||||
const leaveTimerRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (isGuideBannerDismissed()) return undefined;
|
||||
const timer = setTimeout(() => setVisible(true), SHOW_DELAY_MS);
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
useEffect(() => () => clearTimeout(leaveTimerRef.current), []);
|
||||
|
||||
const dismiss = useCallback(() => {
|
||||
rememberDismissed();
|
||||
setLeaving(true);
|
||||
leaveTimerRef.current = setTimeout(() => setVisible(false), LEAVE_ANIMATION_MS);
|
||||
}, []);
|
||||
|
||||
const openGuide = () => {
|
||||
rememberDismissed();
|
||||
setVisible(false);
|
||||
onOpenGuide();
|
||||
};
|
||||
|
||||
const onTouchStart = (e) => {
|
||||
startYRef.current = e.touches[0].clientY;
|
||||
setDragging(true);
|
||||
};
|
||||
|
||||
const onTouchMove = (e) => {
|
||||
if (startYRef.current == null) return;
|
||||
const dy = e.touches[0].clientY - startYRef.current;
|
||||
// Вверх — тянется за пальцем, вниз — едва поддаётся (как у системных уведомлений)
|
||||
setDrag(dy < 0 ? dy : dy / 6);
|
||||
};
|
||||
|
||||
const onTouchEnd = () => {
|
||||
const shouldDismiss = drag < -SWIPE_DISMISS_PX;
|
||||
startYRef.current = null;
|
||||
setDragging(false);
|
||||
if (shouldDismiss) {
|
||||
dismiss();
|
||||
} else {
|
||||
setDrag(0);
|
||||
}
|
||||
};
|
||||
|
||||
if (!visible) return null;
|
||||
|
||||
const className = [
|
||||
"guest-banner",
|
||||
dragging ? "is-dragging" : "is-settling",
|
||||
leaving ? "is-leaving" : "",
|
||||
].join(" ");
|
||||
|
||||
return (
|
||||
<div
|
||||
className={className}
|
||||
role="status"
|
||||
style={{ "--banner-drag": `${drag}px` }}
|
||||
onTouchStart={onTouchStart}
|
||||
onTouchMove={onTouchMove}
|
||||
onTouchEnd={onTouchEnd}
|
||||
onTouchCancel={onTouchEnd}
|
||||
>
|
||||
<span className="guest-banner-icon" aria-hidden="true">
|
||||
<span className="guest-banner-wave">👋</span>
|
||||
</span>
|
||||
<div className="guest-banner-body">
|
||||
<div className="guest-banner-title">{t("guide.bannerTitle")}</div>
|
||||
<div className="guest-banner-text">{t("guide.bannerText")}</div>
|
||||
<button type="button" className="guest-banner-btn" onClick={openGuide}>
|
||||
{t("guide.bannerButton")}
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" className="guest-banner-close" onClick={dismiss}
|
||||
aria-label={t("guide.bannerClose")} title={t("guide.bannerClose")}>
|
||||
<CloseIcon />
|
||||
</button>
|
||||
<span className="guest-banner-handle" aria-hidden="true" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
86
src/components/GuideModal.jsx
Normal file
86
src/components/GuideModal.jsx
Normal file
@@ -0,0 +1,86 @@
|
||||
import { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import CloseIcon from "./icons/CloseIcon";
|
||||
import "../styles/guide.css";
|
||||
|
||||
const STEPS = [
|
||||
{ key: "search", icon: "🔎" },
|
||||
{ key: "map", icon: "🗺️" },
|
||||
{ key: "create", icon: "📝" },
|
||||
{ key: "chat", icon: "💬" },
|
||||
{ key: "phone", icon: "📞" },
|
||||
{ key: "done", icon: "✅" },
|
||||
];
|
||||
|
||||
const SAFETY = ["safety1", "safety2", "safety3", "safety4"];
|
||||
|
||||
/**
|
||||
* Короткая инструкция для обычного пользователя: шесть шагов и правила
|
||||
* безопасности. Открывается из приветственной подсказки в ленте и из меню.
|
||||
* onLoginClick — для гостя: кнопка «Войти или зарегистрироваться».
|
||||
*
|
||||
* @param {{ onClose: () => void, onLoginClick?: () => void }} props
|
||||
*/
|
||||
export default function GuideModal({ onClose, onLoginClick }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
useEffect(() => {
|
||||
const prev = document.body.style.overflow;
|
||||
document.body.style.overflow = "hidden";
|
||||
const onKey = (e) => {
|
||||
if (e.key === "Escape") onClose();
|
||||
};
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => {
|
||||
document.body.style.overflow = prev;
|
||||
window.removeEventListener("keydown", onKey);
|
||||
};
|
||||
}, [onClose]);
|
||||
|
||||
return (
|
||||
<div className="f-modal-bg" onClick={(e) => e.target === e.currentTarget && onClose()}>
|
||||
<div className="f-modal guide-modal" role="dialog" aria-modal="true" aria-labelledby="guide-title">
|
||||
<div className="f-modal-head">
|
||||
<span className="f-modal-title" id="guide-title">{t("guide.title")}</span>
|
||||
<button type="button" className="f-close-btn" onClick={onClose} aria-label={t("common.close")}>
|
||||
<CloseIcon />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p className="guide-intro">{t("guide.intro")}</p>
|
||||
|
||||
<ol className="guide-steps">
|
||||
{STEPS.map(({ key, icon }, i) => (
|
||||
<li key={key} className="guide-step">
|
||||
<span className="guide-step-icon" aria-hidden="true">{icon}</span>
|
||||
<div className="guide-step-body">
|
||||
<div className="guide-step-title">
|
||||
<span className="guide-step-num">{i + 1}.</span> {t(`guide.${key}Title`)}
|
||||
</div>
|
||||
<div className="guide-step-text">{t(`guide.${key}Text`)}</div>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
|
||||
<section className="guide-safety" aria-labelledby="guide-safety-title">
|
||||
<div className="guide-safety-title" id="guide-safety-title">⚠️ {t("guide.safetyTitle")}</div>
|
||||
<ul>
|
||||
{SAFETY.map((key) => <li key={key}>{t(`guide.${key}`)}</li>)}
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<div className="guide-actions">
|
||||
{onLoginClick && (
|
||||
<button type="button" className="guide-btn guide-btn-primary" onClick={onLoginClick}>
|
||||
{t("guide.login")}
|
||||
</button>
|
||||
)}
|
||||
<button type="button" className={`guide-btn${onLoginClick ? "" : " guide-btn-primary"}`} onClick={onClose}>
|
||||
{t("guide.gotIt")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { useAuthContext } from "../context/AuthContext";
|
||||
import { useIsDesktop } from "../hooks/useIsDesktop";
|
||||
import SupportModal from "./SupportModal";
|
||||
import GuideModal from "./GuideModal";
|
||||
import UploadAdModal from "./UploadAdModal";
|
||||
import ProfileAvatar from "./profile/ProfileAvatar";
|
||||
import NahodkaLogo from "./MainNahodkaLogo";
|
||||
@@ -50,7 +51,9 @@ export default function Sidebar({
|
||||
const { language, toggleLanguage } = useLanguageToggle();
|
||||
const [supportOpen, setSupportOpen] = useState(false);
|
||||
const [uploadAdOpen, setUploadAdOpen] = useState(false);
|
||||
const [guideOpen, setGuideOpen] = useState(false);
|
||||
const HelpIcon = NavIcons.help;
|
||||
const BookIcon = NavIcons.book;
|
||||
|
||||
// Десктоп (>= 900px) — отдельная навигация с картой, CTA и свёрткой в рейку.
|
||||
// Мобильный drawer ниже остаётся без изменений.
|
||||
@@ -210,6 +213,16 @@ export default function Sidebar({
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
<button
|
||||
type="button"
|
||||
className="f-sb-item"
|
||||
onClick={() => {
|
||||
setGuideOpen(true);
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
<BookIcon /> {t('nav.guide')}
|
||||
</button>
|
||||
<button type="button" className="f-sb-item" onClick={() => setSupportOpen(true)}>
|
||||
<HelpIcon /> {t('nav.support')} </button>
|
||||
<div className="f-sb-divider" />
|
||||
@@ -246,6 +259,15 @@ export default function Sidebar({
|
||||
</div>
|
||||
{supportOpen && <SupportModal onClose={() => setSupportOpen(false)} />}
|
||||
{uploadAdOpen && <UploadAdModal onClose={() => setUploadAdOpen(false)} />}
|
||||
{guideOpen && (
|
||||
<GuideModal
|
||||
onClose={() => setGuideOpen(false)}
|
||||
onLoginClick={isAuthenticated ? undefined : () => {
|
||||
setGuideOpen(false);
|
||||
onLoginClick();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import GlobeIcon from "../icons/GlobeIcon";
|
||||
import NahodkaLogo from "../MainNahodkaLogo";
|
||||
import ProfileAvatar from "../profile/ProfileAvatar";
|
||||
import SupportModal from "../SupportModal";
|
||||
import GuideModal from "../GuideModal";
|
||||
import UploadAdModal from "../UploadAdModal";
|
||||
import { useTheme } from "../../context/ThemeContext";
|
||||
import { useUnread } from "../../context/UnreadContext";
|
||||
@@ -59,6 +60,7 @@ export default function DesktopSidebar({
|
||||
const { language, toggleLanguage } = useLanguageToggle();
|
||||
const [supportOpen, setSupportOpen] = useState(false);
|
||||
const [uploadAdOpen, setUploadAdOpen] = useState(false);
|
||||
const [guideOpen, setGuideOpen] = useState(false);
|
||||
|
||||
const profileName = `${profileData?.firstName || ""} ${profileData?.lastName || ""}`.trim();
|
||||
|
||||
@@ -180,6 +182,15 @@ export default function DesktopSidebar({
|
||||
<span className="fd-sb-icon">{NavIcons.star()}</span>
|
||||
<span className="fd-sb-label">{t("nav.reviews")}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="fd-sb-item fd-sb-item-sm"
|
||||
onClick={() => setGuideOpen(true)}
|
||||
title={t("nav.guide")}
|
||||
>
|
||||
<span className="fd-sb-icon">{NavIcons.book()}</span>
|
||||
<span className="fd-sb-label">{t("nav.guide")}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="fd-sb-item fd-sb-item-sm"
|
||||
@@ -245,6 +256,15 @@ export default function DesktopSidebar({
|
||||
</aside>
|
||||
{supportOpen && <SupportModal onClose={() => setSupportOpen(false)} />}
|
||||
{uploadAdOpen && <UploadAdModal onClose={() => setUploadAdOpen(false)} />}
|
||||
{guideOpen && (
|
||||
<GuideModal
|
||||
onClose={() => setGuideOpen(false)}
|
||||
onLoginClick={isAuthenticated ? undefined : () => {
|
||||
setGuideOpen(false);
|
||||
onLoginClick();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,13 @@ export const NavIcons = {
|
||||
<line x1="12" y1="17" x2="12.01" y2="17" />
|
||||
</svg>
|
||||
),
|
||||
// Открытая книга — «Инструкция»
|
||||
book: () => (
|
||||
<svg width={20} height={20} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M2 4h6a4 4 0 0 1 4 4v13a3 3 0 0 0-3-3H2z" />
|
||||
<path d="M22 4h-6a4 4 0 0 0-4 4v13a3 3 0 0 1 3-3h7z" />
|
||||
</svg>
|
||||
),
|
||||
megaphone: () => (
|
||||
<svg width={20} height={20} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="m3 11 18-5v12L3 14v-3z" />
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useState, useCallback } from "react";
|
||||
* Управляет всеми модалками MainFeed через единое состояние,
|
||||
* чтобы гарантировать что открыта максимум одна модалка сразу.
|
||||
*
|
||||
* Типы: "create" | "edit" | "profile" | "auth" | "rules" | "postDetail"
|
||||
* Типы: "create" | "edit" | "profile" | "auth" | "rules" | "guide" | "postDetail"
|
||||
*/
|
||||
export function useModals() {
|
||||
const [modal, setModal] = useState(null); // { type, payload }
|
||||
|
||||
@@ -15,7 +15,35 @@
|
||||
"reviews": "Reviews",
|
||||
"rules": "Platform Rules",
|
||||
"support": "Support",
|
||||
"about": "About"
|
||||
"about": "About",
|
||||
"guide": "How it works"
|
||||
},
|
||||
"guide": {
|
||||
"bannerTitle": "New here?",
|
||||
"bannerText": "See how the app works — it takes a minute.",
|
||||
"bannerButton": "How it works",
|
||||
"bannerClose": "Hide the tip",
|
||||
"title": "How to use Nakhodka",
|
||||
"intro": "Nakhodka helps return lost things — belongings, documents and pets. You can browse without an account; posting and chatting need a free sign-up.",
|
||||
"searchTitle": "Search the feed or the map",
|
||||
"searchText": "In the feed, switch between “Lost” and “Found”, pick a city and search by words. To see what was lost or found near you, open the “Map”.",
|
||||
"mapTitle": "Check the map",
|
||||
"mapText": "The map opens where you are (if you allow location access). Red pins are lost items, green pins are found ones; tap a pin to open the listing. The address in a listing is a button too — it shows the place on the map.",
|
||||
"createTitle": "Post a listing",
|
||||
"createText": "Tap “+” or “Post a listing”, add photos and a description, and mark the exact place on the map — people will find you faster. After a quick check the listing appears in the feed and on the map.",
|
||||
"chatTitle": "Message the author",
|
||||
"chatText": "The “Write” button opens a chat. Send photos and videos — it makes it easier to prove the item is yours.",
|
||||
"phoneTitle": "Call if allowed",
|
||||
"phoneText": "If the author allowed it, the listing has a “Show number” button. If not, use the chat.",
|
||||
"doneTitle": "Mark it returned",
|
||||
"doneText": "Item is back with its owner? Tap “✓ Returned to owner” in your listing — it will be closed.",
|
||||
"safetyTitle": "Stay safe",
|
||||
"safety1": "Never pay in advance — scammers ask for a “deposit” or a “delivery fee”.",
|
||||
"safety2": "Ask for details or photos that are not in the listing.",
|
||||
"safety3": "Meet in a public place.",
|
||||
"safety4": "Found documents are returned free of charge.",
|
||||
"login": "Log in or sign up",
|
||||
"gotIt": "Got it"
|
||||
},
|
||||
"categories": {
|
||||
"item": "Item",
|
||||
|
||||
@@ -15,7 +15,35 @@
|
||||
"reviews": "Отзывы",
|
||||
"rules": "Правила площадки",
|
||||
"support": "Поддержка",
|
||||
"about": "О сервисе"
|
||||
"about": "О сервисе",
|
||||
"guide": "Инструкция"
|
||||
},
|
||||
"guide": {
|
||||
"bannerTitle": "Ты здесь впервые?",
|
||||
"bannerText": "Посмотри, как пользоваться приложением — это займёт минуту.",
|
||||
"bannerButton": "Как пользоваться",
|
||||
"bannerClose": "Скрыть подсказку",
|
||||
"title": "Как пользоваться Находкой",
|
||||
"intro": "Находка помогает вернуть потерянное — вещи, документы и питомцев. Смотреть ленту можно без входа, а для объявлений и чата нужна регистрация — она бесплатная.",
|
||||
"searchTitle": "Ищи в ленте или на карте",
|
||||
"searchText": "В ленте переключай «Потери» и «Находки», выбирай город и ищи по словам. А чтобы понять, что потеряли или нашли рядом с тобой, открой «Карту».",
|
||||
"mapTitle": "Смотри на карте",
|
||||
"mapText": "Карта сразу покажет место, где ты сейчас (если разрешишь геолокацию). Красные метки — потери, зелёные — находки; нажми на метку, и откроется объявление. Адрес в объявлении — тоже кнопка: она покажет место на карте.",
|
||||
"createTitle": "Размести объявление",
|
||||
"createText": "Нажми «+» или «Разместить объявление», добавь фото и описание и точно отметь место на карте — так тебя быстрее найдут. После короткой проверки объявление появится в ленте и на карте.",
|
||||
"chatTitle": "Пиши автору",
|
||||
"chatText": "Кнопка «Написать» откроет чат. Отправляй фото и видео — так проще доказать, что вещь твоя.",
|
||||
"phoneTitle": "Звони, если можно",
|
||||
"phoneText": "Если автор разрешил, в объявлении есть кнопка «Показать номер». Если её нет — пиши в чат.",
|
||||
"doneTitle": "Отметь, что вернулось",
|
||||
"doneText": "Вещь у владельца? Нажми «✓ Вернулось к владельцу» в своём объявлении — оно закроется.",
|
||||
"safetyTitle": "Будь осторожен",
|
||||
"safety1": "Не переводи деньги заранее — мошенники просят «залог» или оплату «за доставку».",
|
||||
"safety2": "Попроси назвать приметы или прислать фото, которых нет в объявлении.",
|
||||
"safety3": "Встречайся в людном месте.",
|
||||
"safety4": "Найденные документы возвращают бесплатно.",
|
||||
"login": "Войти или зарегистрироваться",
|
||||
"gotIt": "Понятно"
|
||||
},
|
||||
"categories": {
|
||||
"item": "Вещь",
|
||||
|
||||
@@ -11,6 +11,8 @@ import CityFilterLegacy from "../components/CityFilter";
|
||||
import { ProfileModal } from "../components/profile";
|
||||
import AuthModal from "../components/AuthModal";
|
||||
import RulesModal from "./RulesModal";
|
||||
import GuideModal from "../components/GuideModal";
|
||||
import GuestGuideBanner from "../components/GuestGuideBanner";
|
||||
import FeedTopBar from "../components/feed/FeedTopBar";
|
||||
import FeedSearchBar from "../components/feed/FeedSearchBar";
|
||||
import CityQuickFilterLegacy from "../components/feed/CityQuickFilter";
|
||||
@@ -664,6 +666,18 @@ export default function MainFeed() {
|
||||
|
||||
{modals.isOpen("rules") && <RulesModal onClose={modals.close} />}
|
||||
|
||||
{modals.isOpen("guide") && (
|
||||
<GuideModal
|
||||
onClose={modals.close}
|
||||
onLoginClick={isAuthenticated ? undefined : () => modals.open("auth")}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Гостю в ленте — подсказка «Ты здесь впервые?» со ссылкой на инструкцию */}
|
||||
{!isAuthenticated && !isMapView && (
|
||||
<GuestGuideBanner onOpenGuide={() => modals.open("guide")} />
|
||||
)}
|
||||
|
||||
{modals.isOpen("postDetail") && (
|
||||
<PostDetailModal
|
||||
postId={modals.modal.payload.postId}
|
||||
|
||||
274
src/styles/guide.css
Normal file
274
src/styles/guide.css
Normal file
@@ -0,0 +1,274 @@
|
||||
/* ── Инструкция (GuideModal) ── */
|
||||
.guide-modal {
|
||||
width: 520px;
|
||||
max-width: 96vw;
|
||||
}
|
||||
.guide-intro {
|
||||
margin: -8px 0 16px;
|
||||
color: var(--muted);
|
||||
font-size: .88rem;
|
||||
line-height: 1.55;
|
||||
}
|
||||
.guide-steps {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
.guide-step {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: flex-start;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
background: var(--bg-surface-solid);
|
||||
}
|
||||
.guide-step-icon {
|
||||
flex-shrink: 0;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.15rem;
|
||||
background: rgba(var(--teal-rgb), .1);
|
||||
}
|
||||
.guide-step-body { min-width: 0; }
|
||||
.guide-step-title {
|
||||
color: var(--text-primary);
|
||||
font-weight: 800;
|
||||
font-size: .93rem;
|
||||
}
|
||||
.guide-step-num { color: var(--teal); }
|
||||
.guide-step-text {
|
||||
margin-top: 3px;
|
||||
color: var(--muted);
|
||||
font-size: .84rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.guide-safety {
|
||||
margin-top: 14px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 14px;
|
||||
border: 1px solid rgba(237, 73, 86, .25);
|
||||
background: rgba(237, 73, 86, .06);
|
||||
}
|
||||
.guide-safety-title {
|
||||
color: var(--text-primary);
|
||||
font-weight: 800;
|
||||
font-size: .9rem;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.guide-safety ul {
|
||||
margin: 0;
|
||||
padding-left: 18px;
|
||||
color: var(--muted);
|
||||
font-size: .83rem;
|
||||
line-height: 1.55;
|
||||
}
|
||||
.guide-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
.guide-btn {
|
||||
flex: 1;
|
||||
padding: 12px 16px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--hover-bg);
|
||||
color: var(--text-primary);
|
||||
font: inherit;
|
||||
font-weight: 800;
|
||||
font-size: .88rem;
|
||||
cursor: pointer;
|
||||
transition: filter .15s, background .15s;
|
||||
}
|
||||
.guide-btn-primary {
|
||||
border-color: transparent;
|
||||
background: var(--teal);
|
||||
color: #fff;
|
||||
}
|
||||
.guide-btn:hover { filter: brightness(1.06); }
|
||||
@media (max-width: 600px) {
|
||||
.guide-actions { flex-direction: column-reverse; }
|
||||
}
|
||||
|
||||
/* ── Приветственная подсказка для гостя (GuestGuideBanner) ──
|
||||
Сверху по центру на телефоне (смахивается вверх), справа сверху на десктопе
|
||||
(закрывается крестиком). Не перекрывает модалки: z-index ниже .f-modal-bg. */
|
||||
.guest-banner {
|
||||
position: fixed;
|
||||
z-index: 90;
|
||||
top: calc(10px + env(safe-area-inset-top, 0px));
|
||||
left: 50%;
|
||||
width: min(520px, calc(100% - 24px));
|
||||
--banner-x: -50%;
|
||||
transform: translate(var(--banner-x), var(--banner-drag, 0px));
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
padding: 12px 12px 14px 14px;
|
||||
border-radius: 18px;
|
||||
border: 1px solid rgba(var(--teal-rgb), .25);
|
||||
background:
|
||||
linear-gradient(135deg, rgba(var(--teal-rgb), .10), rgba(var(--teal-rgb), 0) 60%),
|
||||
var(--bg-card);
|
||||
box-shadow: 0 12px 32px rgba(0, 0, 0, .16), 0 2px 6px rgba(0, 0, 0, .06);
|
||||
/* backwards, а не both: после появления transform снова берётся из правила
|
||||
выше — иначе финальный кадр анимации перекрыл бы сдвиг при свайпе */
|
||||
animation: guestBannerIn .45s cubic-bezier(.2, .9, .3, 1.15) backwards;
|
||||
touch-action: pan-x;
|
||||
user-select: none;
|
||||
}
|
||||
.guest-banner.is-dragging { transition: none; }
|
||||
.guest-banner.is-settling { transition: transform .2s ease; }
|
||||
.guest-banner.is-leaving {
|
||||
animation: guestBannerOut .25s ease-in forwards;
|
||||
}
|
||||
@keyframes guestBannerIn {
|
||||
from { opacity: 0; transform: translate(var(--banner-x), -130%); }
|
||||
to { opacity: 1; transform: translate(var(--banner-x), 0); }
|
||||
}
|
||||
@keyframes guestBannerOut {
|
||||
from { opacity: 1; transform: translate(var(--banner-x), var(--banner-drag, 0px)); }
|
||||
to { opacity: 0; transform: translate(var(--banner-x), -140%); }
|
||||
}
|
||||
.guest-banner-icon {
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.35rem;
|
||||
background: rgba(var(--teal-rgb), .14);
|
||||
}
|
||||
/* Машущая рука: несколько взмахов от запястья (transform-origin — у основания
|
||||
ладони), потом пауза; цикл 6 с, первый взмах — сразу после появления карточки */
|
||||
.guest-banner-wave {
|
||||
display: inline-block;
|
||||
line-height: 1;
|
||||
transform-origin: 70% 75%;
|
||||
animation: guestWave 6s ease-in-out .5s infinite;
|
||||
}
|
||||
@keyframes guestWave {
|
||||
0% { transform: rotate(0deg); }
|
||||
4% { transform: rotate(16deg); }
|
||||
8% { transform: rotate(-10deg); }
|
||||
12% { transform: rotate(16deg); }
|
||||
16% { transform: rotate(-6deg); }
|
||||
20% { transform: rotate(12deg); }
|
||||
25% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(0deg); }
|
||||
}
|
||||
/* Мягкая волна от иконки в такт взмаху — привлекает взгляд, но не мигает */
|
||||
.guest-banner-icon::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: inherit;
|
||||
border: 2px solid rgba(var(--teal-rgb), .45);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
animation: guestWaveRing 6s ease-out .5s infinite;
|
||||
}
|
||||
@keyframes guestWaveRing {
|
||||
0% { opacity: .9; transform: scale(1); }
|
||||
22% { opacity: 0; transform: scale(1.45); }
|
||||
100% { opacity: 0; transform: scale(1.45); }
|
||||
}
|
||||
.guest-banner-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.guest-banner-title {
|
||||
color: var(--text-primary);
|
||||
font-weight: 800;
|
||||
font-size: .95rem;
|
||||
}
|
||||
.guest-banner-text {
|
||||
margin-top: 2px;
|
||||
color: var(--muted);
|
||||
font-size: .83rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.guest-banner-btn {
|
||||
margin-top: 10px;
|
||||
padding: 8px 14px;
|
||||
border: none;
|
||||
border-radius: 999px;
|
||||
background: var(--teal);
|
||||
color: #fff;
|
||||
font: inherit;
|
||||
font-weight: 800;
|
||||
font-size: .82rem;
|
||||
cursor: pointer;
|
||||
transition: filter .15s;
|
||||
}
|
||||
.guest-banner-btn:hover { filter: brightness(1.08); }
|
||||
.guest-banner-close {
|
||||
flex-shrink: 0;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
color: var(--muted);
|
||||
cursor: pointer;
|
||||
}
|
||||
.guest-banner-close:hover { background: var(--hover-bg); color: var(--text-primary); }
|
||||
.guest-banner-close svg { width: 16px; height: 16px; }
|
||||
/* «Ручка» — подсказка, что карточку можно смахнуть вверх (только телефон) */
|
||||
.guest-banner-handle {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: 5px;
|
||||
width: 36px;
|
||||
height: 4px;
|
||||
margin-left: -18px;
|
||||
border-radius: 2px;
|
||||
background: var(--muted2);
|
||||
}
|
||||
|
||||
/* Десктоп: правый нижний угол — сверху карточка закрывала бы «Карту» и поиск
|
||||
в шапке ленты. Появляется снизу, закрывается крестиком. */
|
||||
@media (min-width: 900px) {
|
||||
.guest-banner {
|
||||
top: auto;
|
||||
bottom: 24px;
|
||||
left: auto;
|
||||
right: 24px;
|
||||
width: 380px;
|
||||
--banner-x: 0px;
|
||||
padding-bottom: 12px;
|
||||
animation-name: guestBannerInDesktop;
|
||||
}
|
||||
.guest-banner.is-leaving { animation-name: guestBannerOutDesktop; }
|
||||
.guest-banner-handle { display: none; }
|
||||
}
|
||||
@keyframes guestBannerInDesktop {
|
||||
from { opacity: 0; transform: translateY(24px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
@keyframes guestBannerOutDesktop {
|
||||
from { opacity: 1; transform: translateY(0); }
|
||||
to { opacity: 0; transform: translateY(16px); }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.guest-banner,
|
||||
.guest-banner.is-leaving { animation-duration: .01ms; }
|
||||
.guest-banner-wave,
|
||||
.guest-banner-icon::after { animation: none; }
|
||||
}
|
||||
Reference in New Issue
Block a user