// @flow import type { Node } from 'react'; import React, { useState } from 'react'; import classnames from 'classnames'; import Icon from 'component/common/icon'; import Button from 'component/button'; import * as ICONS from 'constants/icons'; type Props = { title?: string | Node, subtitle?: string | Node, titleActions?: string | Node, body?: string | Node, actions?: string | Node, icon?: string, className?: string, isPageTitle?: boolean, isBodyTable?: boolean, defaultExpand?: boolean, nag?: Node, }; export default function Card(props: Props) { const { title, subtitle, titleActions, body, actions, icon, className, isPageTitle = false, isBodyTable = false, defaultExpand, nag, } = props; const [expanded, setExpanded] = useState(defaultExpand); const expandable = defaultExpand !== undefined; return (
{(title || subtitle) && (
{icon && }
{isPageTitle &&

{title}

} {!isPageTitle &&

{title}

} {subtitle &&
{subtitle}
}
{titleActions &&
{titleActions}
} {expandable && (
)}
)} {(!expandable || (expandable && expanded)) && ( <> {body && (
{body}
)} {actions &&
{actions}
} )} {nag}
); }