-
Notifications
You must be signed in to change notification settings - Fork 0
Fix errors that occur when you try to yarn watch: #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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'); | ||
| } | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a newline at the end of this file (keeps git happy) - Looks like you can enable this across all files in PHPStorm like so https://stackoverflow.com/a/36020003/2166894 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export FontLoader from './fonts'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here re: newline |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| @import 'normalize.css'; | ||
| @import '~normalize.css'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here re: newline |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,3 +222,7 @@ | |
| } | ||
| } | ||
| } | ||
|
|
||
| @function fluid-unit($pixel_value) { | ||
| @return #{strip-unit($pixel_value) / strip-unit($max-font)}rem; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here re: newline |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't want to load the theme fonts into the editor/CMS - perhaps we can add a placeholder or just console log for the editor file to be generated for now?