Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to MUI 6 #4092

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion __tests__/src/components/ManifestListItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('ManifestListItem', () => {
expect(screen.getByRole('listitem')).toHaveAttribute('data-active', 'true');

expect(screen.getByRole('listitem')).toHaveClass('active');
expect(screen.getByRole('listitem')).toHaveClass('Mui-selected');
});
it('renders a placeholder element until real data is available', () => {
const { container } = createWrapper({ ready: false });
Expand Down
2 changes: 1 addition & 1 deletion __tests__/src/components/SearchHit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('SearchHit', () => {
const selectAnnotation = vi.fn();
render(<Subject selectAnnotation={selectAnnotation} />);

expect(screen.getByRole('listitem')).toHaveClass('Mui-selected');
expect(screen.getByRole('listitem')).toHaveClass('windowSelected');
expect(screen.getByRole('listitem')).toHaveTextContent('1Light up the moose , and start the chai more');

await user.click(screen.getByRole('button'));
Expand Down
3 changes: 1 addition & 2 deletions __tests__/src/components/SidebarIndexTableOfContents.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ describe('SidebarIndexTableOfContents', () => {
it('toggles branch nodes on click', async () => {
const user = userEvent.setup();
const { store } = createInteractiveWrapper({});

expect(screen.getByRole('treeitem')).toBeInTheDocument();
const root = screen.getByRole('treeitem');

Expand Down Expand Up @@ -199,7 +198,7 @@ describe('SidebarIndexTableOfContents', () => {
it('sets the canvas to a start canvas if present (IIIF v2)', async () => {
const user = userEvent.setup();
createWrapper({
expandNodes: () => { },
expandItems: () => { },
manifest: manifestVersion2,
setCanvas,
windowId: 'a',
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@hello-pangea/dnd": "^16.0.1 || ^17.0.0",
"@mui/icons-material": "^5.11.16",
"@mui/material": "^5.13.5",
"@mui/utils": "^5.13.1",
"@mui/x-tree-view": "^6.17.0",
"@mui/icons-material": "^6.0.0",
"@mui/material": "^6.0.0",
"@mui/utils": "^6.0.0",
"@mui/x-tree-view": "^7.25.0",
"@react-aria/live-announcer": "^3.1.2",
"@redux-devtools/extension": "^3.3.0",
"classnames": "^2.2.6",
Expand Down
4 changes: 2 additions & 2 deletions src/components/CollapsibleSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export function CollapsibleSection({
}, [setOpen]);

return (
<Accordion id={id} elevation={0} expanded={open} onChange={handleChange} disableGutters square variant="compact">
<Accordion slotProps={{ heading: { component: 'h4' } }} id={id} elevation={0} expanded={open} onChange={handleChange} disableGutters square variant="compact">
<AccordionSummary id={`${id}-header`} aria-controls={`${id}-content`} aria-label={t(open ? 'collapseSection' : 'expandSection', { section: label })} expandIcon={<ExpandMoreIcon />}>
<Typography variant="overline" component="h4">
<Typography variant="overline">
{label}
</Typography>
</AccordionSummary>
Expand Down
3 changes: 2 additions & 1 deletion src/components/CompanionArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const Container = styled('div', { name: 'CompanionArea', slot: 'container' })(({
const StyledToggle = styled('div', { name: 'CompanionArea', slot: 'toggle' })(({ theme }) => ({
alignItems: 'center',
backgroundColor: theme.palette.background.paper,
border: `1px solid ${theme.palette.mode === 'dark' ? theme.palette.divider : theme.palette.shades?.dark}`,
border: `1px solid ${theme.palette.shades?.dark}`,
...theme.applyStyles('dark', { borderColor: theme.palette.divider }),
borderInlineStart: 0,
borderRadius: 0,
display: 'inline-flex',
Expand Down
56 changes: 30 additions & 26 deletions src/components/ManifestListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { styled } from '@mui/material/styles';
import ListItem from '@mui/material/ListItem';
import ButtonBase from '@mui/material/ButtonBase';
import Grid from '@mui/material/Grid';
import Grid2 from '@mui/material/Grid2';
import Typography from '@mui/material/Typography';
import Skeleton from '@mui/material/Skeleton';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -40,21 +40,21 @@ const StyledLogo = styled(Img, { name: 'ManifestListItem', slot: 'logo' })(({ th

/** */
const Placeholder = () => (
<Grid container className={ns('manifest-list-item')} spacing={2}>
<Grid item xs={3} sm={2}>
<Grid2 container className={ns('manifest-list-item')} spacing={2}>
<Grid2 xs={3} sm={2}>
<Skeleton sx={{ bgcolor: 'grey[300]' }} variant="rectangular" height={80} width={120} />
</Grid>
<Grid item xs={9} sm={6}>
</Grid2>
<Grid2 xs={9} sm={6}>
<Skeleton sx={{ bgcolor: 'grey[300]' }} variant="text" />
</Grid>
<Grid item xs={8} sm={2}>
</Grid2>
<Grid2 xs={8} sm={2}>
<Skeleton sx={{ bgcolor: 'grey[300]' }} variant="text" />
<Skeleton sx={{ bgcolor: 'grey[300]' }} variant="text" />
</Grid>
<Grid item xs={4} sm={2}>
</Grid2>
<Grid2 xs={4} sm={2}>
<Skeleton sx={{ bgcolor: 'grey[300]' }} variant="rectangular" height={60} width={60} />
</Grid>
</Grid>
</Grid2>
</Grid2>
);

/**
Expand Down Expand Up @@ -116,15 +116,15 @@ export function ManifestListItem({
data-active={active}
>
{ready ? (
<Grid container className={ns('manifest-list-item')} spacing={2}>
<Grid item xs={12} sm={6}>
<Grid2 container className={ns('manifest-list-item')} spacing={2}>
<Grid2 xs={12} sm={6}>
<ButtonBase
ref={buttonRef}
className={ns('manifest-list-item-title')}
style={{ width: '100%' }}
onClick={handleOpenButtonClick}
>
<Grid
<Grid2
container
spacing={2}
sx={{
Expand All @@ -133,7 +133,7 @@ export function ManifestListItem({
}}
component="span"
>
<Grid item xs={4} sm={3} component="span">
<Grid2 xs={4} sm={3} component="span">
{ thumbnail
? (
<StyledThumbnail
Expand All @@ -153,8 +153,8 @@ export function ManifestListItem({
/>
)
: <Skeleton sx={{ bgcolor: 'grey[300]' }} variant="rectangular" height={80} width={120} />}
</Grid>
<Grid item xs={8} sm={9} component="span">
</Grid2>
<Grid2 xs={8} sm={9} component="span">
{ isCollection && (
<Typography component="div" variant="overline">
{ t(isMultipart ? 'multipartCollection' : 'collection') }
Expand All @@ -163,16 +163,16 @@ export function ManifestListItem({
<Typography component="span" variant="h6">
{title || manifestId}
</Typography>
</Grid>
</Grid>
</Grid2>
</Grid2>
</ButtonBase>
</Grid>
<Grid item xs={8} sm={4}>
</Grid2>
<Grid2 xs={8} sm={4}>
<Typography className={ns('manifest-list-item-provider')}>{provider}</Typography>
<Typography>{t('numItems', { count: size, number: size })}</Typography>
</Grid>
</Grid2>

<Grid item xs={4} sm={2}>
<Grid2 xs={4} sm={2}>
{ manifestLogo
&& (
<StyledLogo
Expand All @@ -190,8 +190,8 @@ export function ManifestListItem({
)}
/>
)}
</Grid>
</Grid>
</Grid2>
</Grid2>
) : (
<Placeholder />
)}
Expand All @@ -203,7 +203,11 @@ ManifestListItem.propTypes = {
active: PropTypes.bool,
addWindow: PropTypes.func.isRequired,
buttonRef: PropTypes.elementType,
error: PropTypes.string,
error: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool,
PropTypes.oneOf([null]), // for null
]),
fetchManifest: PropTypes.func.isRequired,
handleClose: PropTypes.func,
isCollection: PropTypes.bool,
Expand Down
38 changes: 19 additions & 19 deletions src/components/ManifestListItemError.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types';
import Button from '@mui/material/Button';
import ErrorIcon from '@mui/icons-material/ErrorOutlineSharp';
import Grid from '@mui/material/Grid';
import Grid2 from '@mui/material/Grid2';
import Typography from '@mui/material/Typography';
import { useTranslation } from 'react-i18next';

Expand All @@ -14,39 +14,39 @@ export function ManifestListItemError({
}) {
const { t } = useTranslation();
return (
<Grid container>
<Grid container>
<Grid container item xs={12} sm={6}>
<Grid item xs={4} sm={3}>
<Grid container justifyContent="center">
<Grid2 container>
<Grid2 container>
<Grid2 container xs={12} sm={6}>
<Grid2 xs={4} sm={3}>
<Grid2 container justifyContent="center">
<ErrorIcon sx={{
color: 'error.main',
height: '2rem',
width: '2rem',
}}
/>
</Grid>
</Grid>
<Grid item xs={8} sm={9}>
</Grid2>
</Grid2>
<Grid2 xs={8} sm={9}>
<Typography>{t('manifestError')}</Typography>
<Typography sx={{ wordBreak: 'break-all' }}>{manifestId}</Typography>
</Grid>
</Grid>
</Grid>
</Grid2>
</Grid2>
</Grid2>

<Grid container>
<Grid container item xs={12} sm={6} justifyContent="flex-end">
<Grid item>
<Grid2 container>
<Grid2 container xs={12} sm={6} justifyContent="flex-end">
<Grid2>
<Button onClick={() => { onDismissClick(manifestId); }}>
{t('dismiss')}
</Button>
<Button onClick={() => { onTryAgainClick(manifestId); }}>
{t('tryAgain')}
</Button>
</Grid>
</Grid>
</Grid>
</Grid>
</Grid2>
</Grid2>
</Grid2>
</Grid2>
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/SearchHit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import Button from '@mui/material/Button';
import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText';
import ListItemButton from '@mui/material/ListItemButton';
import Typography from '@mui/material/Typography';
import Chip from '@mui/material/Chip';
import { styled } from '@mui/material/styles';
Expand Down Expand Up @@ -122,8 +123,7 @@ export function SearchHit({
ownerState={ownerState}
className={windowSelected ? 'windowSelected' : ''}
divider
button={!selected}
component="li"
component={selected ? 'li' : ListItemButton}
onClick={handleClick}
selected={selected}
>
Expand Down
Loading