-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOCS] Converted EuiPopover examples to function component (#3232)
- Loading branch information
1 parent
cea16bf
commit 19910d5
Showing
10 changed files
with
758 additions
and
1,054 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
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’s wider than the default width | ||
</div> | ||
</EuiPopover> | ||
); | ||
} | ||
} | ||
return ( | ||
<EuiPopover | ||
button={button} | ||
isOpen={isPopoverOpen} | ||
closePopover={closePopover}> | ||
<div style={{ width: '300px' }}> | ||
Popover content that’s wider than the default width | ||
</div> | ||
</EuiPopover> | ||
); | ||
}; |
Oops, something went wrong.