8000 Google Fonts never load (import dropped after Tailwind) (#32) by simon-inkie · Pull Request #51 · simon-inkie/inkie-deck · GitHub
[go: up one dir, main page]

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
79 changes: 79 additions & 0 deletions .specs/32-google-fonts-never-load/SPEC.md
8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# #32: Google Fonts never load (import dropped after Tailwind)

- Issue: #32
- Branch: 32-google-fonts-never-load
- Started: 2026-10-07

## TL;DR

`app.css` has the Google Fonts `@import` on line 2, after the Tailwind import.
Tailwind inlines at line 1, so the font `@import` is no longer first and
browsers drop it. The app renders in fallback fonts even when online. Load the
fonts with a `<link rel="stylesheet">` from `links` in `app/root.tsx`, beside
the existing preconnects, remove the dead `@import`, and correct the
"Typography needs the internet" limitation in `INSTALL.md`, which blames the
network for what was a code fault.

## Scope

In scope:
- `packages/deck/app/app.css`: remove the font `@import`.
- `packages/deck/app/root.tsx`: add the font stylesheet to `links`, fix the
comment that points at the `@import`.
- `INSTALL.md`: rewrite the limitation so it says what is true now.

Out of scope: self-hosting the fonts, font choice, any other CSS.

## Acceptance

- No postcss `@import must precede all other statements` warning in dev or
build.
- `document.fonts` shows League Spartan, Work Sans and Space Grotesk loaded in
a clean browser profile.
- The limitation text no longer blames network access for the fonts failing
when online.

## Test plan

- `pnpm -C packages/deck build`: confirm the warning is gone (compare with
`main`).
- Built CSS no longer contains the `fonts.googleapis.com` `@import`, and the
rendered HTML contains the stylesheet `<link>`.
- Browser check with Playwright and a fresh profile: `document.fonts` entries,
if the sandbox allows egress to Google Fonts. Otherwise recorded as not
measured.
- Repo checks: typecheck, test, boundaries, leaks, licence, lib-version,
dashes.

## Decisions log

- 2026-10-07: Use `links` in `root.tsx` rather than reordering the CSS. It sits
beside the existing preconnects, so the connection is warmed before the
stylesheet is requested, and it does not depend on how Tailwind orders
inlined imports. This is the first option the issue gives.

- 2026-10-07: Reword the INSTALL.md limitation rather than delete it. Fonts
still need a route to Google Fonts from the browser, so the limitation stands,
but it now says whose connection matters and records that the offline-only
cause was wrong.
- 2026-10-07: Left the Google Fonts dependency in place. Self-hosting would also
remove the egress limitation but is a separate change.

## Results

- Before: `pnpm build` printed the `@import rules must precede` warning twice.
After: zero. Built CSS has no `googleapis` reference.
- `pnpm dev` server-rendered HTML contains the font stylesheet `<link>` after
the preconnects, and the dev log has no `@import` warning.
- `document.fonts` in a clean browser profile: not measured here (see Test
plan); needs a browser with access to Google Fonts.

- Checks: typecheck, boundaries, leaks, licence, lib-version and dashes pass.
`packages/deck` tests: 2168 passed, 11 skipped. `packages/base` tests: 4
failed, 42 passed, identical on `origin/main` before this change. They are
environmental in this sandbox (no `xxd`, no UTF-8 locale, no model CLI) and
untouched by this change.

## Follow-ups

- Self-host the three fonts so the app has no runtime egress dependency.
11 changes: 7 additions & 4 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,13 @@ on a machine or user account that does not have one. Pointing Deck at a
differently-named session with `MC_TMUX_SESSION` works for the application,
but the launcher will not follow it.

**Typography needs the internet at runtime.** The stylesheet imports three
fonts from Google Fonts, so an installation with no outbound access renders in
fallback fonts with no explanation. Nothing else about the application depends
on egress.
**Typography needs the internet at runtime.** The page links a stylesheet for
three fonts from Google Fonts, so a browser with no route to it renders in
fallback fonts with no explanation. That is the browser's connection, not the
server's. Until #32 was fixed the fonts never loaded even when online, because
the `@import` that was meant to fetch them was dropped; if you see fallback
fonts on a connected browser now, that is a regression worth reporting. Nothing
else about the application depends on egress.

**Optional subsystems are unverified here.** Voice dictation (Deepgram),
image descriptions (Gemini) and web push all need keys, are off without them,
Expand Down
1 change: 0 additions & 1 deletion packages/deck/app/app.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@import "tailwindcss";
@import url("https://fonts.googleapis.com/css2?family=League+Spartan:wght@500;700;900&family=Work+Sans:ital,wght@0,400;0,500;0,600;1,400&family=Space+Grotesk:wght@400;500;700&display=swap");

/*
* Inkie Deck theme - the canonical Inkie design language (retro2, teal-led).
8000 Expand Down
11 changes: 9 additions & 2 deletions packages/deck/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,21 @@ export async function loader() {
}

export const links: Route.LinksFunction = () => [
// Inkie webfonts (League Spartan / Work Sans / Space Grotesk) are loaded via
// the @import in app.css. These preconnects warm the font-CDN connection.
// Inkie webfonts (League Spartan / Work Sans / Space Grotesk). Loaded here and
// not by an @import in app.css: Tailwind inlines at the top of that file, so
// a font @import below it is no longer first and browsers drop it (#32).
// The preconnects warm the font-CDN connection for the stylesheet below.
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
{
rel: "preconnect",
href: "https://fonts.gstatic.com",
crossOrigin: "anonymous",
},
{
rel: "stylesheet",
href:
"https://fonts.googleapis.com/css2?family=League+Spartan:wght@500;700;900&family=Work+Sans:ital,wght@0,400;0,500;0,600;1,400&family=Space+Grotesk:wght@400;500;700&display=swap",
},
// TASK-470 PWA shell: manifest + home-screen icon. iOS only fires web push
// for sites added to the Home Screen (16.4+), and that requires both.
{ rel: "manifest", href: "/manifest.webmanifest" },
Expand Down
Loading
0