-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: add onPressIn, onPressOut, onHoverIn, onHoverOut to FAB and Button #3750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import * as React from 'react'; | |
| import { | ||
| Animated, | ||
| GestureResponderEvent, | ||
| MouseEvent, | ||
| StyleProp, | ||
| StyleSheet, | ||
| TextStyle, | ||
|
|
@@ -101,6 +102,14 @@ export type Props = React.ComponentProps<typeof Surface> & { | |
| * The number of milliseconds a user must touch the element before executing `onLongPress`. | ||
| */ | ||
| delayLongPress?: number; | ||
| /** | ||
| * Called when the hover is activated to provide visual feedback. | ||
| */ | ||
| onHoverIn?: (e: MouseEvent) => void; | ||
| /** | ||
| * Called when the hover is deactivated to undo visual feedback. | ||
| */ | ||
| onHoverOut?: (e: MouseEvent) => void; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This type is valid for web but for native the right type is ({nativeEvent: MouseEvent}) => void |
||
| /** | ||
| * Style of button's inner content. | ||
| * Use this prop to apply custom height and width and to set the icon on the right with `flexDirection: 'row-reverse'`. | ||
|
|
@@ -176,6 +185,8 @@ const Button = ({ | |
| onPress, | ||
| onPressIn, | ||
| onPressOut, | ||
| onHoverOut, | ||
| onHoverIn, | ||
| onLongPress, | ||
| delayLongPress, | ||
| style, | ||
|
|
@@ -310,6 +321,8 @@ const Button = ({ | |
| onLongPress={onLongPress} | ||
| onPressIn={handlePressIn} | ||
| onPressOut={handlePressOut} | ||
| onHoverIn={onHoverIn} | ||
| onHoverOut={onHoverOut} | ||
| delayLongPress={delayLongPress} | ||
| accessibilityLabel={accessibilityLabel} | ||
| accessibilityHint={accessibilityHint} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ import { | |
| AccessibilityState, | ||
| Animated, | ||
| GestureResponderEvent, | ||
| MouseEvent, | ||
| StyleProp, | ||
| StyleSheet, | ||
| View, | ||
|
|
@@ -88,14 +89,30 @@ export type Props = $RemoveChildren<typeof Surface> & { | |
| * Function to execute on press. | ||
| */ | ||
| onPress?: (e: GestureResponderEvent) => void; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the web docs, the correct type for web is For native the right type is |
||
| /** | ||
| * Function to execute as soon as the touchable element is pressed and invoked even before onPress. | ||
| */ | ||
| onPressIn?: (e: GestureResponderEvent) => void; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the web docs, the correct type for web is For native the right type is |
||
| /** | ||
| * Function to execute as soon as the touch is released even before onPress. | ||
| */ | ||
| onPressOut?: (e: GestureResponderEvent) => void; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the web docs, the correct type for web is For native the right type is |
||
| /** | ||
| * Function to execute on long press. | ||
| */ | ||
| onLongPress?: () => void; | ||
| onLongPress?: (e: GestureResponderEvent) => void; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the web docs, the current type is the correct type for web. For native the right type is |
||
| /** | ||
| * The number of milliseconds a user must touch the element before executing `onLongPress`. | ||
| */ | ||
| delayLongPress?: number; | ||
| /** | ||
| * Called when the hover is activated to provide visual feedback. | ||
| */ | ||
| onHoverIn?: (e: MouseEvent) => void; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This type is valid for web but for native the right type is
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then React Native docs are outdated -> https://reactnative.dev/docs/pressable#onhoverin |
||
| /** | ||
| * Called when the hover is deactivated to undo visual feedback. | ||
| */ | ||
| onHoverOut?: (e: MouseEvent) => void; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This type is valid for web but for native the right type is |
||
| /** | ||
| * @supported Available in v5.x with theme version 3 | ||
| * | ||
|
|
@@ -179,6 +196,10 @@ const FAB = forwardRef<View, Props>( | |
| disabled, | ||
| onPress, | ||
| onLongPress, | ||
| onPressIn, | ||
| onPressOut, | ||
| onHoverOut, | ||
| onHoverIn, | ||
| delayLongPress, | ||
| theme: themeOverrides, | ||
| style, | ||
|
|
@@ -279,6 +300,10 @@ const FAB = forwardRef<View, Props>( | |
| borderless | ||
| onPress={onPress} | ||
| onLongPress={onLongPress} | ||
| onPressIn={onPressIn} | ||
| onPressOut={onPressOut} | ||
| onHoverOut={onHoverOut} | ||
| onHoverIn={onHoverIn} | ||
| delayLongPress={delayLongPress} | ||
| rippleColor={rippleColor} | ||
| disabled={disabled} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -65,6 +65,7 @@ export type Props = $RemoveChildren<typeof TouchableRipple> & { | |||
| * Function to execute on press. | ||||
| */ | ||||
| onPress?: (e: GestureResponderEvent) => void; | ||||
|
|
||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>; | ||||
| ref?: React.RefObject<View>; | ||||
| /** | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type is valid for web but for native the right type is ({nativeEvent: MouseEvent}) => void