Skip to content

Commit

Permalink
[IOAPPX-429] Enable allowFontScaling by default in the IOText com…
Browse files Browse the repository at this point in the history
…ponent (#359)

## Short description
This PR enables `allowFontScaling` by default in the `IOText` component.
Previously the default was tied to the state of the `isExperimental`
value, so it was only enabled if you enabled the experimental DS.

## List of changes proposed in this pull request
- Set `allowFontScaling` fallback value to `true` in the `IOText`
component

## How to test
Set larger text on your device and check that the text is dynamic in
both standard and experimental views.
  • Loading branch information
dmnplb authored Dec 17, 2024
1 parent 3798f98 commit b56e04c
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ exports[`Test Advice Components Advice Snapshot 1`] = `
}
/>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="body"
maxFontSizeMultiplier={1.5}
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ exports[`Test Banner Components Banner Snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="headline"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -396,7 +396,7 @@ exports[`Test Banner Components Banner Snapshot 1`] = `
<Text
accessibilityElementsHidden={true}
accessible={false}
allowFontScaling={false}
allowFontScaling={true}
ellipsizeMode="tail"
importantForAccessibility="no-hide-descendants"
maxFontSizeMultiplier={1.5}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ exports[`Test Buttons Components ButtonLink Snapshot 1`] = `
<Text
accessibilityElementsHidden={true}
accessible={false}
allowFontScaling={false}
allowFontScaling={true}
ellipsizeMode="tail"
importantForAccessibility="no-hide-descendants"
maxFontSizeMultiplier={1.5}
Expand Down Expand Up @@ -930,7 +930,7 @@ exports[`Test Buttons Components ButtonOutline Snapshot 1`] = `
<Text
accessibilityElementsHidden={true}
accessible={false}
allowFontScaling={false}
allowFontScaling={true}
ellipsizeMode="tail"
importantForAccessibility="no-hide-descendants"
maxFontSizeMultiplier={1.5}
Expand Down Expand Up @@ -1056,7 +1056,7 @@ exports[`Test Buttons Components ButtonSolid Snapshot 1`] = `
<Text
accessibilityElementsHidden={true}
accessible={false}
allowFontScaling={false}
allowFontScaling={true}
ellipsizeMode="tail"
importantForAccessibility="no-hide-descendants"
maxFontSizeMultiplier={1.5}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ exports[`Test List Item Components ListItemAction Snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
maxFontSizeMultiplier={1.5}
style={
[
Expand Down Expand Up @@ -1840,7 +1840,7 @@ exports[`Test List Item Components ListItemIDP Snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
maxFontSizeMultiplier={1.5}
style={
[
Expand Down Expand Up @@ -1913,7 +1913,7 @@ exports[`Test List Item Components ListItemInfo Snapshot 1`] = `
accessible={true}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="footnote"
maxFontSizeMultiplier={1.5}
style={
Expand All @@ -1933,7 +1933,7 @@ exports[`Test List Item Components ListItemInfo Snapshot 1`] = `
label
</Text>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="headline"
maxFontSizeMultiplier={1.5}
numberOfLines={2}
Expand Down Expand Up @@ -2039,7 +2039,7 @@ exports[`Test List Item Components ListItemInfoCopy Snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="footnote"
maxFontSizeMultiplier={1.5}
style={
Expand All @@ -2059,7 +2059,7 @@ exports[`Test List Item Components ListItemInfoCopy Snapshot 1`] = `
label
</Text>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="headline"
maxFontSizeMultiplier={1.5}
numberOfLines={2}
Expand Down Expand Up @@ -2223,7 +2223,7 @@ exports[`Test List Item Components ListItemNav Snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="headline"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -2448,7 +2448,7 @@ exports[`Test List Item Components ListItemNavAlert Snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="headline"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -2610,7 +2610,7 @@ exports[`Test List Item Components ListItemRadioWithAmount Snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="headline"
maxFontSizeMultiplier={1.5}
numberOfLines={1}
Expand Down Expand Up @@ -2698,7 +2698,7 @@ exports[`Test List Item Components ListItemRadioWithAmount Snapshot 1`] = `
</RNSVGGroup>
</RNSVGSvgView>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="footnote"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -2732,7 +2732,7 @@ exports[`Test List Item Components ListItemRadioWithAmount Snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="headline"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -2983,7 +2983,7 @@ exports[`Test List Item Components ListItemRadioWithAmount Snapshot 2`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="headline"
maxFontSizeMultiplier={1.5}
numberOfLines={1}
Expand Down Expand Up @@ -3017,7 +3017,7 @@ exports[`Test List Item Components ListItemRadioWithAmount Snapshot 2`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="headline"
maxFontSizeMultiplier={1.5}
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ exports[`NumberPad Should match the snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="title2"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -173,7 +173,7 @@ exports[`NumberPad Should match the snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="title2"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -254,7 +254,7 @@ exports[`NumberPad Should match the snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="title2"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -351,7 +351,7 @@ exports[`NumberPad Should match the snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="title2"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -432,7 +432,7 @@ exports[`NumberPad Should match the snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="title2"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -513,7 +513,7 @@ exports[`NumberPad Should match the snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="title2"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -610,7 +610,7 @@ exports[`NumberPad Should match the snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="title2"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -691,7 +691,7 @@ exports[`NumberPad Should match the snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="title2"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -772,7 +772,7 @@ exports[`NumberPad Should match the snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="title2"
maxFontSizeMultiplier={1.5}
style={
Expand Down Expand Up @@ -1010,7 +1010,7 @@ exports[`NumberPad Should match the snapshot 1`] = `
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
dynamicTypeRamp="title2"
maxFontSizeMultiplier={1.5}
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ exports[`Test ToastNotification component should match snapshot for props ({ mes
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
maxFontSizeMultiplier={1.5}
style={
[
Expand Down Expand Up @@ -501,7 +501,7 @@ exports[`Test ToastNotification component should match snapshot for props ({ mes
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
maxFontSizeMultiplier={1.5}
style={
[
Expand Down Expand Up @@ -550,7 +550,7 @@ exports[`Test ToastNotification component should match snapshot for props ({ mes
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
maxFontSizeMultiplier={1.5}
style={
[
Expand Down Expand Up @@ -599,7 +599,7 @@ exports[`Test ToastNotification component should match snapshot for props ({ mes
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
maxFontSizeMultiplier={1.5}
style={
[
Expand Down Expand Up @@ -648,7 +648,7 @@ exports[`Test ToastNotification component should match snapshot for props ({ mes
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
maxFontSizeMultiplier={1.5}
style={
[
Expand Down Expand Up @@ -697,7 +697,7 @@ exports[`Test ToastNotification component should match snapshot for props ({ mes
}
>
<Text
allowFontScaling={false}
allowFontScaling={true}
maxFontSizeMultiplier={1.5}
style={
[
Expand Down
10 changes: 4 additions & 6 deletions src/components/typography/IOText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {
TextStyle,
View
} from "react-native";
import { IOColors, useIOExperimentalDesign, useIOTheme } from "../../core";
import { IOColors, useIOTheme } from "../../core";
import { useBoldTextEnabled } from "../../utils/accessibility";
import {
IOFontFamily,
IOFontWeight,
IOFontSizeMultiplier,
IOFontWeight,
makeFontStyleObject
} from "../../utils/fonts";

Expand Down Expand Up @@ -95,7 +95,7 @@ export const IOText = forwardRef<View, IOTextProps>(
textStyle,
style,
children,
allowFontScaling,
allowFontScaling = true,
maxFontSizeMultiplier,
...props
},
Expand All @@ -104,8 +104,6 @@ export const IOText = forwardRef<View, IOTextProps>(
const theme = useIOTheme();
const boldEnabled = useBoldTextEnabled();

const { isExperimental } = useIOExperimentalDesign();

const computedStyleObj = useMemo(
() =>
calculateTextStyle(
Expand Down Expand Up @@ -143,7 +141,7 @@ export const IOText = forwardRef<View, IOTextProps>(

/* Accessible typography based on the `fontScale` parameter */
const accessibleFontSizeProps: ComponentProps<typeof Text> = {
allowFontScaling: allowFontScaling ?? isExperimental,
allowFontScaling,
maxFontSizeMultiplier: maxFontSizeMultiplier ?? IOFontSizeMultiplier
};

Expand Down
Loading

0 comments on commit b56e04c

Please sign in to comment.