Wait for font to load before rendering
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
966d56972e
commit
6e687e5400
5 changed files with 14 additions and 29 deletions
|
@ -1,15 +0,0 @@
|
|||
@font-face {
|
||||
font-family: 'Fira Code';
|
||||
src: url('/assets/FiraCode-Bold.woff2') format('woff2');
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira Code';
|
||||
src: url('/assets/FiraCode-Regular.woff2') format('woff2');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
|
@ -8,15 +8,17 @@
|
|||
</x-section-head>
|
||||
<div id="cockpit-canvas" style="height: 80vh; margin: 8px; background-color: #000;"></div>
|
||||
</x-tab.content>
|
||||
<push name="head">
|
||||
<link rel="preload" href="/assets/FiraCode-Regular.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="preload" href="/assets/FiraCode-Bold.woff2" as="font" type="font/woff2" crossorigin>
|
||||
</push>
|
||||
<script>
|
||||
<script type="module">
|
||||
const firaCodeFace = new FontFace('Fira Code', `url(${new URL('/assets/FiraCode-Regular.woff2', import.meta.url)})`, {style: "normal", weight: "normal"});
|
||||
const firaCodeBoldFace = new FontFace('Fira Code', `url(${new URL('/assets/FiraCode-Bold.woff2', import.meta.url)})`, {style: "normal", weight: "bold"});
|
||||
Promise.all([firaCodeFace.load(), firaCodeBoldFace.load()]).then((faces) => {
|
||||
document.fonts.add(faces[0]);
|
||||
document.fonts.add(faces[1]);
|
||||
var interval = setInterval(function () {
|
||||
if (typeof window.run_cockpit === 'function') {
|
||||
if (typeof window.runCockpit === 'function') {
|
||||
clearInterval(interval);
|
||||
window.run_cockpit();
|
||||
window.runCockpit();
|
||||
}
|
||||
}, 100);
|
||||
}, 50);
|
||||
});
|
||||
</script>
|
|
@ -1,5 +1,4 @@
|
|||
@import 'apex.css';
|
||||
@import 'firacode.css';
|
||||
|
||||
@custom-media --tablet only screen and (max-width: 1200px);
|
||||
@custom-media --phone only screen and (max-width: 800px);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { default as init, run } from 'thecockpit'
|
||||
window.run_cockpit = async () => {
|
||||
window.runCockpit = async () => {
|
||||
await init();
|
||||
run("cockpit-canvas");
|
||||
};
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
@import 'apex.css';
|
||||
@import 'firacode.css';
|
||||
|
||||
@custom-media --tablet only screen and (max-width: 1200px);
|
||||
@custom-media --phone only screen and (max-width: 800px);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue