Skip to content
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

perf: set FontAwesome icons size always static #43

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@
top: 100px;
min-height: calc(100% - 100px) !important;
}

fa-icon > svg {
/* Otherwise, doesn't display when JavaScript is disabled */
height: 100%;
}
</style>
</noscript>
</head>
Expand Down
12 changes: 12 additions & 0 deletions src/sass/_font-awesome.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// When JavaScript is disabled and page is pre-rendered with SSR Font Awesome icons seemed to be there in the DOM,
// but without their size set.
//
// Seems size is set dynamically by Font Awesome library. With this trick, we make icons always appear by setting its
// size. Which also helps with SSR, given there are less layout shifts. As it appears there from early beginning, not
// until its size is dynamically set
@mixin iconsStaticSizeFix {
fa-icon > svg {
/* Otherwise, doesn't display when JavaScript is disabled */
height: 100%;
}
}
4 changes: 4 additions & 0 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@use 'app/header/header-theme';
@use 'app/no-script/no-script-theme';
@use 'app/navigation-tabs/navigation-tabs-theme';
@use 'font-awesome';
@use 'theming';
@use 'typographies';

Expand Down Expand Up @@ -81,3 +82,6 @@ html:not([data-no-motion]) {
@include about-theme.motion;
@include navigation-tabs-theme.motion;
}

// Font Awesome quirk
@include font-awesome.iconsStaticSizeFix;