Merge pull request #599 from liyasthomas/fix/fouc-page-load-unload
Improve page load/unload experience (remove FOUCs)
This commit is contained in:
@@ -6,7 +6,9 @@
|
|||||||
font-family: "Material Icons";
|
font-family: "Material Icons";
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-display: swap;
|
// Do not use font-display: swap for the icon font - it looks really bad when the page
|
||||||
|
// loads.
|
||||||
|
font-display: block;
|
||||||
src: url("~static/fonts/material-icons-v48.woff2") format("woff2");
|
src: url("~static/fonts/material-icons-v48.woff2") format("woff2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ nav.primary-nav {
|
|||||||
color: var(--fg-light-color);
|
color: var(--fg-light-color);
|
||||||
fill: var(--fg-light-color);
|
fill: var(--fg-light-color);
|
||||||
margin: 8px 0;
|
margin: 8px 0;
|
||||||
|
height: 52px;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: var(--fg-color);
|
color: var(--fg-color);
|
||||||
|
|||||||
@@ -1,7 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<pre ref="editor"></pre>
|
<div class="show-if-initialized" :class="{ initialized }">
|
||||||
|
<pre ref="editor"></pre>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.show-if-initialized {
|
||||||
|
opacity: 0;
|
||||||
|
|
||||||
|
&.initialized {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
& > * {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const DEFAULT_THEME = "twilight";
|
const DEFAULT_THEME = "twilight";
|
||||||
|
|
||||||
@@ -30,6 +46,7 @@ export default {
|
|||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
initialized: false,
|
||||||
editor: null,
|
editor: null,
|
||||||
cacheValue: ""
|
cacheValue: ""
|
||||||
};
|
};
|
||||||
@@ -43,7 +60,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
theme() {
|
theme() {
|
||||||
this.editor.setTheme("ace/theme/" + this.defineTheme());
|
this.initialized = false;
|
||||||
|
this.editor.setTheme(`ace/theme/${this.defineTheme()}`, () => {
|
||||||
|
this.$nextTick().then(() => {
|
||||||
|
this.initialized = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
lang(value) {
|
lang(value) {
|
||||||
this.editor.getSession().setMode("ace/mode/" + value);
|
this.editor.getSession().setMode("ace/mode/" + value);
|
||||||
@@ -55,11 +77,17 @@ export default {
|
|||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
const editor = ace.edit(this.$refs.editor, {
|
const editor = ace.edit(this.$refs.editor, {
|
||||||
theme: `ace/theme/${this.defineTheme()}`,
|
|
||||||
mode: `ace/mode/${this.lang}`,
|
mode: `ace/mode/${this.lang}`,
|
||||||
...this.options
|
...this.options
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set the theme and show the editor only after it's been set to prevent FOUC.
|
||||||
|
editor.setTheme(`ace/theme/${this.defineTheme()}`, () => {
|
||||||
|
this.$nextTick().then(() => {
|
||||||
|
this.initialized = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if (this.value) editor.setValue(this.value, 1);
|
if (this.value) editor.setValue(this.value, 1);
|
||||||
|
|
||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
@@ -83,9 +111,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
destroyed() {
|
||||||
this.editor.destroy();
|
this.editor.destroy();
|
||||||
this.editor.container.remove();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,7 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<pre ref="editor"></pre>
|
<div class="show-if-initialized" :class="{ initialized }">
|
||||||
|
<pre ref="editor"></pre>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.show-if-initialized {
|
||||||
|
opacity: 0;
|
||||||
|
|
||||||
|
&.initialized {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
& > * {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const DEFAULT_THEME = "twilight";
|
const DEFAULT_THEME = "twilight";
|
||||||
|
|
||||||
@@ -34,6 +50,7 @@ export default {
|
|||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
initialized: false,
|
||||||
editor: null,
|
editor: null,
|
||||||
cacheValue: "",
|
cacheValue: "",
|
||||||
validationSchema: null
|
validationSchema: null
|
||||||
@@ -48,7 +65,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
theme() {
|
theme() {
|
||||||
this.editor.setTheme(`ace/theme/${this.defineTheme()}`);
|
this.initialized = false;
|
||||||
|
this.editor.setTheme(`ace/theme/${this.defineTheme()}`, () => {
|
||||||
|
this.$nextTick().then(() => {
|
||||||
|
this.initialized = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
lang(value) {
|
lang(value) {
|
||||||
this.editor.getSession().setMode(`ace/mode/${value}`);
|
this.editor.getSession().setMode(`ace/mode/${value}`);
|
||||||
@@ -62,13 +84,19 @@ export default {
|
|||||||
let langTools = ace.require("ace/ext/language_tools");
|
let langTools = ace.require("ace/ext/language_tools");
|
||||||
|
|
||||||
const editor = ace.edit(this.$refs.editor, {
|
const editor = ace.edit(this.$refs.editor, {
|
||||||
theme: `ace/theme/${this.defineTheme()}`,
|
|
||||||
mode: `ace/mode/${this.lang}`,
|
mode: `ace/mode/${this.lang}`,
|
||||||
enableBasicAutocompletion: true,
|
enableBasicAutocompletion: true,
|
||||||
enableLiveAutocompletion: true,
|
enableLiveAutocompletion: true,
|
||||||
...this.options
|
...this.options
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set the theme and show the editor only after it's been set to prevent FOUC.
|
||||||
|
editor.setTheme(`ace/theme/${this.defineTheme()}`, () => {
|
||||||
|
this.$nextTick().then(() => {
|
||||||
|
this.initialized = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const completer = {
|
const completer = {
|
||||||
getCompletions: (
|
getCompletions: (
|
||||||
editor,
|
editor,
|
||||||
@@ -167,7 +195,6 @@ export default {
|
|||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.editor.destroy();
|
this.editor.destroy();
|
||||||
this.editor.container.remove();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -298,8 +298,8 @@
|
|||||||
>
|
>
|
||||||
<i class="material-icons">offline_bolt</i>
|
<i class="material-icons">offline_bolt</i>
|
||||||
</button>
|
</button>
|
||||||
<login v-if="!fb.currentUser" />
|
<login v-if="fb.currentUser === null" />
|
||||||
<span v-if="fb.currentUser">
|
<span v-else>
|
||||||
<v-popover>
|
<v-popover>
|
||||||
<button
|
<button
|
||||||
class="icon"
|
class="icon"
|
||||||
|
|||||||
@@ -12,14 +12,14 @@
|
|||||||
/>
|
/>
|
||||||
<i v-else class="material-icons">account_circle</i>
|
<i v-else class="material-icons">account_circle</i>
|
||||||
<span>
|
<span>
|
||||||
{{ fb.currentUser.displayName || "Name not found" }}
|
{{ fb.currentUser.displayName || $t("nothing_found") }}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<br />
|
<br />
|
||||||
<button class="icon">
|
<button class="icon">
|
||||||
<i class="material-icons">email</i>
|
<i class="material-icons">email</i>
|
||||||
<span>
|
<span>
|
||||||
{{ fb.currentUser.email || "Email not found" }}
|
{{ fb.currentUser.email || $t("nothing_found") }}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<br />
|
<br />
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
:color="theme.color"
|
:color="theme.color"
|
||||||
:name="theme.name"
|
:name="theme.name"
|
||||||
class="bg"
|
class="bg"
|
||||||
></swatch>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
<div class="colors">
|
<div class="colors">
|
||||||
<span
|
<span
|
||||||
:key="entry.color"
|
:key="entry.color"
|
||||||
@click.prevent="setActiveColor(entry.color, entry.vibrant)"
|
@click="setActiveColor(entry.color, entry.vibrant)"
|
||||||
v-for="entry in colors"
|
v-for="entry in colors"
|
||||||
>
|
>
|
||||||
<swatch
|
<swatch
|
||||||
@@ -138,8 +138,8 @@
|
|||||||
</pw-toggle>
|
</pw-toggle>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<span>
|
<span>
|
||||||
<pw-toggle
|
<pw-toggle
|
||||||
@@ -346,12 +346,13 @@ export default {
|
|||||||
],
|
],
|
||||||
|
|
||||||
settings: {
|
settings: {
|
||||||
SCROLL_INTO_ENABLED:
|
SCROLL_INTO_ENABLED:
|
||||||
typeof this.$store.state.postwoman.settings.SCROLL_INTO_ENABLED !==
|
typeof this.$store.state.postwoman.settings.SCROLL_INTO_ENABLED !==
|
||||||
"undefined"
|
"undefined"
|
||||||
? this.$store.state.postwoman.settings.SCROLL_INTO_ENABLED
|
? this.$store.state.postwoman.settings.SCROLL_INTO_ENABLED
|
||||||
: true,
|
: true,
|
||||||
|
|
||||||
|
THEME_CLASS: "",
|
||||||
THEME_COLOR: "",
|
THEME_COLOR: "",
|
||||||
THEME_TAB_COLOR: "",
|
THEME_TAB_COLOR: "",
|
||||||
THEME_COLOR_VIBRANT: true,
|
THEME_COLOR_VIBRANT: true,
|
||||||
@@ -364,7 +365,7 @@ export default {
|
|||||||
this.$store.state.postwoman.settings.PROXY_URL ||
|
this.$store.state.postwoman.settings.PROXY_URL ||
|
||||||
"https://postwoman.apollotv.xyz/",
|
"https://postwoman.apollotv.xyz/",
|
||||||
PROXY_KEY: this.$store.state.postwoman.settings.PROXY_KEY || "",
|
PROXY_KEY: this.$store.state.postwoman.settings.PROXY_KEY || "",
|
||||||
|
|
||||||
EXTENSIONS_ENABLED:
|
EXTENSIONS_ENABLED:
|
||||||
typeof this.$store.state.postwoman.settings.EXTENSIONS_ENABLED !==
|
typeof this.$store.state.postwoman.settings.EXTENSIONS_ENABLED !==
|
||||||
"undefined"
|
"undefined"
|
||||||
|
|||||||
Reference in New Issue
Block a user