Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 106 additions & 1 deletion src/components/MapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ import CalendarTodayOutlinedIcon from "@mui/icons-material/CalendarTodayOutlined
import DeleteIcon from "@mui/icons-material/Delete";
import PlaceOutlinedIcon from "@mui/icons-material/PlaceOutlined";
import ZoomInIcon from "@mui/icons-material/ZoomIn";
import CloseOutlinedIcon from "@mui/icons-material/CloseOutlined";
import SearchOutlinedIcon from "@mui/icons-material/SearchOutlined";
import AddLocationAltOutlinedIcon from "@mui/icons-material/AddLocationAltOutlined";
import CollectionsBookmarkOutlinedIcon from "@mui/icons-material/CollectionsBookmarkOutlined";
import ConfirmationModal from "./ConfirmationModal";

type MapViewState = {
longitude: number;
latitude: number;
zoom: number;
[key: string]: any;
[key: string]: unknown;
};

type ThemeMode = "light" | "dark";
Expand Down Expand Up @@ -88,6 +92,8 @@ const MapView = () => {
// Image Modal State
const [isImageModalOpen, setIsImageModalOpen] = useState<boolean>(false);

const [isGuideOpen, setIsGuideOpen] = useState<boolean>(false);

// myposts state
const [showMyPostsOnly, setShowMyPostsOnly] = useState(false);

Expand Down Expand Up @@ -182,6 +188,21 @@ const MapView = () => {
fetchBookmarkedPostIds();
}, [user]);

useEffect(() => {
if (!isGuideOpen) {
return;
}

const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === "Escape") {
setIsGuideOpen(false);
}
};

window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown);
}, [isGuideOpen]);

useEffect(() => {
if (!selectedLocation) {
pendingComposerZoomRef.current = null;
Expand Down Expand Up @@ -409,6 +430,7 @@ const MapView = () => {
setShowBookmarkedOnly={setShowBookmarkedOnly}
onUseCurrentLocation={useCurrentLocation}
themeMode={themeMode}
onOpenHelp={() => setIsGuideOpen(true)}
onToggleTheme={() =>
setThemeMode((currentTheme) =>
currentTheme === "light" ? "dark" : "light",
Expand All @@ -417,6 +439,89 @@ const MapView = () => {
/>
</div>

{isGuideOpen && (
<div
className="guide-modal-overlay"
onClick={() => setIsGuideOpen(false)}
role="presentation"
>
<section
className="guide-modal"
role="dialog"
aria-modal="true"
aria-labelledby="guide-modal-title"
onClick={(event) => event.stopPropagation()}
>
<button
type="button"
className="guide-modal-close"
onClick={() => setIsGuideOpen(false)}
aria-label="Close guide"
title="Close guide"
>
<CloseOutlinedIcon fontSize="small" />
</button>

<div className="guide-modal-header">
<p className="guide-modal-kicker">Quick guide</p>
<h2 id="guide-modal-title">How to use GeoGallery</h2>
<p>
Search for a place, browse shared photo pins, or click the map
to start saving your own memories.
</p>
</div>

<div className="guide-steps">
<article className="guide-step">
<span className="guide-step-icon">
<SearchOutlinedIcon fontSize="small" />
</span>
<div>
<h3>Find a place</h3>
<p>
Use search or drag around the map to explore places by
location.
</p>
</div>
</article>

<article className="guide-step">
<span className="guide-step-icon">
<AddLocationAltOutlinedIcon fontSize="small" />
</span>
<div>
<h3>Drop a pin</h3>
<p>
Click the map to choose a spot, then add a photo, date, and
short note.
</p>
</div>
</article>

<article className="guide-step">
<span className="guide-step-icon">
<CollectionsBookmarkOutlinedIcon fontSize="small" />
</span>
<div>
<h3>Save what matters</h3>
<p>
Open pins to view details, bookmark favorites, and filter
back to your own posts.
</p>
</div>
</article>
</div>

{!user && (
<div className="guide-modal-note">
Sign in when you are ready to publish photos, bookmark places,
and keep your map across visits.
</div>
)}
</section>
</div>
)}

{/* if bookedmarked is true then we open side menu */}
<SavedPostsPanel
isOpen={showBookmarkedOnly}
Expand Down
27 changes: 27 additions & 0 deletions src/components/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import BookmarkBorderOutlinedIcon from "@mui/icons-material/BookmarkBorderOutlin
import LoginOutlinedIcon from "@mui/icons-material/LoginOutlined";
import MyLocationOutlinedIcon from "@mui/icons-material/MyLocationOutlined";
import PhotoLibraryOutlinedIcon from "@mui/icons-material/PhotoLibraryOutlined";
import HelpOutlineOutlinedIcon from "@mui/icons-material/HelpOutlineOutlined";
import DarkModeOutlinedIcon from "@mui/icons-material/DarkModeOutlined";
import LightModeOutlinedIcon from "@mui/icons-material/LightModeOutlined";
import { useAuth } from "../context/AuthContext";
Expand All @@ -21,6 +22,7 @@ type MenuProps = {
onUseCurrentLocation?: () => void;
themeMode: ThemeMode;
onToggleTheme: () => void;
onOpenHelp: () => void;
};

const Menu = ({
Expand All @@ -31,13 +33,35 @@ const Menu = ({
onUseCurrentLocation,
themeMode,
onToggleTheme,
onOpenHelp,
}: MenuProps) => {
const { user } = useAuth();
const navigate = useNavigate();
const [open, setOpen] = useState(false);

const fullName = user?.user_metadata.full_name || "Guest";
const firstName = fullName.split(" ")[0];

const helpOption = (
<button
type="button"
className="menu-option"
onClick={() => {
onOpenHelp();
setOpen(false);
}}
role="menuitem"
>
<span className="menu-option-icon">
<HelpOutlineOutlinedIcon fontSize="small" />
</span>
<span className="menu-option-copy">
<strong>How it works</strong>
<small>Get a quick guide to using the map</small>
</span>
</button>
);

const themeOption = (
<button
type="button"
Expand Down Expand Up @@ -110,6 +134,8 @@ const Menu = ({
</button>
)}

{helpOption}

<button
type="button"
className={`menu-option ${showMyPostsOnly ? "menu-option-active" : ""}`}
Expand Down Expand Up @@ -182,6 +208,7 @@ const Menu = ({
<small>Continue with your account</small>
</span>
</button>
{helpOption}
{themeOption}
</div>
</div>
Expand Down
Loading
Loading