Unverified Commit b7f84ed7 authored by Aurora Scharff's avatar Aurora Scharff Committed by GitHub

fix(create-next-app): render filenames in Geist Mono so the preloaded font is used (#95471)

## What?

Render the filename in the "edit the … file" line using **Geist Mono**
across all `create-next-app` templates, so the preloaded font is
actually used.

## Why?

Every fresh app logged a browser warning: the Geist Mono `.woff2` is
preloaded but never used, because the redesign in #81945 dropped the
last monospace element (the old `<code>app/page.tsx</code>`). Rather
than stop preloading the font (this PR's original approach), we _use_ it
— the filename renders in Geist Mono. That clears the warning at its
source and keeps the template showcasing both flagship fonts (two fonts,
no flash of unstyled text).

## How?

- Reverted the `preload: false` change.
- Wrapped the filename in the intro line in a `<code>` rendered in Geist
Mono, styled as a small inline code chip (slightly smaller size, subtle
rounded background, padding) so it reads as a code token rather than
plain heading text:
- Tailwind templates → utility classes (`font-mono` maps to
`--font-geist-mono` via `@theme inline`).
- CSS-module templates → a `.code` class using `var(--font-geist-mono)`;
the chip background uses `color-mix(currentColor …)` so it adapts to
light/dark automatically.
- Applied across all four families (`app`, `app-tw`, `default`,
`default-tw`), JS + TS.

## Screenshots

| | Before | After |
| --------- | --------------------------------------------------- |
-------------------------------------------- |
| **Light** | <img width="2400" height="1520"
alt="cna-geist-mono-before"
src="https://github.com/user-attachments/assets/cf374265-7fdf-4c3b-9f66-05436f966fc9"
/> | <img width="2400" height="1520" alt="cna-geist-mono-after"
src="https://github.com/user-attachments/assets/ae55166d-26d8-4cc2-8268-90c5996d2431"
/> |
| **Dark** | <img width="2400" height="1520"
alt="cna-geist-mono-before-dark"
src="https://github.com/user-attachments/assets/d813adac-85c0-4044-813f-9489b0b4faa7"
/> | <img width="2400" height="1520" alt="cna-geist-mono-after-dark"
src="https://github.com/user-attachments/assets/01199df9-4842-46e0-a73e-a3ba0ef78ad2"
/> |

Before: filename in Geist Sans, preloaded-but-unused warning in the
console. After: filename in Geist Mono, no warning.

<!-- NEXT_JS_LLM_PR -->
parent 2e1eb885
......@@ -14,7 +14,11 @@ export default function Home() {
/>
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
To get started, edit the page.js file.
To get started, edit the{" "}
<code className="rounded bg-black/[.06] px-1.5 py-0.5 font-mono text-[0.9em] dark:bg-white/[.08]">
page.js
</code>{" "}
file.
</h1>
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
Looking for a starting point or more instructions? Head over to{" "}
......
......@@ -14,7 +14,11 @@ export default function Home() {
/>
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
To get started, edit the page.tsx file.
To get started, edit the{" "}
<code className="rounded bg-black/[.06] px-1.5 py-0.5 font-mono text-[0.9em] dark:bg-white/[.08]">
page.tsx
</code>{" "}
file.
</h1>
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
Looking for a starting point or more instructions? Head over to{" "}
......
......@@ -14,7 +14,10 @@ export default function Home() {
priority
/>
<div className={styles.intro}>
<h1>To get started, edit the page.js file.</h1>
<h1>
To get started, edit the{" "}
<code className={styles.code}>page.js</code> file.
</h1>
<p>
Looking for a starting point or more instructions? Head over to{" "}
<a
......
......@@ -140,3 +140,11 @@ a.secondary {
--button-secondary-border: #1a1a1a;
}
}
.code {
font-family: var(--font-geist-mono);
font-size: 0.9em;
background: color-mix(in srgb, currentColor 8%, transparent);
padding: 0.1em 0.4em;
border-radius: 6px;
}
......@@ -140,3 +140,11 @@ a.secondary {
--button-secondary-border: #1a1a1a;
}
}
.code {
font-family: var(--font-geist-mono);
font-size: 0.9em;
background: color-mix(in srgb, currentColor 8%, transparent);
padding: 0.1em 0.4em;
border-radius: 6px;
}
......@@ -14,7 +14,10 @@ export default function Home() {
priority
/>
<div className={styles.intro}>
<h1>To get started, edit the page.tsx file.</h1>
<h1>
To get started, edit the{" "}
<code className={styles.code}>page.tsx</code> file.
</h1>
<p>
Looking for a starting point or more instructions? Head over to{" "}
<a
......
......@@ -14,7 +14,7 @@ const geistMono = Geist_Mono({
export default function Home() {
return (
<div
className={`${geistSans.className} ${geistMono.className} flex min-h-screen items-center justify-center bg-zinc-50 font-sans dark:bg-black`}
className={`${geistSans.variable} ${geistMono.variable} flex min-h-screen items-center justify-center bg-zinc-50 font-sans dark:bg-black`}
>
<main className="flex min-h-screen w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
<Image
......@@ -27,7 +27,11 @@ export default function Home() {
/>
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
To get started, edit the index.js file.
To get started, edit the{" "}
<code className="rounded bg-black/[.06] px-1.5 py-0.5 font-mono text-[0.9em] dark:bg-white/[.08]">
index.js
</code>{" "}
file.
</h1>
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
Looking for a starting point or more instructions? Head over to{" "}
......
......@@ -14,7 +14,7 @@ const geistMono = Geist_Mono({
export default function Home() {
return (
<div
className={`${geistSans.className} ${geistMono.className} flex min-h-screen items-center justify-center bg-zinc-50 font-sans dark:bg-black`}
className={`${geistSans.variable} ${geistMono.variable} flex min-h-screen items-center justify-center bg-zinc-50 font-sans dark:bg-black`}
>
<main className="flex min-h-screen w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
<Image
......@@ -27,7 +27,11 @@ export default function Home() {
/>
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
To get started, edit the index.tsx file.
To get started, edit the{" "}
<code className="rounded bg-black/[.06] px-1.5 py-0.5 font-mono text-[0.9em] dark:bg-white/[.08]">
index.tsx
</code>{" "}
file.
</h1>
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
Looking for a starting point or more instructions? Head over to{" "}
......
......@@ -35,7 +35,10 @@ export default function Home() {
priority
/>
<div className={styles.intro}>
<h1>To get started, edit the index.js file.</h1>
<h1>
To get started, edit the{" "}
<code className={styles.code}>index.js</code> file.
</h1>
<p>
Looking for a starting point or more instructions? Head over to{" "}
<a
......
......@@ -139,3 +139,11 @@ a.secondary {
--button-secondary-border: #1a1a1a;
}
}
.code {
font-family: var(--font-geist-mono);
font-size: 0.9em;
background: color-mix(in srgb, currentColor 8%, transparent);
padding: 0.1em 0.4em;
border-radius: 6px;
}
......@@ -35,7 +35,10 @@ export default function Home() {
priority
/>
<div className={styles.intro}>
<h1>To get started, edit the index.tsx file.</h1>
<h1>
To get started, edit the{" "}
<code className={styles.code}>index.tsx</code> file.
</h1>
<p>
Looking for a starting point or more instructions? Head over to{" "}
<a
......
......@@ -139,3 +139,11 @@ a.secondary {
--button-secondary-border: #1a1a1a;
}
}
.code {
font-family: var(--font-geist-mono);
font-size: 0.9em;
background: color-mix(in srgb, currentColor 8%, transparent);
padding: 0.1em 0.4em;
border-radius: 6px;
}
......@@ -169,12 +169,17 @@ export async function tryNextDev({
expect(await res.text()).toContain('Hello world!')
} else {
const responseText = await res.text()
// The filename in the intro line is wrapped in a `<code>` element, so
// strip HTML tags and collapse whitespace before matching the copy.
const textContent = responseText
.replace(/<[^>]+>/g, '')
.replace(/\s+/g, ' ')
const hasAppRouterText =
responseText.includes('To get started, edit the page.tsx file.') ||
responseText.includes('To get started, edit the page.js file.')
textContent.includes('To get started, edit the page.tsx file.') ||
textContent.includes('To get started, edit the page.js file.')
const hasPagesRouterText =
responseText.includes('To get started, edit the index.tsx file.') ||
responseText.includes('To get started, edit the index.js file.')
textContent.includes('To get started, edit the index.tsx file.') ||
textContent.includes('To get started, edit the index.js file.')
expect(hasAppRouterText || hasPagesRouterText).toBe(true)
}
expect(res.status).toBe(200)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment