Skip to content

Commit 345b129

Browse files
committed
Refactor: unified Card layout component, remove content-card, simplify per-card CSS
1 parent 4c4b919 commit 345b129

12 files changed

Lines changed: 114 additions & 153 deletions

File tree

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styles from "./styles.module.css";
22
import { useHistory } from "@docusaurus/router";
33
import Avatar from "./Avatar";
4+
import Card from "../layout/Card";
45

56
export function SmallPortraitCard({ person }) {
67
const history = useHistory();
@@ -9,34 +10,22 @@ export function SmallPortraitCard({ person }) {
910
const completeName = person.completeName.replace(/\s+/g, '');
1011
const completeNameWithoutAccents = completeName
1112
.normalize("NFD")
12-
.replace(/[\u0300-\u036f]/g, '');
13+
.replace(/[̀-ͯ]/g, '');
1314
history.push({
1415
pathname: `/about/${completeNameWithoutAccents}`,
15-
state: { fromAbout: true, scrollY: window.scrollY, },
16+
state: { fromAbout: true, scrollY: window.scrollY },
1617
});
1718
}
1819

1920
return (
20-
<div onClick={openDialog}>
21-
<div className={"card" + " " + styles.small_portrait_card}>
22-
<div className="card__header">
23-
<Avatar person={person} />
24-
<div
25-
className={
26-
"flex-full-centered" + " " + styles.small_card_complete_name
27-
}
28-
>
29-
{person.completeName}
30-
</div>
31-
</div>
32-
<div className="card__body">
33-
<div
34-
className={"flex-full-centered" + " " + styles.small_card_position}
35-
>
36-
{person.position}
37-
</div>
38-
</div>
21+
<Card hover onClick={openDialog} className={styles.small_portrait_card}>
22+
<Avatar person={person} />
23+
<div className={"flex-full-centered " + styles.small_card_complete_name}>
24+
{person.completeName}
3925
</div>
40-
</div>
26+
<div className={"flex-full-centered " + styles.small_card_position}>
27+
{person.position}
28+
</div>
29+
</Card>
4130
);
4231
}

src/components/about/ValueCard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import styles from "./styles.module.css";
2+
import Card from "../layout/Card";
23

34
export function ValueCard({ value }) {
45
return (
5-
<div className={"content-card " + styles.value_card}>
6+
<Card bg="yellow" className={styles.value_card}>
67
<div className={styles.value_icon}>
78
<value.pictureComponent alt={value.alt} />
89
</div>
910
<div className={styles.value_header}>{value.name}</div>
1011
<div className={styles.value_text}>
1112
<value.DescriptionMD />
1213
</div>
13-
</div>
14+
</Card>
1415
);
1516
}
1617
export default ValueCard;

src/components/about/styles.module.css

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,9 @@
2323
.small_portrait_card {
2424
width: 279px;
2525
height: 320px;
26-
background-color: white;
27-
color: var(--ifm-color-primary-p2);
28-
border-radius: 8px;
29-
box-shadow: var(--ifm-shadow-card);
3026
padding: var(--ifm-spacing-lg) var(--ifm-spacing-xs);
3127
margin-bottom: var(--ifm-spacing-xl);
32-
}
33-
34-
.small_portrait_card:hover {
35-
border: solid 1px gray;
36-
cursor: pointer;
37-
text-decoration: #0000ee underline;
28+
align-items: center;
3829
}
3930

4031
.value_icon {
@@ -159,9 +150,6 @@ div .join_the_team_text {
159150
}
160151

161152

162-
.small_portrait_card:hover {
163-
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
164-
}
165153

166154
@media only screen and (max-width: 996px) {
167155
/*Mobile*/
Lines changed: 19 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,31 @@
1-
// src/components/Card.js
2-
31
import React from "react";
42
import styles from "./styles.module.css";
53
import Link from "@docusaurus/Link";
64
import useBaseUrl from "@docusaurus/useBaseUrl";
5+
import Card from "../layout/Card";
76

87
export default function BlogpostCard({ blogpost, timeIndex }) {
98
return (
10-
<div
11-
className={"card" + " " + styles.blogpost_card}
12-
style={{ marginBottom: "var(--ifm-spacing-lg)" }}
13-
>
9+
<Card hover className={styles.blogpost_card}>
1410
<Link href={blogpost.url}>
15-
<div className="container">
16-
<div
17-
className={
18-
"row" +
19-
" " +
20-
"flex-full-centered" +
21-
" " +
22-
"padding-none" +
23-
" " +
24-
"margin-none"
25-
}
26-
></div>
27-
<div className="card__header">
28-
<div
29-
className={styles.blogpost_image + " " + "flex-full-centered"}
30-
style={{ height: "180px" }}
31-
>
32-
<img
33-
src={useBaseUrl(blogpost.image)}
34-
id={blogpost.imageID}
35-
alt={"Illustration for the blog post."}
36-
/>
37-
</div>
38-
39-
<div className={styles.blogpost_header}>{blogpost.title}</div>
40-
</div>
41-
42-
<div className={"card__body"}>
43-
<div className={styles.blogpost_summary}>
44-
{blogpost.summary.length < 200
45-
? blogpost.summary
46-
: blogpost.summary.substring(0, 200) + "..."}
47-
</div>
48-
</div>
49-
50-
<div
51-
className={"row card__footer"}
52-
style={{ marginBottom: "var(--ifm-spacing-md)" }}
53-
>
54-
<div className="col" style={{ padding: "0px" }}>
55-
<div className={styles.blogpost_date}>{blogpost.date}</div>
56-
<div className={styles.blogpost_authors}>{blogpost.authors}</div>
57-
</div>
58-
</div>
11+
<div className={styles.blogpost_image + " flex-full-centered"}>
12+
<img
13+
src={useBaseUrl(blogpost.image)}
14+
id={blogpost.imageID}
15+
alt={"Illustration for the blog post."}
16+
/>
17+
</div>
18+
<div className={styles.blogpost_header}>{blogpost.title}</div>
19+
<div className={styles.blogpost_summary}>
20+
{blogpost.summary.length < 200
21+
? blogpost.summary
22+
: blogpost.summary.substring(0, 200) + "..."}
23+
</div>
24+
<div className={styles.blogpost_footer}>
25+
<div className={styles.blogpost_date}>{blogpost.date}</div>
26+
<div className={styles.blogpost_authors}>{blogpost.authors}</div>
5927
</div>
6028
</Link>
61-
</div>
29+
</Card>
6230
);
6331
}
Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,55 @@
11
.blogpost_image {
22
filter: grayscale(1);
3+
height: 180px;
4+
display: flex;
5+
align-items: center;
6+
justify-content: center;
37
}
48

59
.blogpost_card {
610
height: 556px;
7-
width: 100%;
8-
border-radius: 8px;
9-
box-shadow: 4px 4px 18px -1px rgba(160, 140, 40, 0.15);
1011
padding: var(--ifm-spacing-xl);
11-
background: var(--ifm-background-color-card);
12-
}
13-
14-
.blogpost_card:hover {
15-
border: 1px solid #cbc7b1;
16-
}
17-
18-
div .blogpost_header {
19-
color: var(--ifm-text-color);
20-
}
21-
div .blogpost_summary {
22-
color: var(--ifm-text-color);
23-
}
24-
25-
div .blogpost_authors {
26-
color: var(--ifm-text-color);
27-
}
28-
29-
div .blogpost_date {
30-
color: var(--ifm-text-color);
3112
}
3213

3314
.blogpost_summary {
34-
font-family: var(--ifm-font-family-roboto);
3515
font-size: 14px;
36-
font-style: normal;
3716
font-weight: 300;
38-
line-height: 150%; /* 21px */
17+
line-height: 150%;
3918
letter-spacing: -0.154px;
4019
text-align: justify;
4120
margin-bottom: var(--ifm-spacing-sm);
4221
height: 124px;
4322
color: var(--ifm-text-color);
23+
flex: 1;
4424
}
4525

4626
.blogpost_header {
47-
color: var(--ifm-text-color);
48-
font-family: var(--ifm-font-family-roboto);
4927
font-size: 16px;
50-
font-style: normal;
5128
font-weight: 600;
52-
line-height: 150%; /* 27px */
29+
line-height: 150%;
5330
letter-spacing: -0.198px;
5431
height: 64px;
5532
margin: var(--ifm-spacing-xl) 0;
5633
color: var(--ifm-text-color);
5734
}
5835

36+
.blogpost_footer {
37+
margin-top: auto;
38+
padding-top: var(--ifm-spacing-sm);
39+
}
40+
5941
.blogpost_date {
60-
color: var(--ifm-text-color);
61-
font-family: var(--ifm-font-family-roboto);
6242
font-size: 12px;
63-
font-style: normal;
6443
font-weight: 800;
6544
line-height: 16px;
6645
letter-spacing: -0.132px;
67-
text-align: left;
6846
color: var(--ifm-text-color);
6947
}
7048

7149
.blogpost_authors {
72-
font-family: var(--ifm-font-family-roboto);
7350
font-size: 12px;
74-
font-style: normal;
7551
font-weight: 400;
7652
line-height: 16px;
77-
text-align: left;
7853
color: var(--ifm-text-color);
7954
}
8055

@@ -86,7 +61,6 @@ div .blogpost_date {
8661
background-repeat: no-repeat;
8762
background-position: 8px;
8863
border-radius: 8px;
89-
padding: var(--ifm-spacing-xs) var(--ifm-spacing-lg) var(--ifm-spacing-xs)
90-
var(--ifm-spacing-lg);
64+
padding: var(--ifm-spacing-xs) var(--ifm-spacing-lg) var(--ifm-spacing-xs) var(--ifm-spacing-lg);
9165
margin: var(--ifm-spacing-lg) 0;
9266
}

src/components/fundable/FundableProjectCard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styles from "./styles.module.css";
22
import { useHistory } from "@docusaurus/router";
33
import ProgressBar from "./ProgressBar";
4+
import Card from "../layout/Card";
45

56
export default function FundableProjectCard({ project }) {
67
const history = useHistory();
@@ -17,7 +18,7 @@ export default function FundableProjectCard({ project }) {
1718
: project.shortDescription;
1819

1920
return (
20-
<div className={styles.fund_card} onClick={open}>
21+
<Card hover onClick={open} className={styles.fund_card}>
2122
<div className={styles.fund_card_category}>{project.category}</div>
2223
<div className={styles.fund_card_title}>{project.title}</div>
2324
<p className={styles.fund_card_desc}>{desc}</p>
@@ -29,6 +30,6 @@ export default function FundableProjectCard({ project }) {
2930
{project.currentNbOfFunders > 0 && ` · ${project.currentNbOfFunders} funder${project.currentNbOfFunders > 1 ? "s" : ""}`}
3031
</div>
3132
</div>
32-
</div>
33+
</Card>
3334
);
3435
}

src/components/fundable/styles.module.css

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,7 @@
3434

3535

3636
.fund_card {
37-
background: white;
38-
border-radius: 10px;
39-
padding: var(--ifm-spacing-lg);
40-
box-shadow: var(--ifm-shadow-card);
41-
cursor: pointer;
42-
display: flex;
43-
flex-direction: column;
4437
gap: var(--ifm-spacing-sm);
45-
transition: box-shadow 0.2s;
46-
border: 1px solid transparent;
47-
}
48-
49-
.fund_card:hover {
50-
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
51-
border-color: var(--ifm-color-neutral-n3);
5238
}
5339

5440
.fund_card_category {

src/components/home/WhatWeDo/TopicsCard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import styles from "./styles.module.css";
2+
import Card from "../../layout/Card";
23

34
export function TopicsCard({ topics, TopicsDescriptionMD }) {
45
return (
5-
<div className={"content-card " + styles.topics_card}>
6+
<Card bg="yellow" className={styles.topics_card}>
67
<div className={styles.topics_header}>{topics.name}</div>
78
<div><TopicsDescriptionMD /></div>
8-
</div>
9+
</Card>
910
);
1011
}
1112

src/components/home/WhatWeDo/styles.module.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,5 @@ div .topics_header {
5454

5555
.topics_card {
5656
padding: var(--ifm-spacing-2xl) var(--ifm-spacing-lg);
57-
height: 100%;
5857
}
5958
}

src/components/layout/Card.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import clsx from "clsx";
2+
import styles from "./styles.module.css";
3+
import React from "react";
4+
5+
type Props = {
6+
bg?: "white" | "yellow";
7+
hover?: boolean;
8+
className?: string;
9+
onClick?: () => void;
10+
children: React.ReactNode;
11+
};
12+
13+
export default function Card({ bg = "white", hover = false, className, onClick, children }: Props) {
14+
return (
15+
<div
16+
className={clsx(
17+
styles.card,
18+
bg === "yellow" && styles.card_yellow,
19+
hover && styles.card_hover,
20+
className
21+
)}
22+
onClick={onClick}
23+
>
24+
{children}
25+
</div>
26+
);
27+
}

0 commit comments

Comments
 (0)