All files / atoms/Header index.jsx

50% Statements 5/10
0% Branches 0/4
0% Functions 0/2
50% Lines 5/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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            1x               1x       1x 1x         1x            
import React from 'react';
import PropTypes from 'prop-types';
 
import Font from '../Font';
import withStyle from '../../Theme/withStyle';
 
const getFontProps = (level, rest) => {
  if (level >= 1 && level <= 6) {
    const element = `h${level}`;
    return { element, [element]: true, ...rest };
  }
  return { element: 'header', ...rest };
};
 
const Header = ({ children, level, ...rest }) => (
  <Font {...getFontProps(level, rest)}>{children}</Font>
);
 
Header.displayName = 'Header';
Header.propTypes = {
  children: PropTypes.node,
  level: PropTypes.number,
};
 
Header.defaultProps = {
  children: null,
  level: 1,
};
 
export default withStyle(Header);