Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/codebayu/style-variants

The Package for creating dynamic and reusable styles in React Native
https://github.com/codebayu/style-variants

react-native style variants

Last synced: 3 months ago
JSON representation

The Package for creating dynamic and reusable styles in React Native

Awesome Lists containing this project

README

        

# @codebayu/style-variants

The Package for creating dynamic and reusable styles in React Native App

## Installation

```bash
# npm
npm install @codebayu/style-variants

# yarn
yarn add @codebayu/style-variants
```

## Usage

```tsx
// ReusableButton.tsx
import { sv } from '@codebayu/style-variants';

export default function ReusableButton({
children,
color,
size,
style,
...rest
}) {
const buttonStyle = buttonVariant({ color, size });
const textStyle = textVariant({ color, size });
return (

{children}

);
}

const textVariant = sv({
base: {
fontWeight: '600',
},
variants: {
color: {
primary: {
color: 'green',
},
secondary: {
color: 'blue',
},
ghost: {
color: 'black',
},
},
size: {
small: {
fontSize: 14,
},
medium: {
fontSize: 16,
},
large: {
fontSize: 18,
},
},
},
defaultVariants: {
color: 'primary',
size: 'medium',
},
});

const buttonVariant = sv({
base: {
height: 'auto',
alignItems: 'center',
},
variants: {
color: {
primary: {
backgroundColor: '#eee',
padding: 17,
fontWeight: '600',
borderRadius: 5,
width: '100%',
borderWidth: 1,
borderColor: '#eee',
},
secondary: {
backgroundColor: '#e3e3e3',
padding: 17,
fontWeight: '600',
borderRadius: 5,
width: '100%',
borderWidth: 1,
borderColor: '#eee',
},
ghost: {
backgroundColor: 'transparent',
},
},
},
defaultVariants: {
color: 'primary',
},
});

// Parent Component

Sign Up Here
;
```

## License

This project is licensed under the [MIT License](https://opensource.org/licenses/MIT) - see the [LICENSE](LICENSE) file for details.