Skip to content

Commit afd8336

Browse files
authored
fix: allow React node in ContentHeader (#544)
1 parent ff50b3f commit afd8336

File tree

2 files changed

+12
-67
lines changed

2 files changed

+12
-67
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: 12 additions & 9 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;
27+
title: React.ReactNode;
2828
/** Optional subtitle for content header */
29-
subtitle?: string;
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,11 +99,11 @@ export const ContentHeader: React.FunctionComponent<React.PropsWithChildren<Cont
9799
</SplitItem>
98100
)}
99101
</Split>
100-
{subtitle && (
102+
{typeof subtitle === 'string' ? (
101103
<Content component="p" ouiaId={`${ouiaId}-subtitle`}>
102104
{subtitle}
103105
</Content>
104-
)}
106+
) : subtitle}
105107
{linkProps && (
106108
<Button variant={ButtonVariant.link} component="a" ouiaId={`${ouiaId}-link-button`} isInline icon={isExternal ? <ExternalLinkAltIcon className='pf-v6-u-ml-sm' /> : null} iconPosition="end" {...linkRestProps}>
107109
{linkProps.label}
@@ -110,6 +112,7 @@ export const ContentHeader: React.FunctionComponent<React.PropsWithChildren<Cont
110112
</FlexItem>
111113
</Flex>
112114
</PageSection>
113-
)};
115+
);
116+
};
114117

115118
export default ContentHeader;

0 commit comments

Comments
 (0)