| 1 |
import styles from '@patternfly/react-styles/css/components/Card/card'; |
| 2 |
import { css } from '@patternfly/react-styles'; |
| 3 |
import { CardContext } from './Card'; |
| 4 |
|
| 5 |
export interface CardExpandableContentProps extends React.HTMLProps<HTMLDivElement> { |
| 6 |
/** Content rendered inside the Card Body */ |
| 7 |
children?: React.ReactNode; |
| 8 |
/** Additional classes added to the Card Body */ |
| 9 |
className?: string; |
| 10 |
} |
| 11 |
|
| 12 |
export const CardExpandableContent: React.FunctionComponent<CardExpandableContentProps> = ({ |
| 13 |
children, |
| 14 |
className, |
| 15 |
...props |
| 16 |
}: CardExpandableContentProps) => ( |
| 17 |
<CardContext.Consumer> |
| 18 |
{({ isExpanded }) => |
| 19 |
isExpanded ? ( |
| 20 |
<div className={css(styles.cardExpandableContent, className)} {...props}> |
| 21 |
{children} |
| 22 |
</div> |
| 23 |
) : null |
| 24 |
} |
| 25 |
</CardContext.Consumer> |
| 26 |
); |
| 27 |
CardExpandableContent.displayName = 'CardExpandableContent'; |