-
Notifications
You must be signed in to change notification settings - Fork 527
Expand file tree
/
Copy pathPopover.js
More file actions
42 lines (38 loc) · 1.04 KB
/
Popover.js
File metadata and controls
42 lines (38 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import './Popover.css'
const Popover = ({ show, children, top, right, bottom, left, align, handleMouseEnter, handleMouseLeave }) => {
return (
<div className={ classNames('popover absolute shadow-3', align && `popover--align-${align}`) }
aria-hidden={ show ? 'false' : 'true' }
style={{
background: 'var(--theme-bg-modal)',
...(top && { top }),
...(right && { right }),
...(bottom && { bottom }),
...(left && { left })
}}
onMouseEnter={ handleMouseEnter }
onMouseLeave={ handleMouseLeave }
>
<div className="pa2">
{ children }
</div>
</div>
)
}
Popover.propTypes = {
show: PropTypes.bool,
top: PropTypes.string,
right: PropTypes.string,
bottom: PropTypes.string,
left: PropTypes.string,
align: PropTypes.string,
handleMouseEnter: PropTypes.func,
handleMouseLeave: PropTypes.func
}
Popover.defaultProps = {
show: false
}
export default Popover