mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-28 16:00:24 +05:30
Add font loading service
This commit is contained in:
parent
770a6c3ae9
commit
bab6293d9e
19
src/index.js
19
src/index.js
@ -6,8 +6,6 @@ import ReactDOM from 'react-dom';
|
||||
import { Provider as ReduxProvider } from 'react-redux';
|
||||
import { Router, browserHistory } from 'react-router';
|
||||
|
||||
import webFont from 'webfontloader';
|
||||
|
||||
import { factory as userFactory } from 'components/user/factory';
|
||||
import { IntlProvider } from 'components/i18n';
|
||||
import routesFactory from 'routes';
|
||||
@ -15,6 +13,7 @@ import storeFactory from 'storeFactory';
|
||||
import bsodFactory from 'components/ui/bsod/factory';
|
||||
import loader from 'services/loader';
|
||||
import logger from 'services/logger';
|
||||
import font from 'services/font';
|
||||
|
||||
logger.init({
|
||||
sentryCdn: window.SENTRY_CDN
|
||||
@ -22,27 +21,13 @@ logger.init({
|
||||
|
||||
import dispatchBsod from 'components/ui/bsod/dispatchBsod'; // TODO: remove after tests
|
||||
|
||||
import dispatchBsod from 'components/ui/bsod/dispatchBsod'; // TODO: remove after tests
|
||||
|
||||
const store = storeFactory();
|
||||
|
||||
bsodFactory(store, stopLoading);
|
||||
|
||||
const fontLoadingPromise = new Promise((resolve) =>
|
||||
webFont.load({
|
||||
classes: false,
|
||||
active: resolve,
|
||||
inactive: resolve, // TODO: may be we should track such cases
|
||||
timeout: 2000,
|
||||
custom: {
|
||||
families: ['Roboto', 'Roboto Condensed']
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
Promise.all([
|
||||
userFactory(store),
|
||||
fontLoadingPromise
|
||||
font.load(['Roboto', 'Roboto Condensed'])
|
||||
])
|
||||
.then(() => {
|
||||
ReactDOM.render(
|
||||
|
22
src/services/font.js
Normal file
22
src/services/font.js
Normal file
@ -0,0 +1,22 @@
|
||||
import webFont from 'webfontloader';
|
||||
|
||||
export default {
|
||||
/**
|
||||
* @param {array} families
|
||||
*
|
||||
* @return {Promise}
|
||||
*/
|
||||
load(families = []) {
|
||||
return new Promise((resolve) =>
|
||||
webFont.load({
|
||||
classes: false,
|
||||
active: resolve,
|
||||
inactive: resolve, // TODO: may be we should track such cases
|
||||
timeout: 2000,
|
||||
custom: {
|
||||
families
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user