Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

fix: refactor useCSSVariables to ensure valid highest font weights (#2852)

Aman Guptad9a24448e899
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));
-
- return { lowestBodyFontWeight, lowestHeadingFontWeight, highestBodyFontWeight, highestHeadingFontWeight };
+ const rawHighestBodyFontWeight = Math.max(...metadata.typography.body.fontWeights.map(Number));
+ const rawHighestHeadingFontWeight = Math.max(...metadata.typography.heading.fontWeights.map(Number));
+
+ 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 {