| 1 |
import { Fragment, useRef } from 'react'; |
| 2 |
import RhUiQuestionMarkCircleFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-question-mark-circle-fill-icon'; |
| 3 |
import { Button, InputGroup, InputGroupItem, TextInput, Popover, PopoverPosition } from '@patternfly/react-core'; |
| 4 |
|
| 5 |
export const InputGroupWithPopover: React.FunctionComponent = () => { |
| 6 |
const inputGroupRef1 = useRef(null); |
| 7 |
const inputGroupRef2 = useRef(null); |
| 8 |
return ( |
| 9 |
<Fragment> |
| 10 |
<InputGroup ref={inputGroupRef1}> |
| 11 |
<InputGroupItem isFill> |
| 12 |
<TextInput |
| 13 |
name="textInput-with-popover-1" |
| 14 |
id="textInput-with-popover-1" |
| 15 |
type="text" |
| 16 |
aria-label="first input example with popover" |
| 17 |
/> |
| 18 |
</InputGroupItem> |
| 19 |
<InputGroupItem> |
| 20 |
<Popover |
| 21 |
aria-label="popover example" |
| 22 |
position={PopoverPosition.top} |
| 23 |
bodyContent="This field is an example of an input group with a popover." |
| 24 |
appendTo={() => inputGroupRef1.current} |
| 25 |
> |
| 26 |
<Button variant="control" aria-label="popover for input" icon={<RhUiQuestionMarkCircleFillIcon />} /> |
| 27 |
</Popover> |
| 28 |
</InputGroupItem> |
| 29 |
</InputGroup> |
| 30 |
<br /> |
| 31 |
<InputGroup ref={inputGroupRef2}> |
| 32 |
<InputGroupItem isFill> |
| 33 |
<TextInput |
| 34 |
name="textInput-with-popover-2" |
| 35 |
id="textInput-with-popover-2" |
| 36 |
type="text" |
| 37 |
aria-label="second input example with popover" |
| 38 |
/> |
| 39 |
</InputGroupItem> |
| 40 |
<InputGroupItem> |
| 41 |
<Popover |
| 42 |
aria-label="popover example" |
| 43 |
position={PopoverPosition.top} |
| 44 |
bodyContent="This field is an example of an input group with a popover." |
| 45 |
appendTo={() => inputGroupRef2.current} |
| 46 |
> |
| 47 |
<Button variant="plain" aria-label="Popover for input" icon={<RhUiQuestionMarkCircleFillIcon />} /> |
| 48 |
</Popover> |
| 49 |
</InputGroupItem> |
| 50 |
</InputGroup> |
| 51 |
</Fragment> |
| 52 |
); |
| 53 |
}; |