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