-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
108 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
packages/react-core/src/components/Card/examples/CardTileMulti.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React from 'react'; | ||
import { Card, CardHeader, CardBody, Gallery } from '@patternfly/react-core'; | ||
import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon'; | ||
|
||
export const CardTileMulti: React.FunctionComponent = () => { | ||
const [isChecked1, setIsChecked1] = React.useState(false); | ||
const [isChecked2, setIsChecked2] = React.useState(false); | ||
const [isChecked3, setIsChecked3] = React.useState(false); | ||
const id1 = 'multi-tile-1'; | ||
const id2 = 'multi-tile-2'; | ||
const id3 = 'multi-tile-3'; | ||
|
||
const onChange = (event: React.FormEvent<HTMLInputElement>, checked: boolean) => { | ||
const name = event.currentTarget.name; | ||
|
||
switch (name) { | ||
case id1: | ||
setIsChecked1(checked); | ||
break; | ||
case id2: | ||
setIsChecked2(checked); | ||
break; | ||
case id3: | ||
setIsChecked3(checked); | ||
break; | ||
} | ||
}; | ||
|
||
return ( | ||
<Gallery hasGutter> | ||
<Card id="multi-tile-example-1" isSelectable isSelected={isChecked1}> | ||
<CardHeader | ||
selectableActions={{ | ||
selectableActionId: id1, | ||
selectableActionAriaLabelledby: 'multi-tile-example-1', | ||
name: id1, | ||
onChange, | ||
isHidden: true | ||
}} | ||
> | ||
<PlusIcon /> | ||
<b>Tile header</b> | ||
</CardHeader> | ||
<CardBody>Tile content and description</CardBody> | ||
</Card> | ||
<Card id="multi-tile-example-2" isSelectable isSelected={isChecked2}> | ||
<CardHeader | ||
selectableActions={{ | ||
selectableActionId: id2, | ||
selectableActionAriaLabelledby: 'multi-tile-example-2', | ||
name: id2, | ||
onChange, | ||
isHidden: true | ||
}} | ||
> | ||
<PlusIcon /> | ||
<b>Tile header</b> | ||
</CardHeader> | ||
<CardBody>Tile content and description</CardBody> | ||
</Card> | ||
<Card id="multi-tile-example-3" isSelectable isDisabled isSelected={isChecked3}> | ||
<CardHeader | ||
selectableActions={{ | ||
selectableActionId: id3, | ||
selectableActionAriaLabelledby: 'multi-tile-example-3', | ||
name: id3, | ||
onChange, | ||
isHidden: true | ||
}} | ||
> | ||
<PlusIcon /> | ||
<b>Tile header (disabled)</b> | ||
</CardHeader> | ||
<CardBody>Tile content and description</CardBody> | ||
</Card> | ||
</Gallery> | ||
); | ||
}; |