Skip to content

Commit b74d3a8

Browse files
Fix issues related to last names like for those having special characters.
Add logics to not scroll systematically to the top of the page when changing from about page to portrait ones and reciprocally.
1 parent 0108c42 commit b74d3a8

File tree

96 files changed

+38
-2408
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+38
-2408
lines changed

src/components/about/LargePortraitCardPage.tsx

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import Layout from '@theme/Layout';
3-
import { useHistory, useLocation} from '@docusaurus/router';
3+
import { useHistory, useLocation } from '@docusaurus/router';
4+
import { useEffect } from 'react';
45
import { Route } from 'react-router-dom';
56
import { About } from '@site/src/components/about'
67
import LargePortraitCard from '@site/src/components/about/LargePortraitCard';
@@ -11,9 +12,32 @@ export default function LargePortraitCardPage() {
1112
const location = useLocation();
1213
const history = useHistory();
1314

14-
function handleClose() {
15+
useEffect(() => {
1516
if (location.state?.fromAbout) {
16-
history.push('/about');
17+
window.scrollTo({ top: location.state.scrollY ?? 0, behavior: 'auto' });
18+
}
19+
}, []);
20+
21+
const handleOverlayClick = () => {
22+
const scrollY = location.state?.scrollY;
23+
setTimeout(() => {
24+
if (scrollY !== undefined) {
25+
window.scrollTo({ top: scrollY, behavior: 'auto' });
26+
}
27+
}, 0);
28+
history.replace('/about');
29+
};
30+
31+
const handleClose = () => {
32+
const scrollY = location.state?.scrollY;
33+
if (location.state?.fromAbout) {
34+
history.replace('/about');
35+
36+
setTimeout(() => {
37+
if (scrollY !== undefined) {
38+
window.scrollTo({ top: scrollY, behavior: 'auto' });
39+
}
40+
}, 0);
1741
} else {
1842
history.goBack();
1943
}
@@ -24,13 +48,13 @@ export default function LargePortraitCardPage() {
2448
<Route
2549
path="/about/:completeName"
2650
render={({ history, match }) => {
27-
const { completeName } = match.params;
51+
const { completeName } = match.params; /* extract the dynamic part from the url i.e. the completeName*/
2852
const teamMembers = getTeamByPersonName(completeName);
29-
const person = teamMembers.find(person => person.completeName.replace(/\s+/g, '') === completeName);
53+
const person = teamMembers.find((person) => person.completeName.replace(/\s+/g, '').normalize("NFD").replace(/[\u0300-\u036f]/g, '') === completeName);
3054
if (!person) return null;
3155

3256
return (
33-
<div className={styles.modal_overlay} onClick={() => history.push('/about')}>
57+
<div className={styles.modal_overlay} onClick={handleOverlayClick}>
3458
<div
3559
className={styles.modal_content}
3660
onClick={(e) => e.stopPropagation()}

src/components/about/SmallPortraitCard.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ import styles from "./styles.module.css";
22
import { useHistory } from "@docusaurus/router";
33
import Avatar from "./Avatar";
44

5-
export function SmallPortraitCard({ person}) {
5+
export function SmallPortraitCard({ person }) {
66
const history = useHistory();
77

88
function openDialog() {
9+
const completeName = person.completeName.replace(/\s+/g, '');
10+
const completeNameWithoutAccents = completeName
11+
.normalize("NFD")
12+
.replace(/[\u0300-\u036f]/g, '');
913
history.push({
10-
pathname: `/about/${person.completeName.replace(/\s+/g, '')}`,
11-
state: { fromAbout: true },
14+
pathname: `/about/${completeNameWithoutAccents}`,
15+
state: { fromAbout: true, scrollY: window.scrollY, },
1216
});
1317
}
1418

src/components/about/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import LinkToContact from "../home/LinkToContact";
66

77
export function getTeamByPersonName(name: string) {
88
for (const [teamName, members] of Object.entries(teams)) {
9-
const person = members.find((person) => person.completeName.replace(/\s+/g, '') === name);
9+
const person = members.find((person) => person.completeName.replace(/\s+/g, '').replace(/\s+/g, '').normalize("NFD").replace(/[\u0300-\u036f]/g, '') === name);
1010
if (person) {
1111
return members;
1212
}
File renamed without changes.

src/pages/about/Meriem.Benismail.tsx renamed to src/pages/about/MeriemBenIsmail.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import React from 'react';
2-
import Layout from '@theme/Layout';
3-
import { useHistory, useLocation} from '@docusaurus/router';
41
import LargePortraitCardPage from "@site/src/components/about/LargePortraitCardPage";
52

63
export default function AboutPage() {

static/img/quantstack/Use a dialog to display the LargePortraitCard. by HaudinFlorence · Pull Request #169 · QuantStack_quantstack.github.io_files/app_assets_modules_github_behaviors_ajax-error_ts-app_assets_modules_github_behaviors_include-d0d0a6-aa0f176b5b12.js

Lines changed: 0 additions & 107 deletions
This file was deleted.

static/img/quantstack/Use a dialog to display the LargePortraitCard. by HaudinFlorence · Pull Request #169 · QuantStack_quantstack.github.io_files/app_assets_modules_github_behaviors_commenting_edit_ts-app_assets_modules_github_behaviors_ht-83c235-c89801ebbe15.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)