-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add hover support to web (#3909)
- Loading branch information
Showing
3 changed files
with
73 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type * as React from 'react'; | ||
import type { | ||
PressableProps as PressableNativeProps, | ||
StyleProp, | ||
View, | ||
ViewStyle, | ||
} from 'react-native'; | ||
import { Pressable as PressableNative } from 'react-native'; | ||
|
||
// This component is added to support type-safe hover and focus states on web | ||
// https://necolas.github.io/react-native-web/docs/pressable/ | ||
|
||
export type PressableStateCallbackType = { | ||
hovered: boolean; | ||
pressed: boolean; | ||
focused: boolean; | ||
}; | ||
|
||
export type PressableProps = Omit< | ||
PressableNativeProps, | ||
'children' | 'style' | ||
> & { | ||
children: | ||
| React.ReactNode | ||
| ((state: PressableStateCallbackType) => React.ReactNode) | ||
| undefined; | ||
style?: | ||
| StyleProp<ViewStyle> | ||
| ((state: PressableStateCallbackType) => StyleProp<ViewStyle>) | ||
| undefined; | ||
}; | ||
|
||
export const Pressable: React.ForwardRefExoticComponent< | ||
PressableProps & React.RefAttributes<View> | ||
> = PressableNative as any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters