mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Always preload app fonts at earliest stages (#5117)
* always preload app fonts at earliest stages, fix #5019 Signed-off-by: Roman <ixrock@gmail.com> * attempt to fix tests, clean up Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
dd0cb8594c
commit
30d22bfb6d
@ -7,9 +7,9 @@
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@import "~flex.box"; // todo: replace with tailwind's flexbox classes
|
||||
@import "./fonts";
|
||||
@import "~flex.box";
|
||||
@import "../themes/theme-vars";
|
||||
@import "./fonts";
|
||||
|
||||
:root {
|
||||
--unit: 8px;
|
||||
|
||||
@ -4,7 +4,4 @@
|
||||
*/
|
||||
|
||||
.TerminalTab {
|
||||
@include font-preload {
|
||||
font-family: "RobotoMono", monospace;
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,3 +24,13 @@
|
||||
font-display: block;
|
||||
src: local('RobotoMono'), url('./fonts/roboto-mono-nerd.ttf') format('truetype');
|
||||
}
|
||||
|
||||
#fonts-preloading {
|
||||
> .icons {
|
||||
@include font-preload("Material Icons");
|
||||
}
|
||||
|
||||
> .terminal {
|
||||
@include font-preload("RobotoMono");
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,14 +60,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Makes custom font available at earlier stages (start preloading)
|
||||
// Element must be in DOM and contain some text of loading font.
|
||||
@mixin font-preload() {
|
||||
// Makes custom @font-family available at earlier stages.
|
||||
// Element must exist in DOM as soon as possible to initiate preloading.
|
||||
@mixin font-preload($fontFamily) {
|
||||
position: absolute;
|
||||
visibility: hidden;
|
||||
height: 0;
|
||||
|
||||
&:before {
|
||||
width: 0;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
content: "x"; // required
|
||||
@content; // must contain `font-family`
|
||||
content: "x"; // some text required to start applying font in document
|
||||
font-family: $fontFamily; // imported name in @font-face declaration
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,16 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="preload" href="<%= assetPath %>/MaterialIcons-Regular.ttf" as="font" crossorigin>
|
||||
<link rel="preload" href="<%= assetPath %>/roboto-mono-nerd.ttf" as="font" crossorigin>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="app"></div>
|
||||
<div id="terminal-init"></div>
|
||||
|
||||
<div id="fonts-preloading">
|
||||
<i class="icons"><!--material icons--></i>
|
||||
<i class="terminal"><!--roboto mono--></i>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user