Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Close popover menu on click (closes #301) #580

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gui/web/src/components/molecules/BotCard/BotCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ class BotCard extends Component {
<div className={styles.optionsSpacer}/>
<PopoverMenu
className={styles.optionsMenu}
alwaysOnClick={this.closeOptions}
enableOffers={true}
onOffers={this.showOffers}
enableMarket={true}
Expand Down
20 changes: 15 additions & 5 deletions gui/web/src/components/molecules/PopoverMenu/PopoverMenu.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import styles from './PopoverMenu.module.scss';

class PopoverMenu extends Component {
static propTypes = {
alwaysOnClick: PropTypes.func.isRequired,
};

defaultOnClick(actualOnClickFn) {
actualOnClickFn()
this.props.alwaysOnClick() // this is the onClose passed into the props
}

render() {
return (
<div className={styles.wrapper}>
<div className={styles.list}>
{this.props.enableOffers ? <div className={styles.item} onClick={this.props.onOffers}>Show Offers</div> : <div className={[styles.item, styles.disabled].join(' ')}>Show Offers</div>}
{this.props.enableMarket ? <div className={styles.item} onClick={this.props.onMarket}>Show Market</div> : <div className={[styles.item, styles.disabled].join(' ')}>Show Market</div>}
{this.props.enableEdit ? <div className={styles.item} onClick={this.props.onEdit}>Edit</div> : <div className={[styles.item, styles.disabled].join(' ')}>Edit</div>}
{this.props.enableCopy ? <div className={styles.item} onClick={this.props.onCopy}>Copy</div> : <div className={[styles.item, styles.disabled].join(' ')}>Copy</div>}
{this.props.enableDelete ? <div className={styles.itemDanger} onClick={this.props.onDelete}>Delete</div> : <div className={[styles.item, styles.disabled].join(' ')}>Delete</div>}
{this.props.enableOffers ? <div className={styles.item} onClick={this.defaultOnClick(this.props.onOffers)}>Show Offers</div> : <div className={[styles.item, styles.disabled].join(' ')}>Show Offers</div>}
{this.props.enableMarket ? <div className={styles.item} onClick={this.defaultOnClick(this.props.onMarket)}>Show Market</div> : <div className={[styles.item, styles.disabled].join(' ')}>Show Market</div>}
{this.props.enableEdit ? <div className={styles.item} onClick={this.defaultOnClick(this.props.onEdit)}>Edit</div> : <div className={[styles.item, styles.disabled].join(' ')}>Edit</div>}
{this.props.enableCopy ? <div className={styles.item} onClick={this.defaultOnClick(this.props.onCopy)}>Copy</div> : <div className={[styles.item, styles.disabled].join(' ')}>Copy</div>}
{this.props.enableDelete ? <div className={styles.itemDanger} onClick={this.defaultOnClick(this.props.onDelete)}>Delete</div> : <div className={[styles.item, styles.disabled].join(' ')}>Delete</div>}
</div>
</div>
);
Expand Down