Skip to content

Commit eccf767

Browse files
authored
chore: [IOAPPX-488] Increase title size in the HeaderFirstLevel (#415)
## Short description This PR increases the size of the title in the `HeaderFirstLevel` ## List of changes proposed in this pull request - Refactor `H2` and `H3` to allow/remove `Bold` weight - Add `maxFontSizeMultiplier` to set a maximum size limit when larger text is enabled - Update `Typography` page in the example app ### Preview <img src="https://github.com/user-attachments/assets/7850c361-597d-41d5-abe9-ff7ca9467ac4" width="320" /> ## How to test N/A
1 parent fbd4097 commit eccf767

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

example/src/pages/HeaderFirstLevel.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
Body,
44
ButtonOutline,
55
ButtonSolid,
6-
H3,
76
H6,
87
HeaderActionProps,
98
HeaderFirstLevel,
@@ -83,7 +82,7 @@ export const HeaderFirstLevelScreen = () => {
8382
header: () => (
8483
<HeaderFirstLevel
8584
ignoreSafeAreaMargin={alert !== undefined}
86-
title={"Pagina"}
85+
title={"Portafoglio"}
8786
actions={actionsConfiguration[actionsSize]}
8887
/>
8988
)
@@ -98,8 +97,6 @@ export const HeaderFirstLevelScreen = () => {
9897
}}
9998
scrollEventThrottle={8}
10099
>
101-
<H3>Questo è un titolo lungo, ma lungo lungo davvero, eh!</H3>
102-
<VSpacer />
103100
<ListItemHeader label="Header actions size" />
104101
<ListItemRadio
105102
value="No actions"

example/src/pages/Typography.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ export const H2Row = () => (
116116
<VStack space={4}>
117117
<H2>{getTitle("H2")}</H2>
118118
<H2 style={styles.distancedTitle}>{getLongerTitle("H2")}</H2>
119+
<H2 style={styles.distancedTitle} weight="Bold">
120+
Header H2 Bold
121+
</H2>
119122
</VStack>
120123
);
121124

@@ -126,7 +129,6 @@ export const H3Row = () => (
126129
<View style={{ backgroundColor: IOColors["grey-700"] }}>
127130
<H3 color={"white"}>Header H3</H3>
128131
</View>
129-
<H3 weight="Bold">Header H3 Bold</H3>
130132
</HStack>
131133
);
132134

src/components/layout/HeaderFirstLevel.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
import { WithTestID } from "../../utils/types";
2424
import { IconButton } from "../buttons";
2525
import { HStack } from "../stack";
26-
import { H3 } from "../typography";
26+
import { H2 } from "../typography";
2727
import { HeaderActionProps } from "./common";
2828

2929
type HeaderActionsProp =
@@ -125,14 +125,15 @@ export const HeaderFirstLevel = ({
125125

126126
<View style={styles.headerInner}>
127127
<View ref={titleRef} accessible accessibilityRole="header">
128-
<H3
128+
<H2
129129
weight="Bold"
130130
style={{ flexShrink: 1 }}
131131
numberOfLines={1}
132132
color={theme["textHeading-default"]}
133+
maxFontSizeMultiplier={1.25}
133134
>
134135
{title}
135-
</H3>
136+
</H2>
136137
</View>
137138
<HStack space={16} style={{ flexShrink: 0 }}>
138139
{actions.map((action, index) => (

src/components/typography/H2.tsx

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
import React, { ForwardedRef, forwardRef } from "react";
22
import { View } from "react-native";
33
import { useIONewTypeface, useIOTheme } from "../../core";
4-
import { IOFontSize } from "../../utils/fonts";
4+
import { IOFontSize, IOFontWeight } from "../../utils/fonts";
55
import { IOText, IOTextProps, TypographicStyleProps } from "./IOText";
66

7+
type H2StyleProps = TypographicStyleProps & {
8+
weight?: Extract<IOFontWeight, "Semibold" | "Bold">;
9+
};
10+
711
export const h2FontSize: IOFontSize = 26;
812
export const h2LineHeight = 34;
913

1014
/**
1115
* `H2` typographic style
1216
*/
13-
export const H2 = forwardRef<View, TypographicStyleProps>(
14-
({ color: customColor, ...props }, ref?: ForwardedRef<View>) => {
17+
export const H2 = forwardRef<View, H2StyleProps>(
18+
(
19+
{ weight: customWeight, color: customColor, ...props },
20+
ref?: ForwardedRef<View>
21+
) => {
1522
const theme = useIOTheme();
1623
const { newTypefaceEnabled } = useIONewTypeface();
1724

1825
const H2Props: IOTextProps = {
1926
...props,
2027
dynamicTypeRamp: "title1", // iOS only
2128
font: newTypefaceEnabled ? "Titillio" : "TitilliumSansPro",
22-
weight: "Semibold",
29+
weight: customWeight ?? "Semibold",
2330
size: h2FontSize,
2431
lineHeight: h2LineHeight,
2532
color: customColor ?? theme["textHeading-default"]

src/components/typography/H3.tsx

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
11
import React, { ForwardedRef, forwardRef } from "react";
22
import { View } from "react-native";
33
import { useIONewTypeface, useIOTheme } from "../../core";
4-
import { IOFontSize, IOFontWeight } from "../../utils/fonts";
4+
import { IOFontSize } from "../../utils/fonts";
55
import { IOText, IOTextProps, TypographicStyleProps } from "./IOText";
66

7-
type H3StyleProps = TypographicStyleProps & {
8-
weight?: Extract<IOFontWeight, "Semibold" | "Bold">;
9-
};
10-
117
/* Common typographic styles */
128
export const h3FontSize: IOFontSize = 22;
139
export const h3LineHeight = 33;
1410

1511
/**
1612
* `H3` typographic style
1713
*/
18-
export const H3 = forwardRef<View, H3StyleProps>(
19-
(
20-
{ weight: customWeight, color: customColor, ...props },
21-
ref?: ForwardedRef<View>
22-
) => {
14+
export const H3 = forwardRef<View, TypographicStyleProps>(
15+
({ color: customColor, ...props }, ref?: ForwardedRef<View>) => {
2316
const theme = useIOTheme();
2417
const { newTypefaceEnabled } = useIONewTypeface();
2518

2619
const H3Props: IOTextProps = {
2720
...props,
2821
dynamicTypeRamp: "title2", // iOS only
2922
font: newTypefaceEnabled ? "Titillio" : "TitilliumSansPro",
30-
weight: customWeight ?? "Semibold",
23+
weight: "Semibold",
3124
size: h3FontSize,
3225
lineHeight: h3LineHeight,
3326
color: customColor ?? theme["textHeading-default"]

0 commit comments

Comments
 (0)