Skip to content

Commit

Permalink
feat: support for maxFontSizeMultiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewalczak committed Apr 17, 2023
1 parent e771197 commit eabd869
Show file tree
Hide file tree
Showing 23 changed files with 60 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/components/Appbar/AppbarContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const AppbarContent = ({
titleRef,
titleStyle,
title,
titleMaxFontSizeMultiplier,
mode = 'small',
theme: themeOverrides,
testID = 'appbar-content',
Expand Down Expand Up @@ -169,6 +170,7 @@ const AppbarContent = ({
// @ts-expect-error We keep old a11y props for backwards compat with old RN versions
accessibilityTraits="header"
testID={`${testID}-title-text`}
maxFontSizeMultiplier={titleMaxFontSizeMultiplier}
>
{title}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Avatar/AvatarText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const AvatarText = ({
labelStyle,
color: customColor,
theme: themeOverrides,
maxFontSizeMultiplier,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -104,6 +105,7 @@ const AvatarText = ({
labelStyle,
]}
numberOfLines={1}
maxFontSizeMultiplier={maxFontSizeMultiplier}
>
{label}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ const Banner = ({
theme: themeOverrides,
onShowAnimationFinished = () => {},
onHideAnimationFinished = () => {},
maxFontSizeMultiplier,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -240,6 +241,7 @@ const Banner = ({
]}
accessibilityLiveRegion={visible ? 'polite' : 'none'}
accessibilityRole="alert"
maxFontSizeMultiplier={maxFontSizeMultiplier}
>
{children}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const Button = ({
labelStyle,
testID = 'button',
accessible,
maxFontSizeMultiplier,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -366,6 +367,7 @@ const Button = ({
textStyle,
labelStyle,
]}
maxFontSizeMultiplier={maxFontSizeMultiplier}
>
{children}
</Text>
Expand Down
4 changes: 4 additions & 0 deletions src/components/Card/CardTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,12 @@ const CardTitle = ({
titleStyle,
titleNumberOfLines = 1,
titleVariant = 'bodyLarge',
titleMaxFontSizeMultiplier,
subtitle,
subtitleStyle,
subtitleNumberOfLines = 1,
subtitleVariant = 'bodyMedium',
subtitleMaxFontSizeMultiplier,
left,
leftStyle,
right,
Expand Down Expand Up @@ -168,6 +170,7 @@ const CardTitle = ({
style={[styles.title, { marginBottom }, titleStyle]}
numberOfLines={titleNumberOfLines}
variant={titleVariant}
maxFontSizeMultiplier={titleMaxFontSizeMultiplier}
>
{title}
</TitleComponent>
Expand All @@ -177,6 +180,7 @@ const CardTitle = ({
style={[styles.subtitle, subtitleStyle]}
numberOfLines={subtitleNumberOfLines}
variant={subtitleVariant}
maxFontSizeMultiplier={subtitleMaxFontSizeMultiplier}
>
{subtitle}
</SubtitleComponent>
Expand Down
1 change: 1 addition & 0 deletions src/components/Checkbox/CheckboxItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const CheckboxItem = ({
computedStyle,
labelStyle,
]}
maxFontSizeMultiplier={labelMaxFontSizeMultiplier}
>
{label}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Chip/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const Chip = ({
ellipsizeMode,
compact,
elevated = false,
maxFontSizeMultiplier,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -343,6 +344,7 @@ const Chip = ({
textStyle,
]}
ellipsizeMode={ellipsizeMode}
maxFontSizeMultiplier={maxFontSizeMultiplier}
>
{children}
</Text>
Expand Down
7 changes: 6 additions & 1 deletion src/components/DataTable/DataTableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,18 @@ const DataTableCell = ({
textStyle,
style,
numeric,
maxFontSizeMultiplier,
...rest
}: Props) => (
<TouchableRipple
{...rest}
style={[styles.container, numeric && styles.right, style]}
>
<Text style={textStyle} numberOfLines={1}>
<Text
style={textStyle}
numberOfLines={1}
maxFontSizeMultiplier={maxFontSizeMultiplier}
>
{children}
</Text>
</TouchableRipple>
Expand Down
2 changes: 2 additions & 0 deletions src/components/DataTable/DataTableTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const DataTableTitle = ({
style,
theme: themeOverrides,
numberOfLines = 1,
maxFontSizeMultiplier,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -151,6 +152,7 @@ const DataTableTitle = ({
textStyle,
]}
numberOfLines={numberOfLines}
maxFontSizeMultiplier={maxFontSizeMultiplier}
>
{children}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Drawer/DrawerCollapsedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const DrawerCollapsedItem = ({
accessibilityLabel,
badge = false,
testID = 'drawer-collapsed-item',
labelMaxFontSizeMultiplier,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -224,6 +225,7 @@ const DrawerCollapsedItem = ({
numberOfLines={2}
onTextLayout={onTextLayout}
style={[styles.label, androidLetterSpacingStyle, labelTextStyle]}
maxFontSizeMultiplier={labelMaxFontSizeMultiplier}
>
{label}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Drawer/DrawerItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const DrawerItem = ({
onPress,
accessibilityLabel,
right,
labelMaxFontSizeMultiplier,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -143,6 +144,7 @@ const DrawerItem = ({
...font,
},
]}
maxFontSizeMultiplier={labelMaxFontSizeMultiplier}
>
{label}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Drawer/DrawerSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const DrawerSection = ({
theme: themeOverrides,
style,
showDivider = true,
titleMaxFontSizeMultiplier,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand All @@ -96,6 +97,7 @@ const DrawerSection = ({
...font,
},
]}
maxFontSizeMultiplier={titleMaxFontSizeMultiplier}
>
{title}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/FAB/AnimatedFAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ const AnimatedFAB = ({
extended = false,
iconMode = 'dynamic',
variant = 'primary',
labelMaxFontSizeMultiplier,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -479,6 +480,7 @@ const AnimatedFAB = ({
]}
theme={theme}
testID={`${testID}-text`}
maxFontSizeMultiplier={labelMaxFontSizeMultiplier}
>
{label}
</AnimatedText>
Expand Down
2 changes: 2 additions & 0 deletions src/components/FAB/FAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ const FAB = forwardRef<View, Props>(
customSize,
mode = 'elevated',
variant = 'primary',
labelMaxFontSizeMultiplier,
...rest
}: Props,
ref
Expand Down Expand Up @@ -315,6 +316,7 @@ const FAB = forwardRef<View, Props>(
uppercase && styles.uppercaseLabel,
textStyle,
]}
maxFontSizeMultiplier={labelMaxFontSizeMultiplier}
>
{label}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/FAB/FABGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export type Props = {
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
containerStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
labelStyle?: StyleProp<TextStyle>;
labelMaxFontSizeMultiplier?: number;
onPress: (e: GestureResponderEvent) => void;
size?: 'small' | 'medium';
testID?: string;
Expand Down Expand Up @@ -381,6 +382,7 @@ const FABGroup = ({
<Text
variant="titleMedium"
style={[labelTextStyle, it.labelStyle]}
maxFontSizeMultiplier={it.labelMaxFontSizeMultiplier}
>
{it.label}
</Text>
Expand Down
4 changes: 4 additions & 0 deletions src/components/List/ListAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ const ListAccordion = ({
expanded: expandedProp,
accessibilityLabel,
pointerEvents = 'none',
titleMaxFontSizeMultiplier,
descriptionMaxFontSizeMultiplier,
}: Props) => {
const theme = useInternalTheme(themeOverrides);
const [expanded, setExpanded] = React.useState<boolean>(
Expand Down Expand Up @@ -235,6 +237,7 @@ const ListAccordion = ({
},
titleStyle,
]}
maxFontSizeMultiplier={titleMaxFontSizeMultiplier}
>
{title}
</Text>
Expand All @@ -249,6 +252,7 @@ const ListAccordion = ({
},
descriptionStyle,
]}
maxFontSizeMultiplier={descriptionMaxFontSizeMultiplier}
>
{description}
</Text>
Expand Down
4 changes: 4 additions & 0 deletions src/components/List/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ const ListItem = ({
titleEllipsizeMode,
descriptionEllipsizeMode,
descriptionStyle,
descriptionMaxFontSizeMultiplier,
titleMaxFontSizeMultiplier,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -183,6 +185,7 @@ const ListItem = ({
descriptionStyle,
]}
onTextLayout={onDescriptionTextLayout}
maxFontSizeMultiplier={descriptionMaxFontSizeMultiplier}
>
{description}
</Text>
Expand All @@ -207,6 +210,7 @@ const ListItem = ({
ellipsizeMode={titleEllipsizeMode}
numberOfLines={titleNumberOfLines}
style={[styles.title, { color: titleColor }, titleStyle]}
maxFontSizeMultiplier={titleMaxFontSizeMultiplier}
>
{title}
</Text>
Expand Down
8 changes: 7 additions & 1 deletion src/components/List/ListSubheader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ export type Props = React.ComponentProps<typeof Text> & {
* export default MyComponent;
* ```
*/
const ListSubheader = ({ style, theme: overrideTheme, ...rest }: Props) => {
const ListSubheader = ({
style,
theme: overrideTheme,
maxFontSizeMultiplier,
...rest
}: Props) => {
const theme = useInternalTheme(overrideTheme);

const textColor = theme.isV3
Expand All @@ -44,6 +49,7 @@ const ListSubheader = ({ style, theme: overrideTheme, ...rest }: Props) => {
<Text
variant="bodyMedium"
numberOfLines={1}
maxFontSizeMultiplier={maxFontSizeMultiplier}
{...rest}
style={[
styles.container,
Expand Down
2 changes: 2 additions & 0 deletions src/components/RadioButton/RadioButtonItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const RadioButtonItem = ({
mode,
position = 'trailing',
labelVariant = 'bodyLarge',
labelMaxFontSizeMultiplier,
}: Props) => {
const theme = useInternalTheme(themeOverrides);
const radioButtonProps = { value, disabled, status, color, uncheckedColor };
Expand Down Expand Up @@ -204,6 +205,7 @@ const RadioButtonItem = ({
computedStyle,
labelStyle,
]}
maxFontSizeMultiplier={labelMaxFontSizeMultiplier}
>
{label}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/SegmentedButtons/SegmentedButtonItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const SegmentedButtonItem = ({
segment,
density = 'regular',
theme: themeOverrides,
labelMaxFontSizeMultiplier,
}: Props) => {
const theme = useInternalTheme(themeOverrides);

Expand Down Expand Up @@ -214,6 +215,7 @@ const SegmentedButtonItem = ({
style={[styles.label, labelTextStyle]}
selectable={false}
numberOfLines={1}
maxFontSizeMultiplier={labelMaxFontSizeMultiplier}
>
{label}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Snackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ const Snackbar = ({
wrapperStyle,
style,
theme: themeOverrides,
maxFontSizeMultiplier,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -245,6 +246,7 @@ const Snackbar = ({
<Text
variant="bodyMedium"
style={[styles.content, { color: textColor }]}
maxFontSizeMultiplier={maxFontSizeMultiplier}
>
{children}
</Text>
Expand Down
4 changes: 2 additions & 2 deletions src/components/TextInput/Label/InputLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const InputLabel = (props: InputLabelProps) => {
labelTranslationX,
]}
>
{labelBackground?.({
{/* {labelBackground?.({
labeled,
labelLayoutWidth,
labelStyle,
Expand All @@ -122,7 +122,7 @@ const InputLabel = (props: InputLabelProps) => {
backgroundColor,
roundness,
maxFontSizeMultiplier: maxFontSizeMultiplier,
})}
})} */}
<AnimatedText
variant="bodySmall"
onLayout={onLayoutAnimatedText}
Expand Down
Loading

0 comments on commit eabd869

Please sign in to comment.