-
Notifications
You must be signed in to change notification settings - Fork 843
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first pass * snippet * comments * more spacing before window edge * Update src-docs/src/views/popover/popover_example.js Co-Authored-By: Caroline Horn <[email protected]> * Update src-docs/src/views/popover/popover_example.js Co-Authored-By: Caroline Horn <[email protected]> * CL * Update CHANGELOG.md Co-Authored-By: Caroline Horn <[email protected]>
- Loading branch information
1 parent
7edd069
commit 4ac7d29
Showing
4 changed files
with
111 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { | ||
EuiInputPopover, | ||
EuiFieldText, | ||
EuiSpacer, | ||
} from '../../../../src/components'; | ||
|
||
export default () => { | ||
const [inputWidth, setInputWidth] = useState(200); | ||
const [isPopoverOpen, setIsPopoverOpen] = useState(false); | ||
const [isPopoverOpenTwo, setIsPopoverOpenTwo] = useState(false); | ||
const toggleIsPopoverOpen = (shouldBeOpen = !isPopoverOpen) => { | ||
setIsPopoverOpen(shouldBeOpen); | ||
}; | ||
const toggleIsPopoverOpenTwo = (shouldBeOpen = !isPopoverOpenTwo) => { | ||
setIsPopoverOpenTwo(shouldBeOpen); | ||
}; | ||
|
||
const input = <EuiFieldText onFocus={() => toggleIsPopoverOpen()} />; | ||
|
||
const inputTwo = ( | ||
<EuiFieldText | ||
onFocus={() => { | ||
setInputWidth(400); | ||
toggleIsPopoverOpenTwo(); | ||
}} | ||
style={{ width: inputWidth }} | ||
/> | ||
); | ||
|
||
return ( | ||
<React.Fragment> | ||
<EuiInputPopover | ||
id="popover" | ||
input={input} | ||
isOpen={isPopoverOpen} | ||
closePopover={() => { | ||
toggleIsPopoverOpen(false); | ||
}}> | ||
Popover content | ||
</EuiInputPopover> | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiInputPopover | ||
id="popover" | ||
input={inputTwo} | ||
isOpen={isPopoverOpenTwo} | ||
closePopover={() => { | ||
toggleIsPopoverOpenTwo(false); | ||
setInputWidth(200); | ||
}}> | ||
Popover will adjust in size as the input does | ||
</EuiInputPopover> | ||
|
||
<EuiSpacer size="xxl" /> | ||
</React.Fragment> | ||
); | ||
}; |
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
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