Skip to content

Commit 683c6c6

Browse files
authored
chore: use PageLayout.Header on all pages (#452)
* chore: use PageLayout.Header on all pages * feat: remove page layout header component
1 parent 9f24d62 commit 683c6c6

File tree

6 files changed

+82
-40
lines changed

6 files changed

+82
-40
lines changed

package-lock.json

Lines changed: 45 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/commonHeader/commonHeader.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2025
2+
* Copyright IBM Corp. 2025, 2026
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -10,6 +10,11 @@
1010
@use '@carbon/react/scss/theme' as *;
1111
@use '@carbon/react/scss/breakpoint' as *;
1212

13+
.cs--common-header {
14+
padding-block-start: $spacing-05;
15+
margin-block-end: $spacing-05;
16+
}
17+
1318
.cs--common-header__content {
1419
// This CSS follow the principles of a condensed carbon grid with 2x2
1520
display: grid;

src/layouts/page-layout.jsx

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2025
2+
* Copyright IBM Corp. 2025, 2026
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -10,30 +10,32 @@ import { Children, Suspense } from 'react';
1010
import { Nav } from '../components/nav/Nav';
1111
import classNames from 'classnames';
1212

13-
export const PageLayout = ({ children, className, fallback }) => {
14-
const childArray = Children.toArray(children);
15-
const otherChildren = childArray.filter(
16-
(child) => child.type !== PageLayoutHeader,
17-
);
18-
const Header = childArray.find((child) => child.type === PageLayoutHeader);
13+
/**
14+
* PageLayout component provides a consistent layout structure for pages in the application.
15+
* It includes the navigation component and wraps content in Carbon's Content component.
16+
*
17+
* @component
18+
* @param {Object} props - Component props
19+
* @param {React.ReactNode} props.children - Child components to render within the layout
20+
* @param {string} [props.className] - Additional CSS class names to apply to the layout container
21+
* @param {React.ReactNode} [props.fallback] - Fallback content to display while Suspense is loading
22+
*
23+
* @example
24+
* <PageLayout>
25+
* <h1>Page Content</h1>
26+
* </PageLayout>
27+
*
28+
*/
1929

30+
export const PageLayout = ({ children, className, fallback }) => {
2031
return (
2132
<Suspense fallback={fallback}>
2233
<div className={classNames('cs--page-layout', className)}>
2334
<Nav />
24-
<Content className="cs--content">
25-
<div className="cs--page-layout__content">
26-
{Header}
27-
<div className="cs--page-layout__content-body">{otherChildren}</div>
28-
</div>
35+
<Content className="cs--content cs--page-layout__content">
36+
{children}
2937
</Content>
3038
</div>
3139
</Suspense>
3240
);
3341
};
34-
35-
const PageLayoutHeader = ({ children }) => (
36-
<div className="cs--page-layout__content-header">{children}</div>
37-
);
38-
PageLayoutHeader.displayName = 'PageLayoutHeader';
39-
PageLayout.Header = PageLayoutHeader;

0 commit comments

Comments
 (0)