Skip to content

Commit 44a1923

Browse files
committed
fixed tooltips, added modal
1 parent bffccb1 commit 44a1923

4 files changed

Lines changed: 63 additions & 8 deletions

File tree

Eplant/views/WorldEFP/InfoContent.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { styled } from '@mui/material'
1+
import { styled, Theme } from '@mui/material'
22

33
interface InfoContentProps {
44
id: string
@@ -20,12 +20,12 @@ const InfoContent = ({ id, mean, std, sampleSize }: InfoContentProps) => {
2020
)
2121
}
2222

23-
const StyledInfoContent = styled('div')(({ theme }) => ({
24-
backgroundColor: 'white',
23+
const StyledInfoContent = styled('div')(() => ({
2524
wordWrap: 'break-word',
2625
maxWidth: '300px',
2726
'& p': {
2827
margin: '5px 0',
28+
color: 'black',
2929
},
3030
'& strong': {
3131
display: 'block',

Eplant/views/WorldEFP/MapContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const MapContainer = ({ activeData, state, dispatch }: MapContainerProps) => {
6969
)
7070
return (
7171
<MapMarker
72+
theme={theme}
7273
key={index}
7374
color={color}
7475
data={activeData.efpData.groups[index]}

Eplant/views/WorldEFP/MapMarker.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useState } from 'react'
22

33
import Modal from '@eplant/UI/Modal'
4-
import { useTheme } from '@mui/material'
4+
import { Theme, useTheme } from '@mui/material'
55
import {
66
AdvancedMarker,
77
InfoWindow,
@@ -12,19 +12,20 @@ import { EFPGroup } from '../eFP/types'
1212

1313
import WorldEFPIcon from './icon'
1414
import InfoContent from './InfoContent'
15+
import { ModalContent } from './ModalContent'
1516
import { Coordinates } from './types'
1617

1718
interface MapMarkerProps {
19+
theme: Theme
1820
color: string
1921
position: Coordinates
2022
data: EFPGroup
2123
}
2224

23-
const MapMarker = ({ data, color, position }: MapMarkerProps) => {
25+
const MapMarker = ({ theme, data, color, position }: MapMarkerProps) => {
2426
const [showPopup, setShowPopup] = useState(false)
2527
const [showModal, setShowModal] = useState(false)
2628
const [markerRef, marker] = useAdvancedMarkerRef()
27-
const theme = useTheme()
2829
const handleMouseOver = () => {
2930
setShowPopup(true)
3031
}
@@ -49,7 +50,7 @@ const MapMarker = ({ data, color, position }: MapMarkerProps) => {
4950
marker.content?.removeEventListener('mouseout', handleMouseOut)
5051
}
5152
}
52-
}, [data])
53+
}, [data, marker])
5354

5455
return (
5556
<>
@@ -81,7 +82,15 @@ const MapMarker = ({ data, color, position }: MapMarkerProps) => {
8182
onClose={() => {
8283
setShowModal(false)
8384
}}
84-
></Modal>
85+
>
86+
<ModalContent
87+
theme={theme}
88+
id={data.name}
89+
mean={data.mean}
90+
std={data.std}
91+
sampleSize={data.samples}
92+
></ModalContent>
93+
</Modal>
8594
</>
8695
)
8796
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Box, Theme } from '@mui/material'
2+
import { styled } from '@mui/material'
3+
4+
interface ModalContentProps {
5+
theme: Theme
6+
id: string
7+
mean: number
8+
std: number
9+
sampleSize: number
10+
}
11+
export const ModalContent = ({
12+
theme,
13+
id,
14+
mean,
15+
std,
16+
sampleSize,
17+
}: ModalContentProps) => {
18+
return (
19+
<StyledBox theme={theme}>
20+
<p>
21+
<strong>{id}</strong>
22+
</p>
23+
<p>Mean: {mean.toFixed(2)}</p>
24+
<p>Standard error: {std.toFixed(2)}</p>
25+
<p>Sample size: {sampleSize}</p>
26+
</StyledBox>
27+
)
28+
}
29+
30+
const StyledBox = styled(Box)(({ theme }: { theme: any }) => ({
31+
top: '50%',
32+
left: '50%',
33+
width: 400,
34+
borderRadius: '24px',
35+
padding: theme.spacing(4),
36+
backgroundColor: theme.palette.background,
37+
'& p': {
38+
margin: '5px 0',
39+
color: theme.palette.secondary.contrastText,
40+
},
41+
'& strong': {
42+
display: 'block',
43+
marginBottom: '10px',
44+
},
45+
}))

0 commit comments

Comments
 (0)