0.8.5 • Published 9 months ago

@nbottarini/react-native-styled v0.8.5

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

npm License: MIT CI Status

React Native Styled

React Native lightweight styled components

Installation

Npm:

$ npm install --save @nbottarini/react-native-styled

Yarn:

$ yarn add @nbottarini/react-native-styled

Usage

import { styledPressable } from './index'

const MyApp = () => (
    <Container>
        <TextField/>
        <PrimaryButton title="Login"/>
    </Container>
)

const Container = styled(View, {
    padding: 10,
    backgroundColor: '#FEFEFE'
})

const TextField = styled(TextInput, (props) => ({
    fontSize: 10,
    backgroundColor: props.editable ? '#FFFFFF' : '#CCCCCC',
}))

const PrimaryButton = (props) => {
    return (
        <Pressable onPress={props.onPress}>
            {({ pressed }) => (
                <ButtonContainer pressed={pressed} disabled={props.isDisabled}>
                    <Text>{props.title}</Text>
                </ButtonContainer>
            )}
        </Pressable>
    );
};

// styledPressable allows to override some styles when the prop pressed is true
const ButtonContainer = styledPressable(View, (props) => ({
    backgroundColor: props.disabled ? '#CCCCCC' : '#FFFFFF',
}), {
    backgroundColor: "#F0F0F0"
})
0.8.5

9 months ago

0.8.4

9 months ago

0.8.3

1 year ago

0.8.2

1 year ago