From 1f92c81c107729efe663c9abac00b84cee39d4d0 Mon Sep 17 00:00:00 2001 From: kenny lopez Date: Wed, 12 Aug 2026 12:52:24 +0100 Subject: [PATCH] Scale font size across the desktop app Signed-off-by: kenny lopez --- desktop/src/app/useWebviewZoomShortcuts.ts | 5 +- .../ui/AppearanceSettingsControls.tsx | 36 ++-- desktop/src/main.tsx | 4 +- .../conversationFontSizePreference.test.mjs | 56 ------ .../lib/conversationFontSizePreference.ts | 84 --------- .../shared/lib/fontSizePreference.test.mjs | 59 +++++++ desktop/src/shared/lib/fontSizePreference.ts | 96 ++++++++++ desktop/src/shared/styles/globals/theme.css | 20 +-- desktop/tailwind.config.js | 4 +- .../tests/e2e/buzz-theme-screenshots.spec.ts | 164 +++++++++++------- .../e2e/inbox-refactor-screenshots.spec.ts | 33 ++-- 11 files changed, 303 insertions(+), 258 deletions(-) delete mode 100644 desktop/src/shared/lib/conversationFontSizePreference.test.mjs delete mode 100644 desktop/src/shared/lib/conversationFontSizePreference.ts create mode 100644 desktop/src/shared/lib/fontSizePreference.test.mjs create mode 100644 desktop/src/shared/lib/fontSizePreference.ts diff --git a/desktop/src/app/useWebviewZoomShortcuts.ts b/desktop/src/app/useWebviewZoomShortcuts.ts index cda6c0f2ed..c664d68da7 100644 --- a/desktop/src/app/useWebviewZoomShortcuts.ts +++ b/desktop/src/app/useWebviewZoomShortcuts.ts @@ -1,13 +1,13 @@ import * as React from "react"; import { getCurrentWebview } from "@tauri-apps/api/webview"; +import { applyTextZoomFactor } from "@/shared/lib/fontSizePreference"; import { hasPrimaryShortcutModifier } from "@/shared/lib/platform"; const DEFAULT_ZOOM_FACTOR = 1; const MIN_ZOOM_FACTOR = 0.75; const MAX_ZOOM_FACTOR = 1.5; const ZOOM_STEP = 0.1; -const BASE_FONT_SIZE_PX = 16; const TEXT_SCALE_STORAGE_KEY = "buzz:text-scale"; type ZoomAction = "increase" | "decrease" | "reset"; @@ -76,13 +76,12 @@ function readStoredZoomFactor() { } function applyTextScale(zoomFactor: number) { + applyTextZoomFactor(zoomFactor); if (zoomFactor === DEFAULT_ZOOM_FACTOR) { - document.documentElement.style.fontSize = ""; window.localStorage.removeItem(TEXT_SCALE_STORAGE_KEY); return; } - document.documentElement.style.fontSize = `${BASE_FONT_SIZE_PX * zoomFactor}px`; window.localStorage.setItem(TEXT_SCALE_STORAGE_KEY, String(zoomFactor)); } diff --git a/desktop/src/features/settings/ui/AppearanceSettingsControls.tsx b/desktop/src/features/settings/ui/AppearanceSettingsControls.tsx index bd7113a461..0f171c5b51 100644 --- a/desktop/src/features/settings/ui/AppearanceSettingsControls.tsx +++ b/desktop/src/features/settings/ui/AppearanceSettingsControls.tsx @@ -21,11 +21,11 @@ import { type ConversationDensity, } from "@/shared/lib/conversationDensityPreference"; import { - previewConversationFontSize, - setConversationFontSize, - useConversationFontSize, - type ConversationFontSize, -} from "@/shared/lib/conversationFontSizePreference"; + previewFontSize, + setFontSize, + useFontSize, + type FontSize, +} from "@/shared/lib/fontSizePreference"; import { ACCENT_COLORS, DEFAULT_GLASS_OPACITY, @@ -111,8 +111,8 @@ const CONVERSATION_DENSITY_OPTIONS: readonly { }, ]; -const CONVERSATION_FONT_SIZE_OPTIONS: readonly { - value: ConversationFontSize; +const FONT_SIZE_OPTIONS: readonly { + value: FontSize; label: string; }[] = [ { @@ -167,10 +167,10 @@ function ConversationPreview() {