From 1b58e3048711602acf9255caec0fb174ee0ef3f9 Mon Sep 17 00:00:00 2001 From: Damiano Plebani Date: Fri, 8 Nov 2024 16:30:06 +0100 Subject: [PATCH] Add granular support for `allowFontScaling` to the `IOText` component (#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. --- src/components/typography/IOText.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/typography/IOText.tsx b/src/components/typography/IOText.tsx index a8e01ce4..965d8668 100644 --- a/src/components/typography/IOText.tsx +++ b/src/components/typography/IOText.tsx @@ -47,10 +47,7 @@ type IOTextBaseProps = { style?: IOTextStyle; }; -type IOTextExcludedProps = Omit< - ComponentProps, - "allowFontScaling" | "maxFontSizeMultiplier" | "style" ->; +type IOTextExcludedProps = Omit, "style">; export type IOTextProps = IOTextBaseProps & IOTextExcludedProps; @@ -98,6 +95,8 @@ export const IOText = forwardRef( textStyle, style, children, + allowFontScaling, + maxFontSizeMultiplier, ...props }, ref @@ -144,8 +143,8 @@ export const IOText = forwardRef( /* Accessible typography based on the `fontScale` parameter */ const accessibleFontSizeProps: ComponentProps = { - allowFontScaling: isExperimental, - maxFontSizeMultiplier: 1.25 + allowFontScaling: allowFontScaling ?? isExperimental, + maxFontSizeMultiplier: maxFontSizeMultiplier ?? 1.25 }; return (