class PopoverExample extends React.Component {
constructor(props) {
super(props);
this.state = { open: false };
this.handleClick = this._handleClick.bind(this);
this.handleDismiss = this._handleDismiss.bind(this);
this.anchorRef = React.createRef();
}
_handleClick() {
this.setState(() => ({ open: !this.state.open }));
}
_handleDismiss() {
this.setState(() => ({ open: false }));
}
render() {
return (
<Box marginTop={10}>
<Box display="inlineBlock" ref={this.anchorRef}>
<div style={{
position: "absolute",
top: 10,
left: 10,
pointerEvents: "none", }}>
<Pulsar paused={this.state.open} />
</div>
<Button
accessibilityExpanded={!!this.state.open}
accessibilityHaspopup
onClick={this.handleClick}
text={this.state.open ? 'Hide Popover' : 'Show Popover'}
/>
</Box>
{this.state.open && (
<Popover
anchor={this.anchorRef.current}
color="darkGray"
idealDirection="right"
onDismiss={this.handleDismiss}
shouldFocus={false}
>
<Box column={12} padding={3}>
<Text color="white" weight="bold">
Create a board to save Pins about Kitchen Design for later
</Text>
</Box>
</Popover>
)}
</Box>
);
}
}