Skip to content

Commit bd8ac18

Browse files
author
Eric Olkowski
committed
PR feedback
1 parent b760ca5 commit bd8ac18

File tree

14 files changed

+94
-11316
lines changed

14 files changed

+94
-11316
lines changed

packages/react-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"tslib": "^2.6.2"
5656
},
5757
"devDependencies": {
58-
"@patternfly/patternfly": "6.0.0-alpha.166",
58+
"@patternfly/patternfly": "6.0.0-alpha.180",
5959
"case-anything": "^2.1.13",
6060
"css": "^3.0.0",
6161
"fs-extra": "^11.2.0"

packages/react-core/src/components/Page/Page.tsx

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { css } from '@patternfly/react-styles';
44
import globalBreakpointXl from '@patternfly/react-tokens/dist/esm/global_breakpoint_xl';
55
import { debounce, canUseDOM } from '../../helpers/util';
66
import { Drawer, DrawerContent, DrawerContentBody, DrawerPanelContent } from '../Drawer';
7-
import { PageBreadcrumbProps } from './PageBreadcrumb';
7+
import { PageBreadcrumb, PageBreadcrumbProps } from './PageBreadcrumb';
88
import { PageGroup, PageGroupProps } from './PageGroup';
99
import { getResizeObserver } from '../../helpers/resizeObserver';
10-
import { formatBreakpointMods, getBreakpoint, getVerticalBreakpoint } from '../../helpers/util';
10+
import { getBreakpoint, getVerticalBreakpoint } from '../../helpers/util';
1111
import { PageContextProvider } from './PageContext';
12-
import { PageMainBody } from './PageMainBody';
12+
import { PageBody } from './PageBody';
1313

1414
export enum PageLayouts {
1515
vertical = 'vertical',
@@ -267,29 +267,20 @@ class Page extends React.Component<PageProps, PageState> {
267267
if (horizontalSubnav && isHorizontalSubnavWidthLimited) {
268268
nav = (
269269
<div className={css(styles.pageMainSubnav, styles.modifiers.limitWidth)}>
270-
<PageMainBody>{horizontalSubnav}</PageMainBody>
270+
<PageBody>{horizontalSubnav}</PageBody>
271271
</div>
272272
);
273273
} else if (horizontalSubnav) {
274274
nav = <div className={css(styles.pageMainSubnav)}>{horizontalSubnav}</div>;
275275
}
276276

277277
const crumb = breadcrumb ? (
278-
<section
279-
className={css(
280-
styles.pageMainBreadcrumb,
281-
isBreadcrumbWidthLimited && styles.modifiers.limitWidth,
282-
formatBreakpointMods(
283-
breadcrumbProps?.stickyOnBreakpoint,
284-
styles,
285-
'sticky-',
286-
getVerticalBreakpoint(height),
287-
true
288-
)
289-
)}
278+
<PageBreadcrumb
279+
stickyOnBreakpoint={breadcrumbProps?.stickyOnBreakpoint}
280+
isWidthLimited={isBreadcrumbWidthLimited}
290281
>
291-
{isBreadcrumbWidthLimited ? <PageMainBody>{breadcrumb}</PageMainBody> : breadcrumb}
292-
</section>
282+
<PageBody>{breadcrumb}</PageBody>
283+
</PageBreadcrumb>
293284
) : null;
294285

295286
const isGrouped = isHorizontalSubnavGrouped || isBreadcrumbGrouped || additionalGroupedContent;

packages/react-core/src/components/Page/PageMainBody.tsx renamed to packages/react-core/src/components/Page/PageBody.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,17 @@ import * as React from 'react';
22
import styles from '@patternfly/react-styles/css/components/Page/page';
33
import { css } from '@patternfly/react-styles';
44

5-
export interface PageMainBodyProps extends React.HTMLProps<HTMLDivElement> {
5+
export interface PageBodyProps extends React.HTMLProps<HTMLDivElement> {
66
/** Content rendered inside the section */
77
children?: React.ReactNode;
88
/** Additional classes added to the section */
99
className?: string;
10-
/** Section background color variant. This will only apply when the type prop has the "default" value. */
1110
}
1211

13-
export const PageMainBody: React.FunctionComponent<PageMainBodyProps> = ({
14-
className,
15-
children,
16-
...props
17-
}: PageMainBodyProps) => (
12+
export const PageBody: React.FunctionComponent<PageBodyProps> = ({ className, children, ...props }: PageBodyProps) => (
1813
<div {...props} className={css(styles.pageMainBody, className)}>
1914
{children}
2015
</div>
2116
);
2217

23-
PageMainBody.displayName = 'PageMainBody';
18+
PageBody.displayName = 'PageBody';

packages/react-core/src/components/Page/PageBreadcrumb.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { css } from '@patternfly/react-styles';
33
import styles from '@patternfly/react-styles/css/components/Page/page';
44
import { formatBreakpointMods, Mods } from '../../helpers/util';
55
import { PageContext } from './PageContext';
6-
import { PageMainBody } from './PageMainBody';
6+
import { PageBody } from './PageBody';
77

88
export interface PageBreadcrumbProps extends React.HTMLProps<HTMLElement> {
99
/** Additional classes to apply to the PageBreadcrumb */
@@ -27,10 +27,10 @@ export interface PageBreadcrumbProps extends React.HTMLProps<HTMLElement> {
2727
hasShadowBottom?: boolean;
2828
/** Flag indicating if the PageBreadcrumb has a scrolling overflow */
2929
hasOverflowScroll?: boolean;
30-
/** @beta Flag indicating whether children passed to the component should be wrapped by a PageMainBody.
31-
* Set this to false in order to pass multiple, custom PageMainBody's as children.
30+
/** @beta Flag indicating whether children passed to the component should be wrapped by a PageBody.
31+
* Set this to false in order to pass multiple, custom PageBody's as children.
3232
*/
33-
hasMainBodyWrapper?: boolean;
33+
hasBodyWrapper?: boolean;
3434
/** Adds an accessible name to the breadcrumb section. Required when the hasOverflowScroll prop is set to true. */
3535
'aria-label'?: string;
3636
}
@@ -44,7 +44,7 @@ export const PageBreadcrumb = ({
4444
hasShadowBottom = false,
4545
hasOverflowScroll = false,
4646
'aria-label': ariaLabel,
47-
hasMainBodyWrapper = true,
47+
hasBodyWrapper = true,
4848
...props
4949
}: PageBreadcrumbProps) => {
5050
const { height, getVerticalBreakpoint } = React.useContext(PageContext);
@@ -71,7 +71,7 @@ export const PageBreadcrumb = ({
7171
aria-label={ariaLabel}
7272
{...props}
7373
>
74-
{hasMainBodyWrapper ? <PageMainBody>{children}</PageMainBody> : children}
74+
{hasBodyWrapper ? <PageBody>{children}</PageBody> : children}
7575
</section>
7676
);
7777
};

packages/react-core/src/components/Page/PageSection.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import styles from '@patternfly/react-styles/css/components/Page/page';
33
import { css } from '@patternfly/react-styles';
44
import { formatBreakpointMods } from '../../helpers/util';
55
import { PageContext } from './PageContext';
6-
import { PageMainBody } from './PageMainBody';
6+
import { PageBody } from './PageBody';
77

88
export enum PageSectionVariants {
99
default = 'default',
@@ -57,10 +57,10 @@ export interface PageSectionProps extends React.HTMLProps<HTMLDivElement> {
5757
hasShadowBottom?: boolean;
5858
/** Flag indicating if the PageSection has a scrolling overflow */
5959
hasOverflowScroll?: boolean;
60-
/** @beta Flag indicating whether children passed to the component should be wrapped by a PageMainBody.
61-
* Set this to false in order to pass multiple, custom PageMainBody's as children.
60+
/** @beta Flag indicating whether children passed to the component should be wrapped by a PageBody.
61+
* Set this to false in order to pass multiple, custom PageBody's as children.
6262
*/
63-
hasMainBodyWrapper?: boolean;
63+
hasBodyWrapper?: boolean;
6464
/** Adds an accessible name to the page section. Required when the hasOverflowScroll prop is set to true.
6565
* This prop should also be passed in if a heading is not being used to describe the content of the page section.
6666
*/
@@ -97,7 +97,7 @@ export const PageSection: React.FunctionComponent<PageSectionProps> = ({
9797
hasOverflowScroll = false,
9898
'aria-label': ariaLabel,
9999
component = 'section',
100-
hasMainBodyWrapper = true,
100+
hasBodyWrapper = true,
101101
...props
102102
}: PageSectionProps) => {
103103
const { height, getVerticalBreakpoint } = React.useContext(PageContext);
@@ -131,7 +131,7 @@ export const PageSection: React.FunctionComponent<PageSectionProps> = ({
131131
{...(hasOverflowScroll && { tabIndex: 0 })}
132132
aria-label={ariaLabel}
133133
>
134-
{hasMainBodyWrapper ? <PageMainBody>{children}</PageMainBody> : children}
134+
{hasBodyWrapper ? <PageBody>{children}</PageBody> : children}
135135
</Component>
136136
);
137137
};

packages/react-core/src/components/Page/__tests__/PageBreadcrumb.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ describe('page breadcrumb', () => {
7474
expect(consoleWarning).toHaveBeenCalled();
7575
});
7676

77-
test('Renders with PageMainBody wrapper by default', () => {
77+
test('Renders with PageBody wrapper by default', () => {
7878
render(<PageBreadcrumb>test</PageBreadcrumb>);
7979

8080
expect(screen.getByText('test')).toHaveClass(styles.pageMainBody);
8181
});
82-
test('Does not render with PageMainBody wrapper when hasMainBodyWrapper is false', () => {
83-
render(<PageBreadcrumb hasMainBodyWrapper={false}>test</PageBreadcrumb>);
82+
test('Does not render with PageBody wrapper when hasBodyWrapper is false', () => {
83+
render(<PageBreadcrumb hasBodyWrapper={false}>test</PageBreadcrumb>);
8484

8585
expect(screen.getByText('test')).not.toHaveClass(styles.pageMainBody);
8686
});
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
import * as React from 'react';
22
import { render, screen } from '@testing-library/react';
3-
import { PageMainBody } from '../PageMainBody';
3+
import { PageBody } from '../PageBody';
44
import styles from '@patternfly/react-styles/css/components/Page/page';
55

66
test('Renders without children', () => {
7-
render(<PageMainBody data-testid="page-main-body" />);
7+
render(<PageBody data-testid="page-main-body" />);
88

99
expect(screen.getByTestId('page-main-body')).toBeVisible();
1010
});
1111
test('Renders children', () => {
12-
render(<PageMainBody>Test</PageMainBody>);
12+
render(<PageBody>Test</PageBody>);
1313

1414
expect(screen.getByText('Test')).toBeVisible();
1515
});
1616
test(`Renders with class ${styles.pageMainBody} by default`, () => {
17-
render(<PageMainBody>Test</PageMainBody>);
17+
render(<PageBody>Test</PageBody>);
1818

1919
expect(screen.getByText('Test')).toHaveClass(styles.pageMainBody);
2020
});
2121
test(`Renders with custom classes when className is passed`, () => {
22-
render(<PageMainBody className="custom-class">Test</PageMainBody>);
22+
render(<PageBody className="custom-class">Test</PageBody>);
2323

2424
expect(screen.getByText('Test')).toHaveClass('custom-class');
2525
});
2626
test(`Renders with spread props`, () => {
27-
render(<PageMainBody id="custom-id">Test</PageMainBody>);
27+
render(<PageBody id="custom-id">Test</PageBody>);
2828

2929
expect(screen.getByText('Test')).toHaveAttribute('id', 'custom-id');
3030
});
3131
test('Matches snapshot', () => {
32-
const { asFragment } = render(<PageMainBody>Test</PageMainBody>);
32+
const { asFragment } = render(<PageBody>Test</PageBody>);
3333
expect(asFragment()).toMatchSnapshot();
3434
});

packages/react-core/src/components/Page/__tests__/PageSection.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ test('Renders as other elements when a different element type is passed using th
143143
expect(screen.getByRole('main')).toHaveTextContent('test');
144144
});
145145

146-
test('Renders with PageMainBody wrapper by default', () => {
146+
test('Renders with PageBody wrapper by default', () => {
147147
render(<PageSection>test</PageSection>);
148148

149149
expect(screen.getByText('test')).toHaveClass(styles.pageMainBody);
150150
});
151-
test('Does not render with PageMainBody wrapper when hasMainBodyWrapper is false', () => {
152-
render(<PageSection hasMainBodyWrapper={false}>test</PageSection>);
151+
test('Does not render with PageBody wrapper when hasBodyWrapper is false', () => {
152+
render(<PageSection hasBodyWrapper={false}>test</PageSection>);
153153

154154
expect(screen.getByText('test')).not.toHaveClass(styles.pageMainBody);
155155
});

packages/react-core/src/components/Page/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export * from './Page';
2-
export * from './PageMainBody';
2+
export * from './PageBody';
33
export * from './PageBreadcrumb';
44
export * from './PageGroup';
55
export * from './PageSidebar';

packages/react-docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"test:a11y": "patternfly-a11y --config patternfly-a11y.config"
2424
},
2525
"dependencies": {
26-
"@patternfly/patternfly": "6.0.0-alpha.166",
26+
"@patternfly/patternfly": "6.0.0-alpha.180",
2727
"@patternfly/react-charts": "workspace:^",
2828
"@patternfly/react-code-editor": "workspace:^",
2929
"@patternfly/react-core": "workspace:^",

0 commit comments

Comments
 (0)