forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {View} from 'react-native'
2
3import {atoms as a, useTheme, type ViewStyleProp} from '#/alf'
4import {IS_NATIVE, IS_WEB, IS_WEB_TOUCH_DEVICE} from '#/env'
5
6export function SubtleHover({
7 style,
8 hover,
9 web = true,
10 native = false,
11}: ViewStyleProp & {hover: boolean; web?: boolean; native?: boolean}) {
12 const t = useTheme()
13
14 let opacity: number
15 switch (t.name) {
16 case 'dark':
17 opacity = 0.4
18 break
19 case 'dim':
20 opacity = 0.45
21 break
22 case 'light':
23 opacity = 0.5
24 break
25 }
26
27 const el = (
28 <View
29 style={[
30 a.absolute,
31 a.inset_0,
32 a.pointer_events_none,
33 a.transition_opacity,
34 t.atoms.bg_contrast_50,
35 style,
36 {opacity: hover ? opacity : 0},
37 ]}
38 />
39 )
40
41 if (IS_WEB && web) {
42 return IS_WEB_TOUCH_DEVICE ? null : el
43 } else if (IS_NATIVE && native) {
44 return el
45 }
46
47 return null
48}