forked from QuantStack/quantstack.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLargePortraitCardPage.tsx
More file actions
80 lines (73 loc) · 2.35 KB
/
LargePortraitCardPage.tsx
File metadata and controls
80 lines (73 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import React from 'react';
import Layout from '@theme/Layout';
import { useHistory, useLocation } from '@docusaurus/router';
import { useEffect } from 'react';
import { Route } from 'react-router-dom';
import { About } from '@site/src/components/about'
import LargePortraitCard from '@site/src/components/about/LargePortraitCard';
import { getTeamByPageName } from '@site/src/components/about';
import styles from "@site/src/components/about/styles.module.css";
export default function LargePortraitCardPage() {
const location = useLocation();
const history = useHistory();
useEffect(() => {
if (location.state?.fromAbout) {
window.scrollTo({ top: location.state.scrollY ?? 0, behavior: 'auto' });
}
}, []);
const handleOverlayClick = () => {
const scrollY = location.state?.scrollY;
setTimeout(() => {
if (scrollY !== undefined) {
window.scrollTo({ top: scrollY, behavior: 'auto' });
}
}, 0);
history.replace('/about');
};
const handleClose = () => {
const scrollY = location.state?.scrollY;
if (location.state?.fromAbout) {
history.replace('/about');
setTimeout(() => {
if (scrollY !== undefined) {
window.scrollTo({ top: scrollY, behavior: 'auto' });
}
}, 0);
} else {
history.goBack();
}
}
return (
<Layout>
<About />
<Route
path="/about/:pageName"
render={({ match }) => {
const { pageName } = match.params; /* extract the dynamic part from the url i.e. the pageName*/
const teamMembers = getTeamByPageName(pageName);
const person = teamMembers.find((person) => person.pageName== pageName);
if (!person) return null;
return (
<div className={styles.modal_overlay} onClick={handleOverlayClick}>
<div
className={styles.modal_content}
onClick={(e) => e.stopPropagation()}
>
<button
className="close-button"
style={{
position: "absolute",
top: "10px",
right: "10px",
}}
onClick={handleClose}
/>
<LargePortraitCard person={person} />
</div>
</div>
);
}}
/>
</Layout>
)
}