LeagueRating.jsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // components
  2. import Spring from '@components/Spring';
  3. import LeagueHeader from '@components/LeagueHeader';
  4. import ProgressItem from '@components/ProgressItem';
  5. import AnimatedCount from '@components/AnimatedCount';
  6. // hooks
  7. import {useThemeProvider} from '@contexts/themeContext';
  8. // assets
  9. import english_premier from '@assets/clubs/english_premier.webp';
  10. const LeagueRating = () => {
  11. const {theme} = useThemeProvider();
  12. const data = {
  13. '5 stars': 400,
  14. '4 stars': 210,
  15. '3 stars': 300,
  16. '2 stars': 56,
  17. '1 star': 150,
  18. }
  19. const getPercents = (data) => {
  20. let total = 0;
  21. for (const key in data) {
  22. total += data[key];
  23. }
  24. const result = {};
  25. for (const key in data) {
  26. result[key] = (data[key] / total) * 200;
  27. }
  28. return result;
  29. }
  30. return (
  31. <Spring className="card d-flex flex-column justify-content-between g-20 card-padded">
  32. <LeagueHeader img={english_premier} title="English Premier League" subtitle="Regular Championship" />
  33. <AnimatedCount className="h1 large" count={4.2} decimals={1} />
  34. <div className="d-flex flex-column g-24">
  35. {
  36. Object.keys(data).map((key, index) => (
  37. <ProgressItem
  38. key={index}
  39. title={key}
  40. value={getPercents(data)[key]}
  41. barColor="accent"
  42. trackColor={theme === 'light' ? 'body' : 'border'}
  43. />
  44. ))
  45. }
  46. </div>
  47. </Spring>
  48. )
  49. }
  50. export default LeagueRating