@patternfly/react-core 4.236.14 → 4.237.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/Button/Button.d.ts +10 -0
- package/dist/esm/components/Button/Button.d.ts.map +1 -1
- package/dist/esm/components/Button/Button.js +5 -2
- package/dist/esm/components/Button/Button.js.map +1 -1
- package/dist/js/components/Button/Button.d.ts +10 -0
- package/dist/js/components/Button/Button.d.ts.map +1 -1
- package/dist/js/components/Button/Button.js +5 -2
- package/dist/js/components/Button/Button.js.map +1 -1
- package/dist/umd/react-core.min.css +98 -98
- package/dist/umd/react-core.min.js +3 -3
- package/package.json +5 -5
- package/src/components/Button/Button.tsx +19 -0
- package/src/components/Button/examples/Button.md +8 -1
- package/src/components/Button/examples/ButtonWithCount.tsx +89 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.237.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",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"generate": "node scripts/copyStyles.js"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@patternfly/react-icons": "^4.
|
|
48
|
-
"@patternfly/react-styles": "^4.
|
|
49
|
-
"@patternfly/react-tokens": "^4.
|
|
47
|
+
"@patternfly/react-icons": "^4.88.0",
|
|
48
|
+
"@patternfly/react-styles": "^4.87.0",
|
|
49
|
+
"@patternfly/react-tokens": "^4.89.0",
|
|
50
50
|
"focus-trap": "6.9.2",
|
|
51
51
|
"react-dropzone": "9.0.0",
|
|
52
52
|
"tippy.js": "5.1.2",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^16.8.0 || ^17.0.0",
|
|
71
71
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "cd1d1c0a95c7a848754272964ee52c5575554829"
|
|
74
74
|
}
|
|
@@ -3,6 +3,7 @@ import styles from '@patternfly/react-styles/css/components/Button/button';
|
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { Spinner, spinnerSize } from '../Spinner';
|
|
5
5
|
import { useOUIAProps, OUIAProps } from '../../helpers';
|
|
6
|
+
import { Badge } from '../Badge';
|
|
6
7
|
|
|
7
8
|
export enum ButtonVariant {
|
|
8
9
|
primary = 'primary',
|
|
@@ -20,6 +21,16 @@ export enum ButtonType {
|
|
|
20
21
|
submit = 'submit',
|
|
21
22
|
reset = 'reset'
|
|
22
23
|
}
|
|
24
|
+
|
|
25
|
+
export interface BadgeCountObject {
|
|
26
|
+
/** Adds styling to the badge to indicate it has been read */
|
|
27
|
+
isRead?: boolean;
|
|
28
|
+
/** Adds count number right of button */
|
|
29
|
+
count?: number;
|
|
30
|
+
/** Additional classes added to the badge count */
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
23
34
|
export interface ButtonProps extends Omit<React.HTMLProps<HTMLButtonElement>, 'ref'>, OUIAProps {
|
|
24
35
|
/** Content rendered inside the button */
|
|
25
36
|
children?: React.ReactNode;
|
|
@@ -67,6 +78,8 @@ export interface ButtonProps extends Omit<React.HTMLProps<HTMLButtonElement>, 'r
|
|
|
67
78
|
isDanger?: boolean;
|
|
68
79
|
/** Forwarded ref */
|
|
69
80
|
innerRef?: React.Ref<any>;
|
|
81
|
+
/** Adds count number to button */
|
|
82
|
+
countOptions?: BadgeCountObject;
|
|
70
83
|
}
|
|
71
84
|
|
|
72
85
|
const ButtonBase: React.FunctionComponent<ButtonProps> = ({
|
|
@@ -95,6 +108,7 @@ const ButtonBase: React.FunctionComponent<ButtonProps> = ({
|
|
|
95
108
|
ouiaSafe = true,
|
|
96
109
|
tabIndex = null,
|
|
97
110
|
innerRef,
|
|
111
|
+
countOptions,
|
|
98
112
|
...props
|
|
99
113
|
}: ButtonProps) => {
|
|
100
114
|
const ouiaProps = useOUIAProps(Button.displayName, ouiaId, ouiaSafe, variant);
|
|
@@ -168,6 +182,11 @@ const ButtonBase: React.FunctionComponent<ButtonProps> = ({
|
|
|
168
182
|
{variant !== ButtonVariant.plain && icon && iconPosition === 'right' && (
|
|
169
183
|
<span className={css(styles.buttonIcon, styles.modifiers.end)}>{icon}</span>
|
|
170
184
|
)}
|
|
185
|
+
{countOptions && (
|
|
186
|
+
<span className={css(styles.buttonCount, countOptions.className)}>
|
|
187
|
+
<Badge isRead={countOptions.isRead}>{countOptions.count}</Badge>
|
|
188
|
+
</span>
|
|
189
|
+
)}
|
|
171
190
|
</Component>
|
|
172
191
|
);
|
|
173
192
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
id: Button
|
|
3
3
|
section: components
|
|
4
4
|
cssPrefix: pf-c-button
|
|
5
|
-
propComponents: ['Button']
|
|
5
|
+
propComponents: ['Button', 'BadgeCountObject']
|
|
6
6
|
ouia: true
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -111,4 +111,11 @@ Unlike normal disabled buttons, aria-disabled buttons can support tooltips.
|
|
|
111
111
|
Aria-disabled buttons can operate as links, which also support tooltips.
|
|
112
112
|
|
|
113
113
|
```ts file="./ButtonAriaDisabledLinkTooltip.tsx"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Button with count
|
|
117
|
+
|
|
118
|
+
Buttons can display a `count` in the form of a badge to indicate some value or number by passing in the `countOptions` prop as a `BadgeCountObject` object. The `BadgeCountObject` object will handle `count`, `isRead`, and `className` props for the badge count.
|
|
119
|
+
|
|
120
|
+
```ts file="./ButtonWithCount.tsx" isBeta
|
|
114
121
|
```
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BadgeCountObject, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ButtonWithCount: React.FunctionComponent = () => {
|
|
5
|
+
const badgeCountObjectNotRead: BadgeCountObject = {
|
|
6
|
+
isRead: false,
|
|
7
|
+
count: 7,
|
|
8
|
+
className: 'custom-badge-unread'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const badgeCountObjectRead: BadgeCountObject = {
|
|
12
|
+
isRead: true,
|
|
13
|
+
count: 10,
|
|
14
|
+
className: 'custom-badge-read'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<React.Fragment>
|
|
19
|
+
<p>Unread:</p>
|
|
20
|
+
<Button variant="primary" countOptions={badgeCountObjectNotRead}>
|
|
21
|
+
View issues
|
|
22
|
+
</Button>{' '}
|
|
23
|
+
<Button variant="secondary" countOptions={badgeCountObjectNotRead}>
|
|
24
|
+
View issues
|
|
25
|
+
</Button>{' '}
|
|
26
|
+
<Button variant="tertiary" countOptions={badgeCountObjectNotRead}>
|
|
27
|
+
View issues
|
|
28
|
+
</Button>{' '}
|
|
29
|
+
<Button variant="control" countOptions={badgeCountObjectNotRead}>
|
|
30
|
+
View issues
|
|
31
|
+
</Button>{' '}
|
|
32
|
+
<Button variant="link" countOptions={badgeCountObjectNotRead}>
|
|
33
|
+
View issues
|
|
34
|
+
</Button>{' '}
|
|
35
|
+
<br />
|
|
36
|
+
<p>Unread disabled:</p>
|
|
37
|
+
<Button variant="primary" isDisabled countOptions={badgeCountObjectNotRead}>
|
|
38
|
+
View issues
|
|
39
|
+
</Button>{' '}
|
|
40
|
+
<Button variant="secondary" isDisabled countOptions={badgeCountObjectNotRead}>
|
|
41
|
+
View issues
|
|
42
|
+
</Button>{' '}
|
|
43
|
+
<Button variant="tertiary" isDisabled countOptions={badgeCountObjectNotRead}>
|
|
44
|
+
View issues
|
|
45
|
+
</Button>{' '}
|
|
46
|
+
<Button variant="control" isDisabled countOptions={badgeCountObjectNotRead}>
|
|
47
|
+
View issues
|
|
48
|
+
</Button>{' '}
|
|
49
|
+
<Button variant="link" isDisabled countOptions={badgeCountObjectNotRead}>
|
|
50
|
+
View issues
|
|
51
|
+
</Button>{' '}
|
|
52
|
+
<br />
|
|
53
|
+
<p>Read:</p>
|
|
54
|
+
<Button variant="primary" countOptions={badgeCountObjectRead}>
|
|
55
|
+
View issues
|
|
56
|
+
</Button>{' '}
|
|
57
|
+
<Button variant="secondary" countOptions={badgeCountObjectRead}>
|
|
58
|
+
View issues
|
|
59
|
+
</Button>{' '}
|
|
60
|
+
<Button variant="tertiary" countOptions={badgeCountObjectRead}>
|
|
61
|
+
View issues
|
|
62
|
+
</Button>{' '}
|
|
63
|
+
<Button variant="control" countOptions={badgeCountObjectRead}>
|
|
64
|
+
View issues
|
|
65
|
+
</Button>{' '}
|
|
66
|
+
<Button variant="link" countOptions={badgeCountObjectRead}>
|
|
67
|
+
View issues
|
|
68
|
+
</Button>{' '}
|
|
69
|
+
<br />
|
|
70
|
+
<p>Read disabled:</p>
|
|
71
|
+
<Button variant="primary" isDisabled countOptions={badgeCountObjectRead}>
|
|
72
|
+
View issues
|
|
73
|
+
</Button>{' '}
|
|
74
|
+
<Button variant="secondary" isDisabled countOptions={badgeCountObjectRead}>
|
|
75
|
+
View issues
|
|
76
|
+
</Button>{' '}
|
|
77
|
+
<Button variant="tertiary" isDisabled countOptions={badgeCountObjectRead}>
|
|
78
|
+
View issues
|
|
79
|
+
</Button>{' '}
|
|
80
|
+
<Button variant="control" isDisabled countOptions={badgeCountObjectRead}>
|
|
81
|
+
View issues
|
|
82
|
+
</Button>{' '}
|
|
83
|
+
<Button variant="link" isDisabled countOptions={badgeCountObjectRead}>
|
|
84
|
+
View issues
|
|
85
|
+
</Button>{' '}
|
|
86
|
+
<br />
|
|
87
|
+
</React.Fragment>
|
|
88
|
+
);
|
|
89
|
+
};
|