-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
visualize global score and net score
- Loading branch information
1 parent
4be17cf
commit 1fc401b
Showing
5 changed files
with
267 additions
and
67 deletions.
There are no files selected for viewing
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
52 changes: 52 additions & 0 deletions
52
otoroshi/javascript/src/extensions/greenscore/GlobalScore.js
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,52 @@ | ||
import React from 'react'; | ||
import { calculateGreenScore, getRankAndLetterFromScore } from "./util"; | ||
|
||
export function GlobalScore(props) { | ||
const score = props.groups.reduce((acc, group) => { | ||
return acc + group.routes.reduce((acc, route) => calculateGreenScore(route.rulesConfig).score + acc, 0) / group.routes.length; | ||
}, 0) / props.groups.length; | ||
|
||
const { letter, rank, ...rest } = getRankAndLetterFromScore(score); | ||
|
||
return <div | ||
className="text-center ms-2" | ||
style={{ | ||
flex: .5, | ||
maxWidth: 250, | ||
background: 'var(--bg-color_level2)', | ||
borderRadius: '.2rem', | ||
padding: '0 .5rem', | ||
fontSize: '10rem', | ||
position: 'relative' | ||
}}> | ||
<div style={{ | ||
display: 'flex', | ||
alignItems: 'baseline', | ||
justifyContent: 'center' | ||
}}> | ||
{!props.raw && <>{letter !== "@" ? letter : '-'} <i className="fa fa-leaf" | ||
style={{ color: rank, fontSize: '6rem' }} /> | ||
</>} | ||
{props.raw && <div> | ||
<span style={{ fontSize: '5rem' }}>{rest.score}</span> | ||
<span style={{ fontSize: '1rem', fontWeight: 'bold' }}>{`/${props.groups.length * 6000}`}</span> | ||
</div>} | ||
</div> | ||
<h3 style={{ color: 'var(--color_level2)' }}>{props.raw ? 'Net' : 'Global'} score</h3> | ||
|
||
<div style={{ | ||
position: 'absolute', | ||
top: 6, | ||
right: 6, | ||
borderRadius: '50%', | ||
background: 'rgba(249, 176, 0, 0.46)', | ||
width: 32, | ||
height: 32, | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center' | ||
}}> | ||
<i className='fas fa-chart-line' style={{ fontSize: 'initial' }} /> | ||
</div> | ||
</div> | ||
}; |
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
Oops, something went wrong.