Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display win rate in heroes page #3171

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/components/Hero/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,21 @@ const HeroStatsWrapper = styled.div`
flex: 1 1 100%;
`;

const Header = ({ hero }) => (
const HeroWR = styled.div`
font-size: 30px;
font-weight: ${constants.fontWeightMedium};
color:${props => (props?.wr >= 50) ? constants.green : constants.red };

@media screen and (max-width: ${constants.wrapTablet}){
font-size: 20px;
}
`


const Header = ({ hero, win_rate }) => {
const pub_wr = (hero.pub_win / hero.pub_pick * 100).toFixed(2)

return(
<HeroDescription>
<HeroProfile>
<HeroProfileBackground
Expand All @@ -122,6 +136,7 @@ const Header = ({ hero }) => (
<HeroAvatar alt={hero.localized_name} src={getHeroImgSrc(hero.img)} />
<HeroDetails>
<HeroName>{hero.localized_name}</HeroName>
<HeroWR wr={pub_wr}> {win_rate} {pub_wr}% </HeroWR>
<HeroRoleInformations>
{hero.attack_type} - <HeroRoles>{hero.roles.join(', ')}</HeroRoles>
</HeroRoleInformations>
Expand All @@ -133,7 +148,7 @@ const Header = ({ hero }) => (
</HeroProfileContent>
</HeroProfile>
</HeroDescription>
);
)}

Header.propTypes = {
hero: shape({}),
Expand Down
2 changes: 1 addition & 1 deletion src/components/Hero/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class Hero extends React.Component {
<div>
<Helmet title={hero.localized_name} />
<HeroBlock>
<Header hero={hero} />
<Header hero={hero} win_rate ={strings.heading_win_rate}/>
<HeroFooter>
<HeroDetailsButton type='button' onClick={this.toggleDetailVisibility}>
{this.state.detailsOpen ? strings.hide_details : strings.show_details}
Expand Down
Loading