Debian Codegraph @

node/@patternfly/react-core/src/components/Drawer/DrawerContent.tsx

raw
1 import { useContext } from 'react';
2 import styles from '@patternfly/react-styles/css/components/Drawer/drawer';
3 import { css } from '@patternfly/react-styles';
4 import { DrawerMain } from './DrawerMain';
5 import { DrawerContext } from './Drawer';
6
7 export enum DrawerContentColorVariant {
8 default = 'default',
9 primary = 'primary',
10 secondary = 'secondary'
11 }
12
13 export interface DrawerContentProps extends React.HTMLProps<HTMLDivElement> {
14 /** Additional classes added to the Drawer. */
15 className?: string;
16 /** Content to be rendered in the drawer. */
17 children?: React.ReactNode;
18 /** Content rendered in the drawer panel. */
19 panelContent: React.ReactNode;
20 /** Color variant of the background of the drawer panel */
21 colorVariant?: DrawerContentColorVariant | 'default' | 'primary' | 'secondary';
22 }
23
24 export const DrawerContent: React.FunctionComponent<DrawerContentProps> = ({
25 className,
26 children,
27 panelContent,
28 colorVariant = DrawerContentColorVariant.default,
29 ...props
30 }: DrawerContentProps) => {
31 const { drawerContentRef } = useContext(DrawerContext);
32
33 return (
34 <DrawerMain>
35 <div
36 className={css(
37 styles.drawerContent,
38 colorVariant === DrawerContentColorVariant.primary && styles.modifiers.primary,
39 colorVariant === DrawerContentColorVariant.secondary && styles.modifiers.secondary,
40 className
41 )}
42 ref={drawerContentRef}
43 {...props}
44 >
45 {children}
46 </div>
47 {panelContent}
48 </DrawerMain>
49 );
50 };
51 DrawerContent.displayName = 'DrawerContent';