Debian Codegraph @

node/@patternfly/react-core/src/components/Card/examples/CardClickable.tsx

raw
1 import { useState } from 'react';
2 import { Card, CardHeader, CardTitle, CardBody, Checkbox, Gallery } from '@patternfly/react-core';
3
4 export const CardClickable: React.FunctionComponent = () => {
5 const [isSecondary, setIsSecondary] = useState<boolean>(false);
6
7 const toggleVariant = (checked: boolean) => {
8 setIsSecondary(checked);
9 };
10
11 return (
12 <>
13 <Checkbox
14 label="secondary styling"
15 isChecked={isSecondary}
16 onChange={(_event, checked) => toggleVariant(checked)}
17 aria-label="add secondary styling"
18 id="toggle-variant-clickable"
19 name="toggle-variant"
20 />
21 <div style={{ marginTop: '15px' }}>
22 <Gallery hasGutter>
23 <Card isClickable variant={isSecondary ? 'secondary' : 'default'}>
24 <CardHeader
25 selectableActions={{
26 // eslint-disable-next-line no-console
27 onClickAction: () => console.log(`First card in actionable example clicked`),
28 selectableActionAriaLabelledby: 'clickable-card-example-title-1'
29 }}
30 >
31 <CardTitle id="clickable-card-example-title-1">First card in the actionable example</CardTitle>
32 </CardHeader>
33 <CardBody>This card performs an action on click.</CardBody>
34 </Card>
35 <Card isClickable variant={isSecondary ? 'secondary' : 'default'}>
36 <CardHeader
37 selectableActions={{
38 to: '#',
39 selectableActionAriaLabelledby: 'clickable-card-example-title-2'
40 }}
41 >
42 <CardTitle id="clickable-card-example-title-2">Second card in the actionable example</CardTitle>
43 </CardHeader>
44 <CardBody>This card can navigate to a link on click.</CardBody>
45 </Card>
46 <Card isClickable isDisabled variant={isSecondary ? 'secondary' : 'default'}>
47 <CardHeader
48 selectableActions={{
49 // eslint-disable-next-line no-console
50 onClickAction: () => console.log(`Third card in actionable example clicked`),
51 selectableActionAriaLabelledby: 'clickable-card-example-title-3'
52 }}
53 >
54 <CardTitle id="clickable-card-example-title-3">Third card in the actionable example</CardTitle>
55 </CardHeader>
56 <CardBody>This card is clickable but disabled.</CardBody>
57 </Card>
58 </Gallery>
59 </div>
60 </>
61 );
62 };