| 1 |
import { Drawer, DrawerContent, DrawerProps } from '../Drawer'; |
| 2 |
import styles from '@patternfly/react-styles/css/components/Compass/compass'; |
| 3 |
import { css } from '@patternfly/react-styles'; |
| 4 |
|
| 5 |
export interface CompassContentProps extends React.HTMLProps<HTMLDivElement> { |
| 6 |
/** Content of the main Compass area. Typically one or more `Panel` components. */ |
| 7 |
children: React.ReactNode; |
| 8 |
/** Additional classes added to the CompassContent */ |
| 9 |
className?: string; |
| 10 |
/** Content rendered in an optional drawer wrapping the CompassContent */ |
| 11 |
drawerContent?: React.ReactNode; |
| 12 |
/** Additional props passed to the drawer */ |
| 13 |
drawerProps?: DrawerProps; |
| 14 |
} |
| 15 |
|
| 16 |
export const CompassContent: React.FunctionComponent<CompassContentProps> = ({ |
| 17 |
children, |
| 18 |
className, |
| 19 |
drawerProps, |
| 20 |
drawerContent, |
| 21 |
...props |
| 22 |
}: CompassContentProps) => { |
| 23 |
const hasDrawer = drawerContent !== undefined; |
| 24 |
|
| 25 |
const compassContent = ( |
| 26 |
<div className={css(styles.compassContent, className)} {...props}> |
| 27 |
{children} |
| 28 |
</div> |
| 29 |
); |
| 30 |
|
| 31 |
if (hasDrawer) { |
| 32 |
return ( |
| 33 |
<Drawer isPill {...drawerProps}> |
| 34 |
<DrawerContent panelContent={drawerContent}>{compassContent}</DrawerContent> |
| 35 |
</Drawer> |
| 36 |
); |
| 37 |
} |
| 38 |
|
| 39 |
return compassContent; |
| 40 |
}; |
| 41 |
|
| 42 |
CompassContent.displayName = 'CompassContent'; |