-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #487 from VinayLodhi1712/stats
stats section added on about us page.#476 done
- Loading branch information
Showing
5 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
|
||
.stats-section { | ||
display: flex; /* Keep items in a single row */ | ||
justify-content: space-between; /* Space items evenly */ | ||
padding: 20px; | ||
} | ||
|
||
.stat-item { | ||
text-align: center; /* Center content within each item */ | ||
flex: 1 1 45%; /* Allow items to take 45% of the row space */ | ||
margin: 10px; /* Add margin for spacing */ | ||
} | ||
|
||
.stat-number { | ||
font-size: 2rem; /* Default size for numbers */ | ||
font-weight: 600; | ||
} | ||
|
||
.stat-title { | ||
margin-top: 10px; | ||
font-size: 1rem; /* Default size for titles */ | ||
color: #555; | ||
} | ||
|
||
/* Responsive styles */ | ||
@media (max-width: 768px) { | ||
.stat-number { | ||
font-size: 1rem; /* Reduced size for numbers on smaller screens */ | ||
} | ||
|
||
.stat-title { | ||
font-size: 0.75rem; /* Reduced size for titles on smaller screens */ | ||
} | ||
|
||
.stats-section { | ||
padding: 0px; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { useState } from 'react'; | ||
import CountUp from 'react-countup'; | ||
import VisibilitySensor from 'react-visibility-sensor'; | ||
import './Stats.css'; | ||
|
||
const Stats = () => { | ||
const [viewed, setViewed] = useState({ | ||
stationsCovered: false, | ||
activeUsers: false, | ||
totalBookings: false, | ||
feedbackRatings: false, | ||
}); | ||
|
||
return ( | ||
<div className='stats-section'> | ||
<StatItem title="Stations Covered" end={200} viewed={viewed.stationsCovered} setViewed={() => setViewed(prev => ({ ...prev, stationsCovered: true }))} /> | ||
<StatItem title="Active Users" end={1500} viewed={viewed.activeUsers} setViewed={() => setViewed(prev => ({ ...prev, activeUsers: true }))} /> | ||
<StatItem title="Total Bookings" end={5000} viewed={viewed.totalBookings} setViewed={() => setViewed(prev => setViewed(prev => ({ ...prev, totalBookings: true })))} /> | ||
<StatItem title="Feedback Ratings" end={4.8} viewed={viewed.feedbackRatings} setViewed={() => setViewed(prev => ({ ...prev, feedbackRatings: true }))} /> | ||
</div> | ||
); | ||
}; | ||
|
||
const StatItem = ({ title, end, viewed, setViewed }) => ( | ||
<div className='stat-item'> | ||
<VisibilitySensor partialVisibility offset={{ bottom: 200 }} onChange={isVisible => isVisible && setViewed()}> | ||
{({ isVisible }) => ( | ||
<div className='stat-number'> | ||
{viewed || isVisible ? ( | ||
// Use CountUp with a formatted decimal display | ||
<CountUp | ||
start={0} | ||
end={typeof end === 'number' && end % 1 !== 0 ? end : Math.floor(end)} | ||
duration={3} | ||
decimals={typeof end === 'number' && end % 1 !== 0 ? 1 : 0} | ||
suffix={typeof end === 'number' && end % 1 !== 0 ? "" : "+"} | ||
/> | ||
) : ( | ||
end | ||
)} | ||
</div> | ||
)} | ||
</VisibilitySensor> | ||
<div className='stat-title '>{title}</div> | ||
</div> | ||
); | ||
|
||
export default Stats; |