about summary refs log tree commit diff
path: root/src/view/com/util/load-latest/LoadLatestBtn.web.tsx
blob: 839685029d0286ce7f060823c8b217224b761da2 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
import React from 'react'
import {StyleSheet, TouchableOpacity} from 'react-native'
import {Text} from '../text/Text'
import {usePalette} from 'lib/hooks/usePalette'
import {UpIcon} from 'lib/icons'
import {LoadLatestBtn as LoadLatestBtnMobile} from './LoadLatestBtnMobile'
import {isMobileWeb} from 'platform/detection'

const HITSLOP = {left: 20, top: 20, right: 20, bottom: 20}

export const LoadLatestBtn = ({
  onPress,
  label,
}: {
  onPress: () => void
  label: string
}) => {
  const pal = usePalette('default')
  if (isMobileWeb) {
    return <LoadLatestBtnMobile onPress={onPress} label={label} />
  }
  return (
    <TouchableOpacity
      style={[pal.view, pal.borderDark, styles.loadLatest]}
      onPress={onPress}
      hitSlop={HITSLOP}
      accessibilityRole="button"
      accessibilityLabel={`Load new ${label}`}
      accessibilityHint="">
      <Text type="md-bold" style={pal.text}>
        <UpIcon size={16} strokeWidth={1} style={[pal.text, styles.icon]} />
        Load new {label}
      </Text>
    </TouchableOpacity>
  )
}

const styles = StyleSheet.create({
  loadLatest: {
    flexDirection: 'row',
    position: 'absolute',
    left: '50vw',
    // @ts-ignore web only -prf
    transform: 'translateX(-50%)',
    top: 60,
    shadowColor: '#000',
    shadowOpacity: 0.2,
    shadowOffset: {width: 0, height: 2},
    shadowRadius: 4,
    paddingLeft: 20,
    paddingRight: 24,
    paddingVertical: 10,
    borderRadius: 30,
    borderWidth: 1,
  },
  icon: {
    position: 'relative',
    top: 2,
    marginRight: 5,
  },
})