Skip to content

Commit

Permalink
Mobile opertermisation
Browse files Browse the repository at this point in the history
  • Loading branch information
JackCrawfordRobertson committed Apr 10, 2024
1 parent 1e4a3a7 commit 328c240
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/pages/Localities/InteractivePoints.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, {useEffect, useState, useRef, useMemo} from "react";
import Button from "@mui/material/Button";
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
import Paper from "@mui/material/Paper";
import InfoIcon from "@mui/icons-material/Info";
import IconButton from "@mui/material/IconButton";
Expand Down
33 changes: 23 additions & 10 deletions src/pages/Widget/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import { IoWater } from "react-icons/io5";
import { FaLocationDot } from "react-icons/fa6";
import InteractivePoints from "../Localities/InteractivePoints";
Expand All @@ -8,22 +8,35 @@ import ExpandableButton from '../Widget/BubbleCharts/ExpandableButton'; // Adjus
const WidgetConsolidation = ({ map, isZoomCompleted, cycleSVG }) => {
const [isOpen, setIsOpen] = useState(false);
const [isInteractivePointsOpen, setIsInteractivePointsOpen] = useState(false);
const [isMobile, setIsMobile] = useState(false);

// Detect screen size
useEffect(() => {
const checkMobile = () => {
setIsMobile(window.innerWidth < 768); // For example, consider < 768px as mobile
};

// Check on mount
checkMobile();

// Listen for resize events
window.addEventListener('resize', checkMobile);

// Cleanup
return () => window.removeEventListener('resize', checkMobile);
}, []);

// Toggle GeoControls Widget
const toggleOpen = () => {
console.log("GeoControls Toggle Button clicked");
setIsOpen(!isOpen); // Toggle current widget
setIsOpen(!isOpen);
if (isInteractivePointsOpen) {
setIsInteractivePointsOpen(false); // Ensure only one widget is open at a time
setIsInteractivePointsOpen(false);
}
};

// Toggle Interactive Points Widget
const toggleInteractivePointsOpen = () => {
console.log("Interactive Points Toggle Button clicked");
setIsInteractivePointsOpen(!isInteractivePointsOpen); // Toggle current widget
setIsInteractivePointsOpen(!isInteractivePointsOpen);
if (isOpen) {
setIsOpen(false); // Ensure only one widget is open at a time
setIsOpen(false);
}
};

Expand All @@ -39,7 +52,7 @@ const WidgetConsolidation = ({ map, isZoomCompleted, cycleSVG }) => {
padding: "10px",
zIndex: 4,
backgroundColor: "rgba(255, 255, 255, 0.8)",
width: "25vw",
width: isMobile ? "90vw" : "25vw", // Dynamic width based on isMobile state
borderRadius: "10px",
}}
>
Expand Down

0 comments on commit 328c240

Please sign in to comment.