-
Notifications
You must be signed in to change notification settings - Fork 16
/
gatsby-browser.js
30 lines (25 loc) · 1.13 KB
/
gatsby-browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var FontFaceObserver = require('fontfaceobserver');
// Define phase 1 fonts
const robotoSubset = new FontFaceObserver('Roboto Subset', { weight: 300 });
const robotoSlabSubset = new FontFaceObserver('Roboto Slab Subset', { weight: 400 });
// Define phase 2 fonts
const robotoNormal = new FontFaceObserver('Roboto', { weight: 400 });
const robotoSemiBold = new FontFaceObserver('Roboto', { weight: 600 });
const robotoBold = new FontFaceObserver('Roboto', { weight: 800 });
const robotoLighter = new FontFaceObserver('Roboto', { weight: 200 });
const robotoSlabNormal = new FontFaceObserver('Roboto Slab', { weight: 400 });
exports.onInitialClientRender = () => {
Promise.all([robotoSubset.load(), robotoSlabSubset.load()]).then(function() {
document.documentElement.classList.add('subset-fonts-enabled');
Promise.all([
robotoNormal.load(),
robotoSemiBold.load(),
robotoBold.load(),
robotoLighter.load(),
robotoSlabNormal.load(),
]).then(function() {
document.documentElement.classList.remove('subset-fonts-enabled');
document.documentElement.classList.add('fonts-enabled');
});
});
};