Chore: change variable names and use classnames

This commit is contained in:
csrapr 2021-02-18 14:57:42 +00:00 committed by Josh Harvey
parent f752bad447
commit 6760c39e29
4 changed files with 17 additions and 18 deletions

View file

@ -55,10 +55,9 @@ const CLEAR_ALL_NOTIFICATIONS = gql`
const NotificationCenter = ({ const NotificationCenter = ({
close, close,
hasUnreadProp, hasUnreadProp,
notifButtonCoords, buttonCoords,
popperRef, popperRef,
refetchHasUnreadHeader, refetchHasUnreadHeader
setHeaderHasUnread
}) => { }) => {
const { data, loading } = useQuery(GET_NOTIFICATIONS, { const { data, loading } = useQuery(GET_NOTIFICATIONS, {
pollInterval: 60000 pollInterval: 60000
@ -68,12 +67,11 @@ const NotificationCenter = ({
const [showingUnread, setShowingUnread] = useState(false) const [showingUnread, setShowingUnread] = useState(false)
const classes = useStyles({ notifButtonCoords, xOffset }) const classes = useStyles({ buttonCoords, xOffset })
const machines = R.compose( const machines = R.compose(
R.map(R.prop('name')), R.map(R.prop('name')),
R.indexBy(R.prop('deviceId')) R.indexBy(R.prop('deviceId'))
)(data?.machines ?? []) )(data?.machines ?? [])
const notifications = R.path(['notifications'])(data) ?? [] const notifications = R.path(['notifications'])(data) ?? []
const [hasUnread, setHasUnread] = useState( const [hasUnread, setHasUnread] = useState(
hasUnreadProp || (data?.hasUnreadNotifications ?? false) hasUnreadProp || (data?.hasUnreadNotifications ?? false)

View file

@ -37,10 +37,10 @@ const styles = {
marginLeft: spacer * 2, marginLeft: spacer * 2,
height: 0 height: 0
}, },
notificationIcon: ({ notifButtonCoords, xOffset }) => ({ notificationIcon: ({ buttonCoords, xOffset }) => ({
position: 'absolute', position: 'absolute',
top: notifButtonCoords ? notifButtonCoords.y - 1 : 0, top: buttonCoords ? buttonCoords.y - 1 : 0,
left: notifButtonCoords ? notifButtonCoords.x - xOffset : 0, left: buttonCoords ? buttonCoords.x - xOffset : 0,
cursor: 'pointer', cursor: 'pointer',
background: 'transparent', background: 'transparent',
boxShadow: '0px 0px 0px transparent', boxShadow: '0px 0px 0px transparent',
@ -94,7 +94,7 @@ const styles = {
marginTop: 5, marginTop: 5,
width: '12px', width: '12px',
height: '12px', height: '12px',
border: `1px solid ${comet}`, border: [[1, 'solid', comet]],
borderRadius: '50%', borderRadius: '50%',
cursor: 'pointer', cursor: 'pointer',
zIndex: 1 zIndex: 1

View file

@ -49,6 +49,10 @@ const NotificationRow = ({
? `${deviceName}` ? `${deviceName}`
: `${typeDisplay}` : `${typeDisplay}`
const iconClass = {
[classes.readIcon]: read,
[classes.unreadIcon]: !read
}
return ( return (
<Grid <Grid
container container
@ -73,11 +77,10 @@ const NotificationRow = ({
</Grid> </Grid>
</Grid> </Grid>
<Grid item xs={3} style={{ zIndex: 1 }}> <Grid item xs={3} style={{ zIndex: 1 }}>
{read ? ( <div
<div onClick={() => toggleClear(id)} className={classes.readIcon} /> onClick={() => toggleClear(id)}
) : ( className={classnames(iconClass)}
<div onClick={() => toggleClear(id)} className={classes.unreadIcon} /> />
)}
</Grid> </Grid>
{!valid && <StripesSvg className={classes.stripes} />} {!valid && <StripesSvg className={classes.stripes} />}
</Grid> </Grid>

View file

@ -170,12 +170,10 @@ const Header = memo(({ tree }) => {
}}> }}>
<NotificationCenter <NotificationCenter
popperRef={popperRef} popperRef={popperRef}
notifButtonCoords={notifButtonCoords} buttonCoords={notifButtonCoords}
close={onClickAway} close={onClickAway}
hasUnreadProp={hasUnread}
refetchHasUnreadHeader={refetch} refetchHasUnreadHeader={refetch}
setHeaderHasUnread={unread => {
setHasUnread(unread)
}}
/> />
</Popper> </Popper>
</div> </div>