| 1 |
import { useState } from 'react'; |
| 2 |
import { Card, CardHeader, CardBody, Gallery, Flex } from '@patternfly/react-core'; |
| 3 |
import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon'; |
| 4 |
|
| 5 |
export const CardTile: React.FunctionComponent = () => { |
| 6 |
const [isChecked, setIsChecked] = useState(''); |
| 7 |
const id1 = 'tile-1'; |
| 8 |
const id2 = 'tile-2'; |
| 9 |
const id3 = 'tile-3'; |
| 10 |
|
| 11 |
const onChange = (event: React.FormEvent<HTMLInputElement>) => { |
| 12 |
setIsChecked(event.currentTarget.id); |
| 13 |
}; |
| 14 |
|
| 15 |
return ( |
| 16 |
<Gallery hasGutter> |
| 17 |
<Card id="tile-example-1" isSelectable isSelected={isChecked === id1}> |
| 18 |
<CardHeader |
| 19 |
selectableActions={{ |
| 20 |
selectableActionId: id1, |
| 21 |
selectableActionAriaLabelledby: 'tile-example-1', |
| 22 |
name: id1, |
| 23 |
variant: 'single', |
| 24 |
onChange, |
| 25 |
isHidden: true |
| 26 |
}} |
| 27 |
> |
| 28 |
<Flex gap={{ default: 'gapSm' }} alignItems={{ default: 'alignItemsCenter' }}> |
| 29 |
<PlusIcon /> |
| 30 |
<b>Tile header</b> |
| 31 |
</Flex> |
| 32 |
</CardHeader> |
| 33 |
<CardBody>Tile content and description</CardBody> |
| 34 |
</Card> |
| 35 |
<Card id="tile-example-2" isSelectable isSelected={isChecked === id2}> |
| 36 |
<CardHeader |
| 37 |
selectableActions={{ |
| 38 |
selectableActionId: id2, |
| 39 |
selectableActionAriaLabelledby: 'tile-example-2', |
| 40 |
name: id2, |
| 41 |
variant: 'single', |
| 42 |
onChange, |
| 43 |
isHidden: true |
| 44 |
}} |
| 45 |
> |
| 46 |
<Flex gap={{ default: 'gapSm' }} alignItems={{ default: 'alignItemsCenter' }}> |
| 47 |
<PlusIcon /> |
| 48 |
<b>Tile header</b> |
| 49 |
</Flex> |
| 50 |
</CardHeader> |
| 51 |
<CardBody>Tile content and description</CardBody> |
| 52 |
</Card> |
| 53 |
<Card id="tile-example-3" isSelectable isDisabled isSelected={isChecked === id3}> |
| 54 |
<CardHeader |
| 55 |
selectableActions={{ |
| 56 |
selectableActionId: id3, |
| 57 |
selectableActionAriaLabelledby: 'tile-example-3', |
| 58 |
name: id3, |
| 59 |
variant: 'single', |
| 60 |
onChange, |
| 61 |
isHidden: true |
| 62 |
}} |
| 63 |
> |
| 64 |
<Flex gap={{ default: 'gapSm' }} alignItems={{ default: 'alignItemsCenter' }}> |
| 65 |
<PlusIcon /> |
| 66 |
<b>Tile header (disabled)</b> |
| 67 |
</Flex> |
| 68 |
</CardHeader> |
| 69 |
<CardBody>Tile content and description</CardBody> |
| 70 |
</Card> |
| 71 |
</Gallery> |
| 72 |
); |
| 73 |
}; |