Skip to content

Commit

Permalink
refactor: add prop description and default values
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewalczak committed Oct 2, 2023
1 parent 819da43 commit adef226
Show file tree
Hide file tree
Showing 39 changed files with 208 additions and 27 deletions.
6 changes: 5 additions & 1 deletion src/components/Appbar/AppbarContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export type Props = $RemoveChildren<typeof View> & {
* Custom color for the text.
*/
color?: string;
/**
* Specifies the largest possible scale a title font can reach.
*/
titleMaxFontSizeMultiplier?: number;
/**
* @internal
*/
Expand Down Expand Up @@ -105,7 +109,7 @@ const AppbarContent = ({
titleRef,
titleStyle,
title,
titleMaxFontSizeMultiplier,
titleMaxFontSizeMultiplier = 1.5,
mode = 'small',
theme: themeOverrides,
testID = 'appbar-content',
Expand Down
6 changes: 5 additions & 1 deletion src/components/Avatar/AvatarText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export type Props = React.ComponentPropsWithRef<typeof View> & {
* Style for the title.
*/
labelStyle?: StyleProp<TextStyle>;
/**
* Specifies the largest possible scale a text font can reach.
*/
maxFontSizeMultiplier?: number;
/**
* @optional
*/
Expand All @@ -63,7 +67,7 @@ const AvatarText = ({
labelStyle,
color: customColor,
theme: themeOverrides,
maxFontSizeMultiplier,
maxFontSizeMultiplier = 1.5,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down
6 changes: 5 additions & 1 deletion src/components/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export type Props = $Omit<$RemoveChildren<typeof Surface>, 'mode'> & {
* Changes Banner shadow and background on iOS and Android.
*/
elevation?: 0 | 1 | 2 | 3 | 4 | 5 | Animated.Value;
/**
* Specifies the largest possible scale a text font can reach.
*/
maxFontSizeMultiplier?: number;
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
ref?: React.RefObject<View>;
/**
Expand Down Expand Up @@ -123,7 +127,7 @@ const Banner = ({
theme: themeOverrides,
onShowAnimationFinished = () => {},
onHideAnimationFinished = () => {},
maxFontSizeMultiplier,
maxFontSizeMultiplier = 1.5,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down
6 changes: 5 additions & 1 deletion src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
* Use this prop to apply custom height and width and to set the icon on the right with `flexDirection: 'row-reverse'`.
*/
contentStyle?: StyleProp<ViewStyle>;
/**
* Specifies the largest possible scale a text font can reach.
*/
maxFontSizeMultiplier?: number;
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
/**
* Style for the button text.
Expand Down Expand Up @@ -170,7 +174,7 @@ const Button = ({
labelStyle,
testID = 'button',
accessible,
maxFontSizeMultiplier,
maxFontSizeMultiplier = 1.5,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down
12 changes: 10 additions & 2 deletions src/components/Card/CardTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ export type Props = React.ComponentPropsWithRef<typeof View> & {
* @internal
*/
total?: number;
/**
* Specifies the largest possible scale a title font can reach.
*/
titleMaxFontSizeMultiplier?: number;
/**
* Specifies the largest possible scale a subtitle font can reach.
*/
subtitleMaxFontSizeMultiplier?: number;
style?: StyleProp<ViewStyle>;
/**
* @optional
Expand Down Expand Up @@ -130,12 +138,12 @@ const CardTitle = ({
titleStyle,
titleNumberOfLines = 1,
titleVariant = 'bodyLarge',
titleMaxFontSizeMultiplier,
titleMaxFontSizeMultiplier = 1.5,
subtitle,
subtitleStyle,
subtitleNumberOfLines = 1,
subtitleVariant = 'bodyMedium',
subtitleMaxFontSizeMultiplier,
subtitleMaxFontSizeMultiplier = 1.5,
left,
leftStyle,
right,
Expand Down
3 changes: 1 addition & 2 deletions src/components/Checkbox/CheckboxItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export type Props = {
*/
style?: StyleProp<ViewStyle>;
/**
* Specifies the largest possible scale a title font can reach.
* Specifies the largest possible scale a label font can reach.
*/
labelMaxFontSizeMultiplier?: number;
/**
Expand Down Expand Up @@ -181,7 +181,6 @@ const CheckboxItem = ({
computedStyle,
labelStyle,
]}
maxFontSizeMultiplier={labelMaxFontSizeMultiplier}
>
{label}
</Text>
Expand Down
6 changes: 5 additions & 1 deletion src/components/Chip/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
* Ellipsize Mode for the children text
*/
ellipsizeMode?: EllipsizeProp;
/**
* Specifies the largest possible scale a text font can reach.
*/
maxFontSizeMultiplier?: number;
};

/**
Expand Down Expand Up @@ -189,7 +193,7 @@ const Chip = ({
ellipsizeMode,
compact,
elevated = false,
maxFontSizeMultiplier,
maxFontSizeMultiplier = 1.5,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down
6 changes: 5 additions & 1 deletion src/components/DataTable/DataTableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export type Props = $RemoveChildren<typeof TouchableRipple> & {
* Text content style of the `DataTableCell`.
*/
textStyle?: StyleProp<TextStyle>;
/**
* Specifies the largest possible scale a text font can reach.
*/
maxFontSizeMultiplier?: number;
};

/**
Expand Down Expand Up @@ -62,7 +66,7 @@ const DataTableCell = ({
textStyle,
style,
numeric,
maxFontSizeMultiplier,
maxFontSizeMultiplier = 1.5,
...rest
}: Props) => (
<TouchableRipple
Expand Down
6 changes: 5 additions & 1 deletion src/components/DataTable/DataTableTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export type Props = React.ComponentPropsWithRef<
* Text content style of the `DataTableTitle`.
*/
textStyle?: StyleProp<TextStyle>;
/**
* Specifies the largest possible scale a text font can reach.
*/
maxFontSizeMultiplier?: number;
/**
* @optional
*/
Expand Down Expand Up @@ -87,7 +91,7 @@ const DataTableTitle = ({
style,
theme: themeOverrides,
numberOfLines = 1,
maxFontSizeMultiplier,
maxFontSizeMultiplier = 1.5,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down
6 changes: 5 additions & 1 deletion src/components/Drawer/DrawerCollapsedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export type Props = React.ComponentPropsWithRef<typeof View> & {
* Function to execute on press.
*/
onPress?: (e: GestureResponderEvent) => void;
/**
* Specifies the largest possible scale a label font can reach.
*/
labelMaxFontSizeMultiplier?: number;
/**
* Accessibility label for the button. This is read by the screen reader when the user taps the button.
*/
Expand Down Expand Up @@ -98,7 +102,7 @@ const DrawerCollapsedItem = ({
accessibilityLabel,
badge = false,
testID = 'drawer-collapsed-item',
labelMaxFontSizeMultiplier,
labelMaxFontSizeMultiplier = 1.5,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down
6 changes: 5 additions & 1 deletion src/components/Drawer/DrawerItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export type Props = React.ComponentPropsWithRef<typeof View> & {
* Callback which returns a React element to display on the right side. For instance a Badge.
*/
right?: (props: { color: string }) => React.ReactNode;
/**
* Specifies the largest possible scale a label font can reach.
*/
labelMaxFontSizeMultiplier?: number;
/**
* Color of the ripple effect.
*/
Expand Down Expand Up @@ -81,7 +85,7 @@ const DrawerItem = ({
onPress,
accessibilityLabel,
right,
labelMaxFontSizeMultiplier,
labelMaxFontSizeMultiplier = 1.5,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down
6 changes: 5 additions & 1 deletion src/components/Drawer/DrawerSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export type Props = React.ComponentPropsWithRef<typeof View> & {
* Whether to show `Divider` at the end of the section. True by default.
*/
showDivider?: boolean;
/**
* Specifies the largest possible scale a title font can reach.
*/
titleMaxFontSizeMultiplier?: number;
style?: StyleProp<ViewStyle>;
/**
* @optional
Expand Down Expand Up @@ -65,7 +69,7 @@ const DrawerSection = ({
theme: themeOverrides,
style,
showDivider = true,
titleMaxFontSizeMultiplier,
titleMaxFontSizeMultiplier = 1.5,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down
6 changes: 5 additions & 1 deletion src/components/FAB/AnimatedFAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export type Props = $Omit<$RemoveChildren<typeof Surface>, 'mode'> & {
* Whether `FAB` should start animation to extend.
*/
extended: boolean;
/**
* Specifies the largest possible scale a label font can reach.
*/
labelMaxFontSizeMultiplier?: number;
/**
* @supported Available in v5.x with theme version 3
*
Expand Down Expand Up @@ -210,7 +214,7 @@ const AnimatedFAB = ({
extended = false,
iconMode = 'dynamic',
variant = 'primary',
labelMaxFontSizeMultiplier,
labelMaxFontSizeMultiplier = 1.5,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down
6 changes: 5 additions & 1 deletion src/components/FAB/FAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ export type Props = $Omit<$RemoveChildren<typeof Surface>, 'mode'> & {
* Color mappings variant for combinations of container and icon colors.
*/
variant?: 'primary' | 'secondary' | 'tertiary' | 'surface';
/**
* Specifies the largest possible scale a label font can reach.
*/
labelMaxFontSizeMultiplier?: number;
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
/**
* @optional
Expand Down Expand Up @@ -193,7 +197,7 @@ const FAB = forwardRef<View, Props>(
customSize,
mode = 'elevated',
variant = 'primary',
labelMaxFontSizeMultiplier,
labelMaxFontSizeMultiplier = 1.5,
...rest
}: Props,
ref
Expand Down
1 change: 1 addition & 0 deletions src/components/FAB/FABGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type Props = {
* - `style`: pass additional styles for the fab item, for example, `backgroundColor`
* - `containerStyle`: pass additional styles for the fab item label container, for example, `backgroundColor` @supported Available in 5.x
* - `labelStyle`: pass additional styles for the fab item label, for example, `fontSize`
* - `labelMaxFontSizeMultiplier`: specifies the largest possible scale a title font can reach.
* - `onPress`: callback that is called when `FAB` is pressed (required)
* - `onLongPress`: callback that is called when `FAB` is long pressed
* - `toggleStackOnLongPress`: callback that is called when `FAB` is long pressed
Expand Down
12 changes: 10 additions & 2 deletions src/components/List/ListAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ export type Props = {
* exceed this number.
*/
descriptionNumberOfLines?: number;
/**
* Specifies the largest possible scale a title font can reach.
*/
titleMaxFontSizeMultiplier?: number;
/**
* Specifies the largest possible scale a description font can reach.
*/
descriptionMaxFontSizeMultiplier?: number;
/**
* Id is used for distinguishing specific accordion when using List.AccordionGroup. Property is required when using List.AccordionGroup and has no impact on behavior when using standalone List.Accordion.
*/
Expand Down Expand Up @@ -167,8 +175,8 @@ const ListAccordion = ({
expanded: expandedProp,
accessibilityLabel,
pointerEvents = 'none',
titleMaxFontSizeMultiplier,
descriptionMaxFontSizeMultiplier,
titleMaxFontSizeMultiplier = 1.5,
descriptionMaxFontSizeMultiplier = 1.5,
}: Props) => {
const theme = useInternalTheme(themeOverrides);
const [expanded, setExpanded] = React.useState<boolean>(
Expand Down
12 changes: 10 additions & 2 deletions src/components/List/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ export type Props = $RemoveChildren<typeof TouchableRipple> & {
* See [`ellipsizeMode`](https://reactnative.dev/docs/text#ellipsizemode)
*/
descriptionEllipsizeMode?: EllipsizeProp;
/**
* Specifies the largest possible scale a title font can reach.
*/
titleMaxFontSizeMultiplier?: number;
/**
* Specifies the largest possible scale a description font can reach.
*/
descriptionMaxFontSizeMultiplier?: number;
};

/**
Expand Down Expand Up @@ -132,8 +140,8 @@ const ListItem = ({
titleEllipsizeMode,
descriptionEllipsizeMode,
descriptionStyle,
descriptionMaxFontSizeMultiplier,
titleMaxFontSizeMultiplier,
descriptionMaxFontSizeMultiplier = 1.5,
titleMaxFontSizeMultiplier = 1.5,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down
6 changes: 5 additions & 1 deletion src/components/List/ListSubheader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export type Props = React.ComponentProps<typeof Text> & {
* Style that is passed to Text element.
*/
style?: StyleProp<TextStyle>;
/**
* Specifies the largest possible scale a text font can reach.
*/
maxFontSizeMultiplier?: number;
};

/**
Expand All @@ -34,7 +38,7 @@ export type Props = React.ComponentProps<typeof Text> & {
const ListSubheader = ({
style,
theme: overrideTheme,
maxFontSizeMultiplier,
maxFontSizeMultiplier = 1.5,
...rest
}: Props) => {
const theme = useInternalTheme(overrideTheme);
Expand Down
6 changes: 5 additions & 1 deletion src/components/RadioButton/RadioButtonItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ export type Props = {
* Body: `bodyLarge`, `bodyMedium`, `bodySmall`
*/
labelVariant?: keyof typeof MD3TypescaleKey;
/**
* Specifies the largest possible scale a label font can reach.
*/
labelMaxFontSizeMultiplier?: number;
/**
* @optional
*/
Expand Down Expand Up @@ -133,7 +137,7 @@ const RadioButtonItem = ({
mode,
position = 'trailing',
labelVariant = 'bodyLarge',
labelMaxFontSizeMultiplier,
labelMaxFontSizeMultiplier = 1.5,
}: Props) => {
const theme = useInternalTheme(themeOverrides);
const radioButtonProps = {
Expand Down
Loading

0 comments on commit adef226

Please sign in to comment.