|
| 1 | +import React from 'react'; |
| 2 | +import MultiContentCard from "@patternfly/react-component-groups/dist/dynamic/MultiContentCard"; |
| 3 | +import { EllipsisVIcon } from '@patternfly/react-icons'; |
| 4 | +import { Button, Card, CardHeader, CardBody, CardFooter, Text, TextContent, TextVariants, Icon, TextList, TextListItem, Divider, Dropdown, DropdownItem, DropdownList, MenuToggle, MenuToggleElement } from '@patternfly/react-core'; |
| 5 | +import { ArrowRightIcon, BellIcon, CogIcon, LockIcon } from '@patternfly/react-icons'; |
| 6 | + |
| 7 | +const cards = [ |
| 8 | + <Card isFullHeight isPlain key="card-1"> |
| 9 | + <CardHeader> |
| 10 | + <TextContent> |
| 11 | + <Text component={TextVariants.h4}>Getting Started</Text> |
| 12 | + </TextContent> |
| 13 | + </CardHeader> |
| 14 | + <CardBody> |
| 15 | + <TextContent> |
| 16 | + <Text className="pf-v5-u-font-size-sm pf-v5-u-font-weight-bold pf-v5-u-mb-sm pf-v5-u-link-color-hover"> |
| 17 | + <Icon size="md" className="pf-v5-u-pl-sm pf-v5-u-pr-md"> |
| 18 | + <CogIcon /> |
| 19 | + </Icon> |
| 20 | + Configure application |
| 21 | + </Text> |
| 22 | + <Text className="pf-v5-u-font-size-sm"> |
| 23 | + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. |
| 24 | + </Text> |
| 25 | + </TextContent> |
| 26 | + </CardBody> |
| 27 | + <CardFooter> |
| 28 | + <TextContent> |
| 29 | + <TextList className="pf-v5-u-font-size-sm pf-v5-u-link-color pf-v5-u-ml-0"> |
| 30 | + <TextListItem> |
| 31 | + <Button variant="link" isInline>First link</Button> |
| 32 | + </TextListItem> |
| 33 | + <TextListItem> |
| 34 | + <Button variant="link" isInline>Second link</Button> |
| 35 | + </TextListItem> |
| 36 | + <TextListItem> |
| 37 | + <Button variant="link" isInline>Another link</Button> |
| 38 | + </TextListItem> |
| 39 | + </TextList> |
| 40 | + </TextContent> |
| 41 | + </CardFooter> |
| 42 | + </Card>, |
| 43 | + <Card isFullHeight isPlain key="card-2"> |
| 44 | + <CardBody className="pf-v5-u-pt-3xl-on-md"> |
| 45 | + <TextContent> |
| 46 | + <Text className="pf-v5-u-font-size-sm pf-v5-u-font-weight-bold pf-v5-u-mb-sm pf-v5-u-link-color-hover"> |
| 47 | + <Icon size="md" className="pf-v5-u-pl-sm pf-v5-u-pr-md"> |
| 48 | + <LockIcon /> |
| 49 | + </Icon> |
| 50 | + Configure access |
| 51 | + </Text> |
| 52 | + <Text className="pf-v5-u-font-size-sm"> |
| 53 | + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. |
| 54 | + </Text> |
| 55 | + </TextContent> |
| 56 | + </CardBody> |
| 57 | + <CardFooter> |
| 58 | + <Text> |
| 59 | + <Button variant="link" isInline> |
| 60 | + Learn more |
| 61 | + <Icon className="pf-u-ml-sm" isInline> |
| 62 | + <ArrowRightIcon /> |
| 63 | + </Icon> |
| 64 | + </Button> |
| 65 | + </Text> |
| 66 | + </CardFooter> |
| 67 | + </Card>, |
| 68 | + <Card isFullHeight isPlain key="card-3"> |
| 69 | + <CardHeader> |
| 70 | + <TextContent> |
| 71 | + <Text component={TextVariants.h4}>Next Steps</Text> |
| 72 | + </TextContent> |
| 73 | + </CardHeader> |
| 74 | + <CardBody> |
| 75 | + <TextContent> |
| 76 | + <Text className="pf-v5-u-font-size-sm pf-v5-u-font-weight-bold pf-v5-u-mb-sm pf-v5-u-link-color-hover"> |
| 77 | + <Icon size="md" className="pf-v5-u-pl-sm pf-v5-u-pr-md"> |
| 78 | + <BellIcon /> |
| 79 | + </Icon> |
| 80 | + Configure notifications |
| 81 | + </Text> |
| 82 | + <Text className="pf-v5-u-font-size-sm"> |
| 83 | + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. |
| 84 | + </Text> |
| 85 | + </TextContent> |
| 86 | + </CardBody> |
| 87 | + <CardFooter> |
| 88 | + <Text> |
| 89 | + <Button variant="link" isInline> |
| 90 | + Learn more |
| 91 | + <Icon className="pf-u-ml-sm" isInline> |
| 92 | + <ArrowRightIcon /> |
| 93 | + </Icon> |
| 94 | + </Button> |
| 95 | + </Text> |
| 96 | + </CardFooter> |
| 97 | + </Card> |
| 98 | +]; |
| 99 | + |
| 100 | +export const BasicExample: React.FunctionComponent = () => { |
| 101 | + const [ isMenuOpen, setMenuOpen ] = React.useState(false) |
| 102 | + |
| 103 | + const onToggleClick = () => { |
| 104 | + setMenuOpen(!isMenuOpen); |
| 105 | + }; |
| 106 | + return ( |
| 107 | + <MultiContentCard |
| 108 | + isExpandable |
| 109 | + toggleText='Card with actions toggle text' |
| 110 | + cards={cards} |
| 111 | + actions={ |
| 112 | + <Dropdown |
| 113 | + isOpen={isMenuOpen} |
| 114 | + onSelect={() => null} |
| 115 | + onOpenChange={(isMenuOpen: boolean) => setMenuOpen(isMenuOpen)} |
| 116 | + toggle={(toggleRef: React.Ref<MenuToggleElement>) => ( |
| 117 | + <MenuToggle |
| 118 | + ref={toggleRef} |
| 119 | + aria-label="kebab dropdown toggle" |
| 120 | + variant="plain" |
| 121 | + onClick={onToggleClick} |
| 122 | + isExpanded={isMenuOpen} |
| 123 | + > |
| 124 | + <EllipsisVIcon /> |
| 125 | + </MenuToggle> |
| 126 | + )} |
| 127 | + shouldFocusToggleOnSelect |
| 128 | + > |
| 129 | + <DropdownList> |
| 130 | + <DropdownItem value={0} key="action"> |
| 131 | + Action |
| 132 | + </DropdownItem> |
| 133 | + <DropdownItem value={1} isDisabled key="disabled action"> |
| 134 | + Disabled Action |
| 135 | + </DropdownItem> |
| 136 | + <Divider component="li" key="separator" /> |
| 137 | + <DropdownItem value={2} key="separated action"> |
| 138 | + Separated Action |
| 139 | + </DropdownItem> |
| 140 | + </DropdownList> |
| 141 | + </Dropdown> |
| 142 | + } |
| 143 | + /> |
| 144 | + ) |
| 145 | +}; |
0 commit comments