diff --git a/js/components/PlaylistWindow/MiscMenu.js b/js/components/PlaylistWindow/MiscMenu.js index 39cc2edd..d145982e 100644 --- a/js/components/PlaylistWindow/MiscMenu.js +++ b/js/components/PlaylistWindow/MiscMenu.js @@ -1,16 +1,14 @@ import React from "react"; import { connect } from "react-redux"; import { FILE_INFO } from "../../actionTypes"; +import PlaylistMenu from "./PlaylistMenu"; const MiscMenu = props => ( -
-
- -
+ +
  • +
  • +
  • + ); const mapDispatchToProps = { diff --git a/js/components/PlaylistWindow/PlaylistMenu.js b/js/components/PlaylistWindow/PlaylistMenu.js new file mode 100644 index 00000000..496cf84f --- /dev/null +++ b/js/components/PlaylistWindow/PlaylistMenu.js @@ -0,0 +1,42 @@ +import React from "react"; +import classnames from "classnames"; + +export default class PlaylistMenu extends React.Component { + constructor(props) { + super(props); + this.state = { selected: false }; + this._handleClick = this._handleClick.bind(this); + } + + _handleClick(e) { + const { target } = e; + this.setState({ selected: !this.state.selected }); + const handleClickOut = ee => { + if (!target.contains(ee.target)) { + this.setState({ selected: false }); + ee.stopPropagation(); + } + window.document.removeEventListener("click", handleClickOut, { + capture: true + }); + }; + window.document.addEventListener("click", handleClickOut, { + capture: true + }); + } + + render() { + return ( +
    +
    +
      {this.props.children}
    +
    + ); + } +} diff --git a/js/components/PlaylistWindow/RemoveMenu.js b/js/components/PlaylistWindow/RemoveMenu.js index e12cb762..16771ebb 100644 --- a/js/components/PlaylistWindow/RemoveMenu.js +++ b/js/components/PlaylistWindow/RemoveMenu.js @@ -5,17 +5,15 @@ import { CROP_TRACKS, REMOVE_SELECTED_TRACKS } from "../../actionTypes"; +import PlaylistMenu from "./PlaylistMenu"; const RemoveMenu = props => ( -
    -
    -
      -
    • -
    • -
    • -
    • -
    -
    + +
  • +
  • +
  • +
  • + ); const mapDispatchToProps = { diff --git a/js/components/PlaylistWindow/SelectionMenu.js b/js/components/PlaylistWindow/SelectionMenu.js index 3876ddaf..425b4997 100644 --- a/js/components/PlaylistWindow/SelectionMenu.js +++ b/js/components/PlaylistWindow/SelectionMenu.js @@ -1,16 +1,14 @@ import React from "react"; import { connect } from "react-redux"; import { SELECT_ALL, SELECT_ZERO, INVERT_SELECTION } from "../../actionTypes"; +import PlaylistMenu from "./PlaylistMenu"; const SelectionMenu = props => ( -
    -
    -
      -
    • -
    • -
    • -
    -
    + +
  • +
  • +
  • + ); const mapDispatchToProps = { diff --git a/js/components/PlaylistWindow/__snapshots__/index.test.js.snap b/js/components/PlaylistWindow/__snapshots__/index.test.js.snap index 0cdf46af..bdb8170b 100644 --- a/js/components/PlaylistWindow/__snapshots__/index.test.js.snap +++ b/js/components/PlaylistWindow/__snapshots__/index.test.js.snap @@ -302,8 +302,36 @@ exports[`PlaylistWindow renders to snapshot 1`] = ` className="playlist-bottom-left draggable" >
    +
    +
      +
    • +
    • +
    • +
    • +
    +
    +