Skip to content

Commit

Permalink
feat: support for maxFontSizeMutliplier on Checkbox.Item (callstack#3791
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dimitrisspacecode committed Apr 17, 2023
1 parent 5d445ed commit 4041942
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/Checkbox/CheckboxItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export type Props = {
* Additional styles for container View.
*/
style?: StyleProp<ViewStyle>;
/**
* Specifies the largest possible scale a title font can reach.
*/
maxFontSizeMultiplier?: number;
/**
* Style that is passed to Label element.
*/
Expand Down Expand Up @@ -121,6 +125,7 @@ const CheckboxItem = ({
accessibilityLabel = label,
disabled,
labelVariant = 'bodyLarge',
maxFontSizeMultiplier = 1.5,
...props
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -168,6 +173,8 @@ const CheckboxItem = ({
{isLeading && checkbox}
<Text
variant={labelVariant}
testID={`${testID}-text`}
maxFontSizeMultiplier={maxFontSizeMultiplier}
style={[
styles.label,
!theme.isV3 && styles.font,
Expand Down
8 changes: 8 additions & 0 deletions src/components/__tests__/Checkbox/CheckboxItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,11 @@ it('disables the row when the prop disabled is true', () => {
accessibilityState: { disabled: true },
});
});

it('should have maxFontSizeMultiplier set to 1.5 by default', () => {
const { getByTestId } = render(
<Checkbox.Item label="" testID="checkbox-item" status="unchecked" />
);
const checkboxItemText = getByTestId('checkbox-item-text');
expect(checkboxItemText.props.maxFontSizeMultiplier).toBe(1.5);
});
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ exports[`can render leading checkbox control 1`] = `
</View>
</View>
<Text
maxFontSizeMultiplier={1.5}
style={
Array [
Object {
Expand Down Expand Up @@ -156,6 +157,7 @@ exports[`can render leading checkbox control 1`] = `
],
]
}
testID="undefined-text"
>
Default with leading control
</Text>
Expand Down Expand Up @@ -210,6 +212,7 @@ exports[`can render the Android checkbox on different platforms 1`] = `
}
>
<Text
maxFontSizeMultiplier={1.5}
style={
Array [
Object {
Expand Down Expand Up @@ -240,6 +243,7 @@ exports[`can render the Android checkbox on different platforms 1`] = `
],
]
}
testID="undefined-text"
>
iOS Checkbox
</Text>
Expand Down Expand Up @@ -409,6 +413,7 @@ exports[`can render the iOS checkbox on different platforms 1`] = `
}
>
<Text
maxFontSizeMultiplier={1.5}
style={
Array [
Object {
Expand Down Expand Up @@ -439,6 +444,7 @@ exports[`can render the iOS checkbox on different platforms 1`] = `
],
]
}
testID="undefined-text"
>
iOS Checkbox
</Text>
Expand Down Expand Up @@ -572,6 +578,7 @@ exports[`renders unchecked 1`] = `
}
>
<Text
maxFontSizeMultiplier={1.5}
style={
Array [
Object {
Expand Down Expand Up @@ -602,6 +609,7 @@ exports[`renders unchecked 1`] = `
],
]
}
testID="undefined-text"
>
Unchecked Button
</Text>
Expand Down

0 comments on commit 4041942

Please sign in to comment.