Last active
November 2, 2020 07:07
-
-
Save daliborgogic/82c33d468401580ae3913f24910c0683 to your computer and use it in GitHub Desktop.
Variable Fonts Vue.js
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
<template> | |
<div id="app" :style="cssVariables"> | |
<label>wdth</label> | |
<input type="range" min="10" max="700" v-model="wght"> | |
<label>wght</label> | |
<input type="range" min="10" max="100" v-model="wdth"> | |
<span>The quick brown fox jumps over the lazy dog</span> | |
</div> | |
</template> | |
<script> | |
export default { | |
data () { | |
return { | |
wdth: 10, | |
wght: 10 | |
} | |
}, | |
computed: { | |
cssVariables () { | |
return { | |
'--wdth': this.wdth, | |
'--wght': this.wght | |
} | |
} | |
} | |
} | |
</script> | |
<style> | |
@supports (font-variation-settings: 'wdth' 200) { | |
body { background-color: rgb(0, 255, 0, 0.12); } | |
@font-face { | |
font-family: 'AmstelvarAlpha'; | |
src: url('./assets/AmstelvarAlpha-VF.ttf'); | |
} | |
span { | |
font-family: AmstelvarAlpha; | |
font-size: 32px; | |
font-variation-settings: 'wdth' var(--wdth), 'wght' var(--wght); | |
} | |
} | |
@supports not (font-variation-settings: 'wdth' 200) { | |
body { background-color: rgb(255, 0, 0, 0.12); } | |
/* Add fallback font */ | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment