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 more components to MUI6 Grid2 #4118

Draft
wants to merge 1 commit 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
27 changes: 11 additions & 16 deletions src/components/ManifestForm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react';
import PropTypes from 'prop-types';
import Button from '@mui/material/Button';
import Grid from '@mui/material/Grid';
import Grid2 from '@mui/material/Grid2';
import TextField from '@mui/material/TextField';
import { useTranslation } from 'react-i18next';

Expand Down Expand Up @@ -39,8 +39,8 @@ export function ManifestForm({

return (
<form onSubmit={formSubmit}>
<Grid container spacing={2}>
<Grid item xs={12} sm={8} md={9}>
<Grid2 container spacing={2}>
<Grid2 size={{ md: 9, sm: 8, xs: 12 }}>
<TextField
autoFocus
fullWidth
Expand All @@ -51,19 +51,14 @@ export function ManifestForm({
variant="filled"
label={t('addManifestUrl')}
helperText={t('addManifestUrlHelp')}
InputLabelProps={{
shrink: true,
}}
InputProps={{
style: { typography: 'body1' },
slotProps={{
inputLabel: { shrink: true },
inputProps: { style: { typography: 'body1' } },
}}
/>
</Grid>
<Grid
item
xs={12}
sm={4}
md={3}
</Grid2>
<Grid2
size={{ md: 3, sm: 4, xs: 12 }}
sx={{
textAlign: { sm: 'inherit', xs: 'right' },
}}
Expand All @@ -76,8 +71,8 @@ export function ManifestForm({
<Button id="fetchBtn" type="submit" variant="contained" color="primary">
{t('fetchManifest')}
</Button>
</Grid>
</Grid>
</Grid2>
</Grid2>
</form>
);
}
Expand Down
21 changes: 10 additions & 11 deletions src/components/ManifestListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ const StyledLogo = styled(Img, { name: 'ManifestListItem', slot: 'logo' })(({ th
/** */
const Placeholder = () => (
<Grid2 container className={ns('manifest-list-item')} spacing={2}>
<Grid2 xs={3} sm={2}>
<Grid2 size={{ sm: 2, xs: 3 }}>
<Skeleton sx={{ bgcolor: 'grey[300]' }} variant="rectangular" height={80} width={120} />
</Grid2>
<Grid2 xs={9} sm={6}>
<Grid2 size={{ sm: 6, xs: 9 }}>
<Skeleton sx={{ bgcolor: 'grey[300]' }} variant="text" />
</Grid2>
<Grid2 xs={8} sm={2}>
<Grid2 size={{ sm: 2, xs: 8 }}>
<Skeleton sx={{ bgcolor: 'grey[300]' }} variant="text" />
<Skeleton sx={{ bgcolor: 'grey[300]' }} variant="text" />
</Grid2>
<Grid2 xs={4} sm={2}>
<Grid2 size={{ sm: 2, xs: 4 }}>
<Skeleton sx={{ bgcolor: 'grey[300]' }} variant="rectangular" height={60} width={60} />
</Grid2>
</Grid2>
Expand Down Expand Up @@ -116,12 +116,11 @@ export function ManifestListItem({
data-active={active}
>
{ready ? (
<Grid2 container className={ns('manifest-list-item')} spacing={2}>
<Grid2 xs={12} sm={6}>
<Grid2 container className={ns('manifest-list-item')} spacing={2} size="grow">
<Grid2 size={{ sm: 6, xs: 12 }}>
<ButtonBase
ref={buttonRef}
className={ns('manifest-list-item-title')}
style={{ width: '100%' }}
onClick={handleOpenButtonClick}
>
<Grid2
Expand All @@ -133,7 +132,7 @@ export function ManifestListItem({
}}
component="span"
>
<Grid2 xs={4} sm={3} component="span">
<Grid2 size={{ sm: 3, xs: 4 }} component="span">
{ thumbnail
? (
<StyledThumbnail
Expand All @@ -154,7 +153,7 @@ export function ManifestListItem({
)
: <Skeleton sx={{ bgcolor: 'grey[300]' }} variant="rectangular" height={80} width={120} />}
</Grid2>
<Grid2 xs={8} sm={9} component="span">
<Grid2 size={{ sm: 9, xs: 8 }} component="span">
{ isCollection && (
<Typography component="div" variant="overline">
{ t(isMultipart ? 'multipartCollection' : 'collection') }
Expand All @@ -167,12 +166,12 @@ export function ManifestListItem({
</Grid2>
</ButtonBase>
</Grid2>
<Grid2 xs={8} sm={4}>
<Grid2 size={{ sm: 4, xs: 8 }}>
<Typography className={ns('manifest-list-item-provider')}>{provider}</Typography>
<Typography>{t('numItems', { count: size, number: size })}</Typography>
</Grid2>

<Grid2 xs={4} sm={2}>
<Grid2 size={{ sm: 2, xs: 4 }}>
{ manifestLogo
&& (
<StyledLogo
Expand Down
20 changes: 15 additions & 5 deletions src/components/ManifestListItemError.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ export function ManifestListItemError({
return (
<Grid2 container>
<Grid2 container>
<Grid2 container xs={12} sm={6}>
<Grid2 xs={4} sm={3}>
<Grid2
container
size={{ sm: 6, xs: 12 }}
>
<Grid2
size={{ sm: 3, xs: 4 }}
>
<Grid2 container justifyContent="center">
<ErrorIcon sx={{
color: 'error.main',
Expand All @@ -27,15 +32,20 @@ export function ManifestListItemError({
/>
</Grid2>
</Grid2>
<Grid2 xs={8} sm={9}>
<Grid2
size={{ sm: 9, xs: 8 }}
>
<Typography>{t('manifestError')}</Typography>
<Typography sx={{ wordBreak: 'break-all' }}>{manifestId}</Typography>
</Grid2>
</Grid2>
</Grid2>

<Grid2 container>
<Grid2 container xs={12} sm={6} justifyContent="flex-end">
<Grid2
container
justifyContent="flex-end"
size={{ sm: 6, xs: 12 }}
>
<Grid2>
<Button onClick={() => { onDismissClick(manifestId); }}>
{t('dismiss')}
Expand Down
12 changes: 6 additions & 6 deletions src/components/SelectCollection.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback } from 'react';
import PropTypes from 'prop-types';
import Button from '@mui/material/Button';
import Grid from '@mui/material/Grid';
import Grid2 from '@mui/material/Grid2';
import Typography from '@mui/material/Typography';
import ListSharpIcon from '@mui/icons-material/ListSharp';
import { useTranslation } from 'react-i18next';
Expand All @@ -18,9 +18,9 @@ export function SelectCollection({
}, [collectionPath, manifestId, showCollectionDialog, windowId]);

return (
<Grid container justifyContent="center" alignItems="center">
<Grid container direction="column" alignItems="center">
<Typography variant="h4" paragraph>
<Grid2 container justifyContent="center" alignItems="center">
<Grid2 container direction="column" alignItems="center">
<Typography variant="h4" component="p">
<em>
{t('noItemSelected')}
</em>
Expand All @@ -34,8 +34,8 @@ export function SelectCollection({
>
{t('showCollection')}
</Button>
</Grid>
</Grid>
</Grid2>
</Grid2>
);
}

Expand Down
13 changes: 6 additions & 7 deletions src/components/Workspace.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types';
import { styled } from '@mui/material/styles';
import classNames from 'classnames';
import Grid from '@mui/material/Grid';
import Grid2 from '@mui/material/Grid2';
import Typography from '@mui/material/Typography';
import { visuallyHidden } from '@mui/utils';
import { useTranslation } from 'react-i18next';
Expand All @@ -23,16 +23,15 @@ const ZeroWindows = () => {

return (
<Root>
<Grid
<Grid2
alignItems="center"
container
style={{
height: '100%',
}}
>
<Grid
xs={12}
item
<Grid2
size={{ xs: 12 }}
>
<Typography
variant="h1"
Expand All @@ -41,8 +40,8 @@ const ZeroWindows = () => {
>
{t('welcome')}
</Typography>
</Grid>
</Grid>
</Grid2>
</Grid2>
</Root>
);
};
Expand Down
13 changes: 6 additions & 7 deletions src/components/WorkspaceAdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AddIcon from '@mui/icons-material/AddSharp';
import ExpandMoreIcon from '@mui/icons-material/ExpandMoreSharp';
import AppBar from '@mui/material/AppBar';
import Drawer from '@mui/material/Drawer';
import Grid from '@mui/material/Grid';
import Grid2 from '@mui/material/Grid2';
import Fab from '@mui/material/Fab';
import List from '@mui/material/List';
import Paper from '@mui/material/Paper';
Expand Down Expand Up @@ -106,16 +106,15 @@ export function WorkspaceAdd({
<IIIFDropTarget onDrop={handleDrop}>
<StyledWorkspaceAdd className={classNames(ns('workspace-add'))} ref={ref}>
{catalog.length < 1 ? (
<Grid
<Grid2
alignItems="center"
container
style={{
height: '100%',
}}
>
<Grid
xs={12}
item
<Grid2
size={{ xs: 12 }}
>
<Typography
variant="h1"
Expand All @@ -124,8 +123,8 @@ export function WorkspaceAdd({
>
{t('emptyResourceList')}
</Typography>
</Grid>
</Grid>
</Grid2>
</Grid2>
) : (
<Paper sx={{ margin: 2 }}>
<Typography style={visuallyHidden} component="h1">{t('miradorResources')}</Typography>
Expand Down