All files / packages/design-system/ui/shared/heading index.js

100% Statements 3/3
100% Branches 2/2
100% Functions 0/0
100% Lines 3/3

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      12x                   31x     12x            
import React from 'react';
import PropTypes from 'prop-types';
 
const elements = {
  1: 'h1',
  2: 'h2',
  3: 'h3',
  4: 'h4',
  5: 'h5',
  6: 'h6'
};
 
function Heading({ level, children, ...props }) {
  return React.createElement(elements[level] || elements[2], props, children);
}
 
Heading.propTypes = {
  level: PropTypes.oneOf(Object.keys(elements)),
  children: PropTypes.node
};
 
export default Heading;