From d9a24448e8995f8d13907ec36c6256fc3e11a369 Mon Sep 17 00:00:00 2001 From: Aman Gupta <82163073+AmanGupta-95@users.noreply.github.com> Date: Wed, 1 Apr 2026 02:11:24 +0530 Subject: [PATCH] fix: refactor useCSSVariables to ensure valid highest font weights (#2852) --- src/components/resume/hooks/use-css-variables.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/resume/hooks/use-css-variables.tsx b/src/components/resume/hooks/use-css-variables.tsx index 409bf8aac..ecdadc7aa 100644 --- a/src/components/resume/hooks/use-css-variables.tsx +++ b/src/components/resume/hooks/use-css-variables.tsx @@ -13,10 +13,19 @@ export const useCSSVariables = ({ picture, metadata }: UseCssVariablesProps) => const lowestBodyFontWeight = Math.min(...metadata.typography.body.fontWeights.map(Number)); const lowestHeadingFontWeight = Math.min(...metadata.typography.heading.fontWeights.map(Number)); - const highestBodyFontWeight = Math.max(...metadata.typography.body.fontWeights.map(Number)); - const highestHeadingFontWeight = Math.max(...metadata.typography.heading.fontWeights.map(Number)); + const rawHighestBodyFontWeight = Math.max(...metadata.typography.body.fontWeights.map(Number)); + const rawHighestHeadingFontWeight = Math.max(...metadata.typography.heading.fontWeights.map(Number)); - return { lowestBodyFontWeight, lowestHeadingFontWeight, highestBodyFontWeight, highestHeadingFontWeight }; + const highestBodyFontWeight = rawHighestBodyFontWeight <= lowestBodyFontWeight ? 700 : rawHighestBodyFontWeight; + const highestHeadingFontWeight = + rawHighestHeadingFontWeight <= lowestHeadingFontWeight ? 700 : rawHighestHeadingFontWeight; + + return { + lowestBodyFontWeight, + lowestHeadingFontWeight, + highestBodyFontWeight, + highestHeadingFontWeight, + }; }, [metadata.typography.body.fontWeights, metadata.typography.heading.fontWeights]); return {