Debian Codegraph @

node/@patternfly/react-core/src/components/Hint/examples/HintBasicWithTitle.tsx

raw
1 import { useState } from 'react';
2 import {
3 Hint,
4 HintTitle,
5 HintBody,
6 HintFooter,
7 Button,
8 Dropdown,
9 DropdownList,
10 DropdownItem,
11 Divider,
12 MenuToggle,
13 MenuToggleElement
14 } from '@patternfly/react-core';
15 import RhUiEllipsisVerticalFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-ellipsis-vertical-fill-icon';
16
17 export const HintBasicWithTitle: React.FunctionComponent = () => {
18 const [isOpen, setIsOpen] = useState<boolean>(false);
19
20 const onToggle = () => {
21 setIsOpen(!isOpen);
22 };
23
24 const onSelect = () => {
25 setIsOpen(!isOpen);
26 };
27
28 const actions = (
29 <Dropdown
30 isOpen={isOpen}
31 onSelect={onSelect}
32 onOpenChange={(isOpen: boolean) => setIsOpen(isOpen)}
33 toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
34 <MenuToggle
35 ref={toggleRef}
36 aria-label="With title example kebab toggle"
37 variant="plain"
38 onClick={onToggle}
39 isExpanded={isOpen}
40 icon={<RhUiEllipsisVerticalFillIcon />}
41 />
42 )}
43 >
44 <DropdownList>
45 <DropdownItem value={0} key="action">
46 Action
47 </DropdownItem>
48 <DropdownItem
49 value={1}
50 key="link"
51 to="#default-link2"
52 // Prevent the default onClick functionality for example purposes
53 onClick={(ev: any) => ev.preventDefault()}
54 >
55 Link
56 </DropdownItem>
57 <DropdownItem value={2} isDisabled key="disabled action">
58 Disabled Action
59 </DropdownItem>
60 <DropdownItem value={3} isDisabled key="disabled link" to="#default-link4">
61 Disabled Link
62 </DropdownItem>
63 <Divider component="li" key="separator" />
64 <DropdownItem value={4} key="separated action">
65 Separated Action
66 </DropdownItem>
67 <DropdownItem value={5} key="separated link" to="#default-link6" onClick={(ev) => ev.preventDefault()}>
68 Separated Link
69 </DropdownItem>
70 </DropdownList>
71 </Dropdown>
72 );
73 return (
74 <Hint actions={actions}>
75 <HintTitle>Do more with Find it Fix it capabilities</HintTitle>
76 <HintBody>
77 Upgrade to Red Hat Smart Management to remediate all your systems across regions and geographies.
78 </HintBody>
79 <HintFooter>
80 <Button variant="link" isInline>
81 Try it for 90 days
82 </Button>
83 </HintFooter>
84 </Hint>
85 );
86 };