You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
carbon/components/Popout.js

45 lines
1.1 KiB
JavaScript

import React from 'react'
import enhanceWithClickOutside from 'react-click-outside'
import WindowPointer from './WindowPointer'
import { COLORS } from '../lib/constants'
class Popout extends React.PureComponent {
static defaultProps = {
borderColor: COLORS.SECONDARY,
style: {},
onClickOutside: () => {}
}
handleClickOutside = e => !this.props.hidden && this.props.onClickOutside(e)
render() {
const { children, borderColor, style, hidden, pointerLeft, pointerRight } = this.props
if (hidden) {
return null
}
return (
<div className="popout" style={style}>
<WindowPointer fromLeft={pointerLeft} fromRight={pointerRight} color={borderColor} />
{children}
<style jsx>
{`
.popout {
position: absolute;
background-color: ${COLORS.BLACK};
border: 2px solid ${borderColor};
border-radius: 3px;
margin-top: 10px;
font-size: 12px;
}
`}
</style>
</div>
)
}
}
export default enhanceWithClickOutside(Popout)