Compare commits

...

4 Commits

Author SHA1 Message Date
Ilia Mashkov
aefe03d811 feat: use class for barlow font with fallbacks
All checks were successful
Workflow / build (pull_request) Successful in 1m9s
Workflow / publish (pull_request) Has been skipped
2026-02-10 13:09:42 +03:00
Ilia Mashkov
e90b2bede5 feat(Page): add appearance animation that is slightly delayed to ensure font loading and lack of FOIT 2026-02-10 13:09:09 +03:00
Ilia Mashkov
bb8d2d685c feat(Layout): add font loading flag and change head links to prevent FOUT 2026-02-10 13:08:07 +03:00
Ilia Mashkov
c8d249d6ce feat(app.css): add fallbacks for the fonts to prevent FOUT 2026-02-10 13:04:26 +03:00
5 changed files with 59 additions and 12 deletions

View File

@@ -117,7 +117,7 @@
} }
body { body {
@apply bg-background text-foreground; @apply bg-background text-foreground;
font-family: 'Karla', system-ui, sans-serif; font-family: "Karla", system-ui, -apple-system, "Segoe UI", Inter, Roboto, Arial, sans-serif;
font-optical-sizing: auto; font-optical-sizing: auto;
} }
} }
@@ -162,3 +162,7 @@
.animate-nudge { .animate-nudge {
animation: nudge 10s ease-in-out infinite; animation: nudge 10s ease-in-out infinite;
} }
.barlow {
font-family: "Barlow", system-ui, Inter, Roboto, "Segoe UI", Arial, sans-serif;
}

View File

@@ -15,32 +15,69 @@ import GD from '$shared/assets/GD.svg';
import { ResponsiveProvider } from '$shared/lib'; import { ResponsiveProvider } from '$shared/lib';
import { ScrollArea } from '$shared/shadcn/ui/scroll-area'; import { ScrollArea } from '$shared/shadcn/ui/scroll-area';
import { Provider as TooltipProvider } from '$shared/shadcn/ui/tooltip'; import { Provider as TooltipProvider } from '$shared/shadcn/ui/tooltip';
import type { Snippet } from 'svelte'; import {
type Snippet,
onMount,
} from 'svelte';
interface Props { interface Props {
children: Snippet; children: Snippet;
} }
/** Slot content for route pages to render */
let { children }: Props = $props(); let { children }: Props = $props();
let fontsReady = $state(false);
/**
* Sets fontsReady flag to true when font for the page logo is loaded.
*/
onMount(async () => {
if (!('fonts' in document)) {
fontsReady = true;
return;
}
const required = ['100'];
const missing = required.filter(
w => !document.fonts.check(`${w} 1em Barlow`),
);
if (missing.length > 0) {
await Promise.all(
missing.map(w => document.fonts.load(`${w} 1em Barlow`)),
);
}
fontsReady = true;
});
$inspect(fontsReady);
</script> </script>
<svelte:head> <svelte:head>
<link rel="icon" href={GD} /> <link rel="icon" href={GD} />
<link rel="preconnect" href="https://api.fontshare.com" /> <link rel="preconnect" href="https://api.fontshare.com" />
<link rel="preconnect" href="https://cdn.fontshare.com" crossorigin="anonymous" /> <link rel="preconnect" href="https://cdn.fontshare.com" crossorigin="anonymous" />
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="anonymous"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="anonymous">
<link <link
href="https://fonts.googleapis.com/css2?family=Karla:ital,wght@0,200..800;1,200..800&display=swap" rel="preload"
rel="stylesheet" as="style"
href="https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,100;0,200;1,100;1,200&family=Karla:wght@200..800&display=swap"
> >
<link <link
href="https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Karla:wght@300&display=swap"
rel="stylesheet" rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,100;0,200;1,100;1,200&family=Karla:wght@200..800&display=swap"
media="print"
onload={(e => ((e.currentTarget as HTMLLinkElement).media = 'all'))}
> >
<noscript>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,100;0,200;1,100;1,200&family=Karla:wght@200..800&display=swap"
>
</noscript>
<title> <title>
Compare Typography & Typefaces | GlyphDiff Compare Typography & Typefaces | GlyphDiff
</title> </title>
@@ -55,7 +92,9 @@ let { children }: Props = $props();
<!-- <ScrollArea class="h-screen w-screen"> --> <!-- <ScrollArea class="h-screen w-screen"> -->
<main class="flex-1 h-full w-full max-w-6xl mx-auto px-0 pt-0 pb-10 sm:px-6 sm:pt-8 sm:pb-12 md:px-8 md:pt-10 md:pb-16 lg:px-10 lg:pt-12 lg:pb-20 xl:px-16 relative overflow-x-hidden"> <main class="flex-1 h-full w-full max-w-6xl mx-auto px-0 pt-0 pb-10 sm:px-6 sm:pt-8 sm:pb-12 md:px-8 md:pt-10 md:pb-16 lg:px-10 lg:pt-12 lg:pb-20 xl:px-16 relative overflow-x-hidden">
<TooltipProvider> <TooltipProvider>
{#if fontsReady}
{@render children?.()} {@render children?.()}
{/if}
</TooltipProvider> </TooltipProvider>
</main> </main>
<!-- </ScrollArea> --> <!-- </ScrollArea> -->

View File

@@ -23,7 +23,7 @@ import { scrollBreadcrumbsStore } from '../../model';
" "
> >
<div class="max-w-8xl mx-auto px-4 sm:px-6 h-full flex items-center gap-2 sm:gap-4"> <div class="max-w-8xl mx-auto px-4 sm:px-6 h-full flex items-center gap-2 sm:gap-4">
<h1 class={cn('font-[Barlow] font-extralight text-sm sm:text-base')}> <h1 class={cn('barlow font-extralight text-sm sm:text-base')}>
GLYPHDIFF GLYPHDIFF
</h1> </h1>

View File

@@ -4,7 +4,6 @@
--> -->
<script lang="ts"> <script lang="ts">
import { scrollBreadcrumbsStore } from '$entities/Breadcrumb'; import { scrollBreadcrumbsStore } from '$entities/Breadcrumb';
import { cn } from '$shared/shadcn/utils/shadcn-utils';
import { import {
Logo, Logo,
Section, Section,
@@ -17,6 +16,8 @@ import EyeIcon from '@lucide/svelte/icons/eye';
import LineSquiggleIcon from '@lucide/svelte/icons/line-squiggle'; import LineSquiggleIcon from '@lucide/svelte/icons/line-squiggle';
import ScanSearchIcon from '@lucide/svelte/icons/search'; import ScanSearchIcon from '@lucide/svelte/icons/search';
import type { Snippet } from 'svelte'; import type { Snippet } from 'svelte';
import { cubicIn } from 'svelte/easing';
import { fade } from 'svelte/transition';
let searchContainer: HTMLElement; let searchContainer: HTMLElement;
@@ -45,7 +46,10 @@ function handleTitleStatusChanged(index: number, isPast: boolean, title?: Snippe
</script> </script>
<!-- Font List --> <!-- Font List -->
<div class="p-2 sm:p-3 md:p-4 h-full flex flex-col gap-3 sm:gap-4"> <div
class="p-2 sm:p-3 md:p-4 h-full flex flex-col gap-3 sm:gap-4"
in:fade={{ duration: 500, delay: 150, easing: cubicIn }}
>
<Section class="my-4 sm:my-10 md:my-12 gap-6 sm:gap-8" onTitleStatusChange={handleTitleStatusChanged}> <Section class="my-4 sm:my-10 md:my-12 gap-6 sm:gap-8" onTitleStatusChange={handleTitleStatusChanged}>
{#snippet icon({ className })} {#snippet icon({ className })}
<CodeIcon class={className} /> <CodeIcon class={className} />

View File

@@ -11,7 +11,7 @@ interface Props {
const { class: className }: Props = $props(); const { class: className }: Props = $props();
const baseClasses = 'font-[Barlow] font-thin text-5xl sm:text-6xl md:text-7xl lg:text-8xl'; const baseClasses = 'barlow font-thin text-5xl sm:text-6xl md:text-7xl lg:text-8xl';
const title = 'GLYPHDIFF'; const title = 'GLYPHDIFF';
</script> </script>