Skip to content

Instantly share code, notes, and snippets.

@statianzo
Forked from ssomnoremac/Styled.js
Last active April 9, 2017 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statianzo/c3b7c345abf82e833cb269dea7277709 to your computer and use it in GitHub Desktop.
Save statianzo/c3b7c345abf82e833cb269dea7277709 to your computer and use it in GitHub Desktop.
//@flow
import React from 'react';
import Styled from './Styled';
import {View, TouchableOpacity, Text} from 'react-native';
type Props = {
children?: any,
};
const Container = Styled(TouchableOpacity, {
flex: 1,
marginHorizontal: 4,
alignItems: 'center',
justifyContent: 'center',
});
const ButtonText = Styled(Text, {
fontSize: 24,
});
export const NumberButton = ({children}: Props) => (
<Container style={{backgroundColor: 'rgba(0, 0, 0, 0.1)'}}>
<ButtonText>{children}</ButtonText>
</Container>
);
export const OperatorButton = ({children}: Props) => (
<Container style={{backgroundColor: '#7B2391'}}>
<ButtonText style={{color: 'rgba(255,255,255,0.8)'}}>{children}</ButtonText>
</Container>
);
import React from 'react';
import {StyleSheet} from 'react-native';
const Styled = (Inner, styles) => {
const styleSheet = StyleSheet.create({
styles,
});
const displayName = `Styled(${(Inner: any).displayName})`;
const wrapper = ({style, children, ...rest}) => {
return (
<Inner style={[styleSheet.styles, style]} {...rest}>
{children}
</Inner>
);
};
wrapper.displayName = displayName;
return wrapper;
};
export default Styled;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment