mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-21 00:59:29 +00:00
Add AvsWindow on top of GenWindow
This commit is contained in:
parent
b378647d38
commit
6fdfc18643
5 changed files with 58 additions and 6 deletions
|
|
@ -81,6 +81,7 @@
|
|||
|
||||
#winamp2-js .gen-middle-center {
|
||||
flex-grow: 1;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#winamp2-js .gen-middle-right {
|
||||
|
|
|
|||
21
js/components/AvsWindow/index.js
Normal file
21
js/components/AvsWindow/index.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import React from "react";
|
||||
import GenWindow from "../GenWindow";
|
||||
import "../../../css/gen-window.css";
|
||||
|
||||
const AvsWindow = () => (
|
||||
<GenWindow title="Avs" close={() => {}} windowId="AVS_WINDOW">
|
||||
<canvas
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: "100%",
|
||||
width: "100%"
|
||||
}}
|
||||
/>
|
||||
</GenWindow>
|
||||
);
|
||||
|
||||
export default AvsWindow;
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
exports[`GenWindow renders to snapshot 1`] = `
|
||||
<div
|
||||
className="gen-window window selected"
|
||||
onMouseDown={[Function]}
|
||||
>
|
||||
<div
|
||||
className="gen-top draggable"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import PropTypes from "prop-types";
|
||||
import classnames from "classnames";
|
||||
import "../../../css/gen-window.css";
|
||||
|
||||
import { SET_FOCUSED_WINDOW } from "../../actionTypes";
|
||||
|
||||
const Text = ({ children }) => {
|
||||
const letters = children.split("");
|
||||
|
|
@ -15,8 +17,19 @@ const Text = ({ children }) => {
|
|||
));
|
||||
};
|
||||
|
||||
const GenWindow = ({ selected, children, close, title }) => (
|
||||
<div className={classnames("gen-window", "window", { selected })}>
|
||||
// Named export for testing
|
||||
export const GenWindow = ({
|
||||
selected,
|
||||
children,
|
||||
close,
|
||||
title,
|
||||
setFocus,
|
||||
windowId
|
||||
}) => (
|
||||
<div
|
||||
className={classnames("gen-window", "window", { selected })}
|
||||
onMouseDown={() => setFocus(windowId)}
|
||||
>
|
||||
<div className="gen-top draggable">
|
||||
<div className="gen-top-left draggable" />
|
||||
<div className="gen-top-left-right-fill draggable" />
|
||||
|
|
@ -48,9 +61,18 @@ const GenWindow = ({ selected, children, close, title }) => (
|
|||
|
||||
GenWindow.propTypes = {
|
||||
title: PropTypes.string.isRequired,
|
||||
windowId: PropTypes.string.isRequired,
|
||||
children: PropTypes.node,
|
||||
close: PropTypes.func.isRequired,
|
||||
selected: PropTypes.bool.isRequired
|
||||
};
|
||||
|
||||
export default GenWindow;
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
selected: state.windows.focused === ownProps.windowId
|
||||
});
|
||||
|
||||
const mapDispatchToProps = {
|
||||
setFocus: window => ({ type: SET_FOCUSED_WINDOW, window })
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(GenWindow);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,19 @@
|
|||
import React from "react";
|
||||
import renderer from "react-test-renderer";
|
||||
|
||||
import GenWindow from "./index";
|
||||
import { GenWindow } from "./index";
|
||||
|
||||
describe("GenWindow", () => {
|
||||
it("renders to snapshot", () => {
|
||||
const tree = renderer
|
||||
.create(<GenWindow title="My Window" selected close={() => {}} />)
|
||||
.create(
|
||||
<GenWindow
|
||||
title="My Window"
|
||||
selected
|
||||
close={() => {}}
|
||||
windowId="TEST_WINDOW_ID"
|
||||
/>
|
||||
)
|
||||
.toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue