Last active
March 2, 2018 18:35
-
-
Save spences10/90b96768417032dad35ca0ec45c89a5b to your computer and use it in GitHub Desktop.
styled-components helper function
This file contains 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
// credit: https://github.com/styled-components/styled-components/issues/233#issuecomment-292602734 | |
export function fontFace(name, src, fontWeight = 'normal', fontStyle = 'normal'){ | |
return ` | |
@font-face{ | |
font-family: "${name}"; | |
src: url(${require('../../public/fonts/' + src + '.eot')}); | |
src: url(${require('../../public/fonts/' + src + '.eot')}?#iefix) format("embedded-opentype"), | |
url(${require('../../public/fonts/' + src + '.woff')}) format("woff"), | |
url(${require('../../public/fonts/' + src + '.ttf')}) format("truetype"), | |
url(${require('../../public/fonts/' + src + '.svg')}#${name}) format("svg"); | |
font-style: ${fontStyle}; | |
font-weight: ${fontWeight}; | |
} | |
` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment