Skip to content

Commit 09acd61

Browse files
committed
Add counter item reusable component
1 parent e914d9e commit 09acd61

File tree

2 files changed

+37
-33
lines changed

2 files changed

+37
-33
lines changed

src/components/about/AboutCounter.jsx

+21-33
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useCountUp } from 'react-countup';
2+
import CounterItem from './CounterItem';
23

34
const AboutCounter = () => {
45
useCountUp({ ref: 'experienceCounter', end: 12, duration: 2 });
@@ -9,42 +10,29 @@ const AboutCounter = () => {
910
return (
1011
<div className="mt-10 sm:mt-20 bg-primary-light dark:bg-ternary-dark shadow-sm">
1112
<div className="font-general-medium container mx-auto py-20 block sm:flex sm:justify-between items-center">
12-
<div className="mb-20 sm:mb-0">
13-
<h2 className="text-4xl text-center text-secondary-dark dark:text-secondary-light mb-2">
14-
<span id="experienceCounter" />
15-
</h2>
16-
<span className="font-general-regular block text-md text-center text-ternary-dark dark:text-ternary-light">
17-
Years of experience
18-
</span>
19-
</div>
13+
<CounterItem
14+
title="Years of experience"
15+
counter={<span id="experienceCounter" />}
16+
measurement=""
17+
/>
2018

21-
<div className="mb-20 sm:mb-0">
22-
<h2 className="text-4xl text-center text-secondary-dark dark:text-secondary-light mb-2">
23-
<span id="githubStarsCounter" />
24-
k+
25-
</h2>
26-
<span className="font-general-regular block text-md text-center text-ternary-dark dark:text-ternary-light">
27-
Stars on GitHub
28-
</span>
29-
</div>
19+
<CounterItem
20+
title="Stars on GitHub"
21+
counter={<span id="githubStarsCounter" />}
22+
measurement="k+"
23+
/>
3024

31-
<div className="mb-20 sm:mb-0">
32-
<h2 className="text-4xl text-center text-secondary-dark dark:text-secondary-light mb-2">
33-
<span id="feedbackCounter" /> %
34-
</h2>
35-
<span className="font-general-regular block text-md text-center text-ternary-dark dark:text-ternary-light">
36-
Positive feedback
37-
</span>
38-
</div>
25+
<CounterItem
26+
title="Positive feedback"
27+
counter={<span id="feedbackCounter" />}
28+
measurement="%"
29+
/>
3930

40-
<div className="mb-20 sm:mb-0">
41-
<h2 className="text-4xl text-center text-secondary-dark dark:text-secondary-light mb-2">
42-
<span id="projectsCounter" /> %
43-
</h2>
44-
<span className="font-general-regular block text-md text-center text-ternary-dark dark:text-ternary-light">
45-
Projects completed
46-
</span>
47-
</div>
31+
<CounterItem
32+
title="Projects completed"
33+
counter={<span id="projectsCounter" />}
34+
measurement="%"
35+
/>
4836
</div>
4937
</div>
5038
);

src/components/about/CounterItem.jsx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
3+
const CounterItem = ({ title, counter, measurement }) => {
4+
return (
5+
<div className="mb-20 sm:mb-0">
6+
<h2 className="text-4xl text-center text-secondary-dark dark:text-secondary-light mb-2">
7+
{counter} {measurement}
8+
</h2>
9+
<span className="font-general-regular block text-md text-center text-ternary-dark dark:text-ternary-light">
10+
{title}
11+
</span>
12+
</div>
13+
);
14+
};
15+
16+
export default CounterItem;

0 commit comments

Comments
 (0)