Skip to content

Commit

Permalink
WIP icon changes in CUL plugins for XML and canvas nav
Browse files Browse the repository at this point in the history
  • Loading branch information
barmintor committed Aug 14, 2024
1 parent 5fb121c commit 9e7bb75
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 3 deletions.
2 changes: 1 addition & 1 deletion __tests__/integration/mirador/cul.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{ manifestId: 'https://iiif.harvardartmuseums.org/manifests/object/299843', provider: 'Other Organization' },
],
},
[...Mirador.culPlugins.downloadDialogPlugin].concat([...Mirador.culPlugins.viewXmlPlugin]).concat([...Mirador.culPlugins.citationsSidebarPlugin]).concat([...Mirador.culPlugins.videojsPlugin]).concat([...Mirador.culPlugins.canvasRelatedLinksPlugin]).concat([...Mirador.culPlugins.hintingSideBar])
[...Mirador.culPlugins.downloadDialogPlugin].concat([...Mirador.culPlugins.viewXmlPlugin]).concat([...Mirador.culPlugins.citationsSidebarPlugin]).concat([...Mirador.culPlugins.videojsPlugin]).concat([...Mirador.culPlugins.canvasRelatedLinksPlugin]).concat([...Mirador.culPlugins.hintingSideBar]).concat([...Mirador.culPlugins.viewerNavigation])
);
</script>
</body>
Expand Down
2 changes: 2 additions & 0 deletions src/culPlugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import downloadDialogPlugin from './mirador-downloaddialog';
import hintingSideBar from './mirador-hinting-sidebar';
import videojsPlugin from './mirador-videojs';
import viewXmlPlugin from './mirador-viewXml';
import viewerNavigation from './mirador-pageIconViewerNavigation';

export default {
canvasLinkPlugin,
Expand All @@ -14,4 +15,5 @@ export default {
hintingSideBar,
videojsPlugin,
viewXmlPlugin,
viewerNavigation,

Check failure on line 18 in src/culPlugins/index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected object keys to be in insensitive ascending order. 'viewerNavigation' should be before 'viewXmlPlugin'

Check failure on line 18 in src/culPlugins/index.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected object keys to be in insensitive ascending order. 'viewerNavigation' should be before 'viewXmlPlugin'
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { Component } from 'react';
import LtrNextPage from '@mui/icons-material/AutoStories';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import MiradorMenuButton from '../../../containers/MiradorMenuButton';
import ns from '../../../config/css-ns';

/**
*/
export class PageIconViewerNavigation extends Component {
/**
* Renders previous next canvas buttons, but only if there are such canvases
* The AutoStories icon appears to be a page turning, and is thus flipped
* via a scale transform rather than a 180deg rotation. Rotations
* for the reading direction can thus be applied uniformly to both but before
* the scale transform.
*/
render() {
const {
hasNextCanvas, hasPreviousCanvas, setNextCanvas, setPreviousCanvas, t,
viewingDirection,
} = this.props;

if (!hasPreviousCanvas && !hasNextCanvas) return (null);
let htmlDir = 'ltr';
let prevTransform = ['scale(-1, 1)'];

Check failure on line 26 in src/culPlugins/mirador-pageIconViewerNavigation/components/PageIconViewerNavigation.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'prevTransform' is never reassigned. Use 'const' instead

Check failure on line 26 in src/culPlugins/mirador-pageIconViewerNavigation/components/PageIconViewerNavigation.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'prevTransform' is never reassigned. Use 'const' instead
let nextTransform = [];

Check failure on line 27 in src/culPlugins/mirador-pageIconViewerNavigation/components/PageIconViewerNavigation.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'nextTransform' is never reassigned. Use 'const' instead

Check failure on line 27 in src/culPlugins/mirador-pageIconViewerNavigation/components/PageIconViewerNavigation.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'nextTransform' is never reassigned. Use 'const' instead
switch (viewingDirection) {
case 'top-to-bottom':
prevTransform.unshift('rotate(90deg)');
nextTransform.unshift('rotate(90deg)');
break;
case 'bottom-to-top':
prevTransform.unshift('rotate(270deg)');
nextTransform.unshift('rotate(270deg)');
break;
case 'right-to-left':
htmlDir = 'rtl';
nextTransform.push(prevTransform.pop());
break;
default:
break;
}
const previousIconStyle = (prevTransform.length > 0) ? { transform: prevTransform.join(' ') } : {};
const nextIconStyle = (nextTransform.length > 0) ? { transform: nextTransform.join(' ') } : {};
return (
<div
className={classNames(ns('osd-navigation'))}
dir={htmlDir}
>
<MiradorMenuButton
aria-label={t('previousCanvas')}
className={ns('previous-canvas-button')}
disabled={!hasPreviousCanvas}
onClick={() => { hasPreviousCanvas && setPreviousCanvas(); }}
>
<LtrNextPage style={previousIconStyle} />
</MiradorMenuButton>
<MiradorMenuButton
aria-label={t('nextCanvas')}
className={ns('next-canvas-button')}
disabled={!hasNextCanvas}
onClick={() => { hasNextCanvas && setNextCanvas(); }}
>
<LtrNextPage style={nextIconStyle} />
</MiradorMenuButton>
</div>
);
}
}

PageIconViewerNavigation.propTypes = {
hasNextCanvas: PropTypes.bool,
hasPreviousCanvas: PropTypes.bool,
setNextCanvas: PropTypes.func,
setPreviousCanvas: PropTypes.func,
t: PropTypes.func.isRequired,
viewingDirection: PropTypes.string,
};

PageIconViewerNavigation.defaultProps = {
hasNextCanvas: false,
hasPreviousCanvas: false,
setNextCanvas: () => {},
setPreviousCanvas: () => {},
viewingDirection: '',
};
32 changes: 32 additions & 0 deletions src/culPlugins/mirador-pageIconViewerNavigation/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
getContainerId,

Check warning on line 2 in src/culPlugins/mirador-pageIconViewerNavigation/index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'getContainerId' is defined but never used

Check warning on line 2 in src/culPlugins/mirador-pageIconViewerNavigation/index.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'getContainerId' is defined but never used
getSequenceViewingDirection,
getNextCanvasGrouping,
getPreviousCanvasGrouping,
} from '../../state/selectors';
import { setNextCanvas, setPreviousCanvas } from '../../state/actions';

import { PageIconViewerNavigation } from './components/PageIconViewerNavigation';

export {
PageIconViewerNavigation,
};

export default [
{
component: PageIconViewerNavigation,
config: {},
mapDispatchToProps: (dispatch, { windowId }) => ({
setNextCanvas: (...args) => dispatch(setNextCanvas(windowId)),
setPreviousCanvas: (...args) => dispatch(setPreviousCanvas(windowId)),
}),
mapStateToProps: (state, { windowId }) => ({
hasNextCanvas: !!getNextCanvasGrouping(state, { windowId }),
hasPreviousCanvas: !!getPreviousCanvasGrouping(state, { windowId }),
viewingDirection: getSequenceViewingDirection(state, { windowId }),
}),
mode: 'wrap',
name: 'PageIconViewerNavigation',
target: 'ViewerNavigation',
},
];
4 changes: 2 additions & 2 deletions src/culPlugins/mirador-viewXml/MiradorViewXmlPlugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';
import CodeIcon from '@mui/icons-material/Code';
import DataObject from '@mui/icons-material/DataObject';
import MiradorMenuButton from '../../containers/MiradorMenuButton';

self.$RefreshReg$ = () => {}; /* eslint-disable-line no-restricted-globals */
Expand All @@ -23,7 +23,7 @@ const MiradorViewXml = ({ config, container, updateConfig }) => {
dialogOpen: !dialogOpen,
})}
>
<CodeIcon />
<DataObject />
</MiradorMenuButton>
);
};
Expand Down

0 comments on commit 9e7bb75

Please sign in to comment.