mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-24 17:03:55 +10:00
chore: update postcss to version 8.5.14 and sort font weights in typography components
This commit is contained in:
@@ -85,4 +85,18 @@ describe("registerFonts", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("returns typography with font weights sorted ascending", async () => {
|
||||
vi.spyOn(Font, "register").mockImplementation(() => {});
|
||||
const { registerFonts } = await import("./use-register-fonts");
|
||||
|
||||
const pdfTypography = registerFonts({
|
||||
...typography,
|
||||
body: { ...typography.body, fontFamily: "Source Sans 3", fontWeights: ["800", "600", "400"] },
|
||||
heading: { ...typography.heading, fontFamily: "Source Sans 3", fontWeights: ["900", "500"] },
|
||||
});
|
||||
|
||||
expect(pdfTypography.body.fontWeights).toEqual(["400", "600", "800"]);
|
||||
expect(pdfTypography.heading.fontWeights).toEqual(["500", "900"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
getPdfCjkFallbackFontFamily,
|
||||
getWebFontSource,
|
||||
isStandardPdfFontFamily,
|
||||
sortFontWeights,
|
||||
} from "@reactive-resume/fonts";
|
||||
|
||||
type FontWeightRange = {
|
||||
@@ -53,15 +54,13 @@ const resolvePdfFontFamily = (family: string) => {
|
||||
const resolvePdfTypography = (typography: Typography): Typography => {
|
||||
const bodyFontFamily = resolvePdfFontFamily(typography.body.fontFamily);
|
||||
const headingFontFamily = resolvePdfFontFamily(typography.heading.fontFamily);
|
||||
|
||||
if (bodyFontFamily === typography.body.fontFamily && headingFontFamily === typography.heading.fontFamily) {
|
||||
return typography;
|
||||
}
|
||||
const bodyFontWeights = sortFontWeights(typography.body.fontWeights);
|
||||
const headingFontWeights = sortFontWeights(typography.heading.fontWeights);
|
||||
|
||||
return {
|
||||
...typography,
|
||||
body: { ...typography.body, fontFamily: bodyFontFamily },
|
||||
heading: { ...typography.heading, fontFamily: headingFontFamily },
|
||||
body: { ...typography.body, fontFamily: bodyFontFamily, fontWeights: bodyFontWeights },
|
||||
heading: { ...typography.heading, fontFamily: headingFontFamily, fontWeights: headingFontWeights },
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user