@patternfly/react-core 4.236.13 → 4.237.1
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 +30 -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/esm/components/Masthead/Masthead.js +1 -1
- package/dist/esm/components/Masthead/Masthead.js.map +1 -1
- package/dist/esm/components/Page/Page.d.ts +0 -13
- package/dist/esm/components/Page/Page.d.ts.map +1 -1
- package/dist/esm/components/Page/Page.js +3 -13
- package/dist/esm/components/Page/Page.js.map +1 -1
- package/dist/esm/components/Page/PageBreadcrumb.js +1 -1
- package/dist/esm/components/Page/PageBreadcrumb.js.map +1 -1
- package/dist/esm/components/Page/PageContext.d.ts +15 -0
- package/dist/esm/components/Page/PageContext.d.ts.map +1 -0
- package/dist/esm/components/Page/PageContext.js +15 -0
- package/dist/esm/components/Page/PageContext.js.map +1 -0
- package/dist/esm/components/Page/PageGroup.js +1 -1
- package/dist/esm/components/Page/PageGroup.js.map +1 -1
- package/dist/esm/components/Page/PageHeader.js +1 -1
- package/dist/esm/components/Page/PageHeader.js.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsGroup.js +1 -1
- package/dist/esm/components/Page/PageHeaderToolsGroup.js.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsItem.js +1 -1
- package/dist/esm/components/Page/PageHeaderToolsItem.js.map +1 -1
- package/dist/esm/components/Page/PageNavigation.js +1 -1
- package/dist/esm/components/Page/PageNavigation.js.map +1 -1
- package/dist/esm/components/Page/PageSection.js +1 -1
- package/dist/esm/components/Page/PageSection.js.map +1 -1
- package/dist/esm/components/Page/PageSidebar.js +1 -1
- package/dist/esm/components/Page/PageSidebar.js.map +1 -1
- package/dist/esm/components/Page/PageToggleButton.js +1 -1
- package/dist/esm/components/Page/PageToggleButton.js.map +1 -1
- package/dist/esm/components/Page/index.d.ts +1 -0
- package/dist/esm/components/Page/index.d.ts.map +1 -1
- package/dist/esm/components/Page/index.js +1 -0
- package/dist/esm/components/Page/index.js.map +1 -1
- package/dist/esm/components/Toolbar/Toolbar.js +1 -1
- package/dist/esm/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarContent.js +1 -1
- package/dist/esm/components/Toolbar/ToolbarContent.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarGroup.js +1 -1
- package/dist/esm/components/Toolbar/ToolbarGroup.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarItem.js +1 -1
- package/dist/esm/components/Toolbar/ToolbarItem.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.js +1 -1
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.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/js/components/Masthead/Masthead.js +2 -2
- package/dist/js/components/Masthead/Masthead.js.map +1 -1
- package/dist/js/components/Page/Page.d.ts +0 -13
- package/dist/js/components/Page/Page.d.ts.map +1 -1
- package/dist/js/components/Page/Page.js +5 -15
- package/dist/js/components/Page/Page.js.map +1 -1
- package/dist/js/components/Page/PageBreadcrumb.js +2 -2
- package/dist/js/components/Page/PageBreadcrumb.js.map +1 -1
- package/dist/js/components/Page/PageContext.d.ts +15 -0
- package/dist/js/components/Page/PageContext.d.ts.map +1 -0
- package/dist/js/components/Page/PageContext.js +19 -0
- package/dist/js/components/Page/PageContext.js.map +1 -0
- package/dist/js/components/Page/PageGroup.js +2 -2
- package/dist/js/components/Page/PageGroup.js.map +1 -1
- package/dist/js/components/Page/PageHeader.js +2 -2
- package/dist/js/components/Page/PageHeader.js.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsGroup.js +2 -2
- package/dist/js/components/Page/PageHeaderToolsGroup.js.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsItem.js +2 -2
- package/dist/js/components/Page/PageHeaderToolsItem.js.map +1 -1
- package/dist/js/components/Page/PageNavigation.js +2 -2
- package/dist/js/components/Page/PageNavigation.js.map +1 -1
- package/dist/js/components/Page/PageSection.js +2 -2
- package/dist/js/components/Page/PageSection.js.map +1 -1
- package/dist/js/components/Page/PageSidebar.js +2 -2
- package/dist/js/components/Page/PageSidebar.js.map +1 -1
- package/dist/js/components/Page/PageToggleButton.js +2 -2
- package/dist/js/components/Page/PageToggleButton.js.map +1 -1
- package/dist/js/components/Page/index.d.ts +1 -0
- package/dist/js/components/Page/index.d.ts.map +1 -1
- package/dist/js/components/Page/index.js +1 -0
- package/dist/js/components/Page/index.js.map +1 -1
- package/dist/js/components/Toolbar/Toolbar.js +2 -2
- package/dist/js/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarContent.js +2 -2
- package/dist/js/components/Toolbar/ToolbarContent.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarGroup.js +2 -2
- package/dist/js/components/Toolbar/ToolbarGroup.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarItem.js +2 -2
- package/dist/js/components/Toolbar/ToolbarItem.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarToggleGroup.js +2 -2
- package/dist/js/components/Toolbar/ToolbarToggleGroup.js.map +1 -1
- package/dist/umd/react-core.min.css +38 -38
- 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/src/components/Masthead/Masthead.tsx +1 -1
- package/src/components/Menu/examples/Menu.md +1 -1
- package/src/components/Page/Page.tsx +4 -34
- package/src/components/Page/PageBreadcrumb.tsx +1 -1
- package/src/components/Page/PageContext.tsx +27 -0
- package/src/components/Page/PageGroup.tsx +1 -1
- package/src/components/Page/PageHeader.tsx +1 -1
- package/src/components/Page/PageHeaderToolsGroup.tsx +1 -1
- package/src/components/Page/PageHeaderToolsItem.tsx +1 -1
- package/src/components/Page/PageNavigation.tsx +1 -1
- package/src/components/Page/PageSection.tsx +1 -1
- package/src/components/Page/PageSidebar.tsx +1 -1
- package/src/components/Page/PageToggleButton.tsx +1 -1
- package/src/components/Page/__tests__/Page.test.tsx +2 -1
- package/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap +2 -2
- package/src/components/Page/index.ts +1 -0
- package/src/components/Toolbar/Toolbar.tsx +1 -1
- package/src/components/Toolbar/ToolbarContent.tsx +1 -1
- package/src/components/Toolbar/ToolbarGroup.tsx +1 -1
- package/src/components/Toolbar/ToolbarItem.tsx +1 -1
- package/src/components/Toolbar/ToolbarToggleGroup.tsx +1 -1
- package/src/demos/Page/Page.md +10 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.237.1",
|
|
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.1",
|
|
48
|
+
"@patternfly/react-styles": "^4.87.1",
|
|
49
|
+
"@patternfly/react-tokens": "^4.89.1",
|
|
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": "d79e7376228e02cd37e0eec224643d9aa439d010"
|
|
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
|
+
};
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Masthead/masthead';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
5
|
-
import { PageContext } from '../Page/
|
|
5
|
+
import { PageContext } from '../Page/PageContext';
|
|
6
6
|
|
|
7
7
|
export interface MastheadProps extends React.DetailedHTMLProps<React.HTMLProps<HTMLDivElement>, HTMLDivElement> {
|
|
8
8
|
/** Content rendered inside of the masthead */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
id: Menu
|
|
3
3
|
section: components
|
|
4
4
|
cssPrefix: pf-c-menu
|
|
5
|
-
propComponents: ['Menu', 'MenuList', 'MenuItem', 'MenuItemAction', 'MenuContent', 'MenuInput']
|
|
5
|
+
propComponents: ['Menu', 'MenuList', 'MenuItem', 'MenuItemAction', 'MenuContent', 'MenuInput', 'MenuGroup']
|
|
6
6
|
ouia: true
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -5,39 +5,15 @@ import globalBreakpointXl from '@patternfly/react-tokens/dist/esm/global_breakpo
|
|
|
5
5
|
import { debounce, canUseDOM } from '../../helpers/util';
|
|
6
6
|
import { Drawer, DrawerContent, DrawerContentBody, DrawerPanelContent } from '../Drawer';
|
|
7
7
|
import { PageBreadcrumbProps } from './PageBreadcrumb';
|
|
8
|
-
import { PageGroupProps } from './PageGroup';
|
|
8
|
+
import { PageGroup, PageGroupProps } from './PageGroup';
|
|
9
9
|
import { getResizeObserver } from '../../helpers/resizeObserver';
|
|
10
10
|
import { formatBreakpointMods, getBreakpoint, getVerticalBreakpoint } from '../../helpers/util';
|
|
11
|
+
import { PageContextProvider } from './PageContext';
|
|
11
12
|
|
|
12
13
|
export enum PageLayouts {
|
|
13
14
|
vertical = 'vertical',
|
|
14
15
|
horizontal = 'horizontal'
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
export interface PageContextProps {
|
|
18
|
-
isManagedSidebar: boolean;
|
|
19
|
-
onNavToggle: () => void;
|
|
20
|
-
isNavOpen: boolean;
|
|
21
|
-
width: number;
|
|
22
|
-
height: number;
|
|
23
|
-
getBreakpoint: (width: number | null) => 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
24
|
-
getVerticalBreakpoint: (height: number | null) => 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const pageContextDefaults: PageContextProps = {
|
|
28
|
-
isManagedSidebar: false,
|
|
29
|
-
isNavOpen: false,
|
|
30
|
-
onNavToggle: () => null,
|
|
31
|
-
width: null,
|
|
32
|
-
height: null,
|
|
33
|
-
getBreakpoint,
|
|
34
|
-
getVerticalBreakpoint
|
|
35
|
-
};
|
|
36
|
-
export const PageContext = React.createContext<PageContextProps>(pageContextDefaults);
|
|
37
|
-
|
|
38
|
-
export const PageContextProvider = PageContext.Provider;
|
|
39
|
-
export const PageContextConsumer = PageContext.Consumer;
|
|
40
|
-
|
|
41
17
|
export interface PageProps extends React.HTMLProps<HTMLDivElement> {
|
|
42
18
|
/** Content rendered inside the main section of the page layout (e.g. <PageSection />) */
|
|
43
19
|
children?: React.ReactNode;
|
|
@@ -306,17 +282,11 @@ export class Page extends React.Component<PageProps, PageState> {
|
|
|
306
282
|
const isGrouped = isTertiaryNavGrouped || isBreadcrumbGrouped || additionalGroupedContent;
|
|
307
283
|
|
|
308
284
|
const group = isGrouped ? (
|
|
309
|
-
<
|
|
310
|
-
className={css(
|
|
311
|
-
styles.pageMainGroup,
|
|
312
|
-
formatBreakpointMods(groupProps?.stickyOnBreakpoint, styles, 'sticky-', getVerticalBreakpoint(height), true)
|
|
313
|
-
)}
|
|
314
|
-
{...groupProps}
|
|
315
|
-
>
|
|
285
|
+
<PageGroup {...groupProps}>
|
|
316
286
|
{isTertiaryNavGrouped && nav}
|
|
317
287
|
{isBreadcrumbGrouped && crumb}
|
|
318
288
|
{additionalGroupedContent}
|
|
319
|
-
</
|
|
289
|
+
</PageGroup>
|
|
320
290
|
) : null;
|
|
321
291
|
|
|
322
292
|
const main = (
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { css } from '@patternfly/react-styles';
|
|
3
3
|
import styles from '@patternfly/react-styles/css/components/Page/page';
|
|
4
4
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
5
|
-
import { PageContext } from '
|
|
5
|
+
import { PageContext } from './PageContext';
|
|
6
6
|
|
|
7
7
|
export interface PageBreadcrumbProps extends React.HTMLProps<HTMLElement> {
|
|
8
8
|
/** Additional classes to apply to the PageBreadcrumb */
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { getBreakpoint, getVerticalBreakpoint } from '../../helpers/util';
|
|
3
|
+
|
|
4
|
+
export interface PageContextProps {
|
|
5
|
+
isManagedSidebar: boolean;
|
|
6
|
+
onNavToggle: () => void;
|
|
7
|
+
isNavOpen: boolean;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
getBreakpoint: (width: number | null) => 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
11
|
+
getVerticalBreakpoint: (height: number | null) => 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const pageContextDefaults: PageContextProps = {
|
|
15
|
+
isManagedSidebar: false,
|
|
16
|
+
isNavOpen: false,
|
|
17
|
+
onNavToggle: () => null,
|
|
18
|
+
width: null,
|
|
19
|
+
height: null,
|
|
20
|
+
getBreakpoint,
|
|
21
|
+
getVerticalBreakpoint
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const PageContext = React.createContext<PageContextProps>(pageContextDefaults);
|
|
25
|
+
|
|
26
|
+
export const PageContextProvider = PageContext.Provider;
|
|
27
|
+
export const PageContextConsumer = PageContext.Consumer;
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { css } from '@patternfly/react-styles';
|
|
3
3
|
import styles from '@patternfly/react-styles/css/components/Page/page';
|
|
4
4
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
5
|
-
import { PageContext } from '
|
|
5
|
+
import { PageContext } from './PageContext';
|
|
6
6
|
export interface PageGroupProps extends React.HTMLProps<HTMLDivElement> {
|
|
7
7
|
/** Additional classes to apply to the PageGroup */
|
|
8
8
|
className?: string;
|
|
@@ -4,7 +4,7 @@ import styles from '@patternfly/react-styles/css/components/Page/page';
|
|
|
4
4
|
import { css } from '@patternfly/react-styles';
|
|
5
5
|
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
6
6
|
import { Button, ButtonVariant } from '../../components/Button';
|
|
7
|
-
import { PageContextConsumer, PageContextProps } from './
|
|
7
|
+
import { PageContextConsumer, PageContextProps } from './PageContext';
|
|
8
8
|
|
|
9
9
|
export interface PageHeaderProps extends React.HTMLProps<HTMLDivElement> {
|
|
10
10
|
/** Additional classes added to the page header */
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Page/page';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
5
|
-
import { PageContext } from '
|
|
5
|
+
import { PageContext } from './PageContext';
|
|
6
6
|
|
|
7
7
|
export interface PageHeaderToolsGroupProps extends React.HTMLProps<HTMLDivElement> {
|
|
8
8
|
/** Content rendered in the page header tools group */
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Page/page';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
5
|
-
import { PageContext } from '
|
|
5
|
+
import { PageContext } from './PageContext';
|
|
6
6
|
|
|
7
7
|
export interface PageHeaderToolsItemProps extends React.HTMLProps<HTMLDivElement> {
|
|
8
8
|
/** Content rendered in page header tools item. */
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { css } from '@patternfly/react-styles';
|
|
3
3
|
import styles from '@patternfly/react-styles/css/components/Page/page';
|
|
4
4
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
5
|
-
import { PageContext } from '
|
|
5
|
+
import { PageContext } from './PageContext';
|
|
6
6
|
|
|
7
7
|
export interface PageNavigationProps extends React.HTMLProps<HTMLDivElement> {
|
|
8
8
|
/** Additional classes to apply to the PageNavigation */
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Page/page';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
5
|
-
import { PageContext } from '
|
|
5
|
+
import { PageContext } from './PageContext';
|
|
6
6
|
|
|
7
7
|
export enum PageSectionVariants {
|
|
8
8
|
default = 'default',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Page/page';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
|
-
import { PageContextConsumer } from './
|
|
4
|
+
import { PageContextConsumer } from './PageContext';
|
|
5
5
|
|
|
6
6
|
export interface PageSidebarProps extends React.HTMLProps<HTMLDivElement> {
|
|
7
7
|
/** Additional classes added to the page sidebar */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { Button, ButtonProps, ButtonVariant } from '../../components/Button';
|
|
4
|
-
import { PageContextConsumer, PageContextProps } from './
|
|
4
|
+
import { PageContextConsumer, PageContextProps } from './PageContext';
|
|
5
5
|
|
|
6
6
|
export interface PageToggleButtonProps extends ButtonProps {
|
|
7
7
|
/** Content of the page toggle button */
|
|
@@ -356,7 +356,7 @@ describe('Page', () => {
|
|
|
356
356
|
tertiaryNav={nav}
|
|
357
357
|
isBreadcrumbGrouped
|
|
358
358
|
isTertiaryNavGrouped
|
|
359
|
-
groupProps={{ stickyOnBreakpoint: { default: 'bottom' }, hasShadowTop: true }}
|
|
359
|
+
groupProps={{ stickyOnBreakpoint: { default: 'bottom' }, hasShadowTop: true, 'aria-label': 'test' }}
|
|
360
360
|
>
|
|
361
361
|
<PageSection variant="default">Section with default background</PageSection>
|
|
362
362
|
<PageSection variant="light">Section with light background</PageSection>
|
|
@@ -366,6 +366,7 @@ describe('Page', () => {
|
|
|
366
366
|
);
|
|
367
367
|
|
|
368
368
|
expect(screen.getByRole('main')).not.toHaveAttribute('id');
|
|
369
|
+
expect(screen.getByLabelText('test')).toHaveClass('pf-m-shadow-top');
|
|
369
370
|
expect(asFragment()).toMatchSnapshot();
|
|
370
371
|
});
|
|
371
372
|
|
|
@@ -785,8 +785,8 @@ exports[`Page Check page to verify grouped nav and breadcrumb - old / props synt
|
|
|
785
785
|
tabindex="-1"
|
|
786
786
|
>
|
|
787
787
|
<div
|
|
788
|
-
|
|
789
|
-
|
|
788
|
+
aria-label="test"
|
|
789
|
+
class="pf-c-page__main-group pf-m-sticky-bottom pf-m-shadow-top"
|
|
790
790
|
>
|
|
791
791
|
<div
|
|
792
792
|
class="pf-c-page__main-nav"
|
|
@@ -6,7 +6,7 @@ import { ToolbarContext } from './ToolbarUtils';
|
|
|
6
6
|
import { ToolbarChipGroupContent } from './ToolbarChipGroupContent';
|
|
7
7
|
import { formatBreakpointMods, canUseDOM } from '../../helpers/util';
|
|
8
8
|
import { getDefaultOUIAId, getOUIAProps, OUIAProps } from '../../helpers';
|
|
9
|
-
import { PageContext } from '../Page/
|
|
9
|
+
import { PageContext } from '../Page/PageContext';
|
|
10
10
|
|
|
11
11
|
export interface ToolbarProps extends React.HTMLProps<HTMLDivElement>, OUIAProps {
|
|
12
12
|
/** Optional callback for clearing all filters in the toolbar */
|
|
@@ -4,7 +4,7 @@ import { css } from '@patternfly/react-styles';
|
|
|
4
4
|
import { ToolbarContentContext, ToolbarContext } from './ToolbarUtils';
|
|
5
5
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
6
6
|
import { ToolbarExpandableContent } from './ToolbarExpandableContent';
|
|
7
|
-
import { PageContext } from '../Page/
|
|
7
|
+
import { PageContext } from '../Page/PageContext';
|
|
8
8
|
|
|
9
9
|
export interface ToolbarContentProps extends React.HTMLProps<HTMLDivElement> {
|
|
10
10
|
/** Classes applied to root element of the data toolbar content row */
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Toolbar/toolbar';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { formatBreakpointMods, toCamel } from '../../helpers/util';
|
|
5
|
-
import { PageContext } from '../Page/
|
|
5
|
+
import { PageContext } from '../Page/PageContext';
|
|
6
6
|
|
|
7
7
|
export enum ToolbarGroupVariant {
|
|
8
8
|
'filter-group' = 'filter-group',
|
|
@@ -4,7 +4,7 @@ import { css } from '@patternfly/react-styles';
|
|
|
4
4
|
|
|
5
5
|
import { formatBreakpointMods, toCamel } from '../../helpers/util';
|
|
6
6
|
import { Divider } from '../Divider';
|
|
7
|
-
import { PageContext } from '../Page/
|
|
7
|
+
import { PageContext } from '../Page/PageContext';
|
|
8
8
|
|
|
9
9
|
export enum ToolbarItemVariant {
|
|
10
10
|
separator = 'separator',
|
|
@@ -7,7 +7,7 @@ import { ToolbarContext, ToolbarContentContext } from './ToolbarUtils';
|
|
|
7
7
|
import { Button } from '../Button';
|
|
8
8
|
import globalBreakpointLg from '@patternfly/react-tokens/dist/esm/global_breakpoint_lg';
|
|
9
9
|
import { formatBreakpointMods, toCamel, canUseDOM } from '../../helpers/util';
|
|
10
|
-
import { PageContext } from '../Page/
|
|
10
|
+
import { PageContext } from '../Page/PageContext';
|
|
11
11
|
|
|
12
12
|
export interface ToolbarToggleGroupProps extends ToolbarGroupProps {
|
|
13
13
|
/** An icon to be rendered when the toggle group has collapsed down */
|
package/src/demos/Page/Page.md
CHANGED
|
@@ -3,8 +3,6 @@ id: Page
|
|
|
3
3
|
section: components
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { css } from '@patternfly/react-styles';
|
|
7
|
-
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
8
6
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
9
7
|
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
10
8
|
import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
|
|
@@ -40,13 +38,11 @@ import {
|
|
|
40
38
|
ButtonVariant,
|
|
41
39
|
Card,
|
|
42
40
|
CardBody,
|
|
43
|
-
Checkbox,
|
|
44
41
|
Divider,
|
|
45
42
|
Dropdown,
|
|
46
43
|
DropdownGroup,
|
|
47
44
|
DropdownToggle,
|
|
48
45
|
DropdownItem,
|
|
49
|
-
DropdownSeparator,
|
|
50
46
|
Gallery,
|
|
51
47
|
GalleryItem,
|
|
52
48
|
KebabToggle,
|
|
@@ -78,8 +74,6 @@ import {
|
|
|
78
74
|
DrawerActions,
|
|
79
75
|
DrawerCloseButton,
|
|
80
76
|
} from '@patternfly/react-core';
|
|
81
|
-
import { css } from '@patternfly/react-styles';
|
|
82
|
-
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
83
77
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
84
78
|
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
85
79
|
import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
|
|
@@ -181,10 +175,10 @@ class PageLayoutGrouped extends React.Component {
|
|
|
181
175
|
);
|
|
182
176
|
|
|
183
177
|
const kebabDropdownItems = [
|
|
184
|
-
<DropdownItem>
|
|
178
|
+
<DropdownItem key="settings">
|
|
185
179
|
<CogIcon /> Settings
|
|
186
180
|
</DropdownItem>,
|
|
187
|
-
<DropdownItem>
|
|
181
|
+
<DropdownItem key="help">
|
|
188
182
|
<HelpIcon /> Help
|
|
189
183
|
</DropdownItem>
|
|
190
184
|
];
|
|
@@ -357,7 +351,7 @@ class PageLayoutGrouped extends React.Component {
|
|
|
357
351
|
</PageSection>
|
|
358
352
|
}
|
|
359
353
|
groupProps={{
|
|
360
|
-
stickyOnBreakpoint: { default: 'top' }
|
|
354
|
+
stickyOnBreakpoint: { default: 'top' }
|
|
361
355
|
}}
|
|
362
356
|
>
|
|
363
357
|
<PageSection>
|
|
@@ -399,7 +393,6 @@ import {
|
|
|
399
393
|
DropdownGroup,
|
|
400
394
|
DropdownToggle,
|
|
401
395
|
DropdownItem,
|
|
402
|
-
DropdownSeparator,
|
|
403
396
|
Gallery,
|
|
404
397
|
GalleryItem,
|
|
405
398
|
KebabToggle,
|
|
@@ -410,7 +403,6 @@ import {
|
|
|
410
403
|
PageHeader,
|
|
411
404
|
PageSection,
|
|
412
405
|
PageSectionVariants,
|
|
413
|
-
PageSidebar,
|
|
414
406
|
SkipToContent,
|
|
415
407
|
TextContent,
|
|
416
408
|
Text,
|
|
@@ -418,8 +410,6 @@ import {
|
|
|
418
410
|
PageHeaderToolsGroup,
|
|
419
411
|
PageHeaderToolsItem
|
|
420
412
|
} from '@patternfly/react-core';
|
|
421
|
-
import { css } from '@patternfly/react-styles';
|
|
422
|
-
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
423
413
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
424
414
|
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
425
415
|
import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
|
|
@@ -490,10 +480,10 @@ class PageLayoutGrouped extends React.Component {
|
|
|
490
480
|
</Nav>
|
|
491
481
|
);
|
|
492
482
|
const kebabDropdownItems = [
|
|
493
|
-
<DropdownItem>
|
|
483
|
+
<DropdownItem key="settings">
|
|
494
484
|
<CogIcon /> Settings
|
|
495
485
|
</DropdownItem>,
|
|
496
|
-
<DropdownItem>
|
|
486
|
+
<DropdownItem key="help">
|
|
497
487
|
<HelpIcon /> Help
|
|
498
488
|
</DropdownItem>
|
|
499
489
|
];
|
|
@@ -641,7 +631,6 @@ import {
|
|
|
641
631
|
DropdownGroup,
|
|
642
632
|
DropdownToggle,
|
|
643
633
|
DropdownItem,
|
|
644
|
-
DropdownSeparator,
|
|
645
634
|
Gallery,
|
|
646
635
|
GalleryItem,
|
|
647
636
|
KebabToggle,
|
|
@@ -652,7 +641,6 @@ import {
|
|
|
652
641
|
PageHeader,
|
|
653
642
|
PageSection,
|
|
654
643
|
PageSectionVariants,
|
|
655
|
-
PageSidebar,
|
|
656
644
|
PageGroup,
|
|
657
645
|
PageBreadcrumb,
|
|
658
646
|
PageNavigation,
|
|
@@ -663,8 +651,6 @@ import {
|
|
|
663
651
|
PageHeaderToolsGroup,
|
|
664
652
|
PageHeaderToolsItem
|
|
665
653
|
} from '@patternfly/react-core';
|
|
666
|
-
import { css } from '@patternfly/react-styles';
|
|
667
|
-
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
668
654
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
669
655
|
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
670
656
|
import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
|
|
@@ -714,10 +700,10 @@ class PageLayoutGroupedAlt extends React.Component {
|
|
|
714
700
|
const { isDropdownOpen, isKebabDropdownOpen, activeItem } = this.state;
|
|
715
701
|
|
|
716
702
|
const kebabDropdownItems = [
|
|
717
|
-
<DropdownItem>
|
|
703
|
+
<DropdownItem key="settings">
|
|
718
704
|
<CogIcon /> Settings
|
|
719
705
|
</DropdownItem>,
|
|
720
|
-
<DropdownItem>
|
|
706
|
+
<DropdownItem key="help">
|
|
721
707
|
<HelpIcon /> Help
|
|
722
708
|
</DropdownItem>
|
|
723
709
|
];
|
|
@@ -863,13 +849,11 @@ import {
|
|
|
863
849
|
ButtonVariant,
|
|
864
850
|
Card,
|
|
865
851
|
CardBody,
|
|
866
|
-
Checkbox,
|
|
867
852
|
Divider,
|
|
868
853
|
Dropdown,
|
|
869
854
|
DropdownGroup,
|
|
870
855
|
DropdownToggle,
|
|
871
856
|
DropdownItem,
|
|
872
|
-
DropdownSeparator,
|
|
873
857
|
Gallery,
|
|
874
858
|
GalleryItem,
|
|
875
859
|
KebabToggle,
|
|
@@ -884,8 +868,8 @@ import {
|
|
|
884
868
|
Page,
|
|
885
869
|
PageSection,
|
|
886
870
|
PageSectionVariants,
|
|
887
|
-
PageSidebar,
|
|
888
871
|
PageToggleButton,
|
|
872
|
+
PageSidebar,
|
|
889
873
|
SkipToContent,
|
|
890
874
|
TextContent,
|
|
891
875
|
Text,
|
|
@@ -901,8 +885,6 @@ import {
|
|
|
901
885
|
DrawerActions,
|
|
902
886
|
DrawerCloseButton,
|
|
903
887
|
} from '@patternfly/react-core';
|
|
904
|
-
import { css } from '@patternfly/react-styles';
|
|
905
|
-
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
906
888
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
907
889
|
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
908
890
|
import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
|
|
@@ -1004,10 +986,10 @@ class PageLayoutGrouped extends React.Component {
|
|
|
1004
986
|
);
|
|
1005
987
|
|
|
1006
988
|
const kebabDropdownItems = [
|
|
1007
|
-
<DropdownItem>
|
|
989
|
+
<DropdownItem key="settings">
|
|
1008
990
|
<CogIcon /> Settings
|
|
1009
991
|
</DropdownItem>,
|
|
1010
|
-
<DropdownItem>
|
|
992
|
+
<DropdownItem key="help">
|
|
1011
993
|
<HelpIcon /> Help
|
|
1012
994
|
</DropdownItem>
|
|
1013
995
|
];
|