import React from "react"; import { createPortal } from "react-dom"; import PropTypes from "prop-types"; import classnames from "classnames"; import "../../css/context-menu.css"; class Portal extends React.Component { constructor(props) { super(props); this._node = document.createElement("div"); document.body.appendChild(this._node); } componentWillUnmount() { document.body.removeChild(this._node); } render() { const style = { position: "absolute", top: this.props.top, left: this.props.left }; return createPortal(
{this.props.children}
, this._node ); } } export const Hr = () => (

  • ); export const Parent = ({ children, label }) => (
  • {label}
  • ); export const LinkNode = props => (
  • {props.label}
  • ); LinkNode.propTypes = { label: PropTypes.string.isRequired, href: PropTypes.string.isRequired }; export const Node = props => { const { label, checked, className = "", ...passThroughProps } = props; return (
  • {label}
  • ); }; Node.propTypes = { label: PropTypes.string.isRequired, hotkey: PropTypes.string }; export class ContextMenu extends React.Component { render() { const { children, offsetTop, offsetLeft, top, bottom, selected } = this.props; return ( selected && ( ) ); } }