Skip to content

Commit ddcbf3c

Browse files
Adding images to researcher tab
1 parent 1757b28 commit ddcbf3c

4 files changed

Lines changed: 99 additions & 3 deletions

File tree

4.79 MB
Loading
240 KB
Loading

src/components/getstarted.js

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import {
1313
Grid,
1414
GridItem,
1515
Tooltip,
16+
Modal,
17+
ModalOverlay,
18+
ModalContent,
19+
ModalBody,
20+
ModalCloseButton,
21+
useDisclosure,
1622
} from '@chakra-ui/react'
1723
import { ColorModeImage } from '@/components/ColorModeImage'
1824
import React from 'react'
@@ -23,6 +29,15 @@ import { Heading } from '@/components/mdx'
2329
export const GetStarted = () => {
2430
const getstarted = React.useMemo(() => data, [])
2531
const [activeIndex, setActiveIndex] = React.useState(null)
32+
const [previewImageSrc, setPreviewImageSrc] = React.useState(
33+
'/getstarted/researcher/running.png',
34+
)
35+
const [previewImageAlt, setPreviewImageAlt] = React.useState('Image preview')
36+
const {
37+
isOpen: isImagePreviewOpen,
38+
onOpen: openImagePreview,
39+
onClose: closeImagePreview,
40+
} = useDisclosure()
2641
const tabSlugs = React.useMemo(
2742
() =>
2843
getstarted.map((item) =>
@@ -110,6 +125,18 @@ export const GetStarted = () => {
110125
return nodes
111126
}
112127

128+
const activeItem = activeIndex !== null ? getstarted[activeIndex] : null
129+
const hasActiveItemImages =
130+
activeItem &&
131+
Array.isArray(activeItem.images) &&
132+
activeItem.images.length > 0
133+
134+
const handleImageClick = (src, alt) => {
135+
setPreviewImageSrc(src)
136+
setPreviewImageAlt(alt || 'Image preview')
137+
openImagePreview()
138+
}
139+
113140
return (
114141
<Box id={'getstarted'} as='section'>
115142
<Container maxW='container.lg' centerContent>
@@ -146,13 +173,72 @@ export const GetStarted = () => {
146173
</Grid>
147174
{activeIndex !== null && (
148175
<Box mt={4} width='100%'>
149-
<Text fontSize={'lg'} whiteSpace='pre-line'>
150-
{renderTextWithLinks(getstarted[activeIndex].text)}
151-
</Text>
176+
{hasActiveItemImages ? (
177+
<Grid
178+
templateColumns={{ base: '1fr', md: '2fr 1fr' }}
179+
gap={6}
180+
alignItems='start'
181+
>
182+
<Text fontSize={'lg'} whiteSpace='pre-line'>
183+
{renderTextWithLinks(getstarted[activeIndex].text)}
184+
</Text>
185+
<Box justifySelf={{ base: 'center', md: 'end' }}>
186+
{activeItem.images.map((image, index) => (
187+
<Image
188+
key={image.src}
189+
src={image.src}
190+
alt={
191+
image.alt || `${activeItem.name} image ${index + 1}`
192+
}
193+
width='100%'
194+
maxW='360px'
195+
borderRadius='md'
196+
cursor='zoom-in'
197+
mt={index === 0 ? 0 : 4}
198+
onClick={() =>
199+
handleImageClick(
200+
image.src,
201+
image.alt ||
202+
`${activeItem.name} image ${index + 1}`,
203+
)
204+
}
205+
/>
206+
))}
207+
<Text
208+
mt={2}
209+
fontSize='sm'
210+
color='gray.500'
211+
textAlign='center'
212+
>
213+
Click images to enlarge
214+
</Text>
215+
</Box>
216+
</Grid>
217+
) : (
218+
<Text fontSize={'lg'} whiteSpace='pre-line'>
219+
{renderTextWithLinks(getstarted[activeIndex].text)}
220+
</Text>
221+
)}
152222
</Box>
153223
)}
154224
</Box>
155225
</Container>
226+
227+
<Modal isOpen={isImagePreviewOpen} onClose={closeImagePreview} size='4xl'>
228+
<ModalOverlay bg='blackAlpha.700' />
229+
<ModalContent bg='transparent' boxShadow='none'>
230+
<ModalCloseButton color='white' zIndex={2} />
231+
<ModalBody p={0} display='flex' justifyContent='center'>
232+
<Image
233+
src={previewImageSrc}
234+
alt={previewImageAlt}
235+
maxH='85vh'
236+
width='auto'
237+
borderRadius='md'
238+
/>
239+
</ModalBody>
240+
</ModalContent>
241+
</Modal>
156242
</Box>
157243
)
158244
}

src/data/getstarted.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ export const GetStarted = [
2323
},
2424
{
2525
name: 'Researcher',
26+
images: [
27+
{
28+
src: '/getstarted/researcher/running.png',
29+
alt: 'Researcher running simulation',
30+
},
31+
{
32+
src: '/getstarted/researcher/VRfigure1.png',
33+
alt: 'Researcher VR figure',
34+
},
35+
],
2636
text: `Researchers can design, test, and optimise oceanographic sampling strategies with VirtualShip's flexible Python package before going to sea.
2737
2838
Ocean data is streamed from the Copernicus Marine Data Store. Together with realistic instrument behaviour, this supports both retrospective and near-real-time applications. Researchers can then simulate expeditions anywhere in the global ocean and evaluate different deployment strategies.

0 commit comments

Comments
 (0)