Created
March 14, 2017 12:33
-
-
Save aaronmcadam/d40579ff70a7f38e8c4224384f00eb3d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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