blob: 03b8f85f7b6f267a2d9064b2430526b244f54211 (
about) (
plain)
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
|
import * as React from 'react'
import { TouchableOpacity } from 'react-native'
import { Text } from '../text/text'
import { viewPresets, textPresets } from './button.presets'
import { ButtonProps } from './button.props'
/**
* For your text displaying needs.
*
* This component is a HOC over the built-in React Native one.
*/
export function Button(props: ButtonProps) {
// grab the props
const {
preset = 'primary',
tx,
text,
style: styleOverride,
textStyle: textStyleOverride,
children,
...rest
} = props
const viewStyle = viewPresets[preset] || viewPresets.primary
const viewStyles = [viewStyle, styleOverride]
const textStyle = textPresets[preset] || textPresets.primary
const textStyles = [textStyle, textStyleOverride]
const content = children || <Text tx={tx} text={text} style={textStyles} />
return (
<TouchableOpacity style={viewStyles} {...rest}>
{content}
</TouchableOpacity>
)
}
|