Open History to see the last commit
1import type { ComponentProps, ReactNode } from "react";
2import { Pressable, View } from "react-native";
3import { GestureDetector } from "react-native-gesture-handler";
4
5import { cn } from "../lib/cn";
6import { useHoverGesture } from "../lib/useHoverGesture";
7
8/** Pointer feedback layered over selection. Touch-down may be the start of a scroll. */
9export function RowPressable({
10 children,
11 className,
12 interactionClassName = "bg-primary",
13 ...props
14}: Omit<ComponentProps<typeof Pressable>, "children"> & {
15 readonly children: ReactNode;
16 readonly interactionClassName?: string;
17}) {
18 const { hovered, hoverGesture } = useHoverGesture(props.disabled ?? false);
19 return (
20 <GestureDetector gesture={hoverGesture}>
21 <Pressable {...props} className={cn("relative overflow-hidden", className)}>
22 {({ pressed }) => (
23 <>
24 <View
25 pointerEvents="none"
26 className={cn("absolute inset-0", interactionClassName)}
27 style={{ opacity: props.disabled || !hovered ? 0 : pressed ? 0.2 : 0.1 }}
28 />
29 {children}
30 </>
31 )}
32 </Pressable>
33 </GestureDetector>
34 );
35}