-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from ProjectMirador/add-window-close-button
extracts topbar to its own component and adds close button
- Loading branch information
Showing
6 changed files
with
117 additions
and
9 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
minimal_redux_poc/__tests__/integration/mirador/window_actions.test.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,15 @@ | ||
describe('Window actions', () => { | ||
beforeAll(async () => { | ||
await page.goto('http://127.0.0.1:4488/__tests__/integration/mirador/'); | ||
}); | ||
it('opens a window and closes it', async () => { | ||
await expect(page).toFill('#manifestURL', 'https://purl.stanford.edu/sn904cj3429/iiif/manifest'); | ||
await expect(page).toClick('#fetchBtn'); | ||
// TODO: Refactor the app so we get rid of the wait | ||
await page.waitFor(1000); | ||
await expect(page).toClick('li button'); | ||
await expect(page).toMatchElement('.mirador-window'); | ||
await expect(page).toClick('.mirador-window-close'); | ||
await expect(page).not.toMatchElement('.mirador-window'); | ||
}); | ||
}); |
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
23 changes: 23 additions & 0 deletions
23
minimal_redux_poc/__tests__/src/components/WindowTopBar.test.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,23 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { actions, store } from '../../../src/store'; | ||
import WindowTopBar from '../../../src/components/WindowTopBar'; | ||
import fixture from '../../fixtures/24.json'; | ||
|
||
describe('Window', () => { | ||
let wrapper; | ||
let window; | ||
beforeEach(() => { | ||
store.dispatch(actions.receiveManifest('foo', fixture)); | ||
store.dispatch(actions.addWindow({ manifestId: 'foo' })); | ||
const manifest = store.getState().manifests.foo; | ||
[window] = store.getState().windows; | ||
wrapper = shallow(<WindowTopBar store={store} manifest={manifest} windowId={window.id} />) | ||
.dive(); | ||
}); | ||
|
||
it('renders without an error', () => { | ||
expect(wrapper.find('div.mirador-window-top-bar h3').text()).toBe('Test 24 Manifest: Image with IIIF Service - adapted with real image'); | ||
expect(wrapper.find('button.mirador-window-close')); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { Component } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import { actions } from '../store'; | ||
import ns from '../config/css-ns'; | ||
|
||
|
||
/** | ||
* WindowTopBar | ||
*/ | ||
class WindowTopBar extends Component { | ||
/** | ||
* render - description | ||
* @return {type} description | ||
*/ | ||
render() { | ||
return ( | ||
<div className={ns('window-top-bar')}> | ||
<h3>{this.props.manifest.manifestation.getLabel().map(label => label.value)[0]}</h3> | ||
<button className={ns('window-close')} aria-label="Close Window" onClick={() => this.props.removeWindow(this.props.windowId)}>×</button> | ||
</div> | ||
); | ||
} | ||
} | ||
// | ||
// /** | ||
// * mapStateToProps - used to hook up connect to action creators | ||
// * @memberof Window | ||
// * @private | ||
// */ | ||
// const mapStateToProps = ({ windows, manifests }, props) => { | ||
// const window = windows.find(win => props.windowId === win.id); | ||
// return { | ||
// window, | ||
// // | ||
// manifest: manifests[window.manifestId], | ||
// }; | ||
// }; | ||
|
||
/** | ||
* mapDispatchToProps - used to hook up connect to action creators | ||
* @memberof ManifestListItem | ||
* @private | ||
*/ | ||
const mapDispatchToProps = dispatch => ({ | ||
removeWindow: windowId => ( | ||
dispatch(actions.removeWindow(windowId)) | ||
), | ||
}); | ||
|
||
WindowTopBar.propTypes = { | ||
manifest: PropTypes.object, // eslint-disable-line react/forbid-prop-types | ||
removeWindow: PropTypes.func.isRequired, | ||
windowId: PropTypes.string.isRequired, | ||
}; | ||
|
||
WindowTopBar.defaultProps = { | ||
manifest: null, | ||
}; | ||
|
||
|
||
export default connect(null, mapDispatchToProps)(WindowTopBar); |
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