@patternfly/react-core 4.174.2 → 4.175.0
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 +11 -0
- package/dist/esm/components/Card/Card.d.ts +6 -0
- package/dist/esm/components/Card/Card.d.ts.map +1 -1
- package/dist/esm/components/Card/Card.js +2 -2
- package/dist/esm/components/Card/Card.js.map +1 -1
- package/dist/esm/components/Panel/Panel.d.ts +13 -0
- package/dist/esm/components/Panel/Panel.d.ts.map +1 -0
- package/dist/esm/components/Panel/Panel.js +10 -0
- package/dist/esm/components/Panel/Panel.js.map +1 -0
- package/dist/esm/components/Panel/PanelFooter.d.ts +9 -0
- package/dist/esm/components/Panel/PanelFooter.d.ts.map +1 -0
- package/dist/esm/components/Panel/PanelFooter.js +10 -0
- package/dist/esm/components/Panel/PanelFooter.js.map +1 -0
- package/dist/esm/components/Panel/PanelHeader.d.ts +9 -0
- package/dist/esm/components/Panel/PanelHeader.d.ts.map +1 -0
- package/dist/esm/components/Panel/PanelHeader.js +10 -0
- package/dist/esm/components/Panel/PanelHeader.js.map +1 -0
- package/dist/esm/components/Panel/PanelMain.d.ts +11 -0
- package/dist/esm/components/Panel/PanelMain.d.ts.map +1 -0
- package/dist/esm/components/Panel/PanelMain.js +10 -0
- package/dist/esm/components/Panel/PanelMain.js.map +1 -0
- package/dist/esm/components/Panel/PanelMainBody.d.ts +9 -0
- package/dist/esm/components/Panel/PanelMainBody.d.ts.map +1 -0
- package/dist/esm/components/Panel/PanelMainBody.js +10 -0
- package/dist/esm/components/Panel/PanelMainBody.js.map +1 -0
- package/dist/esm/components/Panel/index.d.ts +6 -0
- package/dist/esm/components/Panel/index.d.ts.map +1 -0
- package/dist/esm/components/Panel/index.js +6 -0
- package/dist/esm/components/Panel/index.js.map +1 -0
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/js/components/Card/Card.d.ts +6 -0
- package/dist/js/components/Card/Card.d.ts.map +1 -1
- package/dist/js/components/Card/Card.js +2 -2
- package/dist/js/components/Card/Card.js.map +1 -1
- package/dist/js/components/Panel/Panel.d.ts +13 -0
- package/dist/js/components/Panel/Panel.d.ts.map +1 -0
- package/dist/js/components/Panel/Panel.js +14 -0
- package/dist/js/components/Panel/Panel.js.map +1 -0
- package/dist/js/components/Panel/PanelFooter.d.ts +9 -0
- package/dist/js/components/Panel/PanelFooter.d.ts.map +1 -0
- package/dist/js/components/Panel/PanelFooter.js +14 -0
- package/dist/js/components/Panel/PanelFooter.js.map +1 -0
- package/dist/js/components/Panel/PanelHeader.d.ts +9 -0
- package/dist/js/components/Panel/PanelHeader.d.ts.map +1 -0
- package/dist/js/components/Panel/PanelHeader.js +14 -0
- package/dist/js/components/Panel/PanelHeader.js.map +1 -0
- package/dist/js/components/Panel/PanelMain.d.ts +11 -0
- package/dist/js/components/Panel/PanelMain.d.ts.map +1 -0
- package/dist/js/components/Panel/PanelMain.js +14 -0
- package/dist/js/components/Panel/PanelMain.js.map +1 -0
- package/dist/js/components/Panel/PanelMainBody.d.ts +9 -0
- package/dist/js/components/Panel/PanelMainBody.d.ts.map +1 -0
- package/dist/js/components/Panel/PanelMainBody.js +14 -0
- package/dist/js/components/Panel/PanelMainBody.js.map +1 -0
- package/dist/js/components/Panel/index.d.ts +6 -0
- package/dist/js/components/Panel/index.d.ts.map +1 -0
- package/dist/js/components/Panel/index.js +9 -0
- package/dist/js/components/Panel/index.js.map +1 -0
- package/dist/js/components/index.d.ts +1 -0
- package/dist/js/components/index.d.ts.map +1 -1
- package/dist/js/components/index.js +1 -0
- package/dist/js/components/index.js.map +1 -1
- package/dist/umd/react-core.css +83 -0
- package/dist/umd/react-core.js +930 -882
- package/dist/umd/react-core.min.css +152 -69
- package/dist/umd/react-core.min.js +4 -4
- package/package.json +5 -5
- package/src/components/Card/Card.tsx +15 -3
- package/src/components/Card/__tests__/Card.test.tsx +24 -0
- package/src/components/Card/__tests__/__snapshots__/Card.test.tsx.snap +11 -1
- package/src/components/Card/examples/Card.md +133 -26
- package/src/components/Panel/Panel.tsx +37 -0
- package/src/components/Panel/PanelFooter.tsx +22 -0
- package/src/components/Panel/PanelHeader.tsx +22 -0
- package/src/components/Panel/PanelMain.tsx +29 -0
- package/src/components/Panel/PanelMainBody.tsx +22 -0
- package/src/components/Panel/__tests__/Panel.test.tsx +62 -0
- package/src/components/Panel/__tests__/__snapshots__/Panel.test.tsx.snap +83 -0
- package/src/components/Panel/examples/Panel.md +203 -0
- package/src/components/Panel/index.ts +5 -0
- package/src/components/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.175.0",
|
|
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",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.
|
|
38
|
-
"@patternfly/react-styles": "^4.
|
|
39
|
-
"@patternfly/react-tokens": "^4.
|
|
37
|
+
"@patternfly/react-icons": "^4.26.0",
|
|
38
|
+
"@patternfly/react-styles": "^4.25.0",
|
|
39
|
+
"@patternfly/react-tokens": "^4.27.0",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "10.2.2",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "031e0e31853e92aae5dc072a24fdea96403f0472"
|
|
64
64
|
}
|
|
@@ -14,12 +14,18 @@ export interface CardProps extends React.HTMLProps<HTMLElement>, OUIAProps {
|
|
|
14
14
|
component?: keyof JSX.IntrinsicElements;
|
|
15
15
|
/** Modifies the card to include hover styles on :hover */
|
|
16
16
|
isHoverable?: boolean;
|
|
17
|
+
/** Modifies the card to include hoverable-raised styles on :hover, this styling is included by default with isSelectableRaised */
|
|
18
|
+
isHoverableRaised?: boolean;
|
|
17
19
|
/** Modifies the card to include compact styling. Should not be used with isLarge. */
|
|
18
20
|
isCompact?: boolean;
|
|
19
21
|
/** Modifies the card to include selectable styling */
|
|
20
22
|
isSelectable?: boolean;
|
|
21
23
|
/** Modifies the card to include selected styling */
|
|
22
24
|
isSelected?: boolean;
|
|
25
|
+
/** Modifies the card to include selectable-raised styling and hoverable-raised styling */
|
|
26
|
+
isSelectableRaised?: boolean;
|
|
27
|
+
/** Modifies the card to include selected-raised styling */
|
|
28
|
+
isSelectedRaised?: boolean;
|
|
23
29
|
/** Modifies the card to include flat styling */
|
|
24
30
|
isFlat?: boolean;
|
|
25
31
|
/** Modifies the card to include rounded styling */
|
|
@@ -50,9 +56,12 @@ export const Card: React.FunctionComponent<CardProps> = ({
|
|
|
50
56
|
className = '',
|
|
51
57
|
component = 'article',
|
|
52
58
|
isHoverable = false,
|
|
59
|
+
isHoverableRaised = false,
|
|
53
60
|
isCompact = false,
|
|
54
61
|
isSelectable = false,
|
|
55
62
|
isSelected = false,
|
|
63
|
+
isSelectableRaised = false,
|
|
64
|
+
isSelectedRaised = false,
|
|
56
65
|
isFlat = false,
|
|
57
66
|
isExpanded = false,
|
|
58
67
|
isRounded = false,
|
|
@@ -82,9 +91,12 @@ export const Card: React.FunctionComponent<CardProps> = ({
|
|
|
82
91
|
className={css(
|
|
83
92
|
styles.card,
|
|
84
93
|
isHoverable && styles.modifiers.hoverable,
|
|
94
|
+
isHoverableRaised && styles.modifiers.hoverableRaised,
|
|
85
95
|
isCompact && styles.modifiers.compact,
|
|
86
|
-
isSelectable && styles.modifiers.selectable,
|
|
87
|
-
isSelected && isSelectable && styles.modifiers.selected,
|
|
96
|
+
isSelectable && !isSelectableRaised && styles.modifiers.selectable,
|
|
97
|
+
isSelected && !isSelectedRaised && isSelectable && styles.modifiers.selected,
|
|
98
|
+
isSelectableRaised && styles.modifiers.selectableRaised,
|
|
99
|
+
isSelectedRaised && isSelectableRaised && styles.modifiers.selectedRaised,
|
|
88
100
|
isExpanded && styles.modifiers.expanded,
|
|
89
101
|
isFlat && styles.modifiers.flat,
|
|
90
102
|
isRounded && styles.modifiers.rounded,
|
|
@@ -93,7 +105,7 @@ export const Card: React.FunctionComponent<CardProps> = ({
|
|
|
93
105
|
isPlain && styles.modifiers.plain,
|
|
94
106
|
className
|
|
95
107
|
)}
|
|
96
|
-
tabIndex={isSelectable ? '0' : undefined}
|
|
108
|
+
tabIndex={isSelectableRaised || isSelectable ? '0' : undefined}
|
|
97
109
|
{...props}
|
|
98
110
|
{...ouiaProps}
|
|
99
111
|
>
|
|
@@ -35,6 +35,11 @@ test('card with isHoverable applied ', () => {
|
|
|
35
35
|
expect(view).toMatchSnapshot();
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
+
test('card with isHoverableRaised applied ', () => {
|
|
39
|
+
const view = shallow(<Card isHoverableRaised />).dive();
|
|
40
|
+
expect(view).toMatchSnapshot();
|
|
41
|
+
});
|
|
42
|
+
|
|
38
43
|
test('card with isCompact applied ', () => {
|
|
39
44
|
const view = shallow(<Card isCompact />).dive();
|
|
40
45
|
expect(view).toMatchSnapshot();
|
|
@@ -59,6 +64,25 @@ test('card with only isSelected applied - not change', () => {
|
|
|
59
64
|
expect(view.prop('tabIndex')).toBe(undefined);
|
|
60
65
|
});
|
|
61
66
|
|
|
67
|
+
test('card with isSelectableRaised applied ', () => {
|
|
68
|
+
const view = shallow(<Card isSelectableRaised />).dive();
|
|
69
|
+
expect(view.prop('className')).toMatch(/selectable-raised/);
|
|
70
|
+
expect(view.prop('tabIndex')).toBe('0');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('card with isSelectableRaised and isSelectedRaised applied ', () => {
|
|
74
|
+
const view = shallow(<Card isSelectableRaised isSelectedRaised />).dive();
|
|
75
|
+
expect(view.prop('className')).toMatch(/selectable-raised/);
|
|
76
|
+
expect(view.prop('className')).toMatch(/selected-raised/);
|
|
77
|
+
expect(view.prop('tabIndex')).toBe('0');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('card with only isSelectedRaised applied - not change', () => {
|
|
81
|
+
const view = shallow(<Card isSelectedRaised />).dive();
|
|
82
|
+
expect(view.prop('className')).not.toMatch(/selected-raised/);
|
|
83
|
+
expect(view.prop('tabIndex')).toBe(undefined);
|
|
84
|
+
});
|
|
85
|
+
|
|
62
86
|
test('card with isFlat applied', () => {
|
|
63
87
|
const view = shallow(<Card isFlat />).dive();
|
|
64
88
|
expect(view.prop('className')).toMatch(/m-flat/);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`card with isCompact applied 1`] = `
|
|
4
4
|
<article
|
|
5
5
|
className="pf-c-card pf-m-compact"
|
|
6
|
-
data-ouia-component-id="OUIA-Generated-Card-
|
|
6
|
+
data-ouia-component-id="OUIA-Generated-Card-8"
|
|
7
7
|
data-ouia-component-type="PF4/Card"
|
|
8
8
|
data-ouia-safe={true}
|
|
9
9
|
id=""
|
|
@@ -20,6 +20,16 @@ exports[`card with isHoverable applied 1`] = `
|
|
|
20
20
|
/>
|
|
21
21
|
`;
|
|
22
22
|
|
|
23
|
+
exports[`card with isHoverableRaised applied 1`] = `
|
|
24
|
+
<article
|
|
25
|
+
className="pf-c-card pf-m-hoverable-raised"
|
|
26
|
+
data-ouia-component-id="OUIA-Generated-Card-7"
|
|
27
|
+
data-ouia-component-type="PF4/Card"
|
|
28
|
+
data-ouia-safe={true}
|
|
29
|
+
id=""
|
|
30
|
+
/>
|
|
31
|
+
`;
|
|
32
|
+
|
|
23
33
|
exports[`className is added to the root element 1`] = `"pf-c-card extra-class"`;
|
|
24
34
|
|
|
25
35
|
exports[`renders with PatternFly Core styles 1`] = `
|
|
@@ -31,21 +31,13 @@ import React from 'react';
|
|
|
31
31
|
import { Card, CardTitle, CardBody, CardFooter, Checkbox } from '@patternfly/react-core';
|
|
32
32
|
|
|
33
33
|
CardModifiers = () => {
|
|
34
|
-
const mods = [
|
|
35
|
-
'isHoverable',
|
|
36
|
-
'isCompact',
|
|
37
|
-
'isFlat',
|
|
38
|
-
'isRounded',
|
|
39
|
-
'isLarge',
|
|
40
|
-
'isFullHeight',
|
|
41
|
-
'isPlain',
|
|
42
|
-
];
|
|
34
|
+
const mods = ['isHoverable', 'isCompact', 'isFlat', 'isRounded', 'isLarge', 'isFullHeight', 'isPlain'];
|
|
43
35
|
const [modifiers, setModifiers] = React.useState({});
|
|
44
36
|
|
|
45
37
|
return (
|
|
46
38
|
<React.Fragment>
|
|
47
39
|
<div style={{ marginBottom: '12px' }}>
|
|
48
|
-
{mods.map(mod =>
|
|
40
|
+
{mods.map(mod => (
|
|
49
41
|
<Checkbox
|
|
50
42
|
id={mod}
|
|
51
43
|
key={mod}
|
|
@@ -53,10 +45,10 @@ CardModifiers = () => {
|
|
|
53
45
|
isChecked={modifiers[mod]}
|
|
54
46
|
onChange={checked => {
|
|
55
47
|
modifiers[mod] = checked;
|
|
56
|
-
setModifiers({...modifiers});
|
|
48
|
+
setModifiers({ ...modifiers });
|
|
57
49
|
}}
|
|
58
50
|
/>
|
|
59
|
-
)}
|
|
51
|
+
))}
|
|
60
52
|
</div>
|
|
61
53
|
<div style={{ height: '15rem' }}>
|
|
62
54
|
<Card {...modifiers}>
|
|
@@ -67,7 +59,7 @@ CardModifiers = () => {
|
|
|
67
59
|
</div>
|
|
68
60
|
</React.Fragment>
|
|
69
61
|
);
|
|
70
|
-
}
|
|
62
|
+
};
|
|
71
63
|
```
|
|
72
64
|
|
|
73
65
|
### With image and actions
|
|
@@ -120,7 +112,7 @@ class KebabDropdown extends React.Component {
|
|
|
120
112
|
this.setState({
|
|
121
113
|
hasNoOffset: checked
|
|
122
114
|
});
|
|
123
|
-
}
|
|
115
|
+
};
|
|
124
116
|
}
|
|
125
117
|
|
|
126
118
|
render() {
|
|
@@ -171,15 +163,15 @@ class KebabDropdown extends React.Component {
|
|
|
171
163
|
<CardBody>Body</CardBody>
|
|
172
164
|
<CardFooter>Footer</CardFooter>
|
|
173
165
|
</Card>
|
|
174
|
-
<div style={{marginTop:
|
|
166
|
+
<div style={{ marginTop: '20px' }}>
|
|
175
167
|
<Checkbox
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
168
|
+
label="actions hasNoOffset"
|
|
169
|
+
isChecked={this.state.hasNoOffset}
|
|
170
|
+
onChange={this.toggleOffset}
|
|
171
|
+
aria-label="remove actions offset"
|
|
172
|
+
id="toggle-actions-offset"
|
|
173
|
+
name="toggle-actions-offset"
|
|
174
|
+
/>
|
|
183
175
|
</div>
|
|
184
176
|
</>
|
|
185
177
|
);
|
|
@@ -483,6 +475,7 @@ class SelectableCard extends React.Component {
|
|
|
483
475
|
return;
|
|
484
476
|
}
|
|
485
477
|
if ([13, 32].includes(event.keyCode)) {
|
|
478
|
+
event.preventDefault();
|
|
486
479
|
const newSelected = event.currentTarget.id === this.state.selected ? null : event.currentTarget.id;
|
|
487
480
|
this.setState({
|
|
488
481
|
selected: newSelected
|
|
@@ -533,8 +526,8 @@ class SelectableCard extends React.Component {
|
|
|
533
526
|
id="first-card"
|
|
534
527
|
onKeyDown={this.onKeyDown}
|
|
535
528
|
onClick={this.onClick}
|
|
536
|
-
|
|
537
|
-
|
|
529
|
+
isSelectableRaised
|
|
530
|
+
isSelectedRaised={selected === 'first-card'}
|
|
538
531
|
>
|
|
539
532
|
<CardHeader>
|
|
540
533
|
<CardActions>
|
|
@@ -556,8 +549,8 @@ class SelectableCard extends React.Component {
|
|
|
556
549
|
id="second-card"
|
|
557
550
|
onKeyDown={this.onKeyDown}
|
|
558
551
|
onClick={this.onClick}
|
|
559
|
-
|
|
560
|
-
|
|
552
|
+
isSelectableRaised
|
|
553
|
+
isSelectedRaised={selected === 'second-card'}
|
|
561
554
|
>
|
|
562
555
|
<CardTitle>Second card</CardTitle>
|
|
563
556
|
<CardBody>This is a selectable card. Click me to select me. Click again to deselect me.</CardBody>
|
|
@@ -828,3 +821,117 @@ class ExpandableIconCard extends React.Component {
|
|
|
828
821
|
}
|
|
829
822
|
}
|
|
830
823
|
```
|
|
824
|
+
|
|
825
|
+
### Legacy selectable and selected
|
|
826
|
+
|
|
827
|
+
```js
|
|
828
|
+
import React from 'react';
|
|
829
|
+
import {
|
|
830
|
+
Card,
|
|
831
|
+
CardHeader,
|
|
832
|
+
CardActions,
|
|
833
|
+
CardTitle,
|
|
834
|
+
CardBody,
|
|
835
|
+
Dropdown,
|
|
836
|
+
DropdownToggle,
|
|
837
|
+
DropdownItem,
|
|
838
|
+
DropdownSeparator,
|
|
839
|
+
KebabToggle
|
|
840
|
+
} from '@patternfly/react-core';
|
|
841
|
+
|
|
842
|
+
class SelectableCard extends React.Component {
|
|
843
|
+
constructor(props) {
|
|
844
|
+
super(props);
|
|
845
|
+
this.state = {
|
|
846
|
+
selected: null
|
|
847
|
+
};
|
|
848
|
+
this.onKeyDown = event => {
|
|
849
|
+
if (event.target !== event.currentTarget) {
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
if ([13, 32].includes(event.keyCode)) {
|
|
853
|
+
event.preventDefault();
|
|
854
|
+
const newSelected = event.currentTarget.id === this.state.selected ? null : event.currentTarget.id;
|
|
855
|
+
this.setState({
|
|
856
|
+
selected: newSelected
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
this.onClick = event => {
|
|
861
|
+
const newSelected = event.currentTarget.id === this.state.selected ? null : event.currentTarget.id;
|
|
862
|
+
this.setState({
|
|
863
|
+
selected: newSelected
|
|
864
|
+
});
|
|
865
|
+
};
|
|
866
|
+
this.onToggle = (isOpen, event) => {
|
|
867
|
+
event.stopPropagation();
|
|
868
|
+
this.setState({
|
|
869
|
+
isOpen
|
|
870
|
+
});
|
|
871
|
+
};
|
|
872
|
+
this.onSelect = event => {
|
|
873
|
+
event.stopPropagation();
|
|
874
|
+
this.setState({
|
|
875
|
+
isOpen: !this.state.isOpen
|
|
876
|
+
});
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
render() {
|
|
880
|
+
const { selected, isOpen } = this.state;
|
|
881
|
+
const dropdownItems = [
|
|
882
|
+
<DropdownItem key="link">Link</DropdownItem>,
|
|
883
|
+
<DropdownItem key="action" component="button">
|
|
884
|
+
Action
|
|
885
|
+
</DropdownItem>,
|
|
886
|
+
<DropdownItem key="disabled link" isDisabled>
|
|
887
|
+
Disabled Link
|
|
888
|
+
</DropdownItem>,
|
|
889
|
+
<DropdownItem key="disabled action" isDisabled component="button">
|
|
890
|
+
Disabled Action
|
|
891
|
+
</DropdownItem>,
|
|
892
|
+
<DropdownSeparator key="separator" />,
|
|
893
|
+
<DropdownItem key="separated link">Separated Link</DropdownItem>,
|
|
894
|
+
<DropdownItem key="separated action" component="button">
|
|
895
|
+
Separated Action
|
|
896
|
+
</DropdownItem>
|
|
897
|
+
];
|
|
898
|
+
return (
|
|
899
|
+
<>
|
|
900
|
+
<Card
|
|
901
|
+
id="first-card"
|
|
902
|
+
onKeyDown={this.onKeyDown}
|
|
903
|
+
onClick={this.onClick}
|
|
904
|
+
isSelectable
|
|
905
|
+
isSelected={selected === 'first-card'}
|
|
906
|
+
>
|
|
907
|
+
<CardHeader>
|
|
908
|
+
<CardActions>
|
|
909
|
+
<Dropdown
|
|
910
|
+
onSelect={this.onSelect}
|
|
911
|
+
toggle={<KebabToggle onToggle={this.onToggle} />}
|
|
912
|
+
isOpen={isOpen}
|
|
913
|
+
isPlain
|
|
914
|
+
dropdownItems={dropdownItems}
|
|
915
|
+
position={'right'}
|
|
916
|
+
/>
|
|
917
|
+
</CardActions>
|
|
918
|
+
</CardHeader>
|
|
919
|
+
<CardTitle>First card</CardTitle>
|
|
920
|
+
<CardBody>This is a selectable card. Click me to select me. Click again to deselect me.</CardBody>
|
|
921
|
+
</Card>
|
|
922
|
+
<br />
|
|
923
|
+
<Card
|
|
924
|
+
id="second-card"
|
|
925
|
+
onKeyDown={this.onKeyDown}
|
|
926
|
+
onClick={this.onClick}
|
|
927
|
+
isSelectable
|
|
928
|
+
isSelected={selected === 'second-card'}
|
|
929
|
+
>
|
|
930
|
+
<CardTitle>Second card</CardTitle>
|
|
931
|
+
<CardBody>This is a selectable card. Click me to select me. Click again to deselect me.</CardBody>
|
|
932
|
+
</Card>
|
|
933
|
+
</>
|
|
934
|
+
);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styles from '@patternfly/react-styles/css/components/Panel/panel';
|
|
3
|
+
import { css } from '@patternfly/react-styles';
|
|
4
|
+
|
|
5
|
+
export interface PanelProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
+
/** Content rendered inside the panel */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** Class to add to outer div */
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Adds panel variant styles */
|
|
11
|
+
variant?: 'raised' | 'bordered';
|
|
12
|
+
/** Flag to add scrollable styling to the panel */
|
|
13
|
+
isScrollable?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const Panel: React.FunctionComponent<PanelProps> = ({
|
|
17
|
+
className,
|
|
18
|
+
children,
|
|
19
|
+
variant,
|
|
20
|
+
isScrollable,
|
|
21
|
+
...props
|
|
22
|
+
}: PanelProps) => (
|
|
23
|
+
<div
|
|
24
|
+
className={css(
|
|
25
|
+
styles.panel,
|
|
26
|
+
variant === 'raised' && styles.modifiers.raised,
|
|
27
|
+
variant === 'bordered' && styles.modifiers.bordered,
|
|
28
|
+
isScrollable && styles.modifiers.scrollable,
|
|
29
|
+
className
|
|
30
|
+
)}
|
|
31
|
+
{...props}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
Panel.displayName = 'Panel';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styles from '@patternfly/react-styles/css/components/Panel/panel';
|
|
3
|
+
import { css } from '@patternfly/react-styles';
|
|
4
|
+
|
|
5
|
+
export interface PanelFooterProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
+
/** Content rendered inside the panel footer */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** Class to add to outer div */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const PanelFooter: React.FunctionComponent<PanelFooterProps> = ({
|
|
13
|
+
className,
|
|
14
|
+
children,
|
|
15
|
+
...props
|
|
16
|
+
}: PanelFooterProps) => (
|
|
17
|
+
<div className={css(styles.panelFooter, className)} {...props}>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
PanelFooter.displayName = 'PanelFooter';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styles from '@patternfly/react-styles/css/components/Panel/panel';
|
|
3
|
+
import { css } from '@patternfly/react-styles';
|
|
4
|
+
|
|
5
|
+
export interface PanelHeaderProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
+
/** Content rendered inside the panel header */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** Class to add to outer div */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const PanelHeader: React.FunctionComponent<PanelHeaderProps> = ({
|
|
13
|
+
className,
|
|
14
|
+
children,
|
|
15
|
+
...props
|
|
16
|
+
}: PanelHeaderProps) => (
|
|
17
|
+
<div className={css(styles.panelHeader, className)} {...props}>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
PanelHeader.displayName = 'PanelHeader';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styles from '@patternfly/react-styles/css/components/Panel/panel';
|
|
3
|
+
import { css } from '@patternfly/react-styles';
|
|
4
|
+
|
|
5
|
+
export interface PanelMainProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
+
/** Content rendered inside the panel main div */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** Class to add to outer div */
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Max height of the panel main div as a string with the value and unit */
|
|
11
|
+
maxHeight?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const PanelMain: React.FunctionComponent<PanelMainProps> = ({
|
|
15
|
+
className,
|
|
16
|
+
children,
|
|
17
|
+
maxHeight,
|
|
18
|
+
...props
|
|
19
|
+
}: PanelMainProps) => (
|
|
20
|
+
<div
|
|
21
|
+
className={css(styles.panelMain, className)}
|
|
22
|
+
style={{ '--pf-c-panel__main--MaxHeight': maxHeight } as React.CSSProperties}
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
PanelMain.displayName = 'PanelMain';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styles from '@patternfly/react-styles/css/components/Panel/panel';
|
|
3
|
+
import { css } from '@patternfly/react-styles';
|
|
4
|
+
|
|
5
|
+
export interface PanelMainBodyProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
+
/** Content rendered inside the panel main body div */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** Class to add to outer div */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const PanelMainBody: React.FunctionComponent<PanelMainBodyProps> = ({
|
|
13
|
+
className,
|
|
14
|
+
children,
|
|
15
|
+
...props
|
|
16
|
+
}: PanelMainBodyProps) => (
|
|
17
|
+
<div className={css(styles.panelMainBody, className)} {...props}>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
PanelMainBody.displayName = 'PanelMainBody';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { Panel } from '../Panel';
|
|
4
|
+
import { PanelMain } from '../PanelMain';
|
|
5
|
+
import { PanelMainBody } from '../PanelMainBody';
|
|
6
|
+
import { PanelHeader } from '../PanelHeader';
|
|
7
|
+
import { PanelFooter } from '../PanelFooter';
|
|
8
|
+
|
|
9
|
+
describe('Panel', () => {
|
|
10
|
+
test('renders content', () => {
|
|
11
|
+
const view = shallow(<Panel>Foo</Panel>);
|
|
12
|
+
expect(view).toMatchSnapshot();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('renders content with raised styling', () => {
|
|
16
|
+
const view = shallow(<Panel variant='raised'>Foo</Panel>);
|
|
17
|
+
expect(view).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('renders content with bordered styling', () => {
|
|
21
|
+
const view = shallow(<Panel variant='bordered'>Foo</Panel>);
|
|
22
|
+
expect(view).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('renders content with scrollable styling', () => {
|
|
26
|
+
const view = shallow(<Panel isScrollable>Foo</Panel>);
|
|
27
|
+
expect(view).toMatchSnapshot();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('PanelMain', () => {
|
|
32
|
+
test('renders content', () => {
|
|
33
|
+
const view = shallow(<PanelMain>Foo</PanelMain>);
|
|
34
|
+
expect(view).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('renders content with the set maximum height', () => {
|
|
38
|
+
const view = shallow(<PanelMain maxHeight={'80px'}>Foo</PanelMain>);
|
|
39
|
+
expect(view).toMatchSnapshot();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('PanelMainBody', () => {
|
|
44
|
+
test('renders content', () => {
|
|
45
|
+
const view = shallow(<PanelMainBody>Foo</PanelMainBody>);
|
|
46
|
+
expect(view).toMatchSnapshot();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('PanelHeader', () => {
|
|
51
|
+
test('renders content', () => {
|
|
52
|
+
const view = shallow(<PanelHeader>Foo</PanelHeader>);
|
|
53
|
+
expect(view).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('PanelFooter', () => {
|
|
58
|
+
test('renders content', () => {
|
|
59
|
+
const view = shallow(<PanelFooter>Foo</PanelFooter>);
|
|
60
|
+
expect(view).toMatchSnapshot();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Panel renders content 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="pf-c-panel"
|
|
6
|
+
>
|
|
7
|
+
Foo
|
|
8
|
+
</div>
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
exports[`Panel renders content with bordered styling 1`] = `
|
|
12
|
+
<div
|
|
13
|
+
className="pf-c-panel pf-m-bordered"
|
|
14
|
+
>
|
|
15
|
+
Foo
|
|
16
|
+
</div>
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
exports[`Panel renders content with raised styling 1`] = `
|
|
20
|
+
<div
|
|
21
|
+
className="pf-c-panel pf-m-raised"
|
|
22
|
+
>
|
|
23
|
+
Foo
|
|
24
|
+
</div>
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
exports[`Panel renders content with scrollable styling 1`] = `
|
|
28
|
+
<div
|
|
29
|
+
className="pf-c-panel pf-m-scrollable"
|
|
30
|
+
>
|
|
31
|
+
Foo
|
|
32
|
+
</div>
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
exports[`PanelFooter renders content 1`] = `
|
|
36
|
+
<div
|
|
37
|
+
className="pf-c-panel__footer"
|
|
38
|
+
>
|
|
39
|
+
Foo
|
|
40
|
+
</div>
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
exports[`PanelHeader renders content 1`] = `
|
|
44
|
+
<div
|
|
45
|
+
className="pf-c-panel__header"
|
|
46
|
+
>
|
|
47
|
+
Foo
|
|
48
|
+
</div>
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
exports[`PanelMain renders content 1`] = `
|
|
52
|
+
<div
|
|
53
|
+
className="pf-c-panel__main"
|
|
54
|
+
style={
|
|
55
|
+
Object {
|
|
56
|
+
"--pf-c-panel__main--MaxHeight": undefined,
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
>
|
|
60
|
+
Foo
|
|
61
|
+
</div>
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
exports[`PanelMain renders content with the set maximum height 1`] = `
|
|
65
|
+
<div
|
|
66
|
+
className="pf-c-panel__main"
|
|
67
|
+
style={
|
|
68
|
+
Object {
|
|
69
|
+
"--pf-c-panel__main--MaxHeight": "80px",
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
>
|
|
73
|
+
Foo
|
|
74
|
+
</div>
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
exports[`PanelMainBody renders content 1`] = `
|
|
78
|
+
<div
|
|
79
|
+
className="pf-c-panel__main-body"
|
|
80
|
+
>
|
|
81
|
+
Foo
|
|
82
|
+
</div>
|
|
83
|
+
`;
|