Skip to content
Snippets Groups Projects
Commit a780e720 authored by Jessie Keck's avatar Jessie Keck
Browse files

Map maximize/minimize window action dispatches to WindowTopBar props.

parent de16d782
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ import IconButton from '@material-ui/core/IconButton'; ...@@ -5,6 +5,7 @@ import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/MenuSharp'; import MenuIcon from '@material-ui/icons/MenuSharp';
import CloseIcon from '@material-ui/icons/CloseSharp'; import CloseIcon from '@material-ui/icons/CloseSharp';
import FullscreenIcon from '@material-ui/icons/FullscreenSharp'; import FullscreenIcon from '@material-ui/icons/FullscreenSharp';
import FullscreenExitIcon from '@material-ui/icons/FullscreenExitSharp';
import Toolbar from '@material-ui/core/Toolbar'; import Toolbar from '@material-ui/core/Toolbar';
import AppBar from '@material-ui/core/AppBar'; import AppBar from '@material-ui/core/AppBar';
import classNames from 'classnames'; import classNames from 'classnames';
...@@ -18,21 +19,14 @@ import ns from '../config/css-ns'; ...@@ -18,21 +19,14 @@ import ns from '../config/css-ns';
* WindowTopBar * WindowTopBar
*/ */
export class WindowTopBar extends Component { export class WindowTopBar extends Component {
/**
* maximizeWindow
* @return
*/
maximizeWindow() {
console.log('maximized!');
}
/** /**
* render * render
* @return * @return
*/ */
render() { render() {
const { const {
closeWindow, windowId, classes, toggleWindowSideBar, t, manifestTitle, closeWindow, windowId, classes, toggleWindowSideBar,
t, manifestTitle, maximizeWindow, maximized, minimizeWindow,
} = this.props; } = this.props;
return ( return (
<AppBar position="relative"> <AppBar position="relative">
...@@ -54,9 +48,11 @@ export class WindowTopBar extends Component { ...@@ -54,9 +48,11 @@ export class WindowTopBar extends Component {
color="inherit" color="inherit"
className={ns('window-maximize')} className={ns('window-maximize')}
aria-label={t('maximizeWindow')} aria-label={t('maximizeWindow')}
onClick={this.maximizeWindow} onClick={(maximized ? minimizeWindow : maximizeWindow)}
> >
<FullscreenIcon /> {maximized
? <FullscreenExitIcon />
: <FullscreenIcon />}
</IconButton> </IconButton>
<IconButton <IconButton
color="inherit" color="inherit"
...@@ -74,6 +70,9 @@ export class WindowTopBar extends Component { ...@@ -74,6 +70,9 @@ export class WindowTopBar extends Component {
WindowTopBar.propTypes = { WindowTopBar.propTypes = {
manifestTitle: PropTypes.string, manifestTitle: PropTypes.string,
maximizeWindow: PropTypes.func,
maximized: PropTypes.bool,
minimizeWindow: PropTypes.func,
closeWindow: PropTypes.func.isRequired, closeWindow: PropTypes.func.isRequired,
windowId: PropTypes.string.isRequired, windowId: PropTypes.string.isRequired,
classes: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types classes: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
...@@ -83,5 +82,8 @@ WindowTopBar.propTypes = { ...@@ -83,5 +82,8 @@ WindowTopBar.propTypes = {
WindowTopBar.defaultProps = { WindowTopBar.defaultProps = {
manifestTitle: '', manifestTitle: '',
maximizeWindow: () => {},
maximized: false,
minimizeWindow: () => {},
t: key => key, t: key => key,
}; };
...@@ -10,6 +10,7 @@ import { WindowTopBar } from '../components/WindowTopBar'; ...@@ -10,6 +10,7 @@ import { WindowTopBar } from '../components/WindowTopBar';
/** mapStateToProps */ /** mapStateToProps */
const mapStateToProps = (state, { windowId }) => ({ const mapStateToProps = (state, { windowId }) => ({
manifestTitle: getManifestTitle(getWindowManifest(state, windowId)), manifestTitle: getManifestTitle(getWindowManifest(state, windowId)),
maximized: state.windows[windowId].maximized,
}); });
/** /**
...@@ -19,6 +20,8 @@ const mapStateToProps = (state, { windowId }) => ({ ...@@ -19,6 +20,8 @@ const mapStateToProps = (state, { windowId }) => ({
*/ */
const mapDispatchToProps = (dispatch, { windowId }) => ({ const mapDispatchToProps = (dispatch, { windowId }) => ({
closeWindow: () => dispatch(actions.closeWindow(windowId)), closeWindow: () => dispatch(actions.closeWindow(windowId)),
maximizeWindow: () => dispatch(actions.maximizeWindow(windowId)),
minimizeWindow: () => dispatch(actions.minimizeWindow(windowId)),
toggleWindowSideBar: () => dispatch(actions.toggleWindowSideBar(windowId)), toggleWindowSideBar: () => dispatch(actions.toggleWindowSideBar(windowId)),
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment