Skip to content

Commit ff2cd95

Browse files
committed
feat: enable smooth scroll to tutorial videos when clicking icon buttons; refs #66
1 parent 6c23312 commit ff2cd95

1 file changed

Lines changed: 18 additions & 31 deletions

File tree

src/pages/AboutPage.tsx

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,11 @@ import {
1010
import { Colors } from "design/theme";
1111
import React, { useRef } from "react";
1212

13-
// const videoData = [
14-
// {
15-
// src: "search.png",
16-
// alt: "search icon",
17-
// tip: "Search tutotial video",
18-
// video: "preview_video.mp4",
19-
// // ref: searchVideoRef,
20-
// },
21-
// { src: "preview.png", alt: "preview icon", tip: "Preview tutotial video" },
22-
// { src: "download.png", alt: "download icon", tip: "Download tutotial video" },
23-
// { src: "api.png", alt: "api icon", tip: "Restful API tutotial video" },
24-
// ];
25-
2613
const AboutPage: React.FC = () => {
27-
const searchVideoRef = useRef<HTMLVideoElement | null>(null);
28-
const previewVideoRef = useRef<HTMLVideoElement | null>(null);
29-
const downloadVideoRef = useRef<HTMLVideoElement | null>(null);
30-
const apiVideoRef = useRef<HTMLVideoElement | null>(null);
14+
const searchVideoRef = useRef<HTMLDivElement | null>(null);
15+
const previewVideoRef = useRef<HTMLDivElement | null>(null);
16+
const downloadVideoRef = useRef<HTMLDivElement | null>(null);
17+
const apiVideoRef = useRef<HTMLDivElement | null>(null);
3118

3219
const videoData = [
3320
{
@@ -75,7 +62,7 @@ const AboutPage: React.FC = () => {
7562
overflow: "hidden",
7663
}}
7764
>
78-
<Typography
65+
{/* <Typography
7966
variant="h6"
8067
sx={{
8168
mb: 1,
@@ -84,7 +71,7 @@ const AboutPage: React.FC = () => {
8471
}}
8572
>
8673
{title}
87-
</Typography>
74+
</Typography> */}
8875
<video
8976
controls
9077
width="100%"
@@ -96,11 +83,7 @@ const AboutPage: React.FC = () => {
9683
</Box>
9784
);
9885
return (
99-
<Box
100-
// sx={{
101-
// position: "relative",
102-
// }}
103-
>
86+
<Box>
10487
{/*section 1 */}
10588
<Box
10689
sx={{
@@ -204,7 +187,7 @@ const AboutPage: React.FC = () => {
204187
justifyContent: "center",
205188
}}
206189
>
207-
{videoData.map(({ src, alt, tip }) => (
190+
{videoData.map(({ src, alt, tip, ref }) => (
208191
<Tooltip
209192
title={tip}
210193
arrow
@@ -227,6 +210,9 @@ const AboutPage: React.FC = () => {
227210
component="img"
228211
src={`${process.env.PUBLIC_URL}/img/about_page/${src}`}
229212
alt={alt}
213+
onClick={() =>
214+
ref?.current?.scrollIntoView({ behavior: "smooth" })
215+
}
230216
sx={{
231217
width: {
232218
xs: "25%",
@@ -253,7 +239,7 @@ const AboutPage: React.FC = () => {
253239
}}
254240
>
255241
<Container
256-
maxWidth="md"
242+
maxWidth="lg"
257243
sx={{
258244
textAlign: "center",
259245
}}
@@ -268,37 +254,38 @@ const AboutPage: React.FC = () => {
268254
Getting Started with NeuroJSON
269255
</Typography>
270256
<Grid container spacing={5} sx={{ mt: 3 }}>
271-
<Grid item xs={12} sm={6}>
257+
<Grid item xs={12} sm={6} ref={searchVideoRef}>
272258
<TutorialVideoItem
273259
title="Search tutorial"
274260
videoUrl="https://neurojson.io/io/download/static/videos/search_video.mp4"
275261
/>
276262
</Grid>
277263

278-
<Grid item xs={12} sm={6}>
264+
<Grid item xs={12} sm={6} ref={previewVideoRef}>
279265
<TutorialVideoItem
280266
title="Preview tutorial"
281267
videoUrl="https://neurojson.io/io/download/static/videos/preview_video.mp4"
282268
/>
283269
</Grid>
284270

285-
<Grid item xs={12} sm={4}>
271+
<Grid item xs={12} sm={4} ref={downloadVideoRef}>
286272
<TutorialVideoItem
287273
title="Download tutorial"
288274
videoUrl="https://neurojson.io/io/download/static/videos/search_video.mp4"
289275
/>
290276
</Grid>
291277

292-
<Grid item xs={12} sm={4}>
278+
<Grid item xs={12} sm={4} ref={apiVideoRef}>
293279
<TutorialVideoItem
294280
title="Rest API - Python tutorial"
295281
videoUrl="https://neurojson.io/io/download/static/videos/search_video.mp4"
296282
/>
297283
</Grid>
284+
298285
<Grid item xs={12} sm={4}>
299286
<TutorialVideoItem
300287
title="Rest API - Matlab tutorial"
301-
videoUrl="https://neurojson.io/io/download/static/videos/search_video.mp4"
288+
videoUrl="https://neurojson.io/io/download/static/videos/matlab_api.mp4"
302289
/>
303290
</Grid>
304291
</Grid>

0 commit comments

Comments
 (0)