about summary refs log tree commit diff
path: root/src/components/SubtleWebHover.web.tsx
blob: e98251e0dd55b89ea4ee5a954e62f163556453bc (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from 'react'
import {StyleSheet, View} from 'react-native'

import {isTouchDevice} from '#/lib/browser'
import {useTheme} from '#/alf'

export function SubtleWebHover({hover}: {hover: boolean}) {
  const t = useTheme()
  if (isTouchDevice) {
    return null
  }
  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={[
        t.atoms.bg_contrast_25,
        styles.container,
        {
          opacity: hover ? opacity : 0,
        },
      ]}
    />
  )
}

const styles = StyleSheet.create({
  container: {
    position: 'absolute',
    left: 0,
    right: 0,
    bottom: 0,
    top: 0,
    pointerEvents: 'none',
    // @ts-ignore web only
    transition: '0.15s ease-in-out opacity',
  },
})