Skip to content

Commit 86996bc

Browse files
committed
fix: allow React node in ContentHeader
1 parent 56aef83 commit 86996bc

File tree

2 files changed

+16
-69
lines changed

2 files changed

+16
-69
lines changed

package-lock.json

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

packages/module/src/ContentHeader/ContentHeader.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export interface PageHeaderLinkProps extends ButtonProps {
2424

2525
export interface ContentHeaderProps {
2626
/** Title for content header */
27-
title: string;
28-
/** Subtitle for content header */
29-
subtitle: string;
27+
title: React.ReactNode;
28+
/** Optional subtitle for content header */
29+
subtitle?: React.ReactNode;
3030
/** Optional link below subtitle */
3131
linkProps?: PageHeaderLinkProps;
3232
/** Optional icon for content header (appears to the left of the content header's title with a divider) */
@@ -49,7 +49,7 @@ const useStyles = createUseStyles({
4949

5050
export const ContentHeader: React.FunctionComponent<React.PropsWithChildren<ContentHeaderProps>> = ({
5151
title,
52-
subtitle,
52+
subtitle = null,
5353
linkProps,
5454
icon,
5555
label,
@@ -81,9 +81,11 @@ export const ContentHeader: React.FunctionComponent<React.PropsWithChildren<Cont
8181
<FlexItem flex={{ default: 'flex_1' }}>
8282
<Split hasGutter>
8383
<SplitItem>
84-
<Content className="pf-v6-u-mb-sm" component="h1" ouiaId={`${ouiaId}-title`}>
85-
{title}
86-
</Content>
84+
{typeof title === 'string' ? (
85+
<Content className="pf-v6-u-mb-sm" component="h1" ouiaId={`${ouiaId}-title`}>
86+
{title}
87+
</Content>
88+
) : title}
8789
</SplitItem>
8890
{label && (
8991
<SplitItem>
@@ -97,9 +99,11 @@ export const ContentHeader: React.FunctionComponent<React.PropsWithChildren<Cont
9799
</SplitItem>
98100
)}
99101
</Split>
100-
<Content component="p" ouiaId={`${ouiaId}-subtitle`}>
101-
{subtitle}
102-
</Content>
102+
{typeof subtitle === 'string' ? (
103+
<Content component="p" ouiaId={`${ouiaId}-subtitle`}>
104+
{subtitle}
105+
</Content>
106+
) : subtitle}
103107
{linkProps && (
104108
<Button variant={ButtonVariant.link} component="a" ouiaId={`${ouiaId}-link-button`} isInline icon={isExternal ? <ExternalLinkAltIcon className='pf-v6-u-ml-sm' /> : null} iconPosition="end" {...linkRestProps}>
105109
{linkProps.label}
@@ -108,6 +112,7 @@ export const ContentHeader: React.FunctionComponent<React.PropsWithChildren<Cont
108112
</FlexItem>
109113
</Flex>
110114
</PageSection>
111-
)};
115+
);
116+
};
112117

113118
export default ContentHeader;

0 commit comments

Comments
 (0)