@patternfly/react-core 4.180.1 → 4.181.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/Popover/Popover.d.ts +7 -1
- package/dist/esm/components/Popover/Popover.d.ts.map +1 -1
- package/dist/esm/components/Popover/Popover.js +11 -4
- package/dist/esm/components/Popover/Popover.js.map +1 -1
- package/dist/esm/components/Popover/PopoverBody.d.ts +5 -3
- package/dist/esm/components/Popover/PopoverBody.d.ts.map +1 -1
- package/dist/esm/components/Popover/PopoverBody.js +2 -2
- package/dist/esm/components/Popover/PopoverBody.js.map +1 -1
- package/dist/esm/components/Popover/PopoverFooter.d.ts +2 -2
- package/dist/esm/components/Popover/PopoverFooter.d.ts.map +1 -1
- package/dist/esm/components/Popover/PopoverFooter.js.map +1 -1
- package/dist/esm/components/Popover/PopoverHeader.d.ts +15 -5
- package/dist/esm/components/Popover/PopoverHeader.d.ts.map +1 -1
- package/dist/esm/components/Popover/PopoverHeader.js +11 -3
- package/dist/esm/components/Popover/PopoverHeader.js.map +1 -1
- package/dist/esm/components/Popover/PopoverHeaderIcon.d.ts +9 -0
- package/dist/esm/components/Popover/PopoverHeaderIcon.d.ts.map +1 -0
- package/dist/esm/components/Popover/PopoverHeaderIcon.js +10 -0
- package/dist/esm/components/Popover/PopoverHeaderIcon.js.map +1 -0
- package/dist/esm/components/Popover/PopoverHeaderText.d.ts +9 -0
- package/dist/esm/components/Popover/PopoverHeaderText.d.ts.map +1 -0
- package/dist/esm/components/Popover/PopoverHeaderText.js +10 -0
- package/dist/esm/components/Popover/PopoverHeaderText.js.map +1 -0
- package/dist/js/components/Popover/Popover.d.ts +7 -1
- package/dist/js/components/Popover/Popover.d.ts.map +1 -1
- package/dist/js/components/Popover/Popover.js +11 -4
- package/dist/js/components/Popover/Popover.js.map +1 -1
- package/dist/js/components/Popover/PopoverBody.d.ts +5 -3
- package/dist/js/components/Popover/PopoverBody.d.ts.map +1 -1
- package/dist/js/components/Popover/PopoverBody.js +2 -2
- package/dist/js/components/Popover/PopoverBody.js.map +1 -1
- package/dist/js/components/Popover/PopoverFooter.d.ts +2 -2
- package/dist/js/components/Popover/PopoverFooter.d.ts.map +1 -1
- package/dist/js/components/Popover/PopoverFooter.js.map +1 -1
- package/dist/js/components/Popover/PopoverHeader.d.ts +15 -5
- package/dist/js/components/Popover/PopoverHeader.d.ts.map +1 -1
- package/dist/js/components/Popover/PopoverHeader.js +11 -3
- package/dist/js/components/Popover/PopoverHeader.js.map +1 -1
- package/dist/js/components/Popover/PopoverHeaderIcon.d.ts +9 -0
- package/dist/js/components/Popover/PopoverHeaderIcon.d.ts.map +1 -0
- package/dist/js/components/Popover/PopoverHeaderIcon.js +14 -0
- package/dist/js/components/Popover/PopoverHeaderIcon.js.map +1 -0
- package/dist/js/components/Popover/PopoverHeaderText.d.ts +9 -0
- package/dist/js/components/Popover/PopoverHeaderText.d.ts.map +1 -0
- package/dist/js/components/Popover/PopoverHeaderText.js +14 -0
- package/dist/js/components/Popover/PopoverHeaderText.js.map +1 -0
- package/dist/umd/react-core.css +390 -390
- package/dist/umd/react-core.js +32 -8
- package/dist/umd/react-core.min.css +143 -143
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +5 -5
- package/src/components/Popover/Popover.tsx +27 -2
- package/src/components/Popover/PopoverBody.tsx +11 -8
- package/src/components/Popover/PopoverFooter.tsx +7 -7
- package/src/components/Popover/PopoverHeader.tsx +45 -17
- package/src/components/Popover/PopoverHeaderIcon.tsx +21 -0
- package/src/components/Popover/PopoverHeaderText.tsx +21 -0
- package/src/components/Popover/__tests__/Generated/__snapshots__/PopoverHeader.test.tsx.snap +9 -3
- package/src/components/Popover/__tests__/__snapshots__/Popover.test.tsx.snap +12 -0
- package/src/components/Popover/examples/Popover.md +83 -7
- package/src/demos/BackToTop.md +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.181.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.32.0",
|
|
38
|
+
"@patternfly/react-styles": "^4.31.0",
|
|
39
|
+
"@patternfly/react-tokens": "^4.33.0",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
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": "3ed7b56d09464d825db5e8e9af2d3b9a3a841f7a"
|
|
64
64
|
}
|
|
@@ -104,7 +104,7 @@ export interface PopoverProps {
|
|
|
104
104
|
*/
|
|
105
105
|
footerContent?: React.ReactNode | ((hide: () => void) => React.ReactNode);
|
|
106
106
|
/**
|
|
107
|
-
*
|
|
107
|
+
* Simple header content to be placed within a title.
|
|
108
108
|
* If you want to close the popover after an action within the bodyContent, you can use the isVisible prop for manual control,
|
|
109
109
|
* or you can provide a function which will receive a callback as an argument to hide the popover
|
|
110
110
|
* i.e. headerContent={hide => <Button onClick={() => hide()}>Close</Button>}
|
|
@@ -112,6 +112,12 @@ export interface PopoverProps {
|
|
|
112
112
|
headerContent?: React.ReactNode | ((hide: () => void) => React.ReactNode);
|
|
113
113
|
/** Sets the heading level to use for the popover header. Default is h6. */
|
|
114
114
|
headerComponent?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
115
|
+
/** @beta Icon to be displayed in the popover header **/
|
|
116
|
+
headerIcon?: React.ReactNode;
|
|
117
|
+
/** @beta Severity variants for an alert popover. This modifies the color of the header to match the severity. */
|
|
118
|
+
alertSeverityVariant?: 'default' | 'info' | 'warning' | 'success' | 'danger';
|
|
119
|
+
/** @beta Text announced by screen reader when alert severity variant is set to indicate severity level */
|
|
120
|
+
alertSeverityScreenReaderText?: string;
|
|
115
121
|
/** Hides the popover when a click occurs outside (only works if isVisible is not controlled by the user) */
|
|
116
122
|
hideOnOutsideClick?: boolean;
|
|
117
123
|
/**
|
|
@@ -198,6 +204,14 @@ export interface PopoverProps {
|
|
|
198
204
|
tippyProps?: Partial<TippyProps>;
|
|
199
205
|
}
|
|
200
206
|
|
|
207
|
+
const alertStyle = {
|
|
208
|
+
default: styles.modifiers.default,
|
|
209
|
+
info: styles.modifiers.info,
|
|
210
|
+
success: styles.modifiers.success,
|
|
211
|
+
warning: styles.modifiers.warning,
|
|
212
|
+
danger: styles.modifiers.danger
|
|
213
|
+
};
|
|
214
|
+
|
|
201
215
|
export const Popover: React.FunctionComponent<PopoverProps> = ({
|
|
202
216
|
children,
|
|
203
217
|
position = 'top',
|
|
@@ -210,6 +224,9 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
|
|
|
210
224
|
bodyContent,
|
|
211
225
|
headerContent = null,
|
|
212
226
|
headerComponent = 'h6',
|
|
227
|
+
headerIcon = null,
|
|
228
|
+
alertSeverityVariant,
|
|
229
|
+
alertSeverityScreenReaderText,
|
|
213
230
|
footerContent = null,
|
|
214
231
|
appendTo = () => document.body,
|
|
215
232
|
hideOnOutsideClick = true,
|
|
@@ -253,6 +270,7 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
|
|
|
253
270
|
const transitionTimerRef = React.useRef(null);
|
|
254
271
|
const showTimerRef = React.useRef(null);
|
|
255
272
|
const hideTimerRef = React.useRef(null);
|
|
273
|
+
|
|
256
274
|
React.useEffect(() => {
|
|
257
275
|
onMount();
|
|
258
276
|
}, []);
|
|
@@ -383,6 +401,7 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
|
|
|
383
401
|
preventScrollOnDeactivate
|
|
384
402
|
className={css(
|
|
385
403
|
styles.popover,
|
|
404
|
+
alertSeverityVariant && alertStyle[alertSeverityVariant],
|
|
386
405
|
hasNoPadding && styles.modifiers.noPadding,
|
|
387
406
|
hasAutoWidth && styles.modifiers.widthAuto,
|
|
388
407
|
className
|
|
@@ -405,7 +424,13 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
|
|
|
405
424
|
<PopoverContent>
|
|
406
425
|
{showClose && <PopoverCloseButton onClose={closePopover} aria-label={closeBtnAriaLabel} />}
|
|
407
426
|
{headerContent && (
|
|
408
|
-
<PopoverHeader
|
|
427
|
+
<PopoverHeader
|
|
428
|
+
id={`popover-${uniqueId}-header`}
|
|
429
|
+
icon={headerIcon}
|
|
430
|
+
alertSeverityVariant={alertSeverityVariant}
|
|
431
|
+
alertSeverityScreenReaderText={alertSeverityScreenReaderText || `${alertSeverityVariant} alert:`}
|
|
432
|
+
titleHeadingLevel={headerComponent}
|
|
433
|
+
>
|
|
409
434
|
{typeof headerContent === 'function' ? headerContent(hide) : headerContent}
|
|
410
435
|
</PopoverHeader>
|
|
411
436
|
)}
|
|
@@ -2,20 +2,23 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Popover/popover';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
|
|
5
|
+
export interface PopoverBodyProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
+
/** Popover body id */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Popover body content */
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
/** Classes to be applied to the popover body. */
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
5
14
|
export const PopoverBody: React.FunctionComponent<PopoverBodyProps> = ({
|
|
6
15
|
children,
|
|
7
16
|
id,
|
|
17
|
+
className,
|
|
8
18
|
...props
|
|
9
19
|
}: PopoverBodyProps) => (
|
|
10
|
-
<div className={css(styles.popoverBody)} id={id} {...props}>
|
|
20
|
+
<div className={css(styles.popoverBody, className)} id={id} {...props}>
|
|
11
21
|
{children}
|
|
12
22
|
</div>
|
|
13
23
|
);
|
|
14
24
|
PopoverBody.displayName = 'PopoverBody';
|
|
15
|
-
|
|
16
|
-
export interface PopoverBodyProps extends React.HTMLProps<HTMLDivElement> {
|
|
17
|
-
/** PopoverBody id */
|
|
18
|
-
id: string;
|
|
19
|
-
/** PopoverBody content */
|
|
20
|
-
children: React.ReactNode;
|
|
21
|
-
}
|
|
@@ -2,6 +2,13 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Popover/popover';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
|
|
5
|
+
export interface PopoverFooterProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
+
/** Additional classes added to the Popover footer */
|
|
7
|
+
className?: string;
|
|
8
|
+
/** Footer node */
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
export const PopoverFooter: React.FunctionComponent<PopoverFooterProps> = ({
|
|
6
13
|
children,
|
|
7
14
|
className = '',
|
|
@@ -12,10 +19,3 @@ export const PopoverFooter: React.FunctionComponent<PopoverFooterProps> = ({
|
|
|
12
19
|
</footer>
|
|
13
20
|
);
|
|
14
21
|
PopoverFooter.displayName = 'PopoverFooter';
|
|
15
|
-
|
|
16
|
-
export interface PopoverFooterProps extends React.HTMLProps<HTMLDivElement> {
|
|
17
|
-
/** Additional classes added to the Popover Footer */
|
|
18
|
-
className?: string;
|
|
19
|
-
/** Footer node */
|
|
20
|
-
children: React.ReactNode;
|
|
21
|
-
}
|
|
@@ -1,25 +1,53 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { css } from '@patternfly/react-styles';
|
|
3
|
+
import styles from '@patternfly/react-styles/css/components/Popover/popover';
|
|
2
4
|
import { Title, TitleSizes } from '../Title';
|
|
3
|
-
import {
|
|
5
|
+
import { PopoverHeaderIcon } from './PopoverHeaderIcon';
|
|
6
|
+
import { PopoverHeaderText } from './PopoverHeaderText';
|
|
7
|
+
|
|
8
|
+
export interface PopoverHeaderProps extends Omit<React.HTMLProps<HTMLHeadingElement>, 'size'> {
|
|
9
|
+
/** Content of the popover header. */
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
/** Indicates the header contains an icon. */
|
|
12
|
+
icon?: React.ReactNode;
|
|
13
|
+
/** Class to be applied to the header. */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** Heading level of the header title */
|
|
16
|
+
titleHeadingLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
17
|
+
/** Severity variants for an alert popover. This modifies the color of the header to match the severity. */
|
|
18
|
+
alertSeverityVariant?: 'default' | 'info' | 'warning' | 'success' | 'danger';
|
|
19
|
+
/** Id of the header */
|
|
20
|
+
id?: string;
|
|
21
|
+
/** Text announced by screen reader when alert severity variant is set to indicate severity level */
|
|
22
|
+
alertSeverityScreenReaderText?: string;
|
|
23
|
+
}
|
|
4
24
|
|
|
5
25
|
export const PopoverHeader: React.FunctionComponent<PopoverHeaderProps> = ({
|
|
6
26
|
children,
|
|
27
|
+
icon,
|
|
28
|
+
className,
|
|
29
|
+
titleHeadingLevel = 'h6',
|
|
30
|
+
alertSeverityVariant,
|
|
7
31
|
id,
|
|
32
|
+
alertSeverityScreenReaderText,
|
|
8
33
|
...props
|
|
9
|
-
}: PopoverHeaderProps) =>
|
|
10
|
-
|
|
11
|
-
{({ headerComponent }) => (
|
|
12
|
-
<Title headingLevel={headerComponent} size={TitleSizes.md} id={id} {...props}>
|
|
13
|
-
{children}
|
|
14
|
-
</Title>
|
|
15
|
-
)}
|
|
16
|
-
</PopoverContext.Consumer>
|
|
17
|
-
);
|
|
18
|
-
PopoverHeader.displayName = 'PopoverHeader';
|
|
34
|
+
}: PopoverHeaderProps) => {
|
|
35
|
+
const HeadingLevel = titleHeadingLevel;
|
|
19
36
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
37
|
+
return icon || alertSeverityVariant ? (
|
|
38
|
+
<header className={css('pf-c-popover__header', className)} id={id} {...props}>
|
|
39
|
+
<HeadingLevel className={css(styles.popoverTitle, icon && styles.modifiers.icon)}>
|
|
40
|
+
{icon && <PopoverHeaderIcon>{icon}</PopoverHeaderIcon>}
|
|
41
|
+
{alertSeverityVariant && alertSeverityScreenReaderText && (
|
|
42
|
+
<span className="pf-u-screen-reader">{alertSeverityScreenReaderText}</span>
|
|
43
|
+
)}
|
|
44
|
+
<PopoverHeaderText>{children}</PopoverHeaderText>
|
|
45
|
+
</HeadingLevel>
|
|
46
|
+
</header>
|
|
47
|
+
) : (
|
|
48
|
+
<Title headingLevel={titleHeadingLevel} size={TitleSizes.md} id={id} className={className} {...props}>
|
|
49
|
+
{children}
|
|
50
|
+
</Title>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
PopoverHeader.displayName = 'PopoverHeader';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { css } from '@patternfly/react-styles';
|
|
3
|
+
import styles from '@patternfly/react-styles/css/components/Popover/popover';
|
|
4
|
+
|
|
5
|
+
export interface PopoverHeaderIconProps extends React.HTMLProps<HTMLSpanElement> {
|
|
6
|
+
/** Content of the header icon */
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/** Class to be applied to the header icon */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const PopoverHeaderIcon: React.FunctionComponent<PopoverHeaderIconProps> = ({
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
...props
|
|
16
|
+
}: PopoverHeaderIconProps) => (
|
|
17
|
+
<span className={css(styles.popoverTitleIcon, className)} {...props}>
|
|
18
|
+
{children}
|
|
19
|
+
</span>
|
|
20
|
+
);
|
|
21
|
+
PopoverHeaderIcon.displayName = 'PopoverHeaderIcon';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { css } from '@patternfly/react-styles';
|
|
3
|
+
import styles from '@patternfly/react-styles/css/components/Popover/popover';
|
|
4
|
+
|
|
5
|
+
export interface PopoverHeaderTextProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
+
/** Content of the header text */
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/** Class to be applied to the header text */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const PopoverHeaderText: React.FunctionComponent<PopoverHeaderTextProps> = ({
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
...props
|
|
16
|
+
}: PopoverHeaderTextProps) => (
|
|
17
|
+
<span className={css(styles.popoverTitleText, className)} {...props}>
|
|
18
|
+
{children}
|
|
19
|
+
</span>
|
|
20
|
+
);
|
|
21
|
+
PopoverHeaderText.displayName = 'PopoverHeaderText';
|
package/src/components/Popover/__tests__/Generated/__snapshots__/PopoverHeader.test.tsx.snap
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`PopoverHeader should match snapshot (auto-generated) 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
<Title
|
|
5
|
+
headingLevel="h6"
|
|
6
|
+
id="string"
|
|
7
|
+
size="md"
|
|
8
|
+
>
|
|
9
|
+
<div>
|
|
10
|
+
ReactNode
|
|
11
|
+
</div>
|
|
12
|
+
</Title>
|
|
7
13
|
`;
|
|
@@ -62,7 +62,10 @@ exports[`popover can close from content (uncontrolled) 1`] = `
|
|
|
62
62
|
onClose={[Function]}
|
|
63
63
|
/>
|
|
64
64
|
<PopoverHeader
|
|
65
|
+
alertSeverityScreenReaderText="undefined alert:"
|
|
66
|
+
icon={null}
|
|
65
67
|
id="popover-test-header"
|
|
68
|
+
titleHeadingLevel="h6"
|
|
66
69
|
>
|
|
67
70
|
<div>
|
|
68
71
|
Popover header
|
|
@@ -184,7 +187,10 @@ exports[`popover can have a custom minimum width 1`] = `
|
|
|
184
187
|
onClose={[Function]}
|
|
185
188
|
/>
|
|
186
189
|
<PopoverHeader
|
|
190
|
+
alertSeverityScreenReaderText="undefined alert:"
|
|
191
|
+
icon={null}
|
|
187
192
|
id="popover-test-header"
|
|
193
|
+
titleHeadingLevel="h6"
|
|
188
194
|
>
|
|
189
195
|
<div>
|
|
190
196
|
Popover Header
|
|
@@ -289,7 +295,10 @@ exports[`popover can specify position as object value 1`] = `
|
|
|
289
295
|
onClose={[Function]}
|
|
290
296
|
/>
|
|
291
297
|
<PopoverHeader
|
|
298
|
+
alertSeverityScreenReaderText="undefined alert:"
|
|
299
|
+
icon={null}
|
|
292
300
|
id="popover-test-header"
|
|
301
|
+
titleHeadingLevel="h6"
|
|
293
302
|
>
|
|
294
303
|
<div>
|
|
295
304
|
Popover Header
|
|
@@ -394,7 +403,10 @@ exports[`popover renders close-button, header and body 1`] = `
|
|
|
394
403
|
onClose={[Function]}
|
|
395
404
|
/>
|
|
396
405
|
<PopoverHeader
|
|
406
|
+
alertSeverityScreenReaderText="undefined alert:"
|
|
407
|
+
icon={null}
|
|
397
408
|
id="popover-test-header"
|
|
409
|
+
titleHeadingLevel="h6"
|
|
398
410
|
>
|
|
399
411
|
<div>
|
|
400
412
|
Popover Header
|
|
@@ -5,6 +5,13 @@ cssPrefix: pf-c-popover
|
|
|
5
5
|
propComponents: ['Popover']
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
9
|
+
import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
|
|
10
|
+
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
11
|
+
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
|
|
12
|
+
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
13
|
+
import BullhornIcon from '@patternfly/react-icons/dist/esm/icons/bullhorn-icon';
|
|
14
|
+
|
|
8
15
|
## Examples
|
|
9
16
|
|
|
10
17
|
### Basic
|
|
@@ -222,13 +229,11 @@ class AdvancedPopover extends React.Component {
|
|
|
222
229
|
this.setState({ position: event.target.value });
|
|
223
230
|
}}
|
|
224
231
|
>
|
|
225
|
-
{
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
))
|
|
231
|
-
}
|
|
232
|
+
{Object.values(PopoverPosition).map(position => (
|
|
233
|
+
<option key={position} value={position}>
|
|
234
|
+
{position}
|
|
235
|
+
</option>
|
|
236
|
+
))}
|
|
232
237
|
</select>
|
|
233
238
|
<Checkbox
|
|
234
239
|
label="Flip popover if the position falls outside the view"
|
|
@@ -272,3 +277,74 @@ class AdvancedPopover extends React.Component {
|
|
|
272
277
|
}
|
|
273
278
|
}
|
|
274
279
|
```
|
|
280
|
+
|
|
281
|
+
### Popover with icon in the title
|
|
282
|
+
|
|
283
|
+
```ts isBeta
|
|
284
|
+
import React from 'react';
|
|
285
|
+
import { Popover, Button } from '@patternfly/react-core';
|
|
286
|
+
import BullhornIcon from '@patternfly/react-icons/dist/esm/icons/bullhorn-icon';
|
|
287
|
+
|
|
288
|
+
<div style={{ margin: '50px' }}>
|
|
289
|
+
<Popover
|
|
290
|
+
aria-label="Alert popover"
|
|
291
|
+
headerContent="Popover with icon"
|
|
292
|
+
headerIcon={<BullhornIcon />}
|
|
293
|
+
bodyContent={<div>Popovers are triggered by click rather than hover.</div>}
|
|
294
|
+
footerContent="Popover footer"
|
|
295
|
+
>
|
|
296
|
+
<Button>Toggle popover</Button>
|
|
297
|
+
</Popover>
|
|
298
|
+
</div>;
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Alert popover
|
|
302
|
+
|
|
303
|
+
```ts isBeta
|
|
304
|
+
import React from 'react';
|
|
305
|
+
import { Popover, Button } from '@patternfly/react-core';
|
|
306
|
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
307
|
+
import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
|
|
308
|
+
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
309
|
+
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
|
|
310
|
+
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
311
|
+
|
|
312
|
+
const AlertPopover = () => {
|
|
313
|
+
const [alertSeverityVariant, setAlertSeverityVariant] = React.useState('default');
|
|
314
|
+
const alertIcons = {
|
|
315
|
+
default: <BellIcon />,
|
|
316
|
+
info: <InfoCircleIcon />,
|
|
317
|
+
success: <CheckCircleIcon />,
|
|
318
|
+
warning: <ExclamationTriangleIcon />,
|
|
319
|
+
danger: <ExclamationCircleIcon />
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
return (
|
|
323
|
+
<div>
|
|
324
|
+
<div>
|
|
325
|
+
<span style={{ paddingRight: '10px' }}>Alert variant:</span>
|
|
326
|
+
<select aria-label="Popover alert type" onChange={event => setAlertSeverityVariant(event.target.value)}>
|
|
327
|
+
<option value="default">default</option>
|
|
328
|
+
<option value="info">info</option>
|
|
329
|
+
<option value="success">success</option>
|
|
330
|
+
<option value="warning">warning</option>
|
|
331
|
+
<option value="danger">danger</option>
|
|
332
|
+
</select>
|
|
333
|
+
</div>
|
|
334
|
+
<div style={{ margin: '50px' }}>
|
|
335
|
+
<Popover
|
|
336
|
+
aria-label="Alert popover"
|
|
337
|
+
alertSeverityVariant={alertSeverityVariant as 'default' | 'info' | 'warning' | 'success' | 'danger'}
|
|
338
|
+
headerContent="Default popover title"
|
|
339
|
+
headerIcon={alertIcons[alertSeverityVariant]}
|
|
340
|
+
headerComponent="h1"
|
|
341
|
+
bodyContent={<div>Popovers are triggered by click rather than hover.</div>}
|
|
342
|
+
footerContent="Popover footer"
|
|
343
|
+
>
|
|
344
|
+
<Button>Toggle popover</Button>
|
|
345
|
+
</Popover>
|
|
346
|
+
</div>
|
|
347
|
+
</div>
|
|
348
|
+
);
|
|
349
|
+
};
|
|
350
|
+
```
|
package/src/demos/BackToTop.md
CHANGED
|
@@ -12,4 +12,4 @@ import DashboardWrapper from './examples/DashboardWrapper';
|
|
|
12
12
|
Note that `tabIndex={0}` is added to the scrolling `PageSection` of the page to allow keyboard users the ability to focus and scroll.
|
|
13
13
|
|
|
14
14
|
```js isFullscreen file="./examples/BackToTop/BackToTopNameDemo.tsx"
|
|
15
|
-
```
|
|
15
|
+
```
|