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
|
@ -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>
|
||||
var interval = setInterval(function () {
|
||||
if (typeof window.run_cockpit === 'function') {
|
||||
clearInterval(interval);
|
||||
window.run_cockpit();
|
||||
}
|
||||
}, 100);
|
||||
<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.runCockpit === 'function') {
|
||||
clearInterval(interval);
|
||||
window.runCockpit();
|
||||
}
|
||||
}, 50);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue