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.
WIP icon changes in CUL plugins for XML and canvas nav
- Loading branch information
Showing
5 changed files
with
124 additions
and
3 deletions.
There are no files selected for viewing
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
87 changes: 87 additions & 0 deletions
87
src/culPlugins/mirador-pageIconViewerNavigation/components/PageIconViewerNavigation.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,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 GitHub Actions / build (18.x)
|
||
let nextTransform = []; | ||
Check failure on line 27 in src/culPlugins/mirador-pageIconViewerNavigation/components/PageIconViewerNavigation.js GitHub Actions / build (18.x)
|
||
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: '', | ||
}; |
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,32 @@ | ||
import { | ||
getContainerId, | ||
Check warning on line 2 in src/culPlugins/mirador-pageIconViewerNavigation/index.js GitHub Actions / build (18.x)
|
||
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', | ||
}, | ||
]; |
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