Skip to content
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
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
first render, instead of swapping in afterwards and shifting the layout -->
<link rel="preload" href="/node_modules/@fontsource/poppins/files/poppins-latin-400-normal.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/node_modules/@fontsource/kay-pho-du/files/kay-pho-du-latin-700-normal.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/node_modules/@fontsource/poppins/files/poppins-latin-ext-400-normal.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/node_modules/@fontsource/kay-pho-du/files/kay-pho-du-latin-ext-700-normal.woff2" as="font" type="font/woff2" crossorigin>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="keywords" content="Svit Spindler, web developer, software engineer, portfolio, front-end development, React, JavaScript, full-stack development" />
Expand Down
8 changes: 7 additions & 1 deletion src/components/header/Header.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
text-align: center;
}

/* The home page name stays on one line, so swapping in Kay Pho Du can't change its
height (src/fonts.css). Extension titles (.md-text) are long and must wrap. */
.name:not(.md-text) {
white-space: nowrap;
}

.App-header h1 {
font-size: 4rem;
}
Expand All @@ -30,7 +36,7 @@

@media screen and (max-width: 768px) {
.App-header h1 {
font-size: 3rem;
font-size: min(3rem, 14vw);
}
.profile-picture {
width: 145px;
Expand Down
46 changes: 46 additions & 0 deletions src/fonts.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* The two web fonts, only the subsets the site uses (Latin, plus Latin Extended for
* č, š, ž). These replace @fontsource's CSS, which hard-codes font-display: swap.
*
* The pages are prerendered and paint before the fonts arrive. With swap on Poppins,
* lines laid out while it was pending wrapped differently once it settled, and the
* header pushed the page down by a line on phones (CLS 0.04–0.08). So:
* - Poppins (all body text) is optional: the page never re-lays out text for it.
* index.html preloads it, so on Wi-Fi and 4G it's ready in time; on a slow
* connection that visit keeps the size-matched "Poppins Fallback" from index.css.
* - Kay Pho Du (the name and page titles) stays swap, so the name always ends up in
* its own font. The home page name can't wrap (Header.css), so the swap can't
* change its line count.
*/
@font-face {
font-family: "Poppins";
font-style: normal;
font-display: optional;
font-weight: 400;
src: url("@fontsource/poppins/files/poppins-latin-400-normal.woff2") format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
font-family: "Poppins";
font-style: normal;
font-display: optional;
font-weight: 400;
src: url("@fontsource/poppins/files/poppins-latin-ext-400-normal.woff2") format("woff2");
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
font-family: "Kay Pho Du";
font-style: normal;
font-display: swap;
font-weight: 700;
src: url("@fontsource/kay-pho-du/files/kay-pho-du-latin-700-normal.woff2") format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
font-family: "Kay Pho Du";
font-style: normal;
font-display: swap;
font-weight: 700;
src: url("@fontsource/kay-pho-du/files/kay-pho-du-latin-ext-700-normal.woff2") format("woff2");
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
3 changes: 1 addition & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import { hydrateRoot, createRoot } from "react-dom/client";
import "@fontsource/kay-pho-du/700.css";
import "@fontsource/poppins/400.css";
import "./fonts.css";
import "./index.css";
import "./fontAwesome";
import { BrowserRouter } from "react-router-dom";
Expand Down
Loading