fix: design fixes on notifications screen

This commit is contained in:
José Oliveira 2021-06-17 17:54:42 +01:00 committed by Josh Harvey
parent fc3ad8e421
commit cdab60069c
5 changed files with 50 additions and 45 deletions

View file

@ -21,7 +21,7 @@ const Cashbox = ({
labelClassName, labelClassName,
inFiatBalanceAlerts inFiatBalanceAlerts
}) => { }) => {
const classes = cashboxClasses({ percent, cashOut }) const classes = cashboxClasses({ percent, cashOut, inFiatBalanceAlerts })
const threshold = 51 const threshold = 51
const showCashBox = { const showCashBox = {

View file

@ -11,8 +11,12 @@ const colors = {
} }
} }
const colorPicker = ({ percent, cashOut }) => const colorPicker = ({ percent, cashOut, inFiatBalanceAlerts }) => {
colors[cashOut ? 'cashOut' : 'cashIn'][percent >= 50 ? 'full' : 'empty'] if (inFiatBalanceAlerts) return colors[cashOut ? 'cashOut' : 'cashIn'].full
return colors[cashOut ? 'cashOut' : 'cashIn'][
percent >= 50 ? 'full' : 'empty'
]
}
const cashboxStyles = { const cashboxStyles = {
cashbox: { cashbox: {

View file

@ -42,6 +42,9 @@ const FiatBalance = ({ section, min = 0, max = 100, fieldWidth = 80 }) => {
.nullable() .nullable()
}) })
const getPercentage = fillingPercentage =>
fillingPercentage ?? data?.fillingPercentageCassette1
return ( return (
<Formik <Formik
validateOnBlur={false} validateOnBlur={false}
@ -58,29 +61,51 @@ const FiatBalance = ({ section, min = 0, max = 100, fieldWidth = 80 }) => {
onReset={() => { onReset={() => {
setEditing(NAME, false) setEditing(NAME, false)
}}> }}>
<Form className={classes.form}> {({ values }) => (
<PromptWhenDirty /> <Form className={classes.form}>
<Header <PromptWhenDirty />
title="Cash out (Empty)" <Header
editing={editing} title="Cash out (Empty)"
disabled={isDisabled(NAME)} editing={editing}
setEditing={it => setEditing(NAME, it)} disabled={isDisabled(NAME)}
/> setEditing={it => setEditing(NAME, it)}
<div className={classes.wrapper}> />
<div className={classes.first}> <div className={classes.wrapper}>
<div className={classes.first}>
<div className={classes.row}>
<Cashbox
labelClassName={classes.cashboxLabel}
emptyPartClassName={classes.cashboxEmptyPart}
percent={getPercentage(values.fillingPercentageCassette1)}
inFiatBalanceAlerts={true}
cashOut
/>
<div className={classes.col2}>
<TL2 className={classes.title}>Cassette 1 (Top)</TL2>
<EditableNumber
label="Alert me under"
name="fillingPercentageCassette1"
editing={editing}
displayValue={x => (x === '' ? '-' : x)}
decoration="%"
width={fieldWidth}
/>
</div>
</div>
</div>
<div className={classes.row}> <div className={classes.row}>
<Cashbox <Cashbox
labelClassName={classes.cashboxLabel} labelClassName={classes.cashboxLabel}
emptyPartClassName={classes.cashboxEmptyPart} emptyPartClassName={classes.cashboxEmptyPart}
percent={data?.fillingPercentageCassette1} percent={getPercentage(values.fillingPercentageCassette2)}
inFiatBalanceAlerts={true} inFiatBalanceAlerts={true}
cashOut cashOut
/> />
<div className={classes.col2}> <div className={classes.col2}>
<TL2 className={classes.title}>Cassette 1 (Top)</TL2> <TL2 className={classes.title}>Cassette 2 (Bottom)</TL2>
<EditableNumber <EditableNumber
label="Alert me under" label="Alert me under"
name="fillingPercentageCassette1" name="fillingPercentageCassette2"
editing={editing} editing={editing}
displayValue={x => (x === '' ? '-' : x)} displayValue={x => (x === '' ? '-' : x)}
decoration="%" decoration="%"
@ -89,28 +114,8 @@ const FiatBalance = ({ section, min = 0, max = 100, fieldWidth = 80 }) => {
</div> </div>
</div> </div>
</div> </div>
<div className={classes.row}> </Form>
<Cashbox )}
labelClassName={classes.cashboxLabel}
emptyPartClassName={classes.cashboxEmptyPart}
percent={data?.fillingPercentageCassette2}
inFiatBalanceAlerts={true}
cashOut
/>
<div className={classes.col2}>
<TL2 className={classes.title}>Cassette 2 (Bottom)</TL2>
<EditableNumber
label="Alert me under"
name="fillingPercentageCassette2"
editing={editing}
displayValue={x => (x === '' ? '-' : x)}
decoration="%"
width={fieldWidth}
/>
</div>
</div>
</div>
</Form>
</Formik> </Formik>
) )
} }

View file

@ -96,7 +96,7 @@ const FiatBalanceOverrides = ({ section }) => {
}, },
{ {
name: CASSETTE_1_KEY, name: CASSETTE_1_KEY,
display: 'Cash-out 1', header: 'Cash-out 1',
width: 155, width: 155,
textAlign: 'right', textAlign: 'right',
doubleHeader: 'Cash-out (Cassette Empty)', doubleHeader: 'Cash-out (Cassette Empty)',
@ -109,7 +109,7 @@ const FiatBalanceOverrides = ({ section }) => {
}, },
{ {
name: CASSETTE_2_KEY, name: CASSETTE_2_KEY,
display: 'Cash-out 2', header: 'Cash-out 2',
width: 155, width: 155,
textAlign: 'right', textAlign: 'right',
doubleHeader: 'Cash-out (Cassette Empty)', doubleHeader: 'Cash-out (Cassette Empty)',

View file

@ -24,7 +24,6 @@ const sizes = {
errors: 142, errors: 142,
active: 263 active: 263
} }
const width = R.sum(R.values(sizes)) + channelSize
const Row = ({ namespace, forceDisable }) => { const Row = ({ namespace, forceDisable }) => {
const { data: rawData, save: rawSave } = useContext(NotificationsCtx) const { data: rawData, save: rawSave } = useContext(NotificationsCtx)
@ -64,9 +63,6 @@ const Row = ({ namespace, forceDisable }) => {
} }
const useStyles = makeStyles({ const useStyles = makeStyles({
mainTable: {
width
},
wizardTable: { wizardTable: {
width: 930 width: 930
} }
@ -75,7 +71,7 @@ const Setup = ({ wizard, forceDisable }) => {
const widthAdjust = wizard ? 20 : 0 const widthAdjust = wizard ? 20 : 0
const classes = useStyles() const classes = useStyles()
return ( return (
<Table className={wizard ? classes.wizardTable : classes.mainTable}> <Table className={wizard ? classes.wizardTable : null}>
<THead> <THead>
<Th width={channelSize - widthAdjust}>Channel</Th> <Th width={channelSize - widthAdjust}>Channel</Th>
{Object.keys(sizes).map(it => ( {Object.keys(sizes).map(it => (