Skip to content
Snippets Groups Projects
Commit 92cd077a authored by Chris Beer's avatar Chris Beer
Browse files

Collapse ValidationCanvas into our ManifestoCanvas wrapper

parent a5d4684b
No related branches found
No related tags found
No related merge requests found
import ManifestoCanvas from '../lib/ManifestoCanvas';
/**
*/
export class ValidationCanvas extends ManifestoCanvas {
/**
* checks whether the canvas has a valid height
*/
get hasValidHeight() {
return (
typeof this.canvas.getHeight() === 'number'
&& this.canvas.getHeight() > 0
);
}
/**
* checks whether the canvas has a valid height
*/
get hasValidWidth() {
return (
typeof this.canvas.getHeight() === 'number'
&& this.canvas.getHeight() > 0
);
}
/**
* checks whether the canvas has valid dimensions
*/
get hasValidDimensions() {
return (
this.hasValidHeight
&& this.hasValidWidth
);
}
}
......@@ -5,7 +5,7 @@ import Typography from '@material-ui/core/Typography';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import { CanvasThumbnail } from './CanvasThumbnail';
import { ValidationCanvas } from './ValidationCanvas';
import ManifestoCanvas from '../lib/ManifestoCanvas';
import { getIdAndLabelOfCanvases } from '../state/selectors';
/**
......@@ -35,8 +35,9 @@ export class WindowSideBarCanvasPanel extends Component {
<List>
{
canvasesIdAndLabel.map((canvas, canvasIndex) => {
const validationCanvas = new ValidationCanvas(canvases[canvasIndex]);
const isValid = validationCanvas.hasValidDimensions;
const { width, height } = config.canvasNavigation;
const manifestoCanvas = new ManifestoCanvas(canvases[canvasIndex]);
const isValid = manifestoCanvas.hasValidDimensions;
const onClick = () => { setCanvas(windowId, canvasIndex); }; // eslint-disable-line require-jsdoc, max-len
return (
......@@ -47,7 +48,7 @@ export class WindowSideBarCanvasPanel extends Component {
<CanvasThumbnail
className={classNames(classes.clickable)}
isValid={isValid}
imageUrl={validationCanvas.thumbnail(config.canvasNavigation.height)}
imageUrl={manifestoCanvas.thumbnail(config.canvasNavigation.height)}
onClick={onClick}
style={{
cursor: 'pointer',
......
......@@ -10,7 +10,6 @@ export * from './NestedMenu';
export * from './OpenSeadragonViewer';
export * from './SanitizedHtml';
export * from './ThumbnailNavigation';
export * from './ValidationCanvas';
export * from './ViewerNavigation';
export * from './Window';
export * from './WindowList';
......
......@@ -52,4 +52,34 @@ export default class ManifestoCanvas {
return this.canonicalImageUri.replace(/\/full\/.*\/0\//, `/full/${width},/0/`);
}
/**
* checks whether the canvas has a valid height
*/
get hasValidHeight() {
return (
typeof this.canvas.getHeight() === 'number'
&& this.canvas.getHeight() > 0
);
}
/**
* checks whether the canvas has a valid height
*/
get hasValidWidth() {
return (
typeof this.canvas.getHeight() === 'number'
&& this.canvas.getHeight() > 0
);
}
/**
* checks whether the canvas has valid dimensions
*/
get hasValidDimensions() {
return (
this.hasValidHeight
&& this.hasValidWidth
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment