From 1de9d1aa33e4e40af29e2341b01e900dbac429f5 Mon Sep 17 00:00:00 2001 From: Claire Chabas Date: Tue, 14 Jan 2025 15:48:05 +0100 Subject: [PATCH] Antialias text but not code/pre elements (#2747) --- .changeset/clever-mangos-explode.md | 5 +++++ .../src/components/RootLayout/CustomizationRootLayout.tsx | 1 - packages/gitbook/src/components/RootLayout/globals.css | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .changeset/clever-mangos-explode.md diff --git a/.changeset/clever-mangos-explode.md b/.changeset/clever-mangos-explode.md new file mode 100644 index 000000000..21a2cfa20 --- /dev/null +++ b/.changeset/clever-mangos-explode.md @@ -0,0 +1,5 @@ +--- +'gitbook': patch +--- + +Apply antialiasing on any text that are not code inline/blocks to avoid contrast issues diff --git a/packages/gitbook/src/components/RootLayout/CustomizationRootLayout.tsx b/packages/gitbook/src/components/RootLayout/CustomizationRootLayout.tsx index 08db8645f..03e341c71 100644 --- a/packages/gitbook/src/components/RootLayout/CustomizationRootLayout.tsx +++ b/packages/gitbook/src/components/RootLayout/CustomizationRootLayout.tsx @@ -160,7 +160,6 @@ export async function CustomizationRootLayout(props: { fontNotoColorEmoji.className, `${fonts[customization.styling.font].className}`, `${ibmPlexMono.variable}`, - 'antialiased', 'bg-light', 'dark:bg-dark', )} diff --git a/packages/gitbook/src/components/RootLayout/globals.css b/packages/gitbook/src/components/RootLayout/globals.css index 961a58fe6..1f7a4b2ab 100644 --- a/packages/gitbook/src/components/RootLayout/globals.css +++ b/packages/gitbook/src/components/RootLayout/globals.css @@ -23,7 +23,7 @@ @apply leading-relaxed; } body { - @apply text-dark dark:text-light; + @apply text-dark dark:text-light antialiased; } html { @apply gutter-stable; @@ -54,6 +54,12 @@ @apply outline-2 outline-primary/6; } + code, + pre { + /* Don't apply antialiased to `code` and `pre` elements */ + @apply subpixel-antialiased; + } + /* Light mode */ ::-webkit-scrollbar { @apply bg-dark/1;