about summary refs log tree commit diff
path: root/src/components/SubtleHover.tsx
blob: bb5911baa6cd3d7ad325517709baa22d0e5a6fe5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import {View} from 'react-native'

import {atoms as a, useTheme, type ViewStyleProp} from '#/alf'

export function SubtleHover({style, hover}: ViewStyleProp & {hover: boolean}) {
  const t = useTheme()

  let opacity: number
  switch (t.name) {
    case 'dark':
      opacity = 0.4
      break
    case 'dim':
      opacity = 0.45
      break
    case 'light':
      opacity = 0.5
      break
  }

  return (
    <View
      style={[
        a.absolute,
        a.inset_0,
        a.pointer_events_none,
        a.transition_opacity,
        t.atoms.bg_contrast_25,
        style,
        {opacity: hover ? opacity : 0},
      ]}
    />
  )
}