move css styles
This commit is contained in:
1 parent
b68214fc47
commit
a9f005b2c4
2 files changed
+128
-92
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
import { useRef, useEffect, useState } from "react";
|
import { useRef, useEffect, useState } from "react";
|
||||||
import { Box, Typography, Stack, useTheme } from "@mui/material";
|
import { Box, Typography, Stack, useTheme, GlobalStyles } from "@mui/material";
|
||||||
import Map, { Marker, Popup } from "react-map-gl/maplibre";
|
import Map, { Marker, Popup } from "react-map-gl/maplibre";
|
||||||
import type { MapRef } from "react-map-gl/maplibre";
|
import type { MapRef } from "react-map-gl/maplibre";
|
||||||
import type { FlatGeoCheck } from "@/Types/GeoCheck";
|
import type { FlatGeoCheck } from "@/Types/GeoCheck";
|
||||||
@@ -15,6 +15,21 @@ export const GeoChecksMap = ({ geoChecks }: GeoChecksMapProps) => {
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isDarkMode = theme.palette.mode === "dark";
|
const isDarkMode = theme.palette.mode === "dark";
|
||||||
|
|
||||||
|
const mapPopupStyles = (
|
||||||
|
<GlobalStyles
|
||||||
|
styles={{
|
||||||
|
".maplibregl-popup-content": {
|
||||||
|
background: "transparent !important",
|
||||||
|
padding: "0 !important",
|
||||||
|
boxShadow: "none !important",
|
||||||
|
},
|
||||||
|
".maplibregl-popup-tip": {
|
||||||
|
display: "none !important",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (geoChecks.length === 0 || !mapRef.current) return;
|
if (geoChecks.length === 0 || !mapRef.current) return;
|
||||||
|
|
||||||
@@ -55,103 +70,119 @@ export const GeoChecksMap = ({ geoChecks }: GeoChecksMapProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<>
|
||||||
style={{ height: "500px", width: "100%", borderRadius: "8px", overflow: "hidden" }}
|
{mapPopupStyles}
|
||||||
>
|
<Box
|
||||||
<Map
|
height={500}
|
||||||
ref={mapRef}
|
width={"100%"}
|
||||||
initialViewState={{
|
borderRadius={theme.shape.borderRadius}
|
||||||
longitude: 0,
|
overflow={"hidden"}
|
||||||
latitude: 20,
|
|
||||||
zoom: 1.5,
|
|
||||||
}}
|
|
||||||
style={{ height: "100%", width: "100%" }}
|
|
||||||
mapStyle={
|
|
||||||
isDarkMode
|
|
||||||
? "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"
|
|
||||||
: "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{geoChecks.map((check, index) => (
|
<Map
|
||||||
<Marker
|
ref={mapRef}
|
||||||
key={`${check.id}-${index}`}
|
initialViewState={{
|
||||||
longitude={check.location.longitude}
|
longitude: 0,
|
||||||
latitude={check.location.latitude}
|
latitude: 20,
|
||||||
anchor="bottom"
|
zoom: 1.5,
|
||||||
onClick={(e: any) => {
|
}}
|
||||||
e.originalEvent.stopPropagation();
|
style={{ height: "100%", width: "100%" }}
|
||||||
setSelectedCheck(check);
|
mapStyle={
|
||||||
}}
|
isDarkMode
|
||||||
>
|
? "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"
|
||||||
<div
|
: "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
|
||||||
style={{
|
}
|
||||||
width: "10px",
|
>
|
||||||
height: "10px",
|
{geoChecks.map((check, index) => (
|
||||||
borderRadius: "50%",
|
<Marker
|
||||||
backgroundColor: getMarkerColor(check.status),
|
key={`${check.id}-${index}`}
|
||||||
boxShadow: "0 2px 4px rgba(0,0,0,0.3)",
|
longitude={check.location.longitude}
|
||||||
cursor: "pointer",
|
latitude={check.location.latitude}
|
||||||
|
anchor="bottom"
|
||||||
|
onClick={(e: any) => {
|
||||||
|
e.originalEvent.stopPropagation();
|
||||||
|
setSelectedCheck(check);
|
||||||
}}
|
}}
|
||||||
/>
|
>
|
||||||
</Marker>
|
<div
|
||||||
))}
|
style={{
|
||||||
|
width: "10px",
|
||||||
|
height: "10px",
|
||||||
|
borderRadius: "50%",
|
||||||
|
backgroundColor: getMarkerColor(check.status),
|
||||||
|
boxShadow: "0 2px 4px rgba(0,0,0,0.3)",
|
||||||
|
cursor: "pointer",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Marker>
|
||||||
|
))}
|
||||||
|
|
||||||
{selectedCheck && (
|
{selectedCheck && (
|
||||||
<Popup
|
<Popup
|
||||||
longitude={selectedCheck.location.longitude}
|
longitude={selectedCheck.location.longitude}
|
||||||
latitude={selectedCheck.location.latitude}
|
latitude={selectedCheck.location.latitude}
|
||||||
anchor="top"
|
anchor="top"
|
||||||
onClose={() => setSelectedCheck(null)}
|
onClose={() => setSelectedCheck(null)}
|
||||||
closeOnClick={false}
|
closeOnClick={false}
|
||||||
>
|
>
|
||||||
<Box sx={{ minWidth: 200, p: 1 }}>
|
<Box
|
||||||
<Typography
|
sx={{
|
||||||
variant="subtitle1"
|
minWidth: 200,
|
||||||
fontWeight="bold"
|
p: theme.spacing(4),
|
||||||
gutterBottom
|
bgcolor: theme.palette.background.paper,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderStyle: "solid",
|
||||||
|
borderColor: theme.palette.divider,
|
||||||
|
borderRadius: 1,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{selectedCheck.location.city}, {selectedCheck.location.country}
|
|
||||||
</Typography>
|
|
||||||
<Stack spacing={0.5}>
|
|
||||||
<Typography variant="body2">
|
|
||||||
<Typography
|
|
||||||
component="span"
|
|
||||||
fontWeight="medium"
|
|
||||||
>
|
|
||||||
Status:
|
|
||||||
</Typography>{" "}
|
|
||||||
{selectedCheck.status ? "Up" : "Down"}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="body2">
|
|
||||||
<Typography
|
|
||||||
component="span"
|
|
||||||
fontWeight="medium"
|
|
||||||
>
|
|
||||||
Status Code:
|
|
||||||
</Typography>{" "}
|
|
||||||
{selectedCheck.statusCode}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="body2">
|
|
||||||
<Typography
|
|
||||||
component="span"
|
|
||||||
fontWeight="medium"
|
|
||||||
>
|
|
||||||
Response Time:
|
|
||||||
</Typography>{" "}
|
|
||||||
{formatResponseTime(selectedCheck.timings.total)}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
<Typography
|
||||||
variant="caption"
|
variant="subtitle1"
|
||||||
color="text.secondary"
|
fontWeight="bold"
|
||||||
sx={{ mt: 0.5 }}
|
gutterBottom
|
||||||
>
|
>
|
||||||
{new Date(selectedCheck.createdAt).toLocaleString()}
|
{selectedCheck.location.city}, {selectedCheck.location.country}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
<Stack spacing={0.5}>
|
||||||
</Box>
|
<Typography variant="body2">
|
||||||
</Popup>
|
<Typography
|
||||||
)}
|
component="span"
|
||||||
</Map>
|
fontWeight="medium"
|
||||||
</div>
|
>
|
||||||
|
Status:
|
||||||
|
</Typography>{" "}
|
||||||
|
{selectedCheck.status ? "Up" : "Down"}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2">
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
fontWeight="medium"
|
||||||
|
>
|
||||||
|
Status Code:
|
||||||
|
</Typography>{" "}
|
||||||
|
{selectedCheck.statusCode}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2">
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
fontWeight="medium"
|
||||||
|
>
|
||||||
|
Response Time:
|
||||||
|
</Typography>{" "}
|
||||||
|
{formatResponseTime(selectedCheck.timings.total)}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
color="text.secondary"
|
||||||
|
sx={{ mt: 0.5 }}
|
||||||
|
>
|
||||||
|
{new Date(selectedCheck.createdAt).toLocaleString()}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
</Popup>
|
||||||
|
)}
|
||||||
|
</Map>
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
Vendored
+5
@@ -17,3 +17,8 @@ declare module "*.svg?react" {
|
|||||||
>;
|
>;
|
||||||
export default ReactComponent;
|
export default ReactComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare module "*.css" {
|
||||||
|
const content: string;
|
||||||
|
export default content;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user