Skip to content

Instantly share code, notes, and snippets.

@rbhatia46
Forked from manojsinghnegiwd/Full-button.js
Created November 9, 2018 15:27
Show Gist options
  • Save rbhatia46/8a827b038a7a3cb80c92bf4a1a99fc27 to your computer and use it in GitHub Desktop.
Save rbhatia46/8a827b038a7a3cb80c92bf4a1a99fc27 to your computer and use it in GitHub Desktop.
import React from 'react'
import {
TouchableOpacity,
StyleSheet,
View
} from 'react-native'
const height = 40
const padding = 10
const margin = 10
const width = 250
const backgroundColor = 'lightgrey'
const Button = ({
children,
rounded,
outlined,
customStyle,
...restProps
}) => {
let inlineStyle = []
inlineStyle = inlineStyle.concat(style.defaultStyle)
if (rounded) {
inlineStyle = inlineStyle.concat(style.roundBorder)
}
if (outlined) {
inlineStyle = inlineStyle.concat(style.outlined)
}
if (customStyle) {
inlineStyle = inlineStyle.concat(customStyle)
}
return (
<TouchableOpacity {...restProps}>
<View style={inlineStyle}>
{children}
</View>
</TouchableOpacity>
)
}
const style = StyleSheet.create({
defaultStyle: {
height,
padding,
margin,
width,
backgroundColor,
borderColor: backgroundColor
},
roundBorder: {
borderRadius: 30
},
outlined: {
backgroundColor: 'transparent',
borderWidth: 1
}
})
export default Button
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment