Skip to content
Snippets Groups Projects
Unverified Commit 5222c731 authored by Shaun Ellis's avatar Shaun Ellis Committed by GitHub
Browse files

Merge pull request #1809 from ProjectMirador/1794-window-icon

Add the manifest's logo to the window top bar; fixes #1794
parents 6bb39c87 431c6e1c
No related branches found
No related tags found
No related merge requests found
import React from 'react';
import { shallow } from 'enzyme';
import WindowIcon from '../../../src/components/WindowIcon';
describe('WindowIcon', () => {
let wrapper;
let manifestation;
describe('without a manifestation', () => {
beforeEach(() => {
wrapper = shallow(<WindowIcon />).dive();
});
it('renders without an error', () => {
expect(wrapper.find('img').length).toBe(0);
});
});
describe('with a manifestation without a logo', () => {
beforeEach(() => {
manifestation = { getLogo: () => null };
wrapper = shallow(<WindowIcon manifestation={manifestation} />).dive();
});
it('renders without an error', () => {
expect(wrapper.find('img').length).toBe(0);
});
});
describe('with a manifestation with a logo', () => {
beforeEach(() => {
manifestation = { getLogo: () => 'http://example.com/thumbnail.jpg' };
wrapper = shallow(<WindowIcon manifestation={manifestation} classes={{ logo: 'logo-class' }} />).dive();
});
it('renders without an error', () => {
expect(wrapper.find('img.logo-class[src="http://example.com/thumbnail.jpg"]').length).toBe(1);
});
});
});
......@@ -36,6 +36,10 @@ describe('WindowTopBar', () => {
.toBe(mockRemoveWindow);
});
it('renders a window icon', () => {
expect(topBar.find('WithStyles(WindowIcon)').length).toBe(1);
});
it('calls the toggleWindowSideBar prop when the menu IconButton is clicked', () => {
topBar.find('WithStyles(IconButton)').simulate('click');
expect(mockToggleWindowSideBar).toHaveBeenCalledTimes(1);
......
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
/**
*/
class WindowIcon extends Component {
/**
* render
* @return
*/
render() {
const {
manifestation, classes,
} = this.props;
if (manifestation && manifestation.getLogo()) {
return (<img src={manifestation.getLogo()} alt="" role="presentation" className={classes.logo} />);
}
return (
<></>
);
}
}
WindowIcon.propTypes = {
manifestation: PropTypes.shape({
getLogo: PropTypes.func,
}),
classes: PropTypes.shape({ logo: PropTypes.string }),
};
WindowIcon.defaultProps = {
manifestation: null,
classes: {},
};
const styles = {
logo: {
height: '2.5rem',
paddingRight: 8,
},
};
export default withStyles(styles)(WindowIcon);
......@@ -7,6 +7,7 @@ import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu';
import Toolbar from '@material-ui/core/Toolbar';
import classNames from 'classnames';
import WindowIcon from './WindowIcon';
import WindowTopMenuButton from './WindowTopMenuButton';
import WindowTopBarButtons from '../containers/WindowTopBarButtons';
import ns from '../config/css-ns';
......@@ -34,7 +35,7 @@ class WindowTopBar extends Component {
*/
render() {
const {
removeWindow, windowId, classes, toggleWindowSideBar,
removeWindow, windowId, classes, toggleWindowSideBar, manifest,
} = this.props;
return (
<Toolbar disableGutters className={classNames(classes.reallyDense, ns('window-top-bar'))} variant="dense">
......@@ -45,6 +46,7 @@ class WindowTopBar extends Component {
>
<MenuIcon />
</IconButton>
<WindowIcon manifestation={manifest.manifestation} />
<Typography variant="h3" noWrap color="inherit" className={classes.typographyBody}>
{this.titleContent()}
</Typography>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment