forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Created popover HOC for EuiPopover. Refactored existing popovers. Added popover HOC. Refactored refresh_control Added paddingSize prop to popover Added EuiButtonIcon and EuiPopover to arg_add_popover Added aria-label to euibuttonicon in arg_add_popover Added ids to all popovers Fixed position of popovers * Replaced EUI Popover with bootstrap popover * Removed comments and unused props * Fix: popover closes when clicking outside of the popover * Fixed CSS for arg_form * Changed div to span in popover * Fixed button prop type in popover * Refactored popover to use bootstrap overlay. * Fixed popover props to match EuiPopover props * Fixed popover title in refresh_control * Removed window resize and wheel event listeners * Added comment to popover * Fixed prop name in popover
- Loading branch information
Showing
9 changed files
with
166 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
@import (reference) "../../style/main"; | ||
@import (reference) '../../style/main'; | ||
|
||
.canvas__add-arg-popover .popover-content { | ||
padding: 0px; | ||
.canvas__add-arg-popover { | ||
width: 200px; | ||
font-size: @textXSmall; | ||
} | ||
|
||
.canvas__add-arg-button.fa { | ||
color: @mediumGrey; | ||
margin-left: @spacingXS; | ||
font-size: @textSmall; | ||
.popover-content { | ||
padding: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Popover } from './popover'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import React, { PureComponent } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Popover as BootstrapPopover, Overlay } from 'react-bootstrap'; | ||
|
||
// mapping for EUI popover positions to bootstrap placements | ||
const anchorPositions = { | ||
upCenter: 'top', | ||
upLeft: 'top', | ||
upRight: 'top', | ||
downCenter: 'bottom', | ||
downLeft: 'bottom', | ||
downRight: 'bottom', | ||
leftCenter: 'left', | ||
leftUp: 'left', | ||
leftDown: 'left', | ||
rightCenter: 'right', | ||
rightUp: 'right', | ||
rightDown: 'right', | ||
}; | ||
|
||
export class Popover extends PureComponent { | ||
static propTypes = { | ||
id: PropTypes.string, | ||
panelClassName: PropTypes.string, | ||
button: PropTypes.func.isRequired, | ||
children: PropTypes.func.isRequired, | ||
title: PropTypes.string, | ||
anchorPosition: PropTypes.string, | ||
style: PropTypes.object, | ||
}; | ||
|
||
static defaultProps = { | ||
ownFocus: false, | ||
anchorPosition: 'downCenter', | ||
panelPaddingSize: 'm', | ||
}; | ||
|
||
state = { | ||
isPopoverOpen: false, | ||
}; | ||
|
||
handleClick = () => { | ||
this.setState({ | ||
isPopoverOpen: !this.state.isPopoverOpen, | ||
}); | ||
}; | ||
|
||
closePopover = () => { | ||
this.setState({ | ||
isPopoverOpen: false, | ||
}); | ||
}; | ||
|
||
render() { | ||
const { id, button, children, panelClassName, title, anchorPosition, style } = this.props; | ||
|
||
const position = anchorPositions[anchorPosition] ? anchorPosition : 'downCenter'; | ||
|
||
// TODO: replace bootstrap popover with EuiPopover https://github.com/elastic/kibana-canvas/issues/612 | ||
// Pending https://github.com/elastic/eui/issues/873 | ||
const popover = ( | ||
<BootstrapPopover id={id} className={panelClassName} title={title}> | ||
{children({ closePopover: this.closePopover })} | ||
</BootstrapPopover> | ||
); | ||
|
||
return ( | ||
<div | ||
ref={button => { | ||
this.target = button; | ||
}} | ||
style={style} | ||
> | ||
{button(this.handleClick)} | ||
<Overlay | ||
show={this.state.isPopoverOpen} | ||
onHide={() => this.setState({ isPopoverOpen: false })} | ||
rootClose | ||
placement={anchorPositions[position]} | ||
target={this.target} | ||
> | ||
{popover} | ||
</Overlay> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters