Created
February 10, 2021 17:19
-
-
Save DZuz14/f5a0252ad892a9285ad9d46faa72d027 to your computer and use it in GitHub Desktop.
handlebarwidth
This file contains hidden or 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
const StatRow = ({ stat }) => { | |
const { away, home } = stat; | |
const handleBarWidth = (value, high) => { | |
return Math.floor((value / high) * 100); | |
}; | |
return ( | |
<div> | |
<Stat> | |
<div> | |
<TeamRank marginRight={10}>#{away.team_rank}</TeamRank> | |
<StatValue>{away.stat_value}</StatValue> | |
</div> | |
<StatName>{away.stat_name}</StatName> | |
<div> | |
<StatValue>{home.stat_value}</StatValue> | |
<TeamRank marginLeft={10}>#{home.team_rank}</TeamRank> | |
</div> | |
</Stat> | |
<BarGroup> | |
<Bar> | |
<Filler | |
color="#F5B947" | |
width={handleBarWidth(away.stat_value, away.league_high)} | |
/> | |
</Bar> | |
<Bar> | |
<Filler | |
color="#EE7F31" | |
width={handleBarWidth(home.stat_value, home.league_high)} | |
/> | |
</Bar> | |
</BarGroup> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment