Skip to content

Commit

Permalink
feat: pass background prop to nested touchables (#4108)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewalczak committed Jan 10, 2024
1 parent 7cf251d commit 6dd615d
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ColorValue,
GestureResponderEvent,
Platform,
PressableAndroidRippleConfig,
StyleProp,
StyleSheet,
TextStyle,
Expand Down Expand Up @@ -83,6 +84,11 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
* Make the label text uppercased. Note that this won't work if you pass React elements as children.
*/
uppercase?: boolean;
/**
* Type of background drawabale to display the feedback (Android).
* https://reactnative.dev/docs/pressable#rippleconfig
*/
background?: PressableAndroidRippleConfig;
/**
* Accessibility label for the button. This is read by the screen reader when the user taps the button.
*/
Expand Down Expand Up @@ -183,6 +189,7 @@ const Button = (
labelStyle,
testID = 'button',
accessible,
background,
maxFontSizeMultiplier,
...rest
}: Props,
Expand Down Expand Up @@ -325,6 +332,7 @@ const Button = (
>
<TouchableRipple
borderless
background={background}
onPress={onPress}
onLongPress={onLongPress}
onPressIn={hasPassedTouchHandler ? handlePressIn : undefined}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Checkbox/CheckboxAndroid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const ANIMATION_DURATION = 100;
* Checkboxes allow the selection of multiple options from a set.
* This component follows platform guidelines for Android, but can be used
* on any platform.
*
* @extends TouchableRipple props https://callstack.github.io/react-native-paper/docs/components/TouchableRipple
*/
const CheckboxAndroid = ({
status,
Expand Down
2 changes: 2 additions & 0 deletions src/components/Checkbox/CheckboxIOS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export type Props = $RemoveChildren<typeof TouchableRipple> & {
* Checkboxes allow the selection of multiple options from a set.
* This component follows platform guidelines for iOS, but can be used
* on any platform.
*
* @extends TouchableRipple props https://callstack.github.io/react-native-paper/docs/components/TouchableRipple
*/
const CheckboxIOS = ({
status,
Expand Down
8 changes: 8 additions & 0 deletions src/components/Checkbox/CheckboxItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import {
ColorValue,
GestureResponderEvent,
PressableAndroidRippleConfig,
StyleProp,
StyleSheet,
TextStyle,
Expand Down Expand Up @@ -38,6 +39,11 @@ export type Props = {
* Function to execute on long press.
*/
onLongPress?: (e: GestureResponderEvent) => void;
/**
* Type of background drawabale to display the feedback (Android).
* https://reactnative.dev/docs/pressable#rippleconfig
*/
background?: PressableAndroidRippleConfig;
/**
* Accessibility label for the touchable. This is read by the screen reader when the user taps the touchable.
*/
Expand Down Expand Up @@ -137,6 +143,7 @@ const CheckboxItem = ({
labelVariant = 'bodyLarge',
labelMaxFontSizeMultiplier = 1.5,
rippleColor,
background,
...props
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -177,6 +184,7 @@ const CheckboxItem = ({
disabled={disabled}
rippleColor={rippleColor}
theme={theme}
background={background}
>
<View
style={[styles.container, style]}
Expand Down
8 changes: 8 additions & 0 deletions src/components/Chip/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ColorValue,
GestureResponderEvent,
Platform,
PressableAndroidRippleConfig,
StyleProp,
StyleSheet,
TextStyle,
Expand Down Expand Up @@ -78,6 +79,11 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
* Whether the chip is disabled. A disabled chip is greyed out and `onPress` is not called on touch.
*/
disabled?: boolean;
/**
* Type of background drawabale to display the feedback (Android).
* https://reactnative.dev/docs/pressable#rippleconfig
*/
background?: PressableAndroidRippleConfig;
/**
* Accessibility label for the chip. This is read by the screen reader when the user taps the chip.
*/
Expand Down Expand Up @@ -173,6 +179,7 @@ const Chip = ({
avatar,
selected = false,
disabled = false,
background,
accessibilityLabel,
closeIconAccessibilityLabel = 'Close',
onPress,
Expand Down Expand Up @@ -306,6 +313,7 @@ const Chip = ({
>
<TouchableRipple
borderless
background={background}
style={[{ borderRadius }, styles.touchable]}
onPress={onPress}
onLongPress={onLongPress}
Expand Down
8 changes: 8 additions & 0 deletions src/components/Drawer/DrawerItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import {
ColorValue,
GestureResponderEvent,
PressableAndroidRippleConfig,
StyleProp,
StyleSheet,
View,
Expand Down Expand Up @@ -37,6 +38,11 @@ export type Props = React.ComponentPropsWithRef<typeof View> & {
* Function to execute on press.
*/
onPress?: (e: GestureResponderEvent) => void;
/**
* Type of background drawabale to display the feedback (Android).
* https://reactnative.dev/docs/pressable#rippleconfig
*/
background?: PressableAndroidRippleConfig;
/**
* Accessibility label for the button. This is read by the screen reader when the user taps the button.
*/
Expand Down Expand Up @@ -88,6 +94,7 @@ const DrawerItem = ({
rippleColor: customRippleColor,
style,
onPress,
background,
accessibilityLabel,
right,
labelMaxFontSizeMultiplier,
Expand Down Expand Up @@ -121,6 +128,7 @@ const DrawerItem = ({
<TouchableRipple
borderless
disabled={disabled}
background={background}
onPress={onPress}
style={[
styles.container,
Expand Down
8 changes: 8 additions & 0 deletions src/components/FAB/AnimatedFAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
AccessibilityState,
ColorValue,
NativeSyntheticEvent,
PressableAndroidRippleConfig,
TextLayoutEventData,
} from 'react-native';
import {
Expand Down Expand Up @@ -45,6 +46,11 @@ export type Props = $Omit<$RemoveChildren<typeof Surface>, 'mode'> & {
* Make the label text uppercased.
*/
uppercase?: boolean;
/**
* Type of background drawabale to display the feedback (Android).
* https://reactnative.dev/docs/pressable#rippleconfig
*/
background?: PressableAndroidRippleConfig;
/**
* Accessibility label for the FAB. This is read by the screen reader when the user taps the FAB.
* Uses `label` by default if specified.
Expand Down Expand Up @@ -197,6 +203,7 @@ const SCALE = 0.9;
const AnimatedFAB = ({
icon,
label,
background,
accessibilityLabel = label,
accessibilityState,
color: customColor,
Expand Down Expand Up @@ -427,6 +434,7 @@ const AnimatedFAB = ({
>
<TouchableRipple
borderless
background={background}
onPress={onPress}
onLongPress={onLongPress}
delayLongPress={delayLongPress}
Expand Down
8 changes: 8 additions & 0 deletions src/components/FAB/FAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Animated,
ColorValue,
GestureResponderEvent,
PressableAndroidRippleConfig,
StyleProp,
StyleSheet,
View,
Expand Down Expand Up @@ -50,6 +51,11 @@ export type Props = $Omit<$RemoveChildren<typeof Surface>, 'mode'> & {
* Make the label text uppercased.
*/
uppercase?: boolean;
/**
* Type of background drawabale to display the feedback (Android).
* https://reactnative.dev/docs/pressable#rippleconfig
*/
background?: PressableAndroidRippleConfig;
/**
* Accessibility label for the FAB. This is read by the screen reader when the user taps the FAB.
* Uses `label` by default if specified.
Expand Down Expand Up @@ -178,6 +184,7 @@ const FAB = forwardRef<View, Props>(
{
icon,
label,
background,
accessibilityLabel = label,
accessibilityState,
animated = true,
Expand Down Expand Up @@ -285,6 +292,7 @@ const FAB = forwardRef<View, Props>(
>
<TouchableRipple
borderless
background={background}
onPress={onPress}
onLongPress={onLongPress}
delayLongPress={delayLongPress}
Expand Down
8 changes: 8 additions & 0 deletions src/components/List/ListAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
View,
ViewProps,
ViewStyle,
PressableAndroidRippleConfig,
} from 'react-native';

import { ListAccordionGroupContext } from './ListAccordionGroup';
Expand Down Expand Up @@ -65,6 +66,11 @@ export type Props = {
* @optional
*/
theme?: ThemeProp;
/**
* Type of background drawabale to display the feedback (Android).
* https://reactnative.dev/docs/pressable#rippleconfig
*/
background?: PressableAndroidRippleConfig;
/**
* Style that is passed to the wrapping TouchableRipple element.
*/
Expand Down Expand Up @@ -169,6 +175,7 @@ const ListAccordion = ({
style,
id,
testID,
background,
onPress,
onLongPress,
delayLongPress,
Expand Down Expand Up @@ -241,6 +248,7 @@ const ListAccordion = ({
accessibilityLabel={accessibilityLabel}
testID={testID}
theme={theme}
background={background}
borderless
>
<View
Expand Down
8 changes: 8 additions & 0 deletions src/components/Menu/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
AccessibilityState,
ColorValue,
GestureResponderEvent,
PressableAndroidRippleConfig,
StyleProp,
StyleSheet,
TextStyle,
Expand Down Expand Up @@ -49,6 +50,11 @@ export type Props = {
* Sets min height with densed layout.
*/
dense?: boolean;
/**
* Type of background drawabale to display the feedback (Android).
* https://reactnative.dev/docs/pressable#rippleconfig
*/
background?: PressableAndroidRippleConfig;
/**
* Function to execute on press.
*/
Expand Down Expand Up @@ -113,6 +119,7 @@ const MenuItem = ({
dense,
title,
disabled,
background,
onPress,
style,
contentStyle,
Expand Down Expand Up @@ -163,6 +170,7 @@ const MenuItem = ({
onPress={onPress}
disabled={disabled}
testID={testID}
background={background}
accessibilityLabel={accessibilityLabel}
accessibilityRole="menuitem"
accessibilityState={newAccessibilityState}
Expand Down
2 changes: 2 additions & 0 deletions src/components/RadioButton/RadioButtonAndroid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const BORDER_WIDTH = 2;
* Radio buttons allow the selection a single option from a set.
* This component follows platform guidelines for Android, but can be used
* on any platform.
*
* @extends TouchableRipple props https://callstack.github.io/react-native-paper/docs/components/TouchableRipple
*/
const RadioButtonAndroid = ({
disabled,
Expand Down
2 changes: 2 additions & 0 deletions src/components/RadioButton/RadioButtonIOS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export type Props = $RemoveChildren<typeof TouchableRipple> & {
* Radio buttons allow the selection a single option from a set.
* This component follows platform guidelines for iOS, but can be used
* on any platform.
*
* @extends TouchableRipple props https://callstack.github.io/react-native-paper/docs/components/TouchableRipple
*/
const RadioButtonIOS = ({
disabled,
Expand Down
8 changes: 8 additions & 0 deletions src/components/RadioButton/RadioButtonItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import {
ColorValue,
GestureResponderEvent,
PressableAndroidRippleConfig,
StyleProp,
StyleSheet,
TextStyle,
Expand Down Expand Up @@ -32,6 +33,11 @@ export type Props = {
* Whether radio is disabled.
*/
disabled?: boolean;
/**
* Type of background drawabale to display the feedback (Android).
* https://reactnative.dev/docs/pressable#rippleconfig
*/
background?: PressableAndroidRippleConfig;
/**
* Function to execute on press.
*/
Expand Down Expand Up @@ -143,6 +149,7 @@ const RadioButtonItem = ({
rippleColor,
status,
theme: themeOverrides,
background,
accessibilityLabel = label,
testID,
mode,
Expand Down Expand Up @@ -209,6 +216,7 @@ const RadioButtonItem = ({
}}
testID={testID}
disabled={disabled}
background={background}
theme={theme}
rippleColor={rippleColor}
>
Expand Down
8 changes: 8 additions & 0 deletions src/components/SegmentedButtons/SegmentedButtonItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Animated,
ColorValue,
GestureResponderEvent,
PressableAndroidRippleConfig,
StyleProp,
StyleSheet,
TextStyle,
Expand Down Expand Up @@ -51,6 +52,11 @@ export type Props = {
* Whether the button is disabled.
*/
disabled?: boolean;
/**
* Type of background drawabale to display the feedback (Android).
* https://reactnative.dev/docs/pressable#rippleconfig
*/
background?: PressableAndroidRippleConfig;
/**
* Accessibility label for the `SegmentedButtonItem`. This is read by the screen reader when the user taps the button.
*/
Expand Down Expand Up @@ -108,6 +114,7 @@ const SegmentedButtonItem = ({
checkedColor,
uncheckedColor,
rippleColor: customRippleColor,
background,
icon,
testID,
label,
Expand Down Expand Up @@ -208,6 +215,7 @@ const SegmentedButtonItem = ({
rippleColor={rippleColor}
testID={testID}
style={rippleStyle}
background={background}
theme={theme}
>
<View style={[styles.content, { paddingVertical }]}>
Expand Down

0 comments on commit 6dd615d

Please sign in to comment.