Skip to content
Snippets Groups Projects
Unverified Commit a0ab72a1 authored by Chris Beer's avatar Chris Beer Committed by GitHub
Browse files

Merge pull request #1701 from ProjectMirador/1686-thumbnail-nav-config

Set a thumbnailNavigationDisplayed boolean value in the window state.
parents eaf3289d 0d2f80a9
Branches
Tags
No related merge requests found
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
loadedManifest: 'https://iiif.harvardartmuseums.org/manifests/object/299843', loadedManifest: 'https://iiif.harvardartmuseums.org/manifests/object/299843',
}, },
{ {
loadedManifest: 'https://iiif.harvardartmuseums.org/manifests/object/299843' loadedManifest: 'https://iiif.harvardartmuseums.org/manifests/object/299843',
thumbnailNavigationDisplayed: false,
}] }]
}); });
</script> </script>
......
...@@ -17,6 +17,7 @@ describe('window actions', () => { ...@@ -17,6 +17,7 @@ describe('window actions', () => {
collectionIndex: 0, collectionIndex: 0,
manifestId: null, manifestId: null,
rangeId: null, rangeId: null,
thumbnailNavigationDisplayed: true,
xywh: [0, 0, 400, 400], xywh: [0, 0, 400, 400],
rotation: null, rotation: null,
}, },
......
...@@ -20,8 +20,9 @@ describe('ThumbnailNavigation', () => { ...@@ -20,8 +20,9 @@ describe('ThumbnailNavigation', () => {
window={{ window={{
id: 'foobar', id: 'foobar',
canvasIndex: 1, canvasIndex: 1,
thumbnailNavigationDisplayed: true,
}} }}
config={{}} config={{ thumbnailNavigation: { height: 150 } }}
setCanvas={setCanvas} setCanvas={setCanvas}
/>, />,
); );
......
...@@ -9,6 +9,7 @@ describe('WindowViewer', () => { ...@@ -9,6 +9,7 @@ describe('WindowViewer', () => {
beforeEach(() => { beforeEach(() => {
store.dispatch(actions.receiveManifest('foo', fixture)); store.dispatch(actions.receiveManifest('foo', fixture));
store.dispatch(actions.addWindow({ manifestId: 'foo' })); store.dispatch(actions.addWindow({ manifestId: 'foo' }));
store.dispatch(actions.setConfig({ thumbnailNavigation: { height: 150 } }));
const manifest = store.getState().manifests.foo; const manifest = store.getState().manifests.foo;
const { windows } = store.getState(); const { windows } = store.getState();
const window = Object.values(windows)[0]; const window = Object.values(windows)[0];
......
...@@ -49,11 +49,16 @@ describe('MiradorViewer', () => { ...@@ -49,11 +49,16 @@ describe('MiradorViewer', () => {
}, },
{ {
loadedManifest: 'https://iiif.harvardartmuseums.org/manifests/object/299843', loadedManifest: 'https://iiif.harvardartmuseums.org/manifests/object/299843',
thumbnailNavigationDisplayed: false,
}, },
], ],
}); });
expect(Object.keys(instance.store.getState().windows).length).toBe(2); const { windows } = instance.store.getState();
const windowIds = Object.keys(windows);
expect(Object.keys(windowIds).length).toBe(2);
expect(windows[windowIds[0]].thumbnailNavigationDisplayed).toBe(true);
expect(windows[windowIds[1]].thumbnailNavigationDisplayed).toBe(false);
}); });
}); });
}); });
...@@ -24,6 +24,7 @@ export function addWindow(options) { ...@@ -24,6 +24,7 @@ export function addWindow(options) {
collectionIndex: 0, collectionIndex: 0,
manifestId: null, manifestId: null,
rangeId: null, rangeId: null,
thumbnailNavigationDisplayed: true, // True by default in settings.js
xywh: [0, 0, 400, 400], xywh: [0, 0, 400, 400],
rotation: null, rotation: null,
}; };
......
...@@ -105,11 +105,22 @@ export class OpenSeadragonViewer extends Component { ...@@ -105,11 +105,22 @@ export class OpenSeadragonViewer extends Component {
}); });
} }
/**
* Returns the height of the thumbnail navigation drawer
*/
calculatedThumbnailNavigationHeight() {
const { config, window } = this.props;
if (window.thumbnailNavigationDisplayed && config.thumbnailNavigation) {
return config.thumbnailNavigation.height;
}
return 0;
}
/** /**
* Renders things * Renders things
*/ */
render() { render() {
const { window, config, children } = this.props; const { window, children } = this.props;
return ( return (
<> <>
<div <div
...@@ -117,7 +128,7 @@ export class OpenSeadragonViewer extends Component { ...@@ -117,7 +128,7 @@ export class OpenSeadragonViewer extends Component {
id={`${window.id}-osd`} id={`${window.id}-osd`}
ref={this.ref} ref={this.ref}
style={{ style={{
height: `calc(100% - ${config.thumbnailNavigationHeight}px)`, height: `calc(100% - ${this.calculatedThumbnailNavigationHeight()}px)`,
}} }}
> >
{ children } { children }
......
...@@ -41,14 +41,15 @@ export class ThumbnailNavigation extends Component { ...@@ -41,14 +41,15 @@ export class ThumbnailNavigation extends Component {
* Renders things * Renders things
*/ */
render() { render() {
const { const { config, window } = this.props;
config, if (!window.thumbnailNavigationDisplayed) {
} = this.props; return <></>;
}
return ( return (
<div <div
className={ns('thumb-navigation')} className={ns('thumb-navigation')}
style={{ style={{
height: `${config.thumbnailNavigationHeight}px`, height: `${config.thumbnailNavigation.height}px`,
}} }}
> >
<ul> <ul>
......
export default { export default {
windows: [], windows: [],
thumbnailNavigationHeight: 150, thumbnailNavigation: {
displayedByDefault: true,
height: 150,
},
}; };
...@@ -42,9 +42,16 @@ class MiradorViewer { ...@@ -42,9 +42,16 @@ class MiradorViewer {
store.dispatch(action); store.dispatch(action);
mergedConfig.windows.forEach((miradorWindow) => { mergedConfig.windows.forEach((miradorWindow) => {
let thumbnailNavigationDisplayed;
if (miradorWindow.thumbnailNavigationDisplayed !== undefined) {
({ thumbnailNavigationDisplayed } = miradorWindow);
} else {
thumbnailNavigationDisplayed = mergedConfig.thumbnailNavigation.displayedByDefault;
}
store.dispatch(actions.fetchManifest(miradorWindow.loadedManifest)); store.dispatch(actions.fetchManifest(miradorWindow.loadedManifest));
store.dispatch(actions.addWindow({ store.dispatch(actions.addWindow({
manifestId: miradorWindow.loadedManifest, manifestId: miradorWindow.loadedManifest,
thumbnailNavigationDisplayed,
})); }));
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment