Skip to content

Commit

Permalink
Merge pull request #4097 from ProjectMirador/mui6-more
Browse files Browse the repository at this point in the history
More updates for MUI6
  • Loading branch information
cbeer authored Feb 6, 2025
2 parents 3747bf9 + 42e912d commit 0e9dce9
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 116 deletions.
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
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

0 comments on commit 0e9dce9

Please sign in to comment.