All files / src/components/PageCard/Heading index.jsx

100% Statements 4/4
100% Branches 4/4
100% Functions 1/1
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                2x 3x   3x                     2x                  
import styles from './style.postcss';
 
import React from 'react';
import pure from 'recompose/pure';
import classnames from 'classnames';
import is from 'is_js';
import PropTypes from 'prop-types';
 
const PageCardHeading = (props) => {
  const { className, titleClassName, text } = props;
 
  return <header className={classnames(styles.PageCardHeading, className, {
    [styles.__stackHorizontal]: props.stackMode === 'horizontal',
  })}>
    {is.string(text) && text.length ?
      <h1 className={classnames(styles.PageCardHeading_h1, titleClassName)}>
        {text}
      </h1> : null}
    {props.children}
  </header>;
};
 
PageCardHeading.propTypes = {
  className: PropTypes.string,
  titleClassName: PropTypes.string,
  text: PropTypes.string,
  stackMode: PropTypes.oneOf(['vertical', 'horizontal']),  // default: vertical
  children: PropTypes.node,
};
 
export default pure(PageCardHeading);