/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at . */ // @flow import React, { Component } from "react"; import type { Node } from "react"; import "./Dropdown.css"; type Props = { panel: React$Element, icon: Node }; type State = { dropdownShown: boolean }; export class Dropdown extends Component { toggleDropdown: Function; constructor(props: Props) { super(props); this.state = { dropdownShown: false }; } toggleDropdown = (e: SyntheticKeyboardEvent) => { this.setState(prevState => ({ dropdownShown: !prevState.dropdownShown })); }; renderPanel() { return (
{this.props.panel}
); } renderButton() { return ( ); } renderMask() { return (
); } render() { return (
{this.renderPanel()} {this.renderButton()} {this.renderMask()}
); } } export default Dropdown;