Skip to content

Commit

Permalink
1529 styling adjustments for materialUI upgrade (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydonkrooss authored Jan 3, 2024
1 parent 6a1a75a commit 1e4e971
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 42 deletions.
33 changes: 21 additions & 12 deletions assets/src/components/AssignmentTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const PREFIX = 'AssignmentTable'

const classes = {
root: `${PREFIX}-root`,
paper: `${PREFIX}-paper`,
messageWrapper: `${PREFIX}-messageWrapper`,
container: `${PREFIX}-container`,
sliderCell: `${PREFIX}-sliderCell`,
goalGradeInput: `${PREFIX}-goalGradeInput`,
Expand Down Expand Up @@ -62,11 +62,6 @@ const Root = styled('div')((
padding: 8
},

[`& .${classes.paper}`]: {
padding: theme.spacing(2),
color: theme.palette.text.secondary
},

[`& .${classes.container}`]: {
maxHeight: 500
},
Expand Down Expand Up @@ -142,6 +137,14 @@ const Root = styled('div')((
}
}))

// separate styles for child of opened popover
const StyledPopoverMessage = styled('div')(({ theme }) => ({
[`& .${classes.messageWrapper}`]: {
padding: theme.spacing(2),
color: theme.palette.text.secondary
}
}))

const headerHeight = 105

function AssignmentTable (props) {
Expand Down Expand Up @@ -404,8 +407,8 @@ function AssignmentTable (props) {
{
a.week
? isPreviousWeekTheSame(a.week, key)
? ''
: `Week ${a.week}`
? ''
: `Week ${a.week}`
: 'No due date'
}
</TableCell>
Expand All @@ -418,8 +421,8 @@ function AssignmentTable (props) {
{
a.week
? isPreviousDayTheSame(a.dueDateMonthDay, key)
? ''
: a.dueDateMonthDay
? ''
: a.dueDateMonthDay
: ''
}
</TableCell>
Expand Down Expand Up @@ -495,9 +498,11 @@ function AssignmentTable (props) {
/>
<Popover
className={classes.popover}
classes={{ paper: classes.paper }}
anchorEl={popoverEl.anchorEl}
open={popoverEl.popoverId === key}
sx={{
pointerEvents: 'none'
}}
onClose={clearPopoverEl}
anchorOrigin={{
vertical: 'top',
Expand All @@ -511,7 +516,11 @@ function AssignmentTable (props) {
disableAutoFocus
disableEnforceFocus
>
<PopupMessage a={a} assignmentGroups={assignmentGroups} />
<StyledPopoverMessage>
<div className={classes.messageWrapper}>
<PopupMessage a={a} assignmentGroups={assignmentGroups} />
</div>
</StyledPopoverMessage>
</Popover>
</div>
</>
Expand Down
22 changes: 11 additions & 11 deletions assets/src/components/AvatarModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Typography from '@mui/material/Typography'
import Avatar from '@mui/material/Avatar'
import Link from '@mui/material/Link'
import List from '@mui/material/List'
import ListItem from '@mui/material/ListItem'
import ListItemButton from '@mui/material/ListItemButton'
import ListItemIcon from '@mui/material/ListItemIcon'
import ListItemText from '@mui/material/ListItemText'
import DialogTitle from '@mui/material/DialogTitle'
Expand Down Expand Up @@ -70,25 +70,25 @@ function AvatarModal (props) {
const Admin = () => (
<>
<Link style={{ textDecoration: 'none' }} href='/admin'>
<ListItem button>
<ListItemButton>
<ListItemIcon>
<Lock />
</ListItemIcon>
<ListItemText inset primary='Admin' className={classes.text} />
</ListItem>
</ListItemButton>
</Link>
<Divider />
</>
)

const SwitchCourses = () => (
<>
<ListItem button onClick={() => setOpenChangeCourseDialog(true)}>
<ListItemButton onClick={() => setOpenChangeCourseDialog(true)}>
<ListItemIcon>
<Launch />
</ListItemIcon>
<ListItemText inset primary='Switch courses' className={classes.text} />
</ListItem>
</ListItemButton>
<Dialog
onClose={() => setOpenChangeCourseDialog(false)}
open={openChangeCourseDialog}
Expand All @@ -101,9 +101,9 @@ function AvatarModal (props) {
href={`/courses/${course.course_id}`}
key={i}
>
<ListItem button>
<ListItemButton>
<ListItemText inset primary={course.course_name} className={classes.text} />
</ListItem>
</ListItemButton>
</Link>
))}
</List>
Expand Down Expand Up @@ -154,12 +154,12 @@ function AvatarModal (props) {
<List>
<Divider />
<Link style={{ textDecoration: 'none' }} href={helpURL} target='_blank' rel='noopener noreferrer'>
<ListItem button>
<ListItemButton>
<ListItemIcon>
<HelpIcon />
</ListItemIcon>
<ListItemText inset primary='Help' className={classes.text} />
</ListItem>
</ListItemButton>
</Link>
<Divider />
{
Expand All @@ -176,12 +176,12 @@ function AvatarModal (props) {
user.logoutURL !== ''
? (
<Link style={{ textDecoration: 'none' }} href={user.logoutURL}>
<ListItem button>
<ListItemButton>
<ListItemIcon>
<LogoutIcon />
</ListItemIcon>
<ListItemText inset primary='Logout' className={classes.text} />
</ListItem>
</ListItemButton>
</Link>
)
: null
Expand Down
2 changes: 1 addition & 1 deletion assets/src/components/ProgressBarV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function ProgressBarV2 (props) {
width: `${percentWidth}%`,
height: `${height}px`,
position: 'relative',
margin: margin
margin
}}
onFocus={(event) => { if (onBarFocus) onBarFocus(event.currentTarget) }}
onBlur={(event) => { if (onBarBlur) onBarBlur() }}
Expand Down
26 changes: 13 additions & 13 deletions assets/src/components/SurveyModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ const classes = {
surveyButton: `${PREFIX}-surveyButton`
}

const Root = styled('div')((
{
theme
}
) => ({
// styling within the modal (root styling doesn't apply to portal elements)
const StyledModalBody = styled('div')(({ theme }) => ({
[`& .${classes.modal}`]: {
top: '10%',
left: '50%',
Expand Down Expand Up @@ -61,11 +58,14 @@ const Root = styled('div')((
right: 0,
width: '100%',
height: '100%'
},
}
}))

[`& .${classes.surveyButton}`]: {
color: theme.palette.primary.main,
background: theme.palette.getContrastText(theme.palette.primary.main)
const ColoredButton = styled(Button)(({ theme }) => ({
backgroundColor: theme.palette.getContrastText(theme.palette.primary.main),
color: theme.palette.primary.main,
'&:hover': {
backgroundColor: '#D5D5D5'
}
}))

Expand Down Expand Up @@ -109,16 +109,16 @@ export default function SurveyModal (props) {
)

return (
<Root>
<Button variant='contained' className={classes.surveyButton} onClick={toggleOpen}>{props.surveyLink.text}</Button>
<>
<ColoredButton variant='contained' onClick={toggleOpen}>{props.surveyLink.text}</ColoredButton>
<Modal
open={open}
onClose={toggleOpen}
aria-labelledby='survey-modal-title'
aria-describedby='survey-modal-description'
>
{body}
<StyledModalBody>{body}</StyledModalBody>
</Modal>
</Root>
</>
)
}
2 changes: 1 addition & 1 deletion assets/src/containers/ResourcesAccessed.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function ResourcesAccessed (props) {
}
<div className={classes.formController}>
<p className={classes.controlText}>Resources accessed from week <b>{weekRange[0]} {weekRange[0] === curWeek ? ' (Now)' : ''}</b> to <b>{weekRange[1]}{weekRange[1] === curWeek ? ' (Now) ' : ''}</b> by students with these grades:</p>
<FormControl>
<FormControl variant='standard'>
<Select
value={resourceGradeFilter}
onChange={handleResourceGradeFilter}
Expand Down
7 changes: 3 additions & 4 deletions assets/src/containers/SideDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react'
import { styled } from '@mui/material/styles'
import Drawer from '@mui/material/Drawer'
import List from '@mui/material/List'
import ListItem from '@mui/material/ListItem'
import ListItemButton from '@mui/material/ListItemButton'
import ListItemIcon from '@mui/material/ListItemIcon'
import ListItemText from '@mui/material/ListItemText'
import { Link } from 'react-router-dom'
Expand Down Expand Up @@ -55,8 +55,7 @@ function SideDrawer (props) {
>
<List>
{routes(courseId, courseInfo.course_view_options, !isTeacherOrAdmin(isAdmin, enrollmentTypes)).map((props, key) => (
<ListItem
button
<ListItemButton
component={Link}
to={props.path}
key={key}
Expand All @@ -71,7 +70,7 @@ function SideDrawer (props) {
}
</ListItemIcon>
<ListItemText primary={props.title} className={classes.text} />
</ListItem>
</ListItemButton>
))}
</List>
</Root>
Expand Down

0 comments on commit 1e4e971

Please sign in to comment.