Add cursor to clickable elements (#491)
* Add cursor to clickable elements * Add cursor to clickable elements * Update per comments * Fix word wrap in notifications * Center the web login-load screen * Add hover states on web * Fix lint --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
This commit is contained in:
parent
1472bd4f17
commit
b24ba3adc9
10 changed files with 184 additions and 142 deletions
45
src/view/com/util/PressableWithHover.tsx
Normal file
45
src/view/com/util/PressableWithHover.tsx
Normal file
|
@ -0,0 +1,45 @@
|
|||
import React, {
|
||||
useState,
|
||||
useCallback,
|
||||
PropsWithChildren,
|
||||
forwardRef,
|
||||
Ref,
|
||||
} from 'react'
|
||||
import {Pressable, PressableProps, StyleProp, ViewStyle} from 'react-native'
|
||||
import {addStyle} from 'lib/styles'
|
||||
|
||||
interface PressableWithHover extends PressableProps {
|
||||
hoverStyle: StyleProp<ViewStyle>
|
||||
}
|
||||
|
||||
export const PressableWithHover = forwardRef(
|
||||
(
|
||||
{
|
||||
children,
|
||||
style,
|
||||
hoverStyle,
|
||||
...props
|
||||
}: PropsWithChildren<PressableWithHover>,
|
||||
ref: Ref<any>,
|
||||
) => {
|
||||
const [isHovering, setIsHovering] = useState(false)
|
||||
|
||||
const onHoverIn = useCallback(() => setIsHovering(true), [setIsHovering])
|
||||
const onHoverOut = useCallback(() => setIsHovering(false), [setIsHovering])
|
||||
style =
|
||||
typeof style !== 'function' && isHovering
|
||||
? addStyle(style, hoverStyle)
|
||||
: style
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
{...props}
|
||||
style={style}
|
||||
onHoverIn={onHoverIn}
|
||||
onHoverOut={onHoverOut}
|
||||
ref={ref}>
|
||||
{children}
|
||||
</Pressable>
|
||||
)
|
||||
},
|
||||
)
|
|
@ -1,10 +1,5 @@
|
|||
import React, {createRef, useState, useMemo, useRef} from 'react'
|
||||
import {
|
||||
Animated,
|
||||
StyleSheet,
|
||||
TouchableWithoutFeedback,
|
||||
View,
|
||||
} from 'react-native'
|
||||
import {Animated, Pressable, StyleSheet, View} from 'react-native'
|
||||
import {Text} from './text/Text'
|
||||
import {usePalette} from 'lib/hooks/usePalette'
|
||||
|
||||
|
@ -99,7 +94,7 @@ export function Selector({
|
|||
{items.map((item, i) => {
|
||||
const selected = i === selectedIndex
|
||||
return (
|
||||
<TouchableWithoutFeedback key={i} onPress={() => onPressItem(i)}>
|
||||
<Pressable key={item} onPress={() => onPressItem(i)}>
|
||||
<View style={styles.item} ref={itemRefs[i]}>
|
||||
<Text
|
||||
style={
|
||||
|
@ -110,7 +105,7 @@ export function Selector({
|
|||
{item}
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableWithoutFeedback>
|
||||
</Pressable>
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
|
|
|
@ -40,7 +40,7 @@ export function ContentHider({
|
|||
}
|
||||
|
||||
if (labelPref.pref === 'hide') {
|
||||
return <></>
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue