Skip to content

Commit 5ba8e90

Browse files
committed
feat(Compass): remove background props, update structure
1 parent 57fe8ee commit 5ba8e90

2 files changed

Lines changed: 10 additions & 30 deletions

File tree

packages/react-core/src/components/Compass/Compass.tsx

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { Drawer, DrawerContent, DrawerContentBody, DrawerProps } from '../Drawer';
22
import styles from '@patternfly/react-styles/css/components/Compass/compass';
33
import { css } from '@patternfly/react-styles';
4-
5-
import compassBackgroundImageLight from '@patternfly/react-tokens/dist/esm/c_compass_BackgroundImage_light';
6-
import compassBackgroundImageDark from '@patternfly/react-tokens/dist/esm/c_compass_BackgroundImage_dark';
7-
84
export interface CompassProps extends React.HTMLProps<HTMLDivElement> {
95
/** Additional classes added to the Compass. */
106
className?: string;
@@ -40,10 +36,6 @@ export interface CompassProps extends React.HTMLProps<HTMLDivElement> {
4036
drawerContent?: React.ReactNode;
4137
/** Additional props passed to the drawer */
4238
drawerProps?: DrawerProps;
43-
/** Light theme background image path of the Compass */
44-
backgroundSrcLight?: string;
45-
/** Dark theme background image path of the Compass */
46-
backgroundSrcDark?: string;
4739
}
4840

4941
export const Compass: React.FunctionComponent<CompassProps> = ({
@@ -63,26 +55,12 @@ export const Compass: React.FunctionComponent<CompassProps> = ({
6355
isFooterExpanded = true,
6456
drawerContent,
6557
drawerProps,
66-
backgroundSrcLight,
67-
backgroundSrcDark,
6858
...props
6959
}: CompassProps) => {
7060
const hasDrawer = drawerContent !== undefined;
7161

72-
const backgroundImageStyles: { [key: string]: string } = {};
73-
if (backgroundSrcLight) {
74-
backgroundImageStyles[compassBackgroundImageLight.name] = `url(${backgroundSrcLight})`;
75-
}
76-
if (backgroundSrcDark) {
77-
backgroundImageStyles[compassBackgroundImageDark.name] = `url(${backgroundSrcDark})`;
78-
}
79-
8062
const compassContent = (
81-
<div
82-
className={css(styles.compass, dock !== undefined && styles.modifiers.docked, className)}
83-
{...props}
84-
style={{ ...props.style, ...backgroundImageStyles }}
85-
>
63+
<div className={css(styles.compassContainer, dock !== undefined && styles.modifiers.docked, className)} {...props}>
8664
{dock && masthead}
8765
{dock && (
8866
<div
@@ -133,15 +111,17 @@ export const Compass: React.FunctionComponent<CompassProps> = ({
133111

134112
if (hasDrawer) {
135113
return (
136-
<Drawer isPill {...drawerProps}>
137-
<DrawerContent panelContent={drawerContent}>
138-
<DrawerContentBody>{compassContent}</DrawerContentBody>
139-
</DrawerContent>
140-
</Drawer>
114+
<div className={css(styles.compass)}>
115+
<Drawer isPill {...drawerProps}>
116+
<DrawerContent panelContent={drawerContent}>
117+
<DrawerContentBody>{compassContent}</DrawerContentBody>
118+
</DrawerContent>
119+
</Drawer>
120+
</div>
141121
);
142122
}
143123

144-
return compassContent;
124+
return <div className={css(styles.compass)}>{compassContent}</div>;
145125
};
146126

147127
Compass.displayName = 'Compass';

packages/react-core/src/components/Compass/examples/Compass.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ In a basic Compass layout, content can be passed to the following props to popul
3535
- `sidebarEnd`: Content rendered at the horizontal end of the page (by default, the right side).
3636
- `footer`: Content rendered at the bottom of the page.
3737

38-
To customize the background image of the `<Compass>` and `<CompassHero>` components, you can use their respective `backgroundSrcLight` and `backgroundSrcDark` props. You can also add and customize a color gradient background for the `<CompassHero>` component by using the `gradientLight` and `gradientDark` props.
38+
The background image of `<Compass>` is set at a global level alongside the theme. You can customize the background image of `<CompassHero>` by using its `backgroundSrcLight` and `backgroundSrcDark` props, or you may set a gradient using the `gradientLight` and `gradientDark` props.
3939

4040
```ts isBeta file="CompassBasic.tsx"
4141

0 commit comments

Comments
 (0)