Skip to content

Commit 7bde6e2

Browse files
committed
Stats for Experience
1 parent 5773a58 commit 7bde6e2

File tree

6 files changed

+104
-12
lines changed

6 files changed

+104
-12
lines changed

src/pages/experience/index.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Blob } from "../../components/blob";
66
import { ExperienceCard } from "./card";
77

88
import "./style.css";
9+
import { ExperienceStats } from "./stats";
910

1011
export function ExperiencePage() {
1112
const [loading, setLoading] = useState(false);
@@ -53,6 +54,8 @@ export function ExperiencePage() {
5354
</h1>
5455

5556
<div className="experience-content">
57+
<ExperienceStats stats={data} />
58+
5659
<div className="experience-list">
5760
{
5861
data.map(experience => <ExperienceCard

src/pages/experience/stats/card/index.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import "./style.css";
44

55
export function StatsCard({ stat, desc }) {
66
return (<>
7-
<Glass className="stats-card">
8-
<h2 className="stat-card-title">{stat}</h2>
9-
<p className="stat-card-desc">{desc}</p>
10-
</Glass>
7+
<div className="stats-card-container">
8+
<Glass className="stats-card">
9+
<h2 className="stats-card-title">{stat}</h2>
10+
<p className="stats-card-desc">{desc}</p>
11+
</Glass>
12+
</div>
1113
</>);
1214
}
1315

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
1+
.stats-card-container {
2+
flex: 1;
3+
}
4+
15
.stats-card {
6+
width: 100%;
7+
height: 100%;
8+
display: flex;
9+
flex-direction: column;
10+
align-items: center;
11+
justify-content: center;
12+
padding: 2rem;
13+
gap: 0;
14+
}
15+
16+
.stats-card-title {
17+
font-size: 6rem;
18+
font-weight: 600;
19+
text-align: center;
20+
}
21+
22+
.stats-card-desc {
23+
font-size: 1rem;
24+
text-align: center;
25+
color: var(--text-secondary);
226
}
27+

src/pages/experience/stats/index.jsx

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,66 @@ import { StatsCard } from "./card";
22

33
import "./style.css";
44

5-
export function ExperienceStats() {
5+
export function ExperienceStats({ stats }) {
6+
const findMonths = (exp) => {
7+
const { start, end, professional } = exp;
8+
if (!professional) return 0;
9+
10+
const startDate = new Date(start);
11+
const endDate = end ? new Date(end) : new Date();
12+
13+
const months = (
14+
endDate.getFullYear() - startDate.getFullYear()
15+
) * 12 + (endDate.getMonth() - startDate.getMonth()) + 1;
16+
17+
return months;
18+
}
19+
20+
const experienceMonths = stats.reduce(
21+
(acc, exp) => findMonths(exp) + acc, 0
22+
);
23+
24+
const experienceDomains = new Set(stats.reduce(
25+
(acc, exp) => ([
26+
...exp.tags.domains,
27+
...acc,
28+
]), []
29+
)).size;
30+
31+
const experienceTools = new Set(stats.reduce(
32+
(acc, exp) => ([
33+
...exp.tags.tools,
34+
...acc,
35+
]), []
36+
)).size;
37+
638
return (<>
739
<div className="stats">
840
<div className="stats-rows">
9-
<StatsCard stat={9} desc={"months of experience"} />
10-
<div className="stat-cols">
11-
<StatsCard stat={9} desc={"months of experience"} />
12-
<StatsCard stat={9} desc={"months of experience"} />
41+
<div className="stats-cols">
42+
<StatsCard
43+
stat={
44+
experienceMonths > 12
45+
? (experienceMonths / 12).toFixed(1)
46+
: experienceMonths
47+
}
48+
desc={
49+
experienceMonths > 12
50+
? "years of experience"
51+
: "months of experience"
52+
}
53+
/>
54+
</div>
55+
<div className="stats-cols">
56+
<StatsCard
57+
stat={experienceDomains}
58+
desc={"domains worked in"}
59+
/>
60+
61+
<StatsCard
62+
stat={experienceTools}
63+
desc={"tools used"}
64+
/>
1365
</div>
1466
</div>
1567
</div>

src/pages/experience/stats/style.css

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}
55

66
.stats-cols {
7-
flex: 1;
7+
flex-grow: 1;
88
display: flex;
99
flex-direction: column;
1010
align-items: stretch;
@@ -14,7 +14,7 @@
1414
}
1515

1616
.stats-rows {
17-
flex: 1;
17+
flex-grow: 1;
1818
display: flex;
1919
flex-direction: row;
2020
align-items: stretch;
@@ -23,3 +23,13 @@
2323
height: 100%;
2424
}
2525

26+
@media screen and (max-width: 768px) {
27+
.stats-rows {
28+
flex-direction: column;
29+
}
30+
31+
.stats-cols {
32+
flex-direction: row;
33+
}
34+
}
35+

src/pages/experience/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
}
4848

4949
.experience-list {
50-
width: 100%;
50+
flex: 1;
5151
display: flex;
5252
flex-direction: column;
5353
align-items: center;

0 commit comments

Comments
 (0)