diff --git a/packages/react-core/src/components/Compass/Compass.tsx b/packages/react-core/src/components/Compass/Compass.tsx index c152a015cc8..9018c1a2528 100644 --- a/packages/react-core/src/components/Compass/Compass.tsx +++ b/packages/react-core/src/components/Compass/Compass.tsx @@ -1,10 +1,6 @@ import { Drawer, DrawerContent, DrawerContentBody, DrawerProps } from '../Drawer'; import styles from '@patternfly/react-styles/css/components/Compass/compass'; import { css } from '@patternfly/react-styles'; - -import compassBackgroundImageLight from '@patternfly/react-tokens/dist/esm/c_compass_BackgroundImage_light'; -import compassBackgroundImageDark from '@patternfly/react-tokens/dist/esm/c_compass_BackgroundImage_dark'; - export interface CompassProps extends React.HTMLProps { /** Additional classes added to the Compass. */ className?: string; @@ -40,10 +36,6 @@ export interface CompassProps extends React.HTMLProps { drawerContent?: React.ReactNode; /** Additional props passed to the drawer */ drawerProps?: DrawerProps; - /** Light theme background image path of the Compass */ - backgroundSrcLight?: string; - /** Dark theme background image path of the Compass */ - backgroundSrcDark?: string; } export const Compass: React.FunctionComponent = ({ @@ -63,26 +55,12 @@ export const Compass: React.FunctionComponent = ({ isFooterExpanded = true, drawerContent, drawerProps, - backgroundSrcLight, - backgroundSrcDark, ...props }: CompassProps) => { const hasDrawer = drawerContent !== undefined; - const backgroundImageStyles: { [key: string]: string } = {}; - if (backgroundSrcLight) { - backgroundImageStyles[compassBackgroundImageLight.name] = `url(${backgroundSrcLight})`; - } - if (backgroundSrcDark) { - backgroundImageStyles[compassBackgroundImageDark.name] = `url(${backgroundSrcDark})`; - } - const compassContent = ( -
+
{dock && masthead} {dock && (
= ({
); - if (hasDrawer) { - return ( - - - {compassContent} - - - ); - } - - return compassContent; + return ( +
+ {hasDrawer ? ( + + + {compassContent} + + + ) : ( + compassContent + )} +
+ ); }; Compass.displayName = 'Compass'; diff --git a/packages/react-core/src/components/Compass/CompassMainHeader.tsx b/packages/react-core/src/components/Compass/CompassMainHeader.tsx index 2351ca4bfa2..9d3389a8c92 100644 --- a/packages/react-core/src/components/Compass/CompassMainHeader.tsx +++ b/packages/react-core/src/components/Compass/CompassMainHeader.tsx @@ -21,7 +21,7 @@ export interface CompassMainHeaderProps extends Omit; + panelProps?: Omit; } export const CompassMainHeader: React.FunctionComponent = ({ @@ -29,12 +29,12 @@ export const CompassMainHeader: React.FunctionComponent title, toolbar, children, - compassPanelProps, + panelProps, ...props }: CompassMainHeaderProps) => { const _content = title !== undefined || toolbar !== undefined ? ( - + diff --git a/packages/react-core/src/components/Compass/__tests__/Compass.test.tsx b/packages/react-core/src/components/Compass/__tests__/Compass.test.tsx index 91973224496..52f60bfec79 100644 --- a/packages/react-core/src/components/Compass/__tests__/Compass.test.tsx +++ b/packages/react-core/src/components/Compass/__tests__/Compass.test.tsx @@ -99,27 +99,6 @@ test('Renders with drawer when drawerContent is provided', () => { expect(screen.getByText('Drawer content')).toBeVisible(); }); -test('Renders with light background image when backgroundSrcLight is provided', () => { - const backgroundSrc = 'light-bg.jpg'; - render(); - expect(screen.getByTestId('compass')).toHaveStyle(`--pf-v6-c-compass--BackgroundImage--light: url(${backgroundSrc})`); -}); - -test('Renders with dark background image when backgroundSrcDark is provided', () => { - const backgroundSrc = 'dark-bg.jpg'; - render(); - expect(screen.getByTestId('compass')).toHaveStyle(`--pf-v6-c-compass--BackgroundImage--dark: url(${backgroundSrc})`); -}); - -test('Renders with both light and dark background images when both are provided', () => { - const lightSrc = 'light-bg.jpg'; - const darkSrc = 'dark-bg.jpg'; - render(); - const compassElement = screen.getByTestId('compass'); - expect(compassElement).toHaveStyle(`--pf-v6-c-compass--BackgroundImage--light: url(${lightSrc})`); - expect(compassElement).toHaveStyle(`--pf-v6-c-compass--BackgroundImage--dark: url(${darkSrc})`); -}); - test('Renders with additional props spread to the component', () => { render(); expect(screen.getByTestId('compass')).toHaveAccessibleName('Test label'); diff --git a/packages/react-core/src/components/Compass/__tests__/CompassMainHeader.test.tsx b/packages/react-core/src/components/Compass/__tests__/CompassMainHeader.test.tsx index 0133f5eaa04..ef2b630edac 100644 --- a/packages/react-core/src/components/Compass/__tests__/CompassMainHeader.test.tsx +++ b/packages/react-core/src/components/Compass/__tests__/CompassMainHeader.test.tsx @@ -100,19 +100,15 @@ test('Does not render Panel when children are passed', () => { expect(content).not.toHaveClass(panelStyles.panel); }); -test('Passes props to Panel when title and compassPanelProps is passed', () => { - render( - - ); +test('Passes props to Panel when title and panelProps is passed', () => { + render(); const panel = screen.getByTestId('test-id').firstChild; expect(panel).toHaveClass('panel-class'); }); -test('Passes props to Panel when toolbar and compassPanelProps is passed', () => { - render( - - ); +test('Passes props to Panel when toolbar and panelProps is passed', () => { + render(); const panel = screen.getByTestId('test-id').firstChild; expect(panel).toHaveClass('panel-class'); diff --git a/packages/react-core/src/components/Compass/__tests__/__snapshots__/Compass.test.tsx.snap b/packages/react-core/src/components/Compass/__tests__/__snapshots__/Compass.test.tsx.snap index a4d1e225ed6..212fc26e41b 100644 --- a/packages/react-core/src/components/Compass/__tests__/__snapshots__/Compass.test.tsx.snap +++ b/packages/react-core/src/components/Compass/__tests__/__snapshots__/Compass.test.tsx.snap @@ -6,38 +6,42 @@ exports[`Matches the snapshot with basic layout 1`] = ` class="pf-v6-c-compass" >
-
- Header +
+
+ Header +
-
-
-
- Sidebar start +
+
+ Sidebar start +
-
-
-
- Main content +
+
+ Main content +
-
-
-
- Sidebar end +
+
+ Sidebar end +
-
- @@ -47,60 +51,64 @@ exports[`Matches the snapshot with basic layout 1`] = ` exports[`Matches the snapshot with drawer 1`] = `
-
- Header +
+
+ Header +
-
-
-
- Sidebar start +
+
+ Sidebar start +
-
-
-
- Main content +
+
+ Main content +
-
-
-
- Sidebar end +
+
+ Sidebar end +
-
-
-
-
- Drawer content +
+ Drawer content +
diff --git a/packages/react-core/src/components/Compass/examples/Compass.md b/packages/react-core/src/components/Compass/examples/Compass.md index 9664ee51c6f..c10254b59f7 100644 --- a/packages/react-core/src/components/Compass/examples/Compass.md +++ b/packages/react-core/src/components/Compass/examples/Compass.md @@ -35,7 +35,7 @@ In a basic Compass layout, content can be passed to the following props to popul - `sidebarEnd`: Content rendered at the horizontal end of the page (by default, the right side). - `footer`: Content rendered at the bottom of the page. -To customize the background image of the `` and `` components, you can use their respective `backgroundSrcLight` and `backgroundSrcDark` props. You can also add and customize a color gradient background for the `` component by using the `gradientLight` and `gradientDark` props. +The background image of `` is set at a global level alongside the theme. You can customize the background image of the `` inside `` by using its `backgroundSrcLight` and `backgroundSrcDark` props, or you may set a gradient using the `gradientLight` and `gradientDark` props. ```ts isBeta file="CompassBasic.tsx" diff --git a/packages/react-core/src/demos/Compass/examples/CompassDemo.tsx b/packages/react-core/src/demos/Compass/examples/CompassDemo.tsx index 60acc9ab2c6..243fd93aae5 100644 --- a/packages/react-core/src/demos/Compass/examples/CompassDemo.tsx +++ b/packages/react-core/src/demos/Compass/examples/CompassDemo.tsx @@ -40,7 +40,7 @@ export const CompassBasic: React.FunctionComponent = () => { const navContent = ( <> - + @@ -70,7 +70,7 @@ export const CompassBasic: React.FunctionComponent = () => { - + @@ -105,7 +105,7 @@ export const CompassBasic: React.FunctionComponent = () => { ); const sidebarContent = ( - + @@ -153,9 +153,9 @@ export const CompassBasic: React.FunctionComponent = () => { Hero - Content title} /> + Content title} panelProps={{ isGlass: true }} /> - + Content @@ -166,7 +166,7 @@ export const CompassBasic: React.FunctionComponent = () => { const sidebarEndContent = sidebarContent; const footerContent = ( - + Message bar diff --git a/packages/react-core/src/demos/Compass/examples/CompassDockDemo.tsx b/packages/react-core/src/demos/Compass/examples/CompassDockDemo.tsx index 59f09ddbcf1..5a5a83080e3 100644 --- a/packages/react-core/src/demos/Compass/examples/CompassDockDemo.tsx +++ b/packages/react-core/src/demos/Compass/examples/CompassDockDemo.tsx @@ -377,9 +377,9 @@ export const CompassDockDemo: React.FunctionComponent = () => { const mainContent = ( <> - Content title} /> + Content title} panelProps={{ isGlass: true }} /> - + Content