Last active
August 20, 2021 02:21
-
-
Save hayes0724/c8f1b24956e66fade78b65e6a48bd90e 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
/// @name Font Face | |
/// @description Loads woff/local type fonts | |
/// @version 1.0.2 | |
/// @param {String} $font-family | |
/// @param {String} $fallback - fallback system font to use until main font is rendered [sans-serif] | |
/// @param {URL} $file - the URL of the font without extension, it will assume the woff type has the same file name | |
/// @param {String | Number} $weight [normal] | |
/// @param {String} $style [normal] | |
/* | |
@include font-face("grotesk", "hkgrotesk-regularlegacy", 400, "normal", "sans-serif"); | |
@include font-face("grotesk", "hkgrotesk-regularlegacy"); | |
*/ | |
@mixin font-face($font-family, $file, $weight: "normal", $style: "normal", $fallback: 'sans-serif') { | |
$path: "{{ 'placeholder.woff' | asset_url | split: 'placeholder.woff' | first }}"; | |
@font-face { | |
font-family: "#{$font-family}"; | |
src: local("#{$font-family}"), | |
local("#{$fallback}"), | |
url("#{$path + $file}.woff2") format("woff2"), | |
url("#{$path + $file}.woff") format("woff"); | |
font-weight: $weight; | |
font-style: $style; | |
font-display: swap; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment