Skip to content

Instantly share code, notes, and snippets.

@aaronmcadam
Created March 14, 2017 12:33
Show Gist options
  • Save aaronmcadam/d40579ff70a7f38e8c4224384f00eb3d to your computer and use it in GitHub Desktop.
Save aaronmcadam/d40579ff70a7f38e8c4224384f00eb3d to your computer and use it in GitHub Desktop.
import React from 'react';
import styled, { css } from 'styled-components';
export const getFontSize = ({ level }) => `${0.5 + (1 / level)}rem`;
const styles = css`
font-family: ${(props) => props.theme.fonts.primary};
font-weight: 500;
font-size: ${getFontSize};
`;
const Heading = styled(
({ level, children, ...props }) =>
React.createElement(`h${level}`, props, children)
)`${styles}`;
Heading.defaultProps = {
level: 1
};
export default Heading;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment