Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IOAPPX-362] Change Label… default weight to Semibold + Fix autocomplete of IOText when using font prop #322

Merged
merged 4 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/typography/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const Label = forwardRef<View, LabelProps>(
const LabelProps: IOTextProps = {
...props,
font: "TitilliumSansPro",
weight: customWeight ?? "Bold",
weight: customWeight ?? "Semibold",
size: 16,
lineHeight: 24,
color: customColor ?? defaultColor,
Expand Down
2 changes: 1 addition & 1 deletion src/components/typography/LabelMini.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const LabelMini = forwardRef<View, LabelMiniProps>(
...props,
dynamicTypeRamp: "footnote" /* iOS only */,
font: "TitilliumSansPro",
weight: customWeight ?? "Bold",
weight: customWeight ?? "Semibold",
size: 12,
lineHeight: 18,
color: customColor ?? defaultColor,
Expand Down
2 changes: 1 addition & 1 deletion src/components/typography/LabelSmall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const LabelSmall = forwardRef<View, LabelSmallProps>(
...props,
dynamicTypeRamp: "footnote" /* iOS only */,
font: "TitilliumSansPro",
weight: customWeight ?? "Bold",
weight: customWeight ?? "Semibold",
size: 14,
lineHeight: 21,
color: customColor ?? defaultColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
]
Expand All @@ -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,
},
]
Expand All @@ -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,
},
]
Expand All @@ -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,
},
]
Expand All @@ -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,
},
]
Expand All @@ -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,
},
]
Expand All @@ -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,
},
]
Expand All @@ -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,
},
]
Expand Down
8 changes: 5 additions & 3 deletions src/utils/fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Platform, TextStyle } from "react-native";
/**
* Choose the font name based on the platform
*/
const fonts: Record<string, string> = {
const fonts = {
TitilliumSansPro: Platform.select({
android: "TitilliumSansPro",
web: "TitilliumSansPro",
Expand Down Expand Up @@ -64,7 +64,9 @@ export const fontWeights: Record<IOFontWeight, IOFontWeightNumeric> = {

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"];
Expand Down Expand Up @@ -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"}${
Expand Down
Loading