| 1 |
import { forwardRef } from 'react'; |
| 2 |
|
| 3 |
import styles from '@patternfly/react-styles/css/components/Panel/panel'; |
| 4 |
import { css } from '@patternfly/react-styles'; |
| 5 |
|
| 6 |
export interface PanelProps extends React.HTMLProps<HTMLDivElement> { |
| 7 |
/** Content rendered inside the panel */ |
| 8 |
children?: React.ReactNode; |
| 9 |
/** Class to add to outer div */ |
| 10 |
className?: string; |
| 11 |
/** Adds panel variant styles */ |
| 12 |
variant?: 'raised' | 'bordered' | 'secondary'; |
| 13 |
/** Flag to add scrollable styling to the panel */ |
| 14 |
isScrollable?: boolean; |
| 15 |
/** @beta When used with a scrollable panel, sets the panel to auto height */ |
| 16 |
isAutoHeight?: boolean; |
| 17 |
/** @beta Flag to remove the panel's border */ |
| 18 |
hasNoBorder?: boolean; |
| 19 |
/** @beta Flag to make the panel fill the available height of its container */ |
| 20 |
isFullHeight?: boolean; |
| 21 |
/** @beta Modifies the panel to use glass styling when the glass theme is enabled */ |
| 22 |
isGlass?: boolean; |
| 23 |
/** @beta Uses pill (fully rounded) border radius for the panel */ |
| 24 |
isPill?: boolean; |
| 25 |
/** @hide Forwarded ref */ |
| 26 |
innerRef?: React.Ref<any>; |
| 27 |
} |
| 28 |
|
| 29 |
const PanelBase: React.FunctionComponent<PanelProps> = ({ |
| 30 |
className, |
| 31 |
children, |
| 32 |
variant, |
| 33 |
isScrollable, |
| 34 |
isAutoHeight, |
| 35 |
hasNoBorder, |
| 36 |
isFullHeight, |
| 37 |
isGlass, |
| 38 |
isPill, |
| 39 |
innerRef, |
| 40 |
...props |
| 41 |
}: PanelProps) => ( |
| 42 |
<div |
| 43 |
className={css( |
| 44 |
styles.panel, |
| 45 |
variant && styles.modifiers[variant], |
| 46 |
isScrollable && styles.modifiers.scrollable, |
| 47 |
isAutoHeight && styles.modifiers.scrollableAutoHeight, |
| 48 |
hasNoBorder && styles.modifiers.noBorder, |
| 49 |
isFullHeight && styles.modifiers.fullHeight, |
| 50 |
isGlass && styles.modifiers.glass, |
| 51 |
isPill && styles.modifiers.pill, |
| 52 |
className |
| 53 |
)} |
| 54 |
ref={innerRef} |
| 55 |
{...props} |
| 56 |
> |
| 57 |
{children} |
| 58 |
</div> |
| 59 |
); |
| 60 |
|
| 61 |
export const Panel = forwardRef((props: PanelProps, ref: React.Ref<any>) => <PanelBase innerRef={ref} {...props} />); |
| 62 |
Panel.displayName = 'Panel'; |