Skip to content

Commit

Permalink
[DOCS] Converted EuiPopover examples to function component (#3232)
Browse files Browse the repository at this point in the history
  • Loading branch information
mridulgogia authored Apr 3, 2020
1 parent cea16bf commit 19910d5
Show file tree
Hide file tree
Showing 10 changed files with 758 additions and 1,054 deletions.
62 changes: 21 additions & 41 deletions src-docs/src/views/popover/popover.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,27 @@
import React, { Component } from 'react';
import React, { useState } from 'react';

import { EuiPopover, EuiButton } from '../../../../src/components';

export default class extends Component {
constructor(props) {
super(props);
export default () => {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);

this.state = {
isPopoverOpen: false,
};
}
const onButtonClick = () => setIsPopoverOpen(isPopoverOpen => !isPopoverOpen);
const closePopover = () => setIsPopoverOpen(false);

onButtonClick() {
this.setState({
isPopoverOpen: !this.state.isPopoverOpen,
});
}
const button = (
<EuiButton iconType="arrowDown" iconSide="right" onClick={onButtonClick}>
Show popover
</EuiButton>
);

closePopover() {
this.setState({
isPopoverOpen: false,
});
}

render() {
const button = (
<EuiButton
iconType="arrowDown"
iconSide="right"
onClick={this.onButtonClick.bind(this)}>
Show popover
</EuiButton>
);

return (
<EuiPopover
button={button}
isOpen={this.state.isPopoverOpen}
closePopover={this.closePopover.bind(this)}>
<div style={{ width: '300px' }}>
Popover content that&rsquo;s wider than the default width
</div>
</EuiPopover>
);
}
}
return (
<EuiPopover
button={button}
isOpen={isPopoverOpen}
closePopover={closePopover}>
<div style={{ width: '300px' }}>
Popover content that&rsquo;s wider than the default width
</div>
</EuiPopover>
);
};
Loading

0 comments on commit 19910d5

Please sign in to comment.