fix: move number alongside bar on empty part until 51%, and them move it

to the filled part
This commit is contained in:
Liordino Neto 2020-11-03 20:31:11 -03:00 committed by Josh Harvey
parent 106fa166b0
commit f10b49f31c
2 changed files with 10 additions and 4 deletions

View file

@ -15,13 +15,15 @@ const gridClasses = makeStyles(gridStyles)
const Cashbox = ({ percent = 0, cashOut = false, className }) => { const Cashbox = ({ percent = 0, cashOut = false, className }) => {
const classes = cashboxClasses({ percent, cashOut }) const classes = cashboxClasses({ percent, cashOut })
const threshold = 51
return ( return (
<div className={classnames(className, classes.cashbox)}> <div className={classnames(className, classes.cashbox)}>
<div className={classes.emptyPart}> <div className={classes.emptyPart}>
{percent <= 50 && <Label2>{percent.toFixed(0)}%</Label2>} {percent <= threshold && <Label2>{percent.toFixed(0)}%</Label2>}
</div> </div>
<div className={classes.fullPart}> <div className={classes.fullPart}>
{percent > 50 && <Label2>{percent.toFixed(0)}%</Label2>} {percent > threshold && <Label2>{percent.toFixed(0)}%</Label2>}
</div> </div>
</div> </div>
) )

View file

@ -27,14 +27,18 @@ const cashboxStyles = {
emptyPart: { emptyPart: {
backgroundColor: 'white', backgroundColor: 'white',
height: ({ percent }) => `${100 - percent}%`, height: ({ percent }) => `${100 - percent}%`,
position: 'relative',
'& > p': { '& > p': {
color: colorPicker, color: colorPicker,
display: 'inline-block' display: 'inline-block',
position: 'absolute',
margin: 0,
bottom: 0,
right: 0
} }
}, },
fullPart: { fullPart: {
backgroundColor: colorPicker, backgroundColor: colorPicker,
height: ({ percent }) => `${percent}%`,
'& > p': { '& > p': {
color: 'white', color: 'white',
display: 'inline' display: 'inline'