Skip to content

Commit

Permalink
Add granular support for allowFontScaling to the IOText component (
Browse files Browse the repository at this point in the history
…#347)

## Short description
This PR adds granular support for the `allowFontScaling` and
`maxFontSizeMultiplier` props to the `IOText` component. This change
alone allows the developer to override these values in the single
instance instead of all instances.

## List of changes proposed in this pull request
- Relax the TS check about `IOText` for the mentioned props

## How to test
Try forcing `allowFontScaling` on the typographic styles, even with the
experimental DS turned off.
  • Loading branch information
dmnplb authored Nov 8, 2024
1 parent 00198c4 commit 1b58e30
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/components/typography/IOText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ type IOTextBaseProps = {
style?: IOTextStyle;
};

type IOTextExcludedProps = Omit<
ComponentProps<typeof Text>,
"allowFontScaling" | "maxFontSizeMultiplier" | "style"
>;
type IOTextExcludedProps = Omit<ComponentProps<typeof Text>, "style">;

export type IOTextProps = IOTextBaseProps & IOTextExcludedProps;

Expand Down Expand Up @@ -98,6 +95,8 @@ export const IOText = forwardRef<View, IOTextProps>(
textStyle,
style,
children,
allowFontScaling,
maxFontSizeMultiplier,
...props
},
ref
Expand Down Expand Up @@ -144,8 +143,8 @@ export const IOText = forwardRef<View, IOTextProps>(

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

return (
Expand Down

0 comments on commit 1b58e30

Please sign in to comment.