import React from "react"; import { connect } from "react-redux"; import PropTypes from "prop-types"; import classnames from "classnames"; import { SET_FOCUSED_WINDOW, CLOSE_GEN_WINDOW } from "../../actionTypes"; import { scrollVolume } from "../../actionCreators"; const Text = ({ children }) => { const letters = children.split(""); return letters.map((letter, i) => (
)); }; // Named export for testing export const GenWindow = ({ selected, children, close, title, setFocus, windowId, scrollVolume: handleWheel }) => (
setFocus(windowId)} onWheel={handleWheel} >
{title}
close(windowId)} />
{children}
); GenWindow.propTypes = { title: PropTypes.string.isRequired, windowId: PropTypes.string.isRequired, children: PropTypes.node, close: PropTypes.func.isRequired, selected: PropTypes.bool.isRequired }; const mapStateToProps = (state, ownProps) => ({ selected: state.windows.focused === ownProps.windowId }); const mapDispatchToProps = { setFocus: windowId => ({ type: SET_FOCUSED_WINDOW, window: windowId }), close: windowId => ({ type: CLOSE_GEN_WINDOW, windowId }), scrollVolume }; export default connect(mapStateToProps, mapDispatchToProps)(GenWindow);