From b771b51842f418a757d72f68ee49375260f81d8a Mon Sep 17 00:00:00 2001 From: Stefan de Vogelaere Date: Sat, 17 Jan 2026 02:17:26 +0100 Subject: [PATCH] fix: address code review feedback - Fix git+ssh URL to git+https for @electron/node-gyp (build compatibility) - Remove duplicate @fontsource packages from root package.json - Refactor font state initialization to reduce code duplication --- .../project-theme-section.tsx | 40 +++++++------------ package-lock.json | 18 +-------- package.json | 7 ---- 3 files changed, 15 insertions(+), 50 deletions(-) diff --git a/apps/ui/src/components/views/project-settings-view/project-theme-section.tsx b/apps/ui/src/components/views/project-settings-view/project-theme-section.tsx index 003e8b86..933521fd 100644 --- a/apps/ui/src/components/views/project-settings-view/project-theme-section.tsx +++ b/apps/ui/src/components/views/project-settings-view/project-theme-section.tsx @@ -43,40 +43,28 @@ export function ProjectThemeSection({ project }: ProjectThemeSectionProps) { const [activeTab, setActiveTab] = useState<'dark' | 'light'>(isLightTheme ? 'light' : 'dark'); // Helper to validate fonts against available options - const isValidSansFont = (font: string | undefined): boolean => { - if (!font) return false; - return UI_SANS_FONT_OPTIONS.some((opt) => opt.value === font); - }; - const isValidMonoFont = (font: string | undefined): boolean => { - if (!font) return false; - return UI_MONO_FONT_OPTIONS.some((opt) => opt.value === font); - }; + const isValidSansFont = (font?: string): boolean => + !!font && UI_SANS_FONT_OPTIONS.some((opt) => opt.value === font); + const isValidMonoFont = (font?: string): boolean => + !!font && UI_MONO_FONT_OPTIONS.some((opt) => opt.value === font); + + // Helper to get initial font value with validation + const getInitialFontValue = (font: string | undefined, validator: (f?: string) => boolean) => + font && validator(font) ? font : DEFAULT_FONT_VALUE; // Font local state - tracks what's selected when using custom fonts // Falls back to default if stored font is not in available options - const [fontSansLocal, setFontSansLocal] = useState( - project.fontFamilySans && isValidSansFont(project.fontFamilySans) - ? project.fontFamilySans - : DEFAULT_FONT_VALUE + const [fontSansLocal, setFontSansLocal] = useState(() => + getInitialFontValue(project.fontFamilySans, isValidSansFont) ); - const [fontMonoLocal, setFontMonoLocal] = useState( - project.fontFamilyMono && isValidMonoFont(project.fontFamilyMono) - ? project.fontFamilyMono - : DEFAULT_FONT_VALUE + const [fontMonoLocal, setFontMonoLocal] = useState(() => + getInitialFontValue(project.fontFamilyMono, isValidMonoFont) ); // Sync state when project changes useEffect(() => { - setFontSansLocal( - project.fontFamilySans && isValidSansFont(project.fontFamilySans) - ? project.fontFamilySans - : DEFAULT_FONT_VALUE - ); - setFontMonoLocal( - project.fontFamilyMono && isValidMonoFont(project.fontFamilyMono) - ? project.fontFamilyMono - : DEFAULT_FONT_VALUE - ); + setFontSansLocal(getInitialFontValue(project.fontFamilySans, isValidSansFont)); + setFontMonoLocal(getInitialFontValue(project.fontFamilyMono, isValidMonoFont)); // Also sync the active tab based on current theme const currentIsLight = lightThemes.some((t) => t.value === (project.theme || globalTheme)); setActiveTab(currentIsLight ? 'light' : 'dark'); diff --git a/package-lock.json b/package-lock.json index bd5fbb43..005c1e7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,13 +13,6 @@ "libs/*" ], "dependencies": { - "@fontsource/cascadia-code": "^5.2.3", - "@fontsource/iosevka": "^5.2.5", - "@fontsource/lato": "^5.2.7", - "@fontsource/montserrat": "^5.2.8", - "@fontsource/playfair-display": "^5.2.8", - "@fontsource/raleway": "^5.2.8", - "@fontsource/source-sans-3": "^5.2.9", "cross-spawn": "7.0.6", "rehype-sanitize": "6.0.0", "tree-kill": "1.2.2" @@ -1503,7 +1496,7 @@ }, "node_modules/@electron/node-gyp": { "version": "10.2.0-electron.1", - "resolved": "git+ssh://git@github.com/electron/node-gyp.git#06b29aafb7708acef8b3669835c8a7857ebc92d2", + "resolved": "git+https://github.com/electron/node-gyp.git#06b29aafb7708acef8b3669835c8a7857ebc92d2", "integrity": "sha512-4MSBTT8y07YUDqf69/vSh80Hh791epYqGtWHO3zSKhYFwQg+gx9wi1PqbqP6YqC4WMsNxZ5l9oDmnWdK5pfCKQ==", "dev": true, "license": "MIT", @@ -2927,15 +2920,6 @@ "url": "https://github.com/sponsors/ayuhito" } }, - "node_modules/@fontsource/playfair-display": { - "version": "5.2.8", - "resolved": "https://registry.npmjs.org/@fontsource/playfair-display/-/playfair-display-5.2.8.tgz", - "integrity": "sha512-fUEhib70SszNhQVsGbUMSsWJhr7Je0rdeuZdtGpDNu0GKF1xJM8QhpI/y0pckU25GcChXm9TLOmeZupkvvZo2g==", - "license": "OFL-1.1", - "funding": { - "url": "https://github.com/sponsors/ayuhito" - } - }, "node_modules/@fontsource/poppins": { "version": "5.2.7", "resolved": "https://registry.npmjs.org/@fontsource/poppins/-/poppins-5.2.7.tgz", diff --git a/package.json b/package.json index f550b786..5418b71b 100644 --- a/package.json +++ b/package.json @@ -62,13 +62,6 @@ ] }, "dependencies": { - "@fontsource/cascadia-code": "^5.2.3", - "@fontsource/iosevka": "^5.2.5", - "@fontsource/lato": "^5.2.7", - "@fontsource/montserrat": "^5.2.8", - "@fontsource/playfair-display": "^5.2.8", - "@fontsource/raleway": "^5.2.8", - "@fontsource/source-sans-3": "^5.2.9", "cross-spawn": "7.0.6", "rehype-sanitize": "6.0.0", "tree-kill": "1.2.2"