Make score prettier

This commit is contained in:
Marco van Dijk 2022-04-17 01:42:15 +02:00
parent d4b69833cf
commit 6572385906
2 changed files with 28 additions and 9 deletions

View File

@ -19,6 +19,7 @@
"https": "^1.0.0", "https": "^1.0.0",
"md5": "^2.3.0", "md5": "^2.3.0",
"react": "^17.0.2", "react": "^17.0.2",
"react-circular-progressbar": "^2.0.4",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-indiana-drag-scroll": "^2.1.0", "react-indiana-drag-scroll": "^2.1.0",
"react-markdown": "^7.1.1", "react-markdown": "^7.1.1",

View File

@ -2,6 +2,8 @@ import React, { useState, useEffect } from 'react'
import Address from '../components/OrchAddressViewer'; import Address from '../components/OrchAddressViewer';
import { Popover } from '@mantine/core'; import { Popover } from '@mantine/core';
import ScoreView from './scoreViewer'; import ScoreView from './scoreViewer';
import { CircularProgressbar } from 'react-circular-progressbar';
import 'react-circular-progressbar/dist/styles.css';
const Winner = (obj) => { const Winner = (obj) => {
const [thisScore, setThisScore] = useState(0); const [thisScore, setThisScore] = useState(0);
@ -26,21 +28,37 @@ const Winner = (obj) => {
let scoreObj = null; let scoreObj = null;
if (thisScore) { if (thisScore) {
scoreObj = scoreObj =
<Popover className="strokeSmollLeft" style={{ minWidth: '100px', cursor: 'pointer' }} <Popover className="strokeSmollLeft" style={{ cursor: 'pointer', marginTop: '0.2em', marginBottom: '0.2em' }}
opened={opened} opened={opened}
onClose={() => setOpened(false)} onClose={() => setOpened(false)}
target={ target={
<div className="strokeSmollLeft" onClick={() => setOpened((o) => !o)} > <div className="strokeSmollLeft" style={{ width: '4em', height: '4em', marginLeft: '2em' }} onClick={() => setOpened((o) => !o)} >
<div className="rowAlignLeft" > <CircularProgressbar value={thisScore} maxValue={1} text={`${((thisScore * 10).toFixed(1))}`}
<h4>Global Score</h4> styles={{
</div> root: {},
<div className="rowAlignRight" > path: {
<span>{(thisScore * 10).toFixed(1)}</span> stroke: `rgba(20, 153, 53, ${thisScore})`,
</div> strokeLinecap: 'round',
transition: 'stroke-dashoffset 0.5s ease 0s',
transformOrigin: 'center center',
},
trail: {
stroke: '#d66400',
strokeLinecap: 'rounnd',
transformOrigin: 'center center',
},
text: {
fill: 'rgba(0, 0, 0, 0.875)',
fontSize: '32px',
},
background: {
fill: '#3e98c7',
},
}}/>
</div> </div>
} }
width={260} width={260}
position="bottom" position="right"
withArrow withArrow
> >
<ScoreView score={obj.stats.scores[obj.address]} /> <ScoreView score={obj.stats.scores[obj.address]} />