Skip to content

Instantly share code, notes, and snippets.

@spences10
Last active March 2, 2018 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spences10/90b96768417032dad35ca0ec45c89a5b to your computer and use it in GitHub Desktop.
Save spences10/90b96768417032dad35ca0ec45c89a5b to your computer and use it in GitHub Desktop.
styled-components helper function
// 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