diff --git a/assets/js/editor.js b/assets/js/editor.js new file mode 100644 index 00000000..179b31c2 --- /dev/null +++ b/assets/js/editor.js @@ -0,0 +1,10 @@ +import { FontLoader } from './tools'; + +const fonts = new FontLoader([ + { name: 'Scene', weight: 700 }, + { name: 'Scene', weight: 600 }, + { name: 'Scene', weight: 400 }, + { name: 'Scene', weight: 300 } +]); + +fonts.load(); \ No newline at end of file diff --git a/assets/js/tools/fonts.js b/assets/js/tools/fonts.js new file mode 100644 index 00000000..20c165b5 --- /dev/null +++ b/assets/js/tools/fonts.js @@ -0,0 +1,49 @@ +import FontFaceObserver from 'fontfaceobserver'; + +export default class FontLoader { + fonts = []; + + constructor(fontsArray) { + this.fonts = fontsArray; + } + + load() { + const fontsToLoad = []; + + this.fonts.map((font) => { + const fontObserver = font.weight !== undefined + ? new FontFaceObserver(font.name, {weight: font.weight}).load(null, 400) + : new FontFaceObserver(font.name).load(null, 400); + + fontsToLoad.push(fontObserver); + }); + + Promise.all(fontsToLoad) + .then(() => { + // eslint-disable-next-line no-console + console.log('All fonts have loaded via FontFaceObserver'); + this.saveSession(); + }) + .catch(() => { + this.removeSession(); + }); + + this.setLoadingClass(); + } + + saveSession() { + sessionStorage.fontsLoaded = true; + + this.setLoadingClass(); + } + + removeSession() { + sessionStorage.fontsLoaded = false; + } + + setLoadingClass() { + if (sessionStorage.fontsLoaded) { + document.documentElement.classList.add('fonts-loaded'); + } + } +} \ No newline at end of file diff --git a/assets/js/tools/index.js b/assets/js/tools/index.js new file mode 100644 index 00000000..695c78d2 --- /dev/null +++ b/assets/js/tools/index.js @@ -0,0 +1 @@ +export FontLoader from './fonts'; \ No newline at end of file diff --git a/assets/scss/globals/_reset.scss b/assets/scss/globals/_reset.scss index 6ecd574d..f9e1ddbf 100644 --- a/assets/scss/globals/_reset.scss +++ b/assets/scss/globals/_reset.scss @@ -1 +1 @@ -@import 'normalize.css'; \ No newline at end of file +@import '~normalize.css'; \ No newline at end of file diff --git a/assets/scss/tools/_mixins.scss b/assets/scss/tools/_mixins.scss index 5c7442fa..f7166b46 100644 --- a/assets/scss/tools/_mixins.scss +++ b/assets/scss/tools/_mixins.scss @@ -222,3 +222,7 @@ } } } + +@function fluid-unit($pixel_value) { + @return #{strip-unit($pixel_value) / strip-unit($max-font)}rem; +} \ No newline at end of file diff --git a/views/base.twig b/views/base.twig index 7f24c8bf..ed57beba 100644 --- a/views/base.twig +++ b/views/base.twig @@ -31,15 +31,10 @@ {% endblock %} {% endblock %} - {% block livechat %} - {{ source('svgs/live-chat-circle.svg') }} - {% endblock %} {% block footer %} {% include 'views/partials/footer.twig' %} {% endblock %} - {% include 'views/partials/components/modal.twig' %} {{ function('wp_footer') }} {% endblock %}