import React, { FunctionComponent } from "react"; import PropTypes from "prop-types"; import classNames from "classnames"; import Button from "../Button"; import Icon from "react-oui-icons"; export interface CardProps { /** Elements that appears within the component */ children: any, /** CSS class names. */ className?: string, /** Method to invoke when a close element is clicked */ onClose?: () => void, /** Display a subtle shadow around card. */ shadow?: boolean, /** For automated testing only. */ testSection?: string, /** A title to be displayed on the card */ title: string, } const Card: FunctionComponent = ({ children, className, onClose, shadow = false, testSection, title, ...props }: CardProps) => { const closer = ( ); const classes = classNames({ "push--bottom border--all": true, "oui-shadow--light": shadow, }, className); return (
{title && (

{title}

{onClose && closer}
)}
{children}
); }; Card.propTypes = { /** Elements that appears within the component */ children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired, /** CSS class names. */ className: PropTypes.string, /** method to invoke when a close element is clicked */ onClose: PropTypes.func, /** Display a subtle shadow around card. */ shadow: PropTypes.bool, /** For automated testing only. */ testSection: PropTypes.string, /** What is the card title */ title: PropTypes.string.isRequired, }; export default Card;