Skip to content

Commit 5c0b449

Browse files
HaudinFlorenceSylvainCorlay
authored andcommitted
Remove logics of having diffferent components for desktop and for mobile screen sizes.
1 parent 0032531 commit 5c0b449

Some content is hidden

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

43 files changed

+204
-1325
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ _site/
44
node_modules/
55
build/
66
.docusaurus
7+
static/img/light-and-dark-pictures/

src/components/about/FourValues.tsx

+5-49
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,9 @@
11
import styles from "./styles.module.css";
2-
import { ValueCardMobile } from "@site/src/components/about/ValueCard";
3-
import { ValueCardDesktop } from "@site/src/components/about/ValueCard";
4-
import { useEffect, useState } from "react";
2+
import { ValueCard } from "@site/src/components/about/ValueCard";
53
import { valuesDetails } from "./Values/valuesDetails";
64

75

8-
const cardColors = ["white", "yellow", "white", "yellow"];
9-
10-
export function FourValuesMobile() {
11-
return (
12-
<div className={styles.four_values_container}>
13-
<ul className={"row" + " " + "flex-full-centered" + " " + "padding-none"}>
14-
{valuesDetails.map((value, index) => (
15-
<li className="cards-list" key={index}>
16-
<div className="col">
17-
<ValueCardMobile
18-
value={value.name}
19-
ValuePicture={value.pictureComponent}
20-
ValueComponent={value.DescriptionMD}
21-
color={cardColors[index]}
22-
/>
23-
</div>
24-
</li>
25-
))}
26-
</ul>
27-
</div>
28-
);
29-
}
30-
31-
export function FourValuesDesktop() {
6+
export default function FourValues() {
327
return (
338
<div className={styles.four_values_container}>
349
<div className="row">
@@ -43,10 +18,8 @@ export function FourValuesDesktop() {
4318
<li className="cards-list" key={index}>
4419
<div className="col">
4520
<div className={styles.value_card_container}>
46-
<ValueCardDesktop
47-
value={value.name}
48-
ValuePicture={value.pictureComponent}
49-
ValueComponent={value.DescriptionMD}
21+
<ValueCard
22+
value={value}
5023
/>
5124
</div>
5225
</div>
@@ -55,21 +28,4 @@ export function FourValuesDesktop() {
5528
</ul>
5629
</div>
5730
);
58-
}
59-
60-
const breakpointValue: number = 996;
61-
62-
export default function FourValues() {
63-
const [isDesktop, setDesktop] = useState(window.innerWidth > breakpointValue);
64-
65-
const updateMedia = () => {
66-
setDesktop(window.innerWidth > breakpointValue);
67-
};
68-
69-
useEffect(() => {
70-
window.addEventListener("resize", updateMedia);
71-
return () => window.removeEventListener("resize", updateMedia);
72-
});
73-
74-
return <div>{isDesktop ? <FourValuesDesktop /> : <FourValuesMobile />}</div>;
75-
}
31+
}

src/components/about/SmallPortraitCardDesktop.tsx renamed to src/components/about/SmallPortraitCard.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function calculateOffsets(elementRef) {
3636
return offsets;
3737
}
3838

39-
export function SmallPortraitCardDesktop({ person, avatarUrl, setOffsets }) {
39+
export function SmallPortraitCard({ person, avatarUrl, setOffsets }) {
4040
const elementRef = useRef(null);
4141

4242
return (
@@ -84,7 +84,7 @@ export default function PopupPortrait({
8484
<Popup
8585
trigger={
8686
<div>
87-
<SmallPortraitCardDesktop
87+
<SmallPortraitCard
8888
person={person}
8989
avatarUrl={avatarUrl}
9090
setOffsets={setOffsets}
@@ -105,4 +105,4 @@ export default function PopupPortrait({
105105
</Popup>
106106
</div>
107107
);
108-
}
108+
}

src/components/about/SmallPortraitCardMobile.tsx

-21
This file was deleted.

src/components/about/SubTeam.tsx

+3-28
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import styles from "./styles.module.css";
22
import Link from "@docusaurus/Link";
3-
import PopupPortrait from "./SmallPortraitCardDesktop";
4-
import SmallPortraitCardMobile from "./SmallPortraitCardMobile";
3+
import PopupPortrait from "./SmallPortraitCard";
54

6-
export function SubTeamDesktop({
5+
export default function SubTeam ({
76
description,
87
subTeam,
98
subTeamAvatarsUrls,
@@ -31,28 +30,4 @@ export function SubTeamDesktop({
3130
);
3231
}
3332

34-
export function SubTeamMobile({ description, subTeamAvatarsUrls, subTeam }) {
35-
return (
36-
<div className={styles.subteam_component}>
37-
<h2 className="text-centered"> {description}</h2>
38-
<div className={"container" + " " + styles.subteam_container}>
39-
<ul
40-
className={"row" + " " + "flex-full-centered" + " " + "padding-none"}
41-
>
42-
{subTeam.map((person, index) => (
43-
<li className="cards-list" key={index}>
44-
<div className="col">
45-
<Link href={"/about/" + person.firstName}>
46-
<SmallPortraitCardMobile
47-
person={person}
48-
avatarUrl={subTeamAvatarsUrls[index]}
49-
></SmallPortraitCardMobile>
50-
</Link>
51-
</div>
52-
</li>
53-
))}
54-
</ul>
55-
</div>
56-
</div>
57-
);
58-
}
33+

src/components/about/ValueCard.tsx

+3-69
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import styles from "./styles.module.css";
2-
import { useEffect, useState } from "react";
32

4-
export function ValueCardDesktop({ value }) {
3+
export function ValueCard({ value }) {
54
return (
65
<div className={"card " + styles.value_card}>
76
<div
@@ -10,76 +9,11 @@ export function ValueCardDesktop({ value }) {
109
>
1110
<value.pictureComponent alt={value.alt} />
1211
</div>
13-
<div className={styles.value_header}>{value}</div>
12+
<div className={styles.value_header}>{value.name}</div>
1413
<div className={styles.value_text}>
1514
<value.DescriptionMD className={styles.value_component} />
1615
</div>
1716
</div>
1817
);
1918
}
20-
21-
export function ValueCardMobile({
22-
value,
23-
ValuePicture,
24-
ValueComponent,
25-
color,
26-
}) {
27-
return (
28-
<div
29-
className={
30-
"card " +
31-
" " +
32-
styles.value_card +
33-
" " +
34-
(color === "yellow"
35-
? styles.value_card_yellow
36-
: styles.value_card_white)
37-
}
38-
>
39-
<div
40-
className={"flex-full-centered"}
41-
style={{ marginBottom: "var(--ifm-spacing-lg)" }}
42-
>
43-
<ValuePicture />
44-
</div>
45-
<div className={styles.value_header}>{value}</div>
46-
<div className={styles.value_text}>
47-
<ValueComponent />
48-
</div>
49-
</div>
50-
);
51-
}
52-
53-
const breakpointValue: number = 996;
54-
55-
export default function ValueCard(value, ValuePicture, ValueComponent, color) {
56-
const [isDesktop, setDesktop] = useState(window.innerWidth > breakpointValue);
57-
58-
const updateMedia = () => {
59-
setDesktop(window.innerWidth > breakpointValue);
60-
};
61-
62-
useEffect(() => {
63-
window.addEventListener("resize", updateMedia);
64-
return () => window.removeEventListener("resize", updateMedia);
65-
});
66-
67-
return (
68-
<div>
69-
{isDesktop ? (
70-
<ValueCardDesktop
71-
value={value}
72-
ValuePicture={ValuePicture}
73-
ValueComponent={ValueComponent}
74-
/>
75-
) : (
76-
<ValueCardMobile
77-
value={value}
78-
ValuePicture={ValuePicture}
79-
ValueComponent={ValueComponent}
80-
color={color}
81-
/>
82-
)}
83-
</div>
84-
);
85-
}
19+
export default ValueCard;

src/components/about/Values/valuesDetails.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ import IntegrityPicture from "@site/static/img/values/integrity.svg";
1010
export const valuesDetails = [
1111
{
1212
name: "Science",
13-
alt: "Icon representing the science value, displaying an atom",
13+
alt: "Icon representing science, displaying an atom",
1414
DescriptionMD: ScienceMD,
1515
pictureComponent: SciencePicture,
1616
},
1717
{
1818
name: "Openness",
19-
alt: "Icon representing the openness value, four people connected together.",
19+
alt: "Icon representing openness, four people connected together.",
2020
DescriptionMD: OpennessMD,
2121
pictureComponent: OpennessPicture,
2222
},
2323
{
2424
name: "Integrity",
25-
alt: "Icon representing the integrity value, with an heart inside a hand",
25+
alt: "Icon representing integrity, with an heart inside a hand",
2626
DescriptionMD: IntegrityMD,
2727
pictureComponent: IntegrityPicture,
2828
},
2929
{
3030
name: "Optimism",
31-
alt: "Icon representing the optimism value, with a smiling face ",
31+
alt: "Icon representing optimism, with a smiling face ",
3232
DescriptionMD: OptimismMD,
3333
pictureComponent: OptimismPicture,
3434
},

0 commit comments

Comments
 (0)