Skip to content

Instantly share code, notes, and snippets.

@dantman
Created October 2, 2017 21:14
Show Gist options
  • Save dantman/f7dfd6c5db251ac68d8ab84a3cd75fe7 to your computer and use it in GitHub Desktop.
Save dantman/f7dfd6c5db251ac68d8ab84a3cd75fe7 to your computer and use it in GitHub Desktop.
Custom MaterialDesign inspired login button used in one app
@Styles({
root: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
borderRadius: 2,
height: 48,
},
enabled: {
backgroundColor: colors.grey600,
},
disabled: {
backgroundColor: shades.dark.dividers,
},
text: {
...typo.button,
textAlign: 'center',
lineHeight: 20,
},
})
class LoginButton extends PureComponent {
render() {
const {styles} = this;
const {
disabled,
text,
onPress,
onLongPress,
onAccessibilityTap,
onMagicTap,
style,
} = this.props;
return (
<RectRipple
pointerEvents='box-only'
accessibilityComponentType='button'
accessibilityTraits={disabled ? 'disabled' : 'button'}
accessibilityLabel={text}
{...(disabled ? {} : {onPress, onLongPress, onAccessibilityTap, onMagicTap})}
dark
style={[
style,
styles.root,
disabled ? styles.disabled : styles.enabled
]}>
<MaterialText
suppressHighlighting
numberOfLines={1}
light
style={styles.text}>
{text}
</MaterialText>
</RectRipple>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment