Skip to content

Commit

Permalink
Fix FontFaceObserver
Browse files Browse the repository at this point in the history
  • Loading branch information
mxstbr committed Jan 25, 2016
1 parent 2046147 commit ab989c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ const reduxRouterMiddleware = syncHistory(browserHistory);

// Observer loading of Open Sans (to remove open sans, remove the <link> tag in
// the index.html file and this observer)
import styles from './containers/App/styles.css';
const openSansObserver = new FontFaceObserver('Open Sans', {});

// When Open Sans is loaded, add the js-open-sans-loaded class to the body
openSansObserver.check().then(() => {
document.body.classList.add('js-open-sans-loaded');
document.body.classList.add(styles.jsOpenSansLoaded);
}, () => {
document.body.classList.remove('js-open-sans-loaded');
document.body.classList.remove(styles.jsOpenSansLoaded);
});

// Import the pages
Expand Down
10 changes: 10 additions & 0 deletions app/containers/App/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/* Global styles */

body {
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
}

body.jsOpenSansLoaded {
font-family: 'Open Sans', Helvetica Neue, Helvetica, Arial, sans-serif;
}

.wrapper {
max-width: calc(768px + 16px * 2);
margin: 0 auto;
Expand Down

0 comments on commit ab989c8

Please sign in to comment.