From 9b8ebdc9b3027e212948dce1c4ff5e12387f6e7c Mon Sep 17 00:00:00 2001 From: lrnselfreliance <33263708+lrnselfreliance@users.noreply.github.com> Date: Thu, 3 Sep 2026 15:47:44 -0600 Subject: [PATCH] files: readable text previews in dark themes (#697) * files: readable text previews in dark themes A same-origin text document inherits the page's color-scheme, so dark themes rendered the browser's default light text on the preview's forced white background. Force a light color-scheme on the preview iframe so text is always black on white. Co-Authored-By: Claude Fable 5 * files: text previews follow the theme Instead of pinning the preview iframe to a light scheme, follow the theme: dark, night, and amber render the document light-on-dark against the theme's panel color; light stays black-on-white. Co-Authored-By: Claude Fable 5 --------- Co-authored-by: Claude Fable 5 --- app/src/components/FilePreview.js | 12 +++++--- app/src/components/FilePreview.test.js | 42 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/app/src/components/FilePreview.js b/app/src/components/FilePreview.js index a9580635..c6ed6e39 100644 --- a/app/src/components/FilePreview.js +++ b/app/src/components/FilePreview.js @@ -100,8 +100,8 @@ function getEpubViewerURL(previewFile) { * A component rather than part of `getIframePreviewModal` because it reads the theme: the * modal builders are plain functions called from an event handler, where hooks cannot run. */ -function IframePreview({url, gatePdf}) { - const {mediaFilterEnabled} = React.useContext(ThemeContext); +export function IframePreview({url, gatePdf}) { + const {isDark, mediaFilterEnabled} = React.useContext(ThemeContext); /* * `gatePdf` only for PDFs. Text and the EPUB viewer are documents of our own, which the @@ -119,8 +119,12 @@ function IframePreview({url, gatePdf}) {