Skip to content

Commit 94f0c02

Browse files
committed
feat: update section3 img to 4 clickable images
1 parent 0479086 commit 94f0c02

File tree

6 files changed

+93
-19
lines changed

6 files changed

+93
-19
lines changed

public/img/section3/altlas.png

66 KB
Loading

public/img/section3/fnirs.png

128 KB
Loading

public/img/section3/mesh.png

122 KB
Loading

public/img/section3/mri.png

93.5 KB
Loading

src/components/HomePageComponents/Section3.tsx

Lines changed: 92 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,82 @@ import { Colors } from "design/theme";
66
import React from "react";
77
import { useState } from "react";
88

9+
type Tile = {
10+
src: string;
11+
alt: string;
12+
video: string;
13+
};
14+
15+
const tiles: Tile[] = [
16+
{
17+
// src: `${process.env.PUBLIC_URL}/img/mesh.png`,
18+
src: "/img/section3/mesh.png",
19+
alt: "Brain mesh",
20+
video: "https://neurojson.io/io/download/static/videos/preview_mesh.mp4",
21+
},
22+
{
23+
// src: `${process.env.PUBLIC_URL}/img/fnirs.png`,
24+
src: "/img/section3/fnirs.png",
25+
alt: "fNIRS signals",
26+
video: "https://neurojson.io/io/download/static/videos/preview_fnirs.mp4",
27+
},
28+
{
29+
// src: `${process.env.PUBLIC_URL}/img/altlas.png`,
30+
src: "/img/section3/altlas.png",
31+
alt: "altlas",
32+
video: "https://neurojson.io/io/download/static/videos/preview_altlas.mp4",
33+
},
34+
{
35+
// src: `${process.env.PUBLIC_URL}/img/mri.png`,
36+
src: "/img/section3/mri.png",
37+
alt: "mri",
38+
video: "https://neurojson.io/io/download/static/videos/preview_mri.mp4",
39+
},
40+
];
41+
42+
// Vertical rectangle image tile (clickable)
43+
const PreviewTile: React.FC<{ tile: Tile; onClick: () => void }> = ({
44+
tile,
45+
onClick,
46+
}) => (
47+
<Box
48+
onClick={onClick}
49+
role="button"
50+
aria-label={tile.alt}
51+
sx={{
52+
position: "relative",
53+
width: "100%",
54+
aspectRatio: "2.5 / 3",
55+
borderRadius: 3,
56+
overflow: "hidden",
57+
cursor: "pointer",
58+
boxShadow: 4,
59+
backgroundImage: `url(${tile.src})`,
60+
backgroundSize: "cover",
61+
backgroundPosition: "center",
62+
transition: "transform .2s ease",
63+
"&:hover": { transform: "translateY(-2px)" },
64+
}}
65+
/>
66+
);
67+
968
interface Section3Props {
1069
scrollToNext: () => void;
1170
}
1271

1372
const Section3: React.FC<Section3Props> = ({ scrollToNext }) => {
1473
const [open, setOpen] = useState(false);
74+
const [videoSrc, setVideoSrc] = useState("");
75+
76+
const handleOpen = (video: string) => {
77+
setVideoSrc(video);
78+
setOpen(true);
79+
};
1580

16-
const handleOpen = () => setOpen(true);
17-
const handleClose = () => setOpen(false);
81+
const handleClose = () => {
82+
setOpen(false);
83+
setVideoSrc("");
84+
};
1885

1986
return (
2087
<Box
@@ -84,18 +151,25 @@ const Section3: React.FC<Section3Props> = ({ scrollToNext }) => {
84151
alignItems: "center",
85152
mt: { xs: 4, md: 2 },
86153
mb: { xs: 8, md: 0 },
87-
cursor: "pointer",
88154
}}
89-
onClick={handleOpen}
90155
>
91-
<img
92-
src={`${process.env.PUBLIC_URL}/img/section3_cards.png`}
93-
alt="rendering feature info cards"
94-
style={{
95-
width: "70%",
96-
height: "auto",
97-
}}
98-
></img>
156+
<Box sx={{ width: "70%" }}>
157+
<Box
158+
sx={{
159+
display: "grid",
160+
gridTemplateColumns: { xs: "1fr 1fr", sm: "1fr 1fr" },
161+
gap: 2,
162+
}}
163+
>
164+
{tiles.map((t, i) => (
165+
<PreviewTile
166+
key={i}
167+
tile={t}
168+
onClick={() => handleOpen(t.video)}
169+
/>
170+
))}
171+
</Box>
172+
</Box>
99173
</Box>
100174

101175
{/* video dialog */}
@@ -113,12 +187,12 @@ const Section3: React.FC<Section3Props> = ({ scrollToNext }) => {
113187
>
114188
<CloseIcon />
115189
</IconButton>
116-
117-
<video controls style={{ width: "100%", borderRadius: "4px" }}>
118-
<source
119-
src="https://neurojson.io/video/preview_video.mp4"
120-
type="video/mp4"
121-
/>
190+
<video
191+
key={videoSrc}
192+
controls
193+
style={{ width: "100%", borderRadius: 4 }}
194+
>
195+
{videoSrc && <source src={videoSrc} type="video/mp4" />}
122196
Your browser does not support the video tag.
123197
</video>
124198
</Box>

src/pages/DatasetDetailPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ const DatasetDetailPage: React.FC = () => {
496496

497497
const is2DPreviewCandidate = (obj: any): boolean => {
498498
if (typeof window !== "undefined" && (window as any).__previewType) {
499-
console.log("work~~~~~~~");
499+
// console.log("preview type: 2d");
500500
return (window as any).__previewType === "2d";
501501
}
502502
// if (window.__previewType) {

0 commit comments

Comments
 (0)