From 86c42daaaf1d12cba31bf0235375e04c651ae2f6 Mon Sep 17 00:00:00 2001 From: Brion Date: Mon, 3 Feb 2025 15:01:04 +0530 Subject: [PATCH 1/7] Support CSS flex mode instead of Grid for better responsiveness --- .../components/page-header/page-header.tsx | 64 ++++++++++++++----- 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/modules/react-components/src/components/page-header/page-header.tsx b/modules/react-components/src/components/page-header/page-header.tsx index 3b0da4b4f39..7309300106a 100644 --- a/modules/react-components/src/components/page-header/page-header.tsx +++ b/modules/react-components/src/components/page-header/page-header.tsx @@ -16,6 +16,7 @@ * under the License. */ +import Box from "@oxygen-ui/react/Box"; import { IdentifiableComponentInterface, LoadableComponentInterface, @@ -61,6 +62,10 @@ export interface PageHeaderPropsInterface extends LoadableComponentInterface, Te * Description. */ description?: ReactNode; + /** + * Flag to enable CSS flex box behavior instead of the Grid. + */ + flex?: boolean; /** * Flag to determine whether max width should be added to page header text content. */ @@ -136,6 +141,7 @@ export const PageHeader: React.FunctionComponent = ( bottomMargin, className, description, + flex, headingColumnWidth, image, isLoading, @@ -275,6 +281,47 @@ export const PageHeader: React.FunctionComponent = ( ); + /** + * Resolves the content rendering logic. + * @returns Header content as a react component. + */ + const renderContent = (): ReactElement => { + if (!action) { + return headingContent; + } + + if (flex) { + return ( + + { headingContent } + { action } + + ); + } + + return ( + + + + { headingContent } + + + { action &&
{ action }
} +
+
+
+ ); + }; + return ( (title || description) ? ( @@ -307,22 +354,7 @@ export const PageHeader: React.FunctionComponent = ( ) } { alertBanner } - { - action - ? ( - - - - { headingContent } - - - { action &&
{ action }
} -
-
-
- ) - : headingContent - } + { renderContent() } { bottomMargin &&