@patternfly/react-core 5.0.0-alpha.27 → 5.0.0-alpha.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/CONTRIBUTING.md +12 -1
- package/components/Card/Card.js +1 -1
- package/components/Card/Card.js.map +1 -1
- package/components/Card/CardActions.d.ts +2 -2
- package/components/Card/CardActions.js +1 -1
- package/components/Card/CardActions.js.map +1 -1
- package/components/Card/CardBody.js +1 -1
- package/components/Card/CardBody.js.map +1 -1
- package/components/Card/CardExpandableContent.js +1 -1
- package/components/Card/CardExpandableContent.js.map +1 -1
- package/components/Card/CardFooter.js +1 -1
- package/components/Card/CardFooter.js.map +1 -1
- package/components/Card/CardHeader.d.ts +12 -2
- package/components/Card/CardHeader.d.ts.map +1 -1
- package/components/Card/CardHeader.js +9 -3
- package/components/Card/CardHeader.js.map +1 -1
- package/components/Card/CardHeaderMain.d.ts.map +1 -1
- package/components/Card/CardHeaderMain.js +4 -2
- package/components/Card/CardHeaderMain.js.map +1 -1
- package/components/Card/CardTitle.js +1 -1
- package/components/Card/CardTitle.js.map +1 -1
- package/components/Card/index.d.ts +0 -2
- package/components/Card/index.d.ts.map +1 -1
- package/components/Card/index.js +0 -2
- package/components/Card/index.js.map +1 -1
- package/dist/esm/components/Card/Card.js +1 -1
- package/dist/esm/components/Card/Card.js.map +1 -1
- package/dist/esm/components/Card/CardActions.d.ts +2 -2
- package/dist/esm/components/Card/CardActions.js +1 -1
- package/dist/esm/components/Card/CardActions.js.map +1 -1
- package/dist/esm/components/Card/CardBody.js +1 -1
- package/dist/esm/components/Card/CardBody.js.map +1 -1
- package/dist/esm/components/Card/CardExpandableContent.js +1 -1
- package/dist/esm/components/Card/CardExpandableContent.js.map +1 -1
- package/dist/esm/components/Card/CardFooter.js +1 -1
- package/dist/esm/components/Card/CardFooter.js.map +1 -1
- package/dist/esm/components/Card/CardHeader.d.ts +12 -2
- package/dist/esm/components/Card/CardHeader.d.ts.map +1 -1
- package/dist/esm/components/Card/CardHeader.js +9 -3
- package/dist/esm/components/Card/CardHeader.js.map +1 -1
- package/dist/esm/components/Card/CardHeaderMain.d.ts.map +1 -1
- package/dist/esm/components/Card/CardHeaderMain.js +4 -2
- package/dist/esm/components/Card/CardHeaderMain.js.map +1 -1
- package/dist/esm/components/Card/CardTitle.js +1 -1
- package/dist/esm/components/Card/CardTitle.js.map +1 -1
- package/dist/esm/components/Card/index.d.ts +0 -2
- package/dist/esm/components/Card/index.d.ts.map +1 -1
- package/dist/esm/components/Card/index.js +0 -2
- package/dist/esm/components/Card/index.js.map +1 -1
- package/dist/js/components/Card/Card.js +1 -1
- package/dist/js/components/Card/Card.js.map +1 -1
- package/dist/js/components/Card/CardActions.d.ts +2 -2
- package/dist/js/components/Card/CardActions.js +1 -1
- package/dist/js/components/Card/CardActions.js.map +1 -1
- package/dist/js/components/Card/CardBody.js +1 -1
- package/dist/js/components/Card/CardBody.js.map +1 -1
- package/dist/js/components/Card/CardExpandableContent.js +1 -1
- package/dist/js/components/Card/CardExpandableContent.js.map +1 -1
- package/dist/js/components/Card/CardFooter.js +1 -1
- package/dist/js/components/Card/CardFooter.js.map +1 -1
- package/dist/js/components/Card/CardHeader.d.ts +12 -2
- package/dist/js/components/Card/CardHeader.d.ts.map +1 -1
- package/dist/js/components/Card/CardHeader.js +9 -3
- package/dist/js/components/Card/CardHeader.js.map +1 -1
- package/dist/js/components/Card/CardHeaderMain.d.ts.map +1 -1
- package/dist/js/components/Card/CardHeaderMain.js +4 -2
- package/dist/js/components/Card/CardHeaderMain.js.map +1 -1
- package/dist/js/components/Card/CardTitle.js +1 -1
- package/dist/js/components/Card/CardTitle.js.map +1 -1
- package/dist/js/components/Card/index.d.ts +0 -2
- package/dist/js/components/Card/index.d.ts.map +1 -1
- package/dist/js/components/Card/index.js +0 -2
- package/dist/js/components/Card/index.js.map +1 -1
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +2 -2
- package/src/components/Card/Card.tsx +2 -2
- package/src/components/Card/CardActions.tsx +4 -4
- package/src/components/Card/CardBody.tsx +2 -2
- package/src/components/Card/CardExpandableContent.tsx +2 -2
- package/src/components/Card/CardFooter.tsx +2 -2
- package/src/components/Card/CardHeader.tsx +21 -6
- package/src/components/Card/CardHeaderMain.tsx +5 -3
- package/src/components/Card/CardTitle.tsx +2 -2
- package/src/components/Card/__tests__/CardHeader.test.tsx +5 -0
- package/src/components/Card/__tests__/__snapshots__/CardHeader.test.tsx.snap +14 -0
- package/src/components/Card/__tests__/__snapshots__/CardHeaderMain.test.tsx.snap +1 -1
- package/src/components/Card/examples/Card.md +6 -6
- package/src/components/Card/examples/CardBasic.tsx +1 -1
- package/src/components/Card/examples/CardExpandable.tsx +22 -19
- package/src/components/Card/examples/CardExpandableWithIcon.tsx +21 -18
- package/src/components/Card/examples/CardHeaderInCardHead.tsx +21 -19
- package/src/components/Card/examples/CardLegacySelectable.tsx +19 -18
- package/src/components/Card/examples/CardOnlyActionsInCardHead.tsx +21 -20
- package/src/components/Card/examples/CardSelectable.tsx +19 -18
- package/src/components/Card/examples/CardSelectableA11yHighlight.tsx +3 -3
- package/src/components/Card/examples/CardWithBodySectionFills.tsx +1 -1
- package/src/components/Card/examples/CardWithHeadingElement.tsx +1 -1
- package/src/components/Card/examples/CardWithImageAndActions.tsx +23 -24
- package/src/components/Card/examples/CardWithModifiers.tsx +1 -1
- package/src/components/Card/examples/CardWithMultipleBodySections.tsx +1 -1
- package/src/components/Card/examples/CardWithNoFooter.tsx +1 -1
- package/src/components/Card/examples/CardWithNoHeader.tsx +1 -1
- package/src/components/Card/index.ts +0 -2
- package/src/demos/Card/Card.md +55 -52
- package/src/demos/CardDemos.md +73 -71
- package/src/demos/PrimaryDetail.md +66 -68
- package/components/Card/CardHeadMain.d.ts +0 -9
- package/components/Card/CardHeadMain.d.ts.map +0 -1
- package/components/Card/CardHeadMain.js +0 -9
- package/components/Card/CardHeadMain.js.map +0 -1
- package/dist/esm/components/Card/CardHeadMain.d.ts +0 -9
- package/dist/esm/components/Card/CardHeadMain.d.ts.map +0 -1
- package/dist/esm/components/Card/CardHeadMain.js +0 -9
- package/dist/esm/components/Card/CardHeadMain.js.map +0 -1
- package/dist/js/components/Card/CardHeadMain.d.ts +0 -9
- package/dist/js/components/Card/CardHeadMain.d.ts.map +0 -1
- package/dist/js/components/Card/CardHeadMain.js +0 -13
- package/dist/js/components/Card/CardHeadMain.js.map +0 -1
- package/src/components/Card/CardHeadMain.tsx +0 -20
- package/src/components/Card/__tests__/CardHeadMain.test.tsx +0 -22
- package/src/components/Card/__tests__/__snapshots__/CardHeadMain.test.tsx.snap +0 -11
- package/src/components/Card/examples/CardOnlyImageInCardHead.tsx +0 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.29",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^16.8 || ^17 || ^18",
|
|
71
71
|
"react-dom": "^16.8 || ^17 || ^18"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "7c588834378fe2c857485727715af5cc4ecc4ceb"
|
|
74
74
|
}
|
|
@@ -64,9 +64,9 @@ export const CardContext = React.createContext<Partial<CardContextProps>>({
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
export const Card: React.FunctionComponent<CardProps> = ({
|
|
67
|
-
children
|
|
67
|
+
children,
|
|
68
68
|
id = '',
|
|
69
|
-
className
|
|
69
|
+
className,
|
|
70
70
|
component = 'div',
|
|
71
71
|
isCompact = false,
|
|
72
72
|
isSelectable = false,
|
|
@@ -3,17 +3,17 @@ import { css } from '@patternfly/react-styles';
|
|
|
3
3
|
import styles from '@patternfly/react-styles/css/components/Card/card';
|
|
4
4
|
|
|
5
5
|
export interface CardActionsProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
-
/** Content rendered inside the
|
|
6
|
+
/** Content rendered inside the card action */
|
|
7
7
|
children?: React.ReactNode;
|
|
8
|
-
/** Additional classes added to the
|
|
8
|
+
/** Additional classes added to the action */
|
|
9
9
|
className?: string;
|
|
10
10
|
/** Flag indicating that the actions have no offset */
|
|
11
11
|
hasNoOffset?: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const CardActions: React.FunctionComponent<CardActionsProps> = ({
|
|
15
|
-
children
|
|
16
|
-
className
|
|
15
|
+
children,
|
|
16
|
+
className,
|
|
17
17
|
hasNoOffset = false,
|
|
18
18
|
...props
|
|
19
19
|
}: CardActionsProps) => (
|
|
@@ -14,8 +14,8 @@ export interface CardBodyProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export const CardBody: React.FunctionComponent<CardBodyProps> = ({
|
|
17
|
-
children
|
|
18
|
-
className
|
|
17
|
+
children,
|
|
18
|
+
className,
|
|
19
19
|
component = 'div',
|
|
20
20
|
isFilled = true,
|
|
21
21
|
...props
|
|
@@ -11,8 +11,8 @@ export interface CardExpandableContentProps extends React.HTMLProps<HTMLDivEleme
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const CardExpandableContent: React.FunctionComponent<CardExpandableContentProps> = ({
|
|
14
|
-
children
|
|
15
|
-
className
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
16
|
...props
|
|
17
17
|
}: CardExpandableContentProps) => (
|
|
18
18
|
<CardContext.Consumer>
|
|
@@ -12,8 +12,8 @@ export interface CardFooterProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const CardFooter: React.FunctionComponent<CardFooterProps> = ({
|
|
15
|
-
children
|
|
16
|
-
className
|
|
15
|
+
children,
|
|
16
|
+
className,
|
|
17
17
|
component = 'div',
|
|
18
18
|
...props
|
|
19
19
|
}: CardFooterProps) => {
|
|
@@ -2,14 +2,27 @@ import * as React from 'react';
|
|
|
2
2
|
import { css } from '@patternfly/react-styles';
|
|
3
3
|
import styles from '@patternfly/react-styles/css/components/Card/card';
|
|
4
4
|
import { CardContext } from './Card';
|
|
5
|
+
import { CardHeaderMain } from './CardHeaderMain';
|
|
6
|
+
import { CardActions } from './CardActions';
|
|
5
7
|
import { Button } from '../Button';
|
|
6
8
|
import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon';
|
|
7
9
|
|
|
10
|
+
export interface CardHeaderActionsObject {
|
|
11
|
+
/** Actions of the card header */
|
|
12
|
+
actions: React.ReactNode;
|
|
13
|
+
/** Flag indicating that the actions have no offset */
|
|
14
|
+
hasNoOffset?: boolean;
|
|
15
|
+
/** Additional classes added to the actions wrapper */
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
8
19
|
export interface CardHeaderProps extends React.HTMLProps<HTMLDivElement> {
|
|
9
|
-
/** Content rendered inside the
|
|
20
|
+
/** Content rendered inside the card header */
|
|
10
21
|
children?: React.ReactNode;
|
|
11
|
-
/** Additional classes added to the
|
|
22
|
+
/** Additional classes added to the card header */
|
|
12
23
|
className?: string;
|
|
24
|
+
/** Actions of the card header */
|
|
25
|
+
actions?: CardHeaderActionsObject;
|
|
13
26
|
/** ID of the card header. */
|
|
14
27
|
id?: string;
|
|
15
28
|
/** Callback expandable card */
|
|
@@ -21,8 +34,9 @@ export interface CardHeaderProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
21
34
|
}
|
|
22
35
|
|
|
23
36
|
export const CardHeader: React.FunctionComponent<CardHeaderProps> = ({
|
|
24
|
-
children
|
|
25
|
-
className
|
|
37
|
+
children,
|
|
38
|
+
className,
|
|
39
|
+
actions,
|
|
26
40
|
id,
|
|
27
41
|
onExpand,
|
|
28
42
|
toggleButtonProps,
|
|
@@ -36,7 +50,7 @@ export const CardHeader: React.FunctionComponent<CardHeaderProps> = ({
|
|
|
36
50
|
<Button
|
|
37
51
|
variant="plain"
|
|
38
52
|
type="button"
|
|
39
|
-
onClick={evt => {
|
|
53
|
+
onClick={(evt) => {
|
|
40
54
|
onExpand(evt, cardId);
|
|
41
55
|
}}
|
|
42
56
|
{...toggleButtonProps}
|
|
@@ -55,7 +69,8 @@ export const CardHeader: React.FunctionComponent<CardHeaderProps> = ({
|
|
|
55
69
|
{...props}
|
|
56
70
|
>
|
|
57
71
|
{onExpand && !isToggleRightAligned && cardHeaderToggle}
|
|
58
|
-
{
|
|
72
|
+
{actions && <CardActions className={actions?.className} hasNoOffset={actions?.hasNoOffset}> {actions.actions} </CardActions>}
|
|
73
|
+
{children && <CardHeaderMain>{children}</CardHeaderMain>}
|
|
59
74
|
{onExpand && isToggleRightAligned && cardHeaderToggle}
|
|
60
75
|
</div>
|
|
61
76
|
);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { css } from '@patternfly/react-styles';
|
|
3
|
+
import styles from '@patternfly/react-styles/css/components/Card/card';
|
|
2
4
|
|
|
3
5
|
export interface CardHeaderMainProps extends React.HTMLProps<HTMLDivElement> {
|
|
4
6
|
/** Content rendered inside the Card Head Main */
|
|
@@ -8,11 +10,11 @@ export interface CardHeaderMainProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
export const CardHeaderMain: React.FunctionComponent<CardHeaderMainProps> = ({
|
|
11
|
-
children
|
|
12
|
-
className
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
13
15
|
...props
|
|
14
16
|
}: CardHeaderMainProps) => (
|
|
15
|
-
<div className={className} {...props}>
|
|
17
|
+
<div className={css(styles.cardHeaderMain ,className)} {...props}>
|
|
16
18
|
{children}
|
|
17
19
|
</div>
|
|
18
20
|
);
|
|
@@ -13,8 +13,8 @@ export interface CardTitleProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export const CardTitle: React.FunctionComponent<CardTitleProps> = ({
|
|
16
|
-
children
|
|
17
|
-
className
|
|
16
|
+
children,
|
|
17
|
+
className,
|
|
18
18
|
component = 'div',
|
|
19
19
|
...props
|
|
20
20
|
}: CardTitleProps) => {
|
|
@@ -7,4 +7,9 @@ describe('CardHeader', () => {
|
|
|
7
7
|
const { asFragment } = render(<CardHeader onExpand={jest.fn()} />);
|
|
8
8
|
expect(asFragment()).toMatchSnapshot();
|
|
9
9
|
});
|
|
10
|
+
|
|
11
|
+
test('actions are rendered', () => {
|
|
12
|
+
const { asFragment } = render(<CardHeader actions="test" />);
|
|
13
|
+
expect(asFragment()).toMatchSnapshot();
|
|
14
|
+
});
|
|
10
15
|
});
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
+
exports[`CardHeader actions are rendered 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="pf-c-card__header"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
class="pf-c-card__actions"
|
|
10
|
+
>
|
|
11
|
+
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</DocumentFragment>
|
|
15
|
+
`;
|
|
16
|
+
|
|
3
17
|
exports[`CardHeader onExpand adds the toggle button 1`] = `
|
|
4
18
|
<DocumentFragment>
|
|
5
19
|
<div
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
id: Card
|
|
3
3
|
section: components
|
|
4
4
|
cssPrefix: pf-c-card
|
|
5
|
-
propComponents: ['Card', '
|
|
5
|
+
propComponents: ['Card', 'CardHeader', 'CardHeaderActionsObject', 'CardTitle', 'CardBody', 'CardFooter', 'CardExpandableContent']
|
|
6
6
|
ouia: true
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -40,11 +40,11 @@ Most modifiers can be used in combination with each other, except for `isCompact
|
|
|
40
40
|
|
|
41
41
|
### Header images and actions
|
|
42
42
|
|
|
43
|
-
You can include header
|
|
43
|
+
You can include header actions with the `actions` property of `<CardHeader>` . The following example includes an image using the [Brand](/components/brand) component, and also includes a kebab dropdown and a checkbox in `<CardHeader>` actions.
|
|
44
44
|
|
|
45
|
-
`<
|
|
45
|
+
The `actions` property for `<CardHeader>` includes the `hasNoOffset` property, which is `false` by default. When `hasNoOffset` is `false`, a negative margin is applied to help align default-sized card titles with card actions.
|
|
46
46
|
|
|
47
|
-
You may use `hasNoOffset` to remove this negative margin, which better aligns
|
|
47
|
+
You may use `hasNoOffset` to remove this negative margin, which better aligns card actions in implementations that use large card titles or tall header images, for example.
|
|
48
48
|
|
|
49
49
|
Select the "actions hasNoOffset" checkbox in the example below to illustrate this behavior.
|
|
50
50
|
|
|
@@ -60,9 +60,9 @@ Moving `<CardTitle>` within the `<CardHeader>` will style it inline with any ima
|
|
|
60
60
|
|
|
61
61
|
### Card header without title
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
Card actions can be placed in the card header even without a `<CardTitle>`.
|
|
64
64
|
|
|
65
|
-
Images can also be placed in the card header
|
|
65
|
+
Images can also be placed in the card header without a `<CardTitle>`.
|
|
66
66
|
|
|
67
67
|
```ts file='./CardOnlyActionsInCardHead.tsx'
|
|
68
68
|
```
|
|
@@ -3,7 +3,7 @@ import { Card, CardTitle, CardBody, CardFooter } from '@patternfly/react-core';
|
|
|
3
3
|
|
|
4
4
|
export const CardBasic: React.FunctionComponent = () => (
|
|
5
5
|
<Card>
|
|
6
|
-
<CardTitle>
|
|
6
|
+
<CardTitle>Title</CardTitle>
|
|
7
7
|
<CardBody>Body</CardBody>
|
|
8
8
|
<CardFooter>Footer</CardFooter>
|
|
9
9
|
</Card>
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
Card,
|
|
4
4
|
CardHeader,
|
|
5
|
-
CardActions,
|
|
6
5
|
CardTitle,
|
|
7
6
|
CardBody,
|
|
8
7
|
CardFooter,
|
|
@@ -56,6 +55,26 @@ export const CardExpandable: React.FunctionComponent = () => {
|
|
|
56
55
|
</DropdownItem>
|
|
57
56
|
];
|
|
58
57
|
|
|
58
|
+
const headerActions = (
|
|
59
|
+
<>
|
|
60
|
+
<Dropdown
|
|
61
|
+
onSelect={onSelect}
|
|
62
|
+
toggle={<KebabToggle onToggle={(_event: any, isOpen: boolean) => setIsOpen(isOpen)} />}
|
|
63
|
+
isOpen={isOpen}
|
|
64
|
+
isPlain
|
|
65
|
+
dropdownItems={dropdownItems}
|
|
66
|
+
position={'right'}
|
|
67
|
+
/>
|
|
68
|
+
<Checkbox
|
|
69
|
+
isChecked={isChecked}
|
|
70
|
+
onChange={(_event, checked) => onClick(checked)}
|
|
71
|
+
aria-label="card checkbox example"
|
|
72
|
+
id="check-4"
|
|
73
|
+
name="check4"
|
|
74
|
+
/>
|
|
75
|
+
</>
|
|
76
|
+
);
|
|
77
|
+
|
|
59
78
|
return (
|
|
60
79
|
<React.Fragment>
|
|
61
80
|
<div style={{ marginBottom: '12px' }}>
|
|
@@ -69,6 +88,7 @@ export const CardExpandable: React.FunctionComponent = () => {
|
|
|
69
88
|
</div>
|
|
70
89
|
<Card id="expandable-card" isExpanded={isExpanded}>
|
|
71
90
|
<CardHeader
|
|
91
|
+
actions={{actions: headerActions}}
|
|
72
92
|
onExpand={onExpand}
|
|
73
93
|
isToggleRightAligned={isToggleRightAligned}
|
|
74
94
|
toggleButtonProps={{
|
|
@@ -78,24 +98,7 @@ export const CardExpandable: React.FunctionComponent = () => {
|
|
|
78
98
|
'aria-expanded': isExpanded
|
|
79
99
|
}}
|
|
80
100
|
>
|
|
81
|
-
<
|
|
82
|
-
<Dropdown
|
|
83
|
-
onSelect={onSelect}
|
|
84
|
-
toggle={<KebabToggle onToggle={(_event: any, isOpen: boolean) => setIsOpen(isOpen)} />}
|
|
85
|
-
isOpen={isOpen}
|
|
86
|
-
isPlain
|
|
87
|
-
dropdownItems={dropdownItems}
|
|
88
|
-
position={'right'}
|
|
89
|
-
/>
|
|
90
|
-
<Checkbox
|
|
91
|
-
isChecked={isChecked}
|
|
92
|
-
onChange={(_event, checked) => onClick(checked)}
|
|
93
|
-
aria-label="card checkbox example"
|
|
94
|
-
id="check-4"
|
|
95
|
-
name="check4"
|
|
96
|
-
/>
|
|
97
|
-
</CardActions>
|
|
98
|
-
<CardTitle id="expandable-card-title">Header</CardTitle>
|
|
101
|
+
<CardTitle id="expandable-card-title">Title</CardTitle>
|
|
99
102
|
</CardHeader>
|
|
100
103
|
<CardExpandableContent>
|
|
101
104
|
<CardBody>Body</CardBody>
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
Card,
|
|
4
4
|
CardHeader,
|
|
5
|
-
CardActions,
|
|
6
5
|
CardBody,
|
|
7
6
|
CardFooter,
|
|
8
7
|
CardExpandableContent,
|
|
@@ -51,9 +50,30 @@ export const CardExpandableWithIcon: React.FunctionComponent = () => {
|
|
|
51
50
|
</DropdownItem>
|
|
52
51
|
];
|
|
53
52
|
|
|
53
|
+
const headerActions = (
|
|
54
|
+
<>
|
|
55
|
+
<Dropdown
|
|
56
|
+
onSelect={onSelect}
|
|
57
|
+
toggle={<KebabToggle onToggle={(_event: any, isOpen: boolean) => setIsOpen(isOpen)} />}
|
|
58
|
+
isOpen={isOpen}
|
|
59
|
+
isPlain
|
|
60
|
+
dropdownItems={dropdownItems}
|
|
61
|
+
position={'right'}
|
|
62
|
+
/>
|
|
63
|
+
<Checkbox
|
|
64
|
+
isChecked={isChecked}
|
|
65
|
+
onChange={(_event, checked) => onClick(checked)}
|
|
66
|
+
aria-label="card checkbox example"
|
|
67
|
+
id="check-5"
|
|
68
|
+
name="check5"
|
|
69
|
+
/>
|
|
70
|
+
</>
|
|
71
|
+
);
|
|
72
|
+
|
|
54
73
|
return (
|
|
55
74
|
<Card id="expandable-card-icon" isExpanded={isExpanded}>
|
|
56
75
|
<CardHeader
|
|
76
|
+
actions={{actions: headerActions}}
|
|
57
77
|
onExpand={onExpand}
|
|
58
78
|
toggleButtonProps={{
|
|
59
79
|
id: 'toggle-button2',
|
|
@@ -62,23 +82,6 @@ export const CardExpandableWithIcon: React.FunctionComponent = () => {
|
|
|
62
82
|
}}
|
|
63
83
|
>
|
|
64
84
|
<img src={pfLogoSmall} alt="PatternFly logo" width="27px" />
|
|
65
|
-
<CardActions>
|
|
66
|
-
<Dropdown
|
|
67
|
-
onSelect={onSelect}
|
|
68
|
-
toggle={<KebabToggle onToggle={(_event: any, isOpen: boolean) => setIsOpen(isOpen)} />}
|
|
69
|
-
isOpen={isOpen}
|
|
70
|
-
isPlain
|
|
71
|
-
dropdownItems={dropdownItems}
|
|
72
|
-
position={'right'}
|
|
73
|
-
/>
|
|
74
|
-
<Checkbox
|
|
75
|
-
isChecked={isChecked}
|
|
76
|
-
onChange={(_event, checked) => onClick(checked)}
|
|
77
|
-
aria-label="card checkbox example"
|
|
78
|
-
id="check-5"
|
|
79
|
-
name="check5"
|
|
80
|
-
/>
|
|
81
|
-
</CardActions>
|
|
82
85
|
</CardHeader>
|
|
83
86
|
<CardExpandableContent>
|
|
84
87
|
<CardBody>Body</CardBody>
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
Card,
|
|
4
4
|
CardHeader,
|
|
5
|
-
CardActions,
|
|
6
5
|
CardTitle,
|
|
7
6
|
CardBody,
|
|
8
7
|
CardFooter,
|
|
@@ -42,26 +41,29 @@ export const CardTitleInHeader: React.FunctionComponent = () => {
|
|
|
42
41
|
</DropdownItem>
|
|
43
42
|
];
|
|
44
43
|
|
|
44
|
+
const headerActions = (
|
|
45
|
+
<>
|
|
46
|
+
<Dropdown
|
|
47
|
+
onSelect={onSelect}
|
|
48
|
+
toggle={<KebabToggle onToggle={(_event: any, isOpen: boolean) => setIsOpen(isOpen)} />}
|
|
49
|
+
isOpen={isOpen}
|
|
50
|
+
isPlain
|
|
51
|
+
dropdownItems={dropdownItems}
|
|
52
|
+
position={'right'}
|
|
53
|
+
/>
|
|
54
|
+
<Checkbox
|
|
55
|
+
isChecked={isChecked}
|
|
56
|
+
onChange={(_event, checked) => onClick(checked)}
|
|
57
|
+
aria-label="card checkbox example"
|
|
58
|
+
id="check-2"
|
|
59
|
+
name="check2"
|
|
60
|
+
/>
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
|
|
45
64
|
return (
|
|
46
65
|
<Card>
|
|
47
|
-
<CardHeader>
|
|
48
|
-
<CardActions>
|
|
49
|
-
<Dropdown
|
|
50
|
-
onSelect={onSelect}
|
|
51
|
-
toggle={<KebabToggle onToggle={(_event: any, isOpen: boolean) => setIsOpen(isOpen)} />}
|
|
52
|
-
isOpen={isOpen}
|
|
53
|
-
isPlain
|
|
54
|
-
dropdownItems={dropdownItems}
|
|
55
|
-
position={'right'}
|
|
56
|
-
/>
|
|
57
|
-
<Checkbox
|
|
58
|
-
isChecked={isChecked}
|
|
59
|
-
onChange={(_event, checked) => onClick(checked)}
|
|
60
|
-
aria-label="card checkbox example"
|
|
61
|
-
id="check-2"
|
|
62
|
-
name="check2"
|
|
63
|
-
/>
|
|
64
|
-
</CardActions>
|
|
66
|
+
<CardHeader actions={{actions: headerActions}}>
|
|
65
67
|
<CardTitle>
|
|
66
68
|
This is a really really really really really really really really really really long header
|
|
67
69
|
</CardTitle>
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
Card,
|
|
4
4
|
CardHeader,
|
|
5
|
-
CardActions,
|
|
6
5
|
CardTitle,
|
|
7
6
|
CardBody,
|
|
8
7
|
Dropdown,
|
|
@@ -21,18 +20,18 @@ export const CardLegacySelectable: React.FunctionComponent = () => {
|
|
|
21
20
|
}
|
|
22
21
|
if (['Enter', ' '].includes(event.key)) {
|
|
23
22
|
event.preventDefault();
|
|
24
|
-
const newSelected = event.currentTarget.id === selected ?
|
|
23
|
+
const newSelected = event.currentTarget.id === selected ? '' : event.currentTarget.id;
|
|
25
24
|
setSelected(newSelected);
|
|
26
25
|
}
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
const onClick = (event: React.MouseEvent) => {
|
|
30
|
-
const newSelected = event.currentTarget.id === selected ?
|
|
29
|
+
const newSelected = event.currentTarget.id === selected ? '' : event.currentTarget.id;
|
|
31
30
|
setSelected(newSelected);
|
|
32
31
|
};
|
|
33
32
|
|
|
34
33
|
const onChange = (_event: React.FormEvent<HTMLInputElement>, labelledById: string) => {
|
|
35
|
-
const newSelected = labelledById === selected ?
|
|
34
|
+
const newSelected = labelledById === selected ? '' : labelledById;
|
|
36
35
|
setSelected(newSelected);
|
|
37
36
|
};
|
|
38
37
|
|
|
@@ -41,8 +40,8 @@ export const CardLegacySelectable: React.FunctionComponent = () => {
|
|
|
41
40
|
setIsKebabOpen(isOpen);
|
|
42
41
|
};
|
|
43
42
|
|
|
44
|
-
const onSelect = (event: React.SyntheticEvent<HTMLDivElement>) => {
|
|
45
|
-
event
|
|
43
|
+
const onSelect = (event: React.SyntheticEvent<HTMLDivElement> | undefined) => {
|
|
44
|
+
event?.stopPropagation();
|
|
46
45
|
setIsKebabOpen(!isKebabOpen);
|
|
47
46
|
};
|
|
48
47
|
|
|
@@ -64,6 +63,19 @@ export const CardLegacySelectable: React.FunctionComponent = () => {
|
|
|
64
63
|
</DropdownItem>
|
|
65
64
|
];
|
|
66
65
|
|
|
66
|
+
const headerActions = (
|
|
67
|
+
<>
|
|
68
|
+
<Dropdown
|
|
69
|
+
onSelect={onSelect}
|
|
70
|
+
toggle={<KebabToggle onToggle={onToggle} />}
|
|
71
|
+
isOpen={isKebabOpen}
|
|
72
|
+
isPlain
|
|
73
|
+
dropdownItems={dropdownItems}
|
|
74
|
+
position={'right'}
|
|
75
|
+
/>
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
|
|
67
79
|
return (
|
|
68
80
|
<>
|
|
69
81
|
<Card
|
|
@@ -75,18 +87,7 @@ export const CardLegacySelectable: React.FunctionComponent = () => {
|
|
|
75
87
|
isSelected={selected === 'legacy-first-card'}
|
|
76
88
|
hasSelectableInput
|
|
77
89
|
>
|
|
78
|
-
<CardHeader
|
|
79
|
-
<CardActions>
|
|
80
|
-
<Dropdown
|
|
81
|
-
onSelect={onSelect}
|
|
82
|
-
toggle={<KebabToggle onToggle={onToggle} />}
|
|
83
|
-
isOpen={isKebabOpen}
|
|
84
|
-
isPlain
|
|
85
|
-
dropdownItems={dropdownItems}
|
|
86
|
-
position={'right'}
|
|
87
|
-
/>
|
|
88
|
-
</CardActions>
|
|
89
|
-
</CardHeader>
|
|
90
|
+
<CardHeader actions={{actions: headerActions}}/>
|
|
90
91
|
<CardTitle>First legacy selectable card</CardTitle>
|
|
91
92
|
<CardBody>This is a selectable card. Click me to select me. Click again to deselect me.</CardBody>
|
|
92
93
|
</Card>
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
KebabToggle,
|
|
8
8
|
Card,
|
|
9
9
|
CardHeader,
|
|
10
|
-
CardActions,
|
|
11
10
|
CardBody
|
|
12
11
|
} from '@patternfly/react-core';
|
|
13
12
|
|
|
@@ -40,27 +39,29 @@ export const CardOnlyActionsInCardHead: React.FunctionComponent = () => {
|
|
|
40
39
|
</DropdownItem>
|
|
41
40
|
];
|
|
42
41
|
|
|
42
|
+
const headerActions = (
|
|
43
|
+
<>
|
|
44
|
+
<Dropdown
|
|
45
|
+
onSelect={onSelect}
|
|
46
|
+
toggle={<KebabToggle onToggle={(_event: any, isOpen: boolean) => setIsOpen(isOpen)} />}
|
|
47
|
+
isOpen={isOpen}
|
|
48
|
+
isPlain
|
|
49
|
+
dropdownItems={dropdownItems}
|
|
50
|
+
position={'right'}
|
|
51
|
+
/>
|
|
52
|
+
<Checkbox
|
|
53
|
+
isChecked={isChecked}
|
|
54
|
+
onChange={(_event, checked) => onClick(checked)}
|
|
55
|
+
aria-label="card checkbox example"
|
|
56
|
+
id="check-3"
|
|
57
|
+
name="check3"
|
|
58
|
+
/>
|
|
59
|
+
</>
|
|
60
|
+
);
|
|
61
|
+
|
|
43
62
|
return (
|
|
44
63
|
<Card>
|
|
45
|
-
<CardHeader
|
|
46
|
-
<CardActions>
|
|
47
|
-
<Dropdown
|
|
48
|
-
onSelect={onSelect}
|
|
49
|
-
toggle={<KebabToggle onToggle={(_event: any, isOpen: boolean) => setIsOpen(isOpen)} />}
|
|
50
|
-
isOpen={isOpen}
|
|
51
|
-
isPlain
|
|
52
|
-
dropdownItems={dropdownItems}
|
|
53
|
-
position={'right'}
|
|
54
|
-
/>
|
|
55
|
-
<Checkbox
|
|
56
|
-
isChecked={isChecked}
|
|
57
|
-
onChange={(_event, checked) => onClick(checked)}
|
|
58
|
-
aria-label="card checkbox example"
|
|
59
|
-
id="check-3"
|
|
60
|
-
name="check3"
|
|
61
|
-
/>
|
|
62
|
-
</CardActions>
|
|
63
|
-
</CardHeader>
|
|
64
|
+
<CardHeader actions={{actions: headerActions}}/>
|
|
64
65
|
<CardBody>This is the card body. There are only actions in the card head.</CardBody>
|
|
65
66
|
</Card>
|
|
66
67
|
);
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
Card,
|
|
4
4
|
CardHeader,
|
|
5
|
-
CardActions,
|
|
6
5
|
CardTitle,
|
|
7
6
|
CardBody,
|
|
8
7
|
Dropdown,
|
|
@@ -21,18 +20,18 @@ export const CardSelectable: React.FunctionComponent = () => {
|
|
|
21
20
|
}
|
|
22
21
|
if ([' ', 'Enter'].includes(event.key)) {
|
|
23
22
|
event.preventDefault();
|
|
24
|
-
const newSelected = event.currentTarget.id === selected ?
|
|
23
|
+
const newSelected = event.currentTarget.id === selected ? '' : event.currentTarget.id;
|
|
25
24
|
setSelected(newSelected);
|
|
26
25
|
}
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
const onClick = (event: React.MouseEvent) => {
|
|
30
|
-
const newSelected = event.currentTarget.id === selected ?
|
|
29
|
+
const newSelected = event.currentTarget.id === selected ? '' : event.currentTarget.id;
|
|
31
30
|
setSelected(newSelected);
|
|
32
31
|
};
|
|
33
32
|
|
|
34
33
|
const onChange = (_event: React.FormEvent<HTMLInputElement>, labelledById: string) => {
|
|
35
|
-
const newSelected = labelledById === selected ?
|
|
34
|
+
const newSelected = labelledById === selected ? '' : labelledById;
|
|
36
35
|
setSelected(newSelected);
|
|
37
36
|
};
|
|
38
37
|
|
|
@@ -44,8 +43,8 @@ export const CardSelectable: React.FunctionComponent = () => {
|
|
|
44
43
|
setIsKebabOpen(isOpen);
|
|
45
44
|
};
|
|
46
45
|
|
|
47
|
-
const onSelect = (event: React.SyntheticEvent<HTMLDivElement>) => {
|
|
48
|
-
event
|
|
46
|
+
const onSelect = (event: React.SyntheticEvent<HTMLDivElement> | undefined) => {
|
|
47
|
+
event?.stopPropagation();
|
|
49
48
|
setIsKebabOpen(false);
|
|
50
49
|
};
|
|
51
50
|
|
|
@@ -67,6 +66,19 @@ export const CardSelectable: React.FunctionComponent = () => {
|
|
|
67
66
|
</DropdownItem>
|
|
68
67
|
];
|
|
69
68
|
|
|
69
|
+
const headerActions = (
|
|
70
|
+
<>
|
|
71
|
+
<Dropdown
|
|
72
|
+
onSelect={onSelect}
|
|
73
|
+
toggle={<KebabToggle onToggle={onToggle} />}
|
|
74
|
+
isOpen={isKebabOpen}
|
|
75
|
+
isPlain
|
|
76
|
+
dropdownItems={dropdownItems}
|
|
77
|
+
position={'right'}
|
|
78
|
+
/>
|
|
79
|
+
</>
|
|
80
|
+
);
|
|
81
|
+
|
|
70
82
|
return (
|
|
71
83
|
<React.Fragment>
|
|
72
84
|
<Card
|
|
@@ -78,18 +90,7 @@ export const CardSelectable: React.FunctionComponent = () => {
|
|
|
78
90
|
isSelectableRaised
|
|
79
91
|
isSelected={selected === 'selectable-first-card'}
|
|
80
92
|
>
|
|
81
|
-
<CardHeader
|
|
82
|
-
<CardActions>
|
|
83
|
-
<Dropdown
|
|
84
|
-
onSelect={onSelect}
|
|
85
|
-
toggle={<KebabToggle onToggle={onToggle} />}
|
|
86
|
-
isOpen={isKebabOpen}
|
|
87
|
-
isPlain
|
|
88
|
-
dropdownItems={dropdownItems}
|
|
89
|
-
position={'right'}
|
|
90
|
-
/>
|
|
91
|
-
</CardActions>
|
|
92
|
-
</CardHeader>
|
|
93
|
+
<CardHeader actions={{actions: headerActions}}/>
|
|
93
94
|
<CardTitle>First card</CardTitle>
|
|
94
95
|
<CardBody>This is a selectable card. Click me to select me. Click again to deselect me.</CardBody>
|
|
95
96
|
</Card>
|