forked from ProjectMirador/mirador
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
COLUMBIA: Refactor download, related links, and XML plugins for consi…
…stency in rendering vs seeAlso - do not render canvas download list if canvas does not enable - consistent organization of selectors - deduplication of some selectors across plugins
- Loading branch information
Showing
12 changed files
with
241 additions
and
111 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...dor-canvasRelatedLinks/state/selectors.js → ...nvasRelatedLinks/state/selectors/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 57 additions & 42 deletions
99
src/culPlugins/mirador-downloaddialog/components/dialog/CanvasDownloadLinks.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/culPlugins/mirador-downloaddialog/components/dialog/ImageDownloadLinks.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import Box from '@mui/material/Box'; | ||
import Card from '@mui/material/Card'; | ||
import CardContent from '@mui/material/CardContent'; | ||
import List from '@mui/material/List'; | ||
import ListItem from '@mui/material/ListItem'; | ||
import Typography from '@mui/material/Typography'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import ImageLink from './ImageLink'; | ||
|
||
/** */ | ||
const ImageDownloadLinks = ({ | ||
canvas, label, sizes, t, | ||
}) => { | ||
const behaviors = canvas?.behaviors || []; | ||
if (behaviors.includes('no-download')) return null; | ||
return ( | ||
<Card className="mb-3" raised> | ||
<CardContent> | ||
<Typography component="h5" style={{ textTransform: 'none' }} variant="h6"> | ||
<Box fontWeight="fontWeightBold" textTransform="none"> | ||
{`${t( | ||
'image', | ||
)}: ${label}`} | ||
</Box> | ||
</Typography> | ||
<List> | ||
{sizes | ||
.sort((a, b) => b.width - a.width) | ||
.slice(1) | ||
.reduce( | ||
(acc, { height, width }) => { | ||
// only take sizes, where the difference between the last taken width | ||
// and the current one is bigger than 500 pixels | ||
if (acc[acc.length - 1].width - width >= 500) { | ||
acc.push({ height, width }); | ||
} | ||
return acc; | ||
}, | ||
// this represents the full size | ||
[{ height: canvas.getHeight(), width: canvas.getWidth() }], | ||
) | ||
.map(({ height, width }) => ( | ||
<ListItem dense key={`${height}x${width}`}> | ||
<ImageLink | ||
height={height} | ||
linkTarget={canvas.getCanonicalImageUri(width)} | ||
t={t} | ||
width={width} | ||
/> | ||
</ListItem> | ||
))} | ||
</List> | ||
</CardContent> | ||
</Card> | ||
); | ||
}; | ||
|
||
ImageDownloadLinks.defaultProps = { | ||
sizes: [], | ||
}; | ||
|
||
ImageDownloadLinks.propTypes = { | ||
canvas: PropTypes.shape({ | ||
getCanonicalImageUri: PropTypes.func.isRequired, | ||
getHeight: PropTypes.func.isRequired, | ||
getWidth: PropTypes.func.isRequired, | ||
}).isRequired, | ||
label: PropTypes.oneOfType(PropTypes.number, PropTypes.string).isRequired, | ||
sizes: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
height: PropTypes.number.isRequired, | ||
width: PropTypes.number.isRequired, | ||
}), | ||
), | ||
t: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default ImageDownloadLinks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...mirador-downloaddialog/state/selectors.js → ...r-downloaddialog/state/selectors/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...irador-hinting-sidebar/state/selectors.js → ...-hinting-sidebar/state/selectors/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.