2018-05-10 19:23:41 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { Component } from '@wordpress/element';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './style.scss';
|
2018-05-14 15:47:42 +00:00
|
|
|
import { EllipsisMenu } from '../ellipsis-menu';
|
2018-06-20 15:10:06 +00:00
|
|
|
import { H, Section } from 'layout/section';
|
2018-05-10 19:23:41 +00:00
|
|
|
|
|
|
|
class Card extends Component {
|
|
|
|
render() {
|
|
|
|
const { action, children, menu, title } = this.props;
|
2018-06-01 14:35:18 +00:00
|
|
|
const className = classnames( 'woocommerce-card', this.props.className, {
|
2018-05-10 19:23:41 +00:00
|
|
|
'has-menu': !! menu,
|
|
|
|
'has-action': !! action,
|
|
|
|
} );
|
|
|
|
return (
|
|
|
|
<div className={ className }>
|
2018-06-01 14:35:18 +00:00
|
|
|
<div className="woocommerce-card__header">
|
2018-06-20 15:10:06 +00:00
|
|
|
<H className="woocommerce-card__title">{ title }</H>
|
2018-06-01 14:35:18 +00:00
|
|
|
{ action && <div className="woocommerce-card__action">{ action }</div> }
|
|
|
|
{ menu && <div className="woocommerce-card__menu">{ menu }</div> }
|
2018-05-10 19:23:41 +00:00
|
|
|
</div>
|
2018-06-20 15:10:06 +00:00
|
|
|
<Section className="woocommerce-card__body">{ children }</Section>
|
2018-05-10 19:23:41 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Card.propTypes = {
|
|
|
|
action: PropTypes.node,
|
|
|
|
className: PropTypes.string,
|
|
|
|
menu: PropTypes.shape( {
|
|
|
|
type: PropTypes.oneOf( [ EllipsisMenu ] ),
|
|
|
|
} ),
|
|
|
|
title: PropTypes.string.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Card;
|