From 13819ba2ef5df2811bd7254c861020b8cf9d9cb4 Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Thu, 1 Aug 2024 10:59:44 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Set=20`Label=E2=80=A6`=20default=20weight?= =?UTF-8?q?=20to=20`Semibold`,=20instead=20of=C2=A0`Bold`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/typography/Label.tsx | 2 +- src/components/typography/LabelMini.tsx | 2 +- src/components/typography/LabelSmall.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/typography/Label.tsx b/src/components/typography/Label.tsx index d02510e7..21e081d0 100644 --- a/src/components/typography/Label.tsx +++ b/src/components/typography/Label.tsx @@ -30,7 +30,7 @@ export const Label = forwardRef( const LabelProps: IOTextProps = { ...props, font: "TitilliumSansPro", - weight: customWeight ?? "Bold", + weight: customWeight ?? "Semibold", size: 16, lineHeight: 24, color: customColor ?? defaultColor, diff --git a/src/components/typography/LabelMini.tsx b/src/components/typography/LabelMini.tsx index d423cd2d..bd503e60 100644 --- a/src/components/typography/LabelMini.tsx +++ b/src/components/typography/LabelMini.tsx @@ -31,7 +31,7 @@ export const LabelMini = forwardRef( ...props, dynamicTypeRamp: "footnote" /* iOS only */, font: "TitilliumSansPro", - weight: customWeight ?? "Bold", + weight: customWeight ?? "Semibold", size: 12, lineHeight: 18, color: customColor ?? defaultColor, diff --git a/src/components/typography/LabelSmall.tsx b/src/components/typography/LabelSmall.tsx index 306f4c8a..1a6f1f57 100644 --- a/src/components/typography/LabelSmall.tsx +++ b/src/components/typography/LabelSmall.tsx @@ -31,7 +31,7 @@ export const LabelSmall = forwardRef( ...props, dynamicTypeRamp: "footnote" /* iOS only */, font: "TitilliumSansPro", - weight: customWeight ?? "Bold", + weight: customWeight ?? "Semibold", size: 14, lineHeight: 21, color: customColor ?? defaultColor, From 6f1496c7235d32bf05b5256e62e87fcf38b1abb8 Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Thu, 1 Aug 2024 11:05:31 +0200 Subject: [PATCH 2/4] Fix wrong autocomplete of `IOText` when using `font` prop --- src/utils/fonts.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utils/fonts.ts b/src/utils/fonts.ts index b35ea869..dc3bd869 100644 --- a/src/utils/fonts.ts +++ b/src/utils/fonts.ts @@ -9,7 +9,7 @@ import { Platform, TextStyle } from "react-native"; /** * Choose the font name based on the platform */ -const fonts: Record = { +const fonts = { TitilliumSansPro: Platform.select({ android: "TitilliumSansPro", web: "TitilliumSansPro", @@ -28,7 +28,7 @@ const fonts: Record = { ios: "DM Mono", default: "DMMono" }) -}; +} as const; export type IOFontFamily = keyof typeof fonts; @@ -64,7 +64,9 @@ export const fontWeights: Record = { type FontStyleObject = { fontSize: IOFontSize; - fontFamily: IOFontFamily; + /* We also accept `string` because Android needs a composed + fontFamily name, like `TitilliumSansPro-Regular` */ + fontFamily: string | IOFontFamily; fontWeight?: IOFontWeightNumeric; lineHeight?: TextStyle["lineHeight"]; fontStyle?: TextStyle["fontStyle"]; @@ -94,7 +96,7 @@ export const makeFontFamilyName = ( font: IOFontFamily, weight: IOFontWeight = defaultWeight, fontStyle: TextStyle["fontStyle"] = "normal" -): IOFontFamily => +): FontStyleObject["fontFamily"] => Platform.select({ web: fonts[font], android: `${fonts[font]}-${weight || "Regular"}${ From 0ffdfcd8653afeb70069b3bf793b97e497f88af5 Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Thu, 1 Aug 2024 11:12:59 +0200 Subject: [PATCH 3/4] =?UTF-8?q?Update=20`Label=E2=80=A6`=20snapshots?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__snapshots__/typography.test.tsx.snap | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/typography/__test__/__snapshots__/typography.test.tsx.snap b/src/components/typography/__test__/__snapshots__/typography.test.tsx.snap index 62f0d7d9..26e3ceec 100644 --- a/src/components/typography/__test__/__snapshots__/typography.test.tsx.snap +++ b/src/components/typography/__test__/__snapshots__/typography.test.tsx.snap @@ -462,7 +462,7 @@ exports[`Test Typography Components Label Snapshot 1`] = ` "fontFamily": "Titillium Sans Pro", "fontSize": 16, "fontStyle": "normal", - "fontWeight": "700", + "fontWeight": "600", "lineHeight": 24, }, ] @@ -484,7 +484,7 @@ exports[`Test Typography Components Label Snapshot 2`] = ` "fontFamily": "Titillium Sans Pro", "fontSize": 16, "fontStyle": "normal", - "fontWeight": "700", + "fontWeight": "600", "lineHeight": 24, }, ] @@ -507,7 +507,7 @@ exports[`Test Typography Components LabelSmall Snapshot 1`] = ` "fontFamily": "Titillium Sans Pro", "fontSize": 14, "fontStyle": "normal", - "fontWeight": "700", + "fontWeight": "600", "lineHeight": 21, }, ] @@ -530,7 +530,7 @@ exports[`Test Typography Components LabelSmall Snapshot 2`] = ` "fontFamily": "Titillium Sans Pro", "fontSize": 14, "fontStyle": "normal", - "fontWeight": "700", + "fontWeight": "600", "lineHeight": 21, }, ] @@ -553,7 +553,7 @@ exports[`Test Typography Components LabelSmall Snapshot 3`] = ` "fontFamily": "Titillium Sans Pro", "fontSize": 14, "fontStyle": "normal", - "fontWeight": "700", + "fontWeight": "600", "lineHeight": 21, }, ] @@ -576,7 +576,7 @@ exports[`Test Typography Components LabelSmall Snapshot 4`] = ` "fontFamily": "Titillium Sans Pro", "fontSize": 14, "fontStyle": "normal", - "fontWeight": "700", + "fontWeight": "600", "lineHeight": 21, }, ] @@ -599,7 +599,7 @@ exports[`Test Typography Components LabelSmall Snapshot 5`] = ` "fontFamily": "Titillium Sans Pro", "fontSize": 14, "fontStyle": "normal", - "fontWeight": "700", + "fontWeight": "600", "lineHeight": 21, }, ] @@ -625,7 +625,7 @@ exports[`Test Typography Components Link Snapshot 1`] = ` "fontFamily": "Titillium Sans Pro", "fontSize": 16, "fontStyle": "normal", - "fontWeight": "700", + "fontWeight": "600", "lineHeight": 24, }, ] From 0f4bcde93520fb659ec379faac6bceb97cf105f4 Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Thu, 1 Aug 2024 11:24:13 +0200 Subject: [PATCH 4/4] Remove `as const` --- src/utils/fonts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/fonts.ts b/src/utils/fonts.ts index dc3bd869..2ff4be4f 100644 --- a/src/utils/fonts.ts +++ b/src/utils/fonts.ts @@ -28,7 +28,7 @@ const fonts = { ios: "DM Mono", default: "DMMono" }) -} as const; +}; export type IOFontFamily = keyof typeof fonts;